|
| 1 | +/* |
| 2 | + * This source is part of the |
| 3 | + * _____ ___ ____ |
| 4 | + * __ / / _ \/ _ | / __/___ _______ _ |
| 5 | + * / // / , _/ __ |/ _/_/ _ \/ __/ _ `/ |
| 6 | + * \___/_/|_/_/ |_/_/ (_)___/_/ \_, / |
| 7 | + * /___/ |
| 8 | + * repository. |
| 9 | + * |
| 10 | + * Copyright (C) 2012-2015 Benoit 'BoD' Lubek ([email protected]) |
| 11 | + * |
| 12 | + * This program is free software: you can redistribute it and/or modify |
| 13 | + * it under the terms of the GNU General Public License as published by |
| 14 | + * the Free Software Foundation, either version 3 of the License, or |
| 15 | + * (at your option) any later version. |
| 16 | + * |
| 17 | + * This program is distributed in the hope that it will be useful, |
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | + * GNU General Public License for more details. |
| 21 | + * |
| 22 | + * You should have received a copy of the GNU General Public License |
| 23 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 24 | + */ |
| 25 | +package org.jraf.androidcontentprovidergenerator.sample.provider.company; |
| 26 | + |
| 27 | +// @formatter:off |
| 28 | +import org.jraf.androidcontentprovidergenerator.sample.provider.base.BaseModel; |
| 29 | + |
| 30 | +import java.util.Date; |
| 31 | + |
| 32 | +import android.support.annotation.NonNull; |
| 33 | +import android.support.annotation.Nullable; |
| 34 | + |
| 35 | +/** |
| 36 | + * A commercial business. |
| 37 | + */ |
| 38 | +@SuppressWarnings({"WeakerAccess", "unused", "ConstantConditions"}) |
| 39 | +public class CompanyBean implements CompanyModel { |
| 40 | + private long mId; |
| 41 | + private String mName; |
| 42 | + private String mAddress; |
| 43 | + private long mSerialNumberId; |
| 44 | + |
| 45 | + /** |
| 46 | + * Primary key. |
| 47 | + */ |
| 48 | + @Override |
| 49 | + public long getId() { |
| 50 | + return mId; |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * Primary key. |
| 55 | + */ |
| 56 | + public void setId(long id) { |
| 57 | + mId = id; |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * The commercial name of this company. |
| 62 | + * Cannot be {@code null}. |
| 63 | + */ |
| 64 | + @NonNull |
| 65 | + @Override |
| 66 | + public String getName() { |
| 67 | + return mName; |
| 68 | + } |
| 69 | + |
| 70 | + /** |
| 71 | + * The commercial name of this company. |
| 72 | + * Must not be {@code null}. |
| 73 | + */ |
| 74 | + public void setName(@NonNull String name) { |
| 75 | + if (name == null) throw new IllegalArgumentException("name must not be null"); |
| 76 | + mName = name; |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * The full address of this company. |
| 81 | + * Can be {@code null}. |
| 82 | + */ |
| 83 | + @Nullable |
| 84 | + @Override |
| 85 | + public String getAddress() { |
| 86 | + return mAddress; |
| 87 | + } |
| 88 | + |
| 89 | + /** |
| 90 | + * The full address of this company. |
| 91 | + * Can be {@code null}. |
| 92 | + */ |
| 93 | + public void setAddress(@Nullable String address) { |
| 94 | + mAddress = address; |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * The serial number of this company. |
| 99 | + */ |
| 100 | + @Override |
| 101 | + public long getSerialNumberId() { |
| 102 | + return mSerialNumberId; |
| 103 | + } |
| 104 | + |
| 105 | + /** |
| 106 | + * The serial number of this company. |
| 107 | + */ |
| 108 | + public void setSerialNumberId(long serialNumberId) { |
| 109 | + mSerialNumberId = serialNumberId; |
| 110 | + } |
| 111 | + |
| 112 | + @Override |
| 113 | + public boolean equals(Object o) { |
| 114 | + if (this == o) return true; |
| 115 | + if (o == null || getClass() != o.getClass()) return false; |
| 116 | + CompanyBean bean = (CompanyBean) o; |
| 117 | + return mId == bean.mId; |
| 118 | + } |
| 119 | + |
| 120 | + @Override |
| 121 | + public int hashCode() { |
| 122 | + return (int) (mId ^ (mId >>> 32)); |
| 123 | + } |
| 124 | + |
| 125 | + /** |
| 126 | + * Instantiate a new CompanyBean with specified values. |
| 127 | + */ |
| 128 | + @NonNull |
| 129 | + public static CompanyBean newInstance(long id, @NonNull String name, @Nullable String address, long serialNumberId) { |
| 130 | + if (name == null) throw new IllegalArgumentException("name must not be null"); |
| 131 | + CompanyBean res = new CompanyBean(); |
| 132 | + res.mId = id; |
| 133 | + res.mName = name; |
| 134 | + res.mAddress = address; |
| 135 | + res.mSerialNumberId = serialNumberId; |
| 136 | + return res; |
| 137 | + } |
| 138 | + |
| 139 | + /** |
| 140 | + * Instantiate a new CompanyBean with all the values copied from the given model. |
| 141 | + */ |
| 142 | + @NonNull |
| 143 | + public static CompanyBean copy(@NonNull CompanyModel from) { |
| 144 | + CompanyBean res = new CompanyBean(); |
| 145 | + res.mId = from.getId(); |
| 146 | + res.mName = from.getName(); |
| 147 | + res.mAddress = from.getAddress(); |
| 148 | + res.mSerialNumberId = from.getSerialNumberId(); |
| 149 | + return res; |
| 150 | + } |
| 151 | + |
| 152 | + public static class Builder { |
| 153 | + private CompanyBean mRes = new CompanyBean(); |
| 154 | + |
| 155 | + /** |
| 156 | + * Primary key. |
| 157 | + */ |
| 158 | + public Builder id(long id) { |
| 159 | + mRes.mId = id; |
| 160 | + return this; |
| 161 | + } |
| 162 | + |
| 163 | + /** |
| 164 | + * The commercial name of this company. |
| 165 | + * Must not be {@code null}. |
| 166 | + */ |
| 167 | + public Builder name(@NonNull String name) { |
| 168 | + if (name == null) throw new IllegalArgumentException("name must not be null"); |
| 169 | + mRes.mName = name; |
| 170 | + return this; |
| 171 | + } |
| 172 | + |
| 173 | + /** |
| 174 | + * The full address of this company. |
| 175 | + * Can be {@code null}. |
| 176 | + */ |
| 177 | + public Builder address(@Nullable String address) { |
| 178 | + mRes.mAddress = address; |
| 179 | + return this; |
| 180 | + } |
| 181 | + |
| 182 | + /** |
| 183 | + * The serial number of this company. |
| 184 | + */ |
| 185 | + public Builder serialNumberId(long serialNumberId) { |
| 186 | + mRes.mSerialNumberId = serialNumberId; |
| 187 | + return this; |
| 188 | + } |
| 189 | + |
| 190 | + /** |
| 191 | + * Get a new CompanyBean built with the given values. |
| 192 | + */ |
| 193 | + public CompanyBean build() { |
| 194 | + if (mRes.mName == null) throw new IllegalArgumentException("name must not be null"); |
| 195 | + return mRes; |
| 196 | + } |
| 197 | + } |
| 198 | + |
| 199 | + public static Builder newBuilder() { |
| 200 | + return new Builder(); |
| 201 | + } |
| 202 | +} |
0 commit comments