Skip to content

Commit

Permalink
refactor: removed lombok from the project and added necessary methods…
Browse files Browse the repository at this point in the history
… to the classes. Fixes fossasia#2371
  • Loading branch information
sriramr98 committed Mar 12, 2018
1 parent a83c742 commit f1ffd12
Show file tree
Hide file tree
Showing 40 changed files with 3,584 additions and 177 deletions.
2 changes: 0 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ dependencies {
implementation 'com.github.yalantis:ucrop:2.2.1'
implementation 'io.reactivex.rxjava2:rxjava:2.1.3'
implementation "android.arch.lifecycle:reactivestreams:1.0.0"
compileOnly "org.projectlombok:lombok:1.16.18"
annotationProcessor "org.projectlombok:lombok:1.16.18"
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'

// Googleplay Variant
Expand Down
112 changes: 107 additions & 5 deletions android/app/src/main/java/org/fossasia/openevent/config/Config.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,122 @@
package org.fossasia.openevent.config;

import lombok.Builder;
import lombok.Data;

/**
* Config to be replaced in {@link org.fossasia.openevent.config.strategies.AppConfigStrategy}
*
* TODO: Add the correct JSON parsing mechanism and populate config in this format and share across project
*
* NOT IMPLEMENTED YET
*/
@Data
@Builder
public class Config {
private final String apiLink;
private final String email;
private final String appName;
private final boolean authEnabled;

Config(String apiLink, String email, String appName, boolean authEnabled) {
this.apiLink = apiLink;
this.email = email;
this.appName = appName;
this.authEnabled = authEnabled;
}

public static ConfigBuilder builder() {
return new ConfigBuilder();
}

public String getApiLink() {
return this.apiLink;
}

public String getEmail() {
return this.email;
}

public String getAppName() {
return this.appName;
}

public boolean getAuthEnabled() {
return this.authEnabled;
}

public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof Config)) return false;
final Config other = (Config) o;
if (!other.canEqual((Object) this)) return false;
final Object this$apiLink = this.getApiLink();
final Object other$apiLink = other.getApiLink();
if (this$apiLink == null ? other$apiLink != null : !this$apiLink.equals(other$apiLink))
return false;
final Object this$email = this.getEmail();
final Object other$email = other.getEmail();
if (this$email == null ? other$email != null : !this$email.equals(other$email))
return false;
final Object this$appName = this.getAppName();
final Object other$appName = other.getAppName();
if (this$appName == null ? other$appName != null : !this$appName.equals(other$appName))
return false;
if (this.getAuthEnabled() != other.getAuthEnabled()) return false;
return true;
}

public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $apiLink = this.getApiLink();
result = result * PRIME + ($apiLink == null ? 43 : $apiLink.hashCode());
final Object $email = this.getEmail();
result = result * PRIME + ($email == null ? 43 : $email.hashCode());
final Object $appName = this.getAppName();
result = result * PRIME + ($appName == null ? 43 : $appName.hashCode());
result = result * PRIME + (this.getAuthEnabled() ? 79 : 97);
return result;
}

protected boolean canEqual(Object other) {
return other instanceof Config;
}

public String toString() {
return "Config(apiLink=" + this.getApiLink() + ", email=" + this.getEmail() + ", appName=" + this.getAppName() + ", authEnabled=" + this.getAuthEnabled() + ")";
}

public static class ConfigBuilder {
private String apiLink;
private String email;
private String appName;
private boolean authEnabled;

ConfigBuilder() {
}

public Config.ConfigBuilder apiLink(String apiLink) {
this.apiLink = apiLink;
return this;
}

public Config.ConfigBuilder email(String email) {
this.email = email;
return this;
}

public Config.ConfigBuilder appName(String appName) {
this.appName = appName;
return this;
}

public Config.ConfigBuilder authEnabled(boolean authEnabled) {
this.authEnabled = authEnabled;
return this;
}

public Config build() {
return new Config(apiLink, email, appName, authEnabled);
}

public String toString() {
return "Config.ConfigBuilder(apiLink=" + this.apiLink + ", email=" + this.email + ", appName=" + this.appName + ", authEnabled=" + this.authEnabled + ")";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import java.util.LinkedHashSet;
import java.util.Set;

import lombok.Getter;

@Getter
public class ConfigStrategyHolder {

private final Set<ConfigStrategy> strategies = new LinkedHashSet<>();
Expand All @@ -14,4 +11,7 @@ public void register(ConfigStrategy configStrategy) {
strategies.add(configStrategy);
}

public Set<ConfigStrategy> getStrategies() {
return this.strategies;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@
import org.fossasia.openevent.config.strategies.TimberStrategy;
import org.fossasia.openevent.config.strategies.TimeConfigStrategy;

import lombok.Setter;

/**
* Project level configuration strategies holder singleton
*
* Holds all strategies and provides an interface to get singleton strategies or
* override the default strategy holder. Also sets the order and strategies in default
* holder which is then utilised by {@link AppConfigurer} to configure the application
*/
@Setter
public class StrategyRegistry {

private static StrategyRegistry strategyRegistry;
Expand Down Expand Up @@ -99,4 +96,31 @@ public ConfigStrategyHolder getDefaultHolder() {
return defaultHolder;
}

public void setStrategyHolder(ConfigStrategyHolder strategyHolder) {
this.strategyHolder = strategyHolder;
}

public void setHttpStrategy(HttpStrategy httpStrategy) {
this.httpStrategy = httpStrategy;
}

public void setLanguageStrategy(LanguageStrategy languageStrategy) {
this.languageStrategy = languageStrategy;
}

public void setLeakCanaryStrategy(LeakCanaryStrategy leakCanaryStrategy) {
this.leakCanaryStrategy = leakCanaryStrategy;
}

public void setEventBusStrategy(EventBusStrategy eventBusStrategy) {
this.eventBusStrategy = eventBusStrategy;
}

public void setMapModuleStrategy(MapModuleStrategy mapModuleStrategy) {
this.mapModuleStrategy = mapModuleStrategy;
}

public void setAppConfigStrategy(AppConfigStrategy appConfigStrategy) {
this.appConfigStrategy = appConfigStrategy;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import java.io.File;

import lombok.Getter;
import okhttp3.Cache;
import okhttp3.OkHttpClient;

Expand All @@ -23,7 +22,6 @@
* Also provides an interface for application to use Picasso with cache
* To be used via {@link org.fossasia.openevent.config.StrategyRegistry}
*/
@Getter
public class HttpStrategy implements ConfigStrategy {

private Picasso picassoWithCache;
Expand Down Expand Up @@ -59,4 +57,7 @@ public boolean configure(Context context) {
return false;
}

public Picasso getPicassoWithCache() {
return this.picassoWithCache;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@

import java.util.Locale;

import lombok.Getter;
import lombok.Setter;

/**
* Sets and provides default system language
* To be used via {@link org.fossasia.openevent.config.StrategyRegistry}
*/
@Setter
@Getter
public class LanguageStrategy implements ConfigStrategy {

private String defaultSystemLanguage;
Expand All @@ -25,4 +20,11 @@ public boolean configure(Context context) {
return false;
}

public String getDefaultSystemLanguage() {
return this.defaultSystemLanguage;
}

public void setDefaultSystemLanguage(String defaultSystemLanguage) {
this.defaultSystemLanguage = defaultSystemLanguage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
import org.fossasia.openevent.OpenEventApp;
import org.fossasia.openevent.config.ConfigStrategy;

import lombok.Getter;

/**
* Configures and provides Leak Canary Reference Watcher
* To be used via {@link org.fossasia.openevent.config.StrategyRegistry}
*/
@Getter
public class LeakCanaryStrategy implements ConfigStrategy {

private RefWatcher refWatcher;
Expand All @@ -31,4 +28,7 @@ public boolean configure(Context context) {
return false;
}

public RefWatcher getRefWatcher() {
return this.refWatcher;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
import org.fossasia.openevent.config.ConfigStrategy;
import org.fossasia.openevent.core.location.modules.MapModuleFactory;

import lombok.Getter;

/**
* Configures and provides Map Module Factory to switch map implementations between flavours
* To be used via {@link org.fossasia.openevent.config.StrategyRegistry}
*/
@Getter
public class MapModuleStrategy implements ConfigStrategy {

private MapModuleFactory mapModuleFactory;
Expand All @@ -22,4 +19,7 @@ public boolean configure(Context context) {
return false;
}

public MapModuleFactory getMapModuleFactory() {
return this.mapModuleFactory;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
import lombok.Data;
import timber.log.Timber;

import static org.fossasia.openevent.core.auth.AuthUtil.INVALID;
Expand Down Expand Up @@ -44,9 +43,51 @@ protected void onCleared() {
super.onCleared();
}

@Data
public static class LoginResponse {
private final int response;
private final String accessToken;

public LoginResponse(int response, String accessToken) {
this.response = response;
this.accessToken = accessToken;
}

public int getResponse() {
return this.response;
}

public String getAccessToken() {
return this.accessToken;
}

public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof LoginResponse)) return false;
final LoginResponse other = (LoginResponse) o;
if (!other.canEqual((Object) this)) return false;
if (this.getResponse() != other.getResponse()) return false;
final Object this$accessToken = this.getAccessToken();
final Object other$accessToken = other.getAccessToken();
if (this$accessToken == null ? other$accessToken != null : !this$accessToken.equals(other$accessToken))
return false;
return true;
}

public int hashCode() {
final int PRIME = 59;
int result = 1;
result = result * PRIME + this.getResponse();
final Object $accessToken = this.getAccessToken();
result = result * PRIME + ($accessToken == null ? 43 : $accessToken.hashCode());
return result;
}

protected boolean canEqual(Object other) {
return other instanceof LoginResponse;
}

public String toString() {
return "LoginActivityViewModel.LoginResponse(response=" + this.getResponse() + ", accessToken=" + this.getAccessToken() + ")";
}
}
}
Loading

0 comments on commit f1ffd12

Please sign in to comment.