1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17 package com.android.contacts.util; 18 19 import android.content.Context; 20 21 /** 22 * Builder for {@link StreamItemEntry}s to make writing tests easier. 23 */ 24 public class StreamItemEntryBuilder { 25 private long mId; 26 private String mText; 27 private String mComment; 28 private long mTimestamp; 29 private String mAccountType; 30 private String mAccountName; 31 private String mDataSet; 32 private String mResPackage; 33 private String mIconRes; 34 private String mLabelRes; 35 36 public StreamItemEntryBuilder() {} 37 38 public StreamItemEntryBuilder setText(String value) { 39 mText = value; 40 return this; 41 } 42 43 public StreamItemEntryBuilder setComment(String value) { 44 mComment = value; 45 return this; 46 } 47 48 public StreamItemEntryBuilder setAccountType(String value) { 49 mAccountType = value; 50 return this; 51 } 52 53 public StreamItemEntryBuilder setAccountName(String value) { 54 mAccountName = value; 55 return this; 56 } 57 58 public StreamItemEntryBuilder setDataSet(String value) { 59 mDataSet = value; 60 return this; 61 } 62 63 public StreamItemEntry build(Context context) { 64 StreamItemEntry ret = StreamItemEntry.createForTest(mId, mText, mComment, mTimestamp, 65 mAccountType, mAccountName, mDataSet, mResPackage, mIconRes, mLabelRes); 66 ret.decodeHtml(context); 67 return ret; 68 } 69 } 70