From 52a0c9b90f988eac2d4d81296e6129b2635898a2 Mon Sep 17 00:00:00 2001 From: Navadharshini08 <136996571+Navadharshini08@users.noreply.github.com> Date: Sat, 19 Oct 2024 00:02:25 +0530 Subject: [PATCH] Update User.java --- .../android10/sample/domain/User.java | 125 ++++++++++-------- 1 file changed, 68 insertions(+), 57 deletions(-) diff --git a/domain/src/main/java/com/fernandocejas/android10/sample/domain/User.java b/domain/src/main/java/com/fernandocejas/android10/sample/domain/User.java index 21bf5378..3383419c 100644 --- a/domain/src/main/java/com/fernandocejas/android10/sample/domain/User.java +++ b/domain/src/main/java/com/fernandocejas/android10/sample/domain/User.java @@ -1,18 +1,3 @@ -/** - * Copyright (C) 2015 Fernando Cejas Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package com.fernandocejas.android10.sample.domain; /** @@ -20,59 +5,85 @@ */ public class User { - private final int userId; + private final int userId; + private String coverUrl; + private String fullName; + private String email; + private String description; + private int followers; + + private User(Builder builder) { + this.userId = builder.userId; + this.coverUrl = builder.coverUrl; + this.fullName = builder.fullName; + this.email = builder.email; + this.description = builder.description; + this.followers = builder.followers; + } + + public int getUserId() { + return userId; + } - public User(int userId) { - this.userId = userId; - } + public String getCoverUrl() { + return coverUrl; + } - private String coverUrl; - private String fullName; - private String email; - private String description; - private int followers; + public String getFullName() { + return fullName; + } - public int getUserId() { - return userId; - } + public String getEmail() { + return email; + } - public String getCoverUrl() { - return coverUrl; - } + public String getDescription() { + return description; + } - public void setCoverUrl(String coverUrl) { - this.coverUrl = coverUrl; - } + public int getFollowers() { + return followers; + } - public String getFullName() { - return fullName; - } + public static class Builder { + private final int userId; + private String coverUrl; + private String fullName; + private String email; + private String description; + private int followers; - public void setFullName(String fullName) { - this.fullName = fullName; - } + public Builder(int userId) { + this.userId = userId; + } - public String getEmail() { - return email; - } + public Builder coverUrl(String coverUrl) { + this.coverUrl = coverUrl; + return this; + } - public void setEmail(String email) { - this.email = email; - } + public Builder fullName(String fullName) { + this.fullName = fullName; + return this; + } - public String getDescription() { - return description; - } + public Builder email(String email) { + this.email = email; + return this; + } - public void setDescription(String description) { - this.description = description; - } + public Builder description(String description) { + this.description = description; + return this; + } - public int getFollowers() { - return followers; - } + public Builder followers(int followers) { + this.followers = followers; + return this; + } - public void setFollowers(int followers) { - this.followers = followers; - } + public User build() { + return new User(this); + } + } }