repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
FuckBoilerplate/base_app_android | app/src/main/java/app/presentation/sections/user_demo/detail/UserPresenter.java | // Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/sections/WireframeRepository.java
// public class WireframeRepository extends Repository {
//
// @Inject public WireframeRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// super(restApi, rxProviders, uiUtils);
// }
//
// public <T> Observable<T> getWireframeCurrentObject() {
// return rxProviders
// .<T>getWireframeCurrentObject(Observable.just(null), new EvictProvider(false))
// .doOnError(throwable -> {
// throw new WireframeException();
// });
// }
//
// public Observable<Void> setWireframeCurrentObject(Object object) {
// return rxProviders.getWireframeCurrentObject(Observable.just(object), new EvictProvider(true))
// .map(_I -> null);
// }
//
// public class WireframeException extends RuntimeException {
//
// public WireframeException() {
// super("There is not cached object in the wireframe");
// }
//
// }
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
//
// Path: app/src/main/java/app/presentation/foundation/PresenterFragment.java
// public abstract class PresenterFragment {
// protected final WireframeRepository wireframeRepository;
// protected final UIUtils uiUtils;
//
// protected PresenterFragment(WireframeRepository wireframeRepository, UIUtils uiUtils) {
// this.wireframeRepository = wireframeRepository;
// this.uiUtils = uiUtils;
// }
//
// public Observable<Void> dataForNextScreen(Object data) {
// return wireframeRepository.setWireframeCurrentObject(data);
// }
// }
| import javax.inject.Inject;
import app.data.foundation.UIUtils;
import app.data.sections.WireframeRepository;
import app.domain.user_demo.User;
import app.presentation.foundation.PresenterFragment;
import rx.Observable; | package app.presentation.sections.user_demo.detail;
public class UserPresenter extends PresenterFragment {
@Inject public UserPresenter(WireframeRepository wireframeRepository, UIUtils uiUtils) {
super(wireframeRepository, uiUtils);
}
| // Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/sections/WireframeRepository.java
// public class WireframeRepository extends Repository {
//
// @Inject public WireframeRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// super(restApi, rxProviders, uiUtils);
// }
//
// public <T> Observable<T> getWireframeCurrentObject() {
// return rxProviders
// .<T>getWireframeCurrentObject(Observable.just(null), new EvictProvider(false))
// .doOnError(throwable -> {
// throw new WireframeException();
// });
// }
//
// public Observable<Void> setWireframeCurrentObject(Object object) {
// return rxProviders.getWireframeCurrentObject(Observable.just(object), new EvictProvider(true))
// .map(_I -> null);
// }
//
// public class WireframeException extends RuntimeException {
//
// public WireframeException() {
// super("There is not cached object in the wireframe");
// }
//
// }
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
//
// Path: app/src/main/java/app/presentation/foundation/PresenterFragment.java
// public abstract class PresenterFragment {
// protected final WireframeRepository wireframeRepository;
// protected final UIUtils uiUtils;
//
// protected PresenterFragment(WireframeRepository wireframeRepository, UIUtils uiUtils) {
// this.wireframeRepository = wireframeRepository;
// this.uiUtils = uiUtils;
// }
//
// public Observable<Void> dataForNextScreen(Object data) {
// return wireframeRepository.setWireframeCurrentObject(data);
// }
// }
// Path: app/src/main/java/app/presentation/sections/user_demo/detail/UserPresenter.java
import javax.inject.Inject;
import app.data.foundation.UIUtils;
import app.data.sections.WireframeRepository;
import app.domain.user_demo.User;
import app.presentation.foundation.PresenterFragment;
import rx.Observable;
package app.presentation.sections.user_demo.detail;
public class UserPresenter extends PresenterFragment {
@Inject public UserPresenter(WireframeRepository wireframeRepository, UIUtils uiUtils) {
super(wireframeRepository, uiUtils);
}
| Observable<User> getCurrentUser() { |
FuckBoilerplate/base_app_android | app/src/test/java/app/data/foundation/RestApiTest.java | // Path: app/src/main/java/app/data/foundation/dagger/DataModule.java
// @Module
// public class DataModule {
//
// @Singleton @Provides public RestApi provideRestApi() {
// boolean mockMode = false;//BuildConfig.DEBUG;
// if (mockMode) return new RestApiMock();
//
// return new Retrofit.Builder()
// .baseUrl(RestApi.URL_BASE)
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .addConverterFactory(GsonConverterFactory.create())
// .build().create(RestApi.class);
// }
//
// @Singleton @Provides public RxProviders provideRxProviders(UIUtils uiUtils) {
// return new RxCache.Builder()
// .persistence(uiUtils.getFilesDir())
// .using(RxProviders.class);
// }
//
// @Singleton @Provides UIUtils provideUiUtils(BaseApp baseApp) {
// return new UIUtils() {
// @Override public String getLang() {
// return baseApp.getResources().getConfiguration().locale.getLanguage();
// }
//
// @Override public String getString(int idResource) {
// return baseApp.getString(idResource);
// }
//
// @Override public File getFilesDir() {
// return baseApp.getFilesDir();
// }
// };
// }
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import java.util.List;
import app.data.foundation.dagger.DataModule;
import app.data.foundation.net.RestApi;
import app.domain.user_demo.User;
import retrofit2.Response;
import rx.observers.TestSubscriber;
import static junit.framework.Assert.assertNull; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.foundation;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class RestApiTest {
private static final String VALID_USERNAME = "RefineriaWeb", INVALID_USERNAME = ""; | // Path: app/src/main/java/app/data/foundation/dagger/DataModule.java
// @Module
// public class DataModule {
//
// @Singleton @Provides public RestApi provideRestApi() {
// boolean mockMode = false;//BuildConfig.DEBUG;
// if (mockMode) return new RestApiMock();
//
// return new Retrofit.Builder()
// .baseUrl(RestApi.URL_BASE)
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .addConverterFactory(GsonConverterFactory.create())
// .build().create(RestApi.class);
// }
//
// @Singleton @Provides public RxProviders provideRxProviders(UIUtils uiUtils) {
// return new RxCache.Builder()
// .persistence(uiUtils.getFilesDir())
// .using(RxProviders.class);
// }
//
// @Singleton @Provides UIUtils provideUiUtils(BaseApp baseApp) {
// return new UIUtils() {
// @Override public String getLang() {
// return baseApp.getResources().getConfiguration().locale.getLanguage();
// }
//
// @Override public String getString(int idResource) {
// return baseApp.getString(idResource);
// }
//
// @Override public File getFilesDir() {
// return baseApp.getFilesDir();
// }
// };
// }
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: app/src/test/java/app/data/foundation/RestApiTest.java
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import java.util.List;
import app.data.foundation.dagger.DataModule;
import app.data.foundation.net.RestApi;
import app.domain.user_demo.User;
import retrofit2.Response;
import rx.observers.TestSubscriber;
import static junit.framework.Assert.assertNull;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.foundation;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class RestApiTest {
private static final String VALID_USERNAME = "RefineriaWeb", INVALID_USERNAME = ""; | private RestApi restApiUT; |
FuckBoilerplate/base_app_android | app/src/test/java/app/data/foundation/RestApiTest.java | // Path: app/src/main/java/app/data/foundation/dagger/DataModule.java
// @Module
// public class DataModule {
//
// @Singleton @Provides public RestApi provideRestApi() {
// boolean mockMode = false;//BuildConfig.DEBUG;
// if (mockMode) return new RestApiMock();
//
// return new Retrofit.Builder()
// .baseUrl(RestApi.URL_BASE)
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .addConverterFactory(GsonConverterFactory.create())
// .build().create(RestApi.class);
// }
//
// @Singleton @Provides public RxProviders provideRxProviders(UIUtils uiUtils) {
// return new RxCache.Builder()
// .persistence(uiUtils.getFilesDir())
// .using(RxProviders.class);
// }
//
// @Singleton @Provides UIUtils provideUiUtils(BaseApp baseApp) {
// return new UIUtils() {
// @Override public String getLang() {
// return baseApp.getResources().getConfiguration().locale.getLanguage();
// }
//
// @Override public String getString(int idResource) {
// return baseApp.getString(idResource);
// }
//
// @Override public File getFilesDir() {
// return baseApp.getFilesDir();
// }
// };
// }
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import java.util.List;
import app.data.foundation.dagger.DataModule;
import app.data.foundation.net.RestApi;
import app.domain.user_demo.User;
import retrofit2.Response;
import rx.observers.TestSubscriber;
import static junit.framework.Assert.assertNull; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.foundation;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class RestApiTest {
private static final String VALID_USERNAME = "RefineriaWeb", INVALID_USERNAME = "";
private RestApi restApiUT;
@Before public void setUp() { | // Path: app/src/main/java/app/data/foundation/dagger/DataModule.java
// @Module
// public class DataModule {
//
// @Singleton @Provides public RestApi provideRestApi() {
// boolean mockMode = false;//BuildConfig.DEBUG;
// if (mockMode) return new RestApiMock();
//
// return new Retrofit.Builder()
// .baseUrl(RestApi.URL_BASE)
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .addConverterFactory(GsonConverterFactory.create())
// .build().create(RestApi.class);
// }
//
// @Singleton @Provides public RxProviders provideRxProviders(UIUtils uiUtils) {
// return new RxCache.Builder()
// .persistence(uiUtils.getFilesDir())
// .using(RxProviders.class);
// }
//
// @Singleton @Provides UIUtils provideUiUtils(BaseApp baseApp) {
// return new UIUtils() {
// @Override public String getLang() {
// return baseApp.getResources().getConfiguration().locale.getLanguage();
// }
//
// @Override public String getString(int idResource) {
// return baseApp.getString(idResource);
// }
//
// @Override public File getFilesDir() {
// return baseApp.getFilesDir();
// }
// };
// }
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: app/src/test/java/app/data/foundation/RestApiTest.java
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import java.util.List;
import app.data.foundation.dagger.DataModule;
import app.data.foundation.net.RestApi;
import app.domain.user_demo.User;
import retrofit2.Response;
import rx.observers.TestSubscriber;
import static junit.framework.Assert.assertNull;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.foundation;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class RestApiTest {
private static final String VALID_USERNAME = "RefineriaWeb", INVALID_USERNAME = "";
private RestApi restApiUT;
@Before public void setUp() { | restApiUT = new DataModule().provideRestApi(); |
FuckBoilerplate/base_app_android | app/src/test/java/app/data/foundation/RestApiTest.java | // Path: app/src/main/java/app/data/foundation/dagger/DataModule.java
// @Module
// public class DataModule {
//
// @Singleton @Provides public RestApi provideRestApi() {
// boolean mockMode = false;//BuildConfig.DEBUG;
// if (mockMode) return new RestApiMock();
//
// return new Retrofit.Builder()
// .baseUrl(RestApi.URL_BASE)
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .addConverterFactory(GsonConverterFactory.create())
// .build().create(RestApi.class);
// }
//
// @Singleton @Provides public RxProviders provideRxProviders(UIUtils uiUtils) {
// return new RxCache.Builder()
// .persistence(uiUtils.getFilesDir())
// .using(RxProviders.class);
// }
//
// @Singleton @Provides UIUtils provideUiUtils(BaseApp baseApp) {
// return new UIUtils() {
// @Override public String getLang() {
// return baseApp.getResources().getConfiguration().locale.getLanguage();
// }
//
// @Override public String getString(int idResource) {
// return baseApp.getString(idResource);
// }
//
// @Override public File getFilesDir() {
// return baseApp.getFilesDir();
// }
// };
// }
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import java.util.List;
import app.data.foundation.dagger.DataModule;
import app.data.foundation.net.RestApi;
import app.domain.user_demo.User;
import retrofit2.Response;
import rx.observers.TestSubscriber;
import static junit.framework.Assert.assertNull; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.foundation;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class RestApiTest {
private static final String VALID_USERNAME = "RefineriaWeb", INVALID_USERNAME = "";
private RestApi restApiUT;
@Before public void setUp() {
restApiUT = new DataModule().provideRestApi();
}
@Test public void _1_When_Get_User_With_Valid_User_Name_Then_Get_UserDemo() { | // Path: app/src/main/java/app/data/foundation/dagger/DataModule.java
// @Module
// public class DataModule {
//
// @Singleton @Provides public RestApi provideRestApi() {
// boolean mockMode = false;//BuildConfig.DEBUG;
// if (mockMode) return new RestApiMock();
//
// return new Retrofit.Builder()
// .baseUrl(RestApi.URL_BASE)
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .addConverterFactory(GsonConverterFactory.create())
// .build().create(RestApi.class);
// }
//
// @Singleton @Provides public RxProviders provideRxProviders(UIUtils uiUtils) {
// return new RxCache.Builder()
// .persistence(uiUtils.getFilesDir())
// .using(RxProviders.class);
// }
//
// @Singleton @Provides UIUtils provideUiUtils(BaseApp baseApp) {
// return new UIUtils() {
// @Override public String getLang() {
// return baseApp.getResources().getConfiguration().locale.getLanguage();
// }
//
// @Override public String getString(int idResource) {
// return baseApp.getString(idResource);
// }
//
// @Override public File getFilesDir() {
// return baseApp.getFilesDir();
// }
// };
// }
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: app/src/test/java/app/data/foundation/RestApiTest.java
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import java.util.List;
import app.data.foundation.dagger.DataModule;
import app.data.foundation.net.RestApi;
import app.domain.user_demo.User;
import retrofit2.Response;
import rx.observers.TestSubscriber;
import static junit.framework.Assert.assertNull;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.foundation;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class RestApiTest {
private static final String VALID_USERNAME = "RefineriaWeb", INVALID_USERNAME = "";
private RestApi restApiUT;
@Before public void setUp() {
restApiUT = new DataModule().provideRestApi();
}
@Test public void _1_When_Get_User_With_Valid_User_Name_Then_Get_UserDemo() { | TestSubscriber<Response<User>> subscriber = new TestSubscriber<>(); |
FuckBoilerplate/base_app_android | app/src/main/java/app/data/foundation/gcm/GcmTokenReceiver.java | // Path: app/src/main/java/app/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private PresentationComponent presentationComponent;
// private GoogleAnalytics analytics;
// private Tracker tracker;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// initGcm();
// initGoogleAnalytics();
// }
//
// private void initInject() {
// presentationComponent = DaggerPresentationComponent.builder()
// .presentationModule(new PresentationModule(this))
// .build();
// }
//
// private void initGcm() {
// RxGcm.Notifications.register(this, GcmMessageReceiver.class, GcmReceiverBackground.class)
// .subscribe(token -> {}, error -> {});
//
// RxGcm.Notifications.onRefreshToken(GcmTokenReceiver.class);
// }
//
// private void initGoogleAnalytics() {
// analytics = GoogleAnalytics.getInstance(this);
//
// if(BuildConfig.DEBUG) {
// // true = for log output, it does not sent data to Google Analytics
// analytics.setDryRun(true);
// // To enable debug logging on a device run:
// // adb shell setprop log.tag.GAv4 DEBUG
// // adb logcat -s GAv4
// // true = disable google analytics on the app
// // analytics.setAppOptOut(true);
// }
//
// tracker = analytics.newTracker(getString(R.string.ga_trackingId));
// tracker.enableExceptionReporting(true);
// tracker.enableAdvertisingIdCollection(true);
// tracker.enableAutoActivityTracking(false);
// }
//
// public Tracker getTracker() {
// return tracker;
// }
//
// public PresentationComponent getPresentationComponent() {
// return presentationComponent;
// }
//
// @Nullable public BaseActivity getLiveActivity(){
// return (BaseActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
| import javax.inject.Inject;
import app.presentation.foundation.BaseApp;
import rx.Observable;
import rx_gcm.GcmRefreshTokenReceiver;
import rx_gcm.TokenUpdate; | package app.data.foundation.gcm;
/**
* Created by victor on 12/04/16.
*/
public final class GcmTokenReceiver implements GcmRefreshTokenReceiver {
@Override public void onTokenReceive(Observable<TokenUpdate> oTokenUpdate) {
oTokenUpdate.subscribe(tokenUpdate -> { | // Path: app/src/main/java/app/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private PresentationComponent presentationComponent;
// private GoogleAnalytics analytics;
// private Tracker tracker;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// initGcm();
// initGoogleAnalytics();
// }
//
// private void initInject() {
// presentationComponent = DaggerPresentationComponent.builder()
// .presentationModule(new PresentationModule(this))
// .build();
// }
//
// private void initGcm() {
// RxGcm.Notifications.register(this, GcmMessageReceiver.class, GcmReceiverBackground.class)
// .subscribe(token -> {}, error -> {});
//
// RxGcm.Notifications.onRefreshToken(GcmTokenReceiver.class);
// }
//
// private void initGoogleAnalytics() {
// analytics = GoogleAnalytics.getInstance(this);
//
// if(BuildConfig.DEBUG) {
// // true = for log output, it does not sent data to Google Analytics
// analytics.setDryRun(true);
// // To enable debug logging on a device run:
// // adb shell setprop log.tag.GAv4 DEBUG
// // adb logcat -s GAv4
// // true = disable google analytics on the app
// // analytics.setAppOptOut(true);
// }
//
// tracker = analytics.newTracker(getString(R.string.ga_trackingId));
// tracker.enableExceptionReporting(true);
// tracker.enableAdvertisingIdCollection(true);
// tracker.enableAutoActivityTracking(false);
// }
//
// public Tracker getTracker() {
// return tracker;
// }
//
// public PresentationComponent getPresentationComponent() {
// return presentationComponent;
// }
//
// @Nullable public BaseActivity getLiveActivity(){
// return (BaseActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
// Path: app/src/main/java/app/data/foundation/gcm/GcmTokenReceiver.java
import javax.inject.Inject;
import app.presentation.foundation.BaseApp;
import rx.Observable;
import rx_gcm.GcmRefreshTokenReceiver;
import rx_gcm.TokenUpdate;
package app.data.foundation.gcm;
/**
* Created by victor on 12/04/16.
*/
public final class GcmTokenReceiver implements GcmRefreshTokenReceiver {
@Override public void onTokenReceive(Observable<TokenUpdate> oTokenUpdate) {
oTokenUpdate.subscribe(tokenUpdate -> { | BaseApp baseApp = (BaseApp) tokenUpdate.getApplication(); |
FuckBoilerplate/base_app_android | app/src/androidTest/java/app/common/BaseTest.java | // Path: app/src/main/java/app/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private PresentationComponent presentationComponent;
// private GoogleAnalytics analytics;
// private Tracker tracker;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// initGcm();
// initGoogleAnalytics();
// }
//
// private void initInject() {
// presentationComponent = DaggerPresentationComponent.builder()
// .presentationModule(new PresentationModule(this))
// .build();
// }
//
// private void initGcm() {
// RxGcm.Notifications.register(this, GcmMessageReceiver.class, GcmReceiverBackground.class)
// .subscribe(token -> {}, error -> {});
//
// RxGcm.Notifications.onRefreshToken(GcmTokenReceiver.class);
// }
//
// private void initGoogleAnalytics() {
// analytics = GoogleAnalytics.getInstance(this);
//
// if(BuildConfig.DEBUG) {
// // true = for log output, it does not sent data to Google Analytics
// analytics.setDryRun(true);
// // To enable debug logging on a device run:
// // adb shell setprop log.tag.GAv4 DEBUG
// // adb logcat -s GAv4
// // true = disable google analytics on the app
// // analytics.setAppOptOut(true);
// }
//
// tracker = analytics.newTracker(getString(R.string.ga_trackingId));
// tracker.enableExceptionReporting(true);
// tracker.enableAdvertisingIdCollection(true);
// tracker.enableAutoActivityTracking(false);
// }
//
// public Tracker getTracker() {
// return tracker;
// }
//
// public PresentationComponent getPresentationComponent() {
// return presentationComponent;
// }
//
// @Nullable public BaseActivity getLiveActivity(){
// return (BaseActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: app/src/main/java/app/presentation/sections/launch/LaunchActivity.java
// public class LaunchActivity extends BaseActivity {
// @Inject GoogleAnalyticsSender googleAnalytics;
//
// @Override protected void injectDagger() {
// getApplicationComponent().inject(this);
// }
//
// @Override protected void initViews() {
// super.initViews();
// wireframe.dashboard();
// googleAnalytics.send(this.getClass().getSimpleName());
// }
// }
| import android.app.Activity;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Before;
import org.junit.Rule;
import org.junit.runner.RunWith;
import app.presentation.foundation.BaseApp;
import app.presentation.sections.launch.LaunchActivity; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.common;
@RunWith(AndroidJUnit4.class)
public abstract class BaseTest {
public static final long SHORT_WAIT = 1000;
public static final long MEDIUM_WAIT = 2500;
public static final long LONG_WAIT = 5000;
public static void shortWait() {
waitTime(SHORT_WAIT);
}
public static void mediumWait() {
waitTime(MEDIUM_WAIT);
}
public static void longWait() {
waitTime(LONG_WAIT);
}
private static void waitTime(long time) {
try {Thread.sleep(time);
} catch (InterruptedException e) { e.printStackTrace();}
}
| // Path: app/src/main/java/app/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private PresentationComponent presentationComponent;
// private GoogleAnalytics analytics;
// private Tracker tracker;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// initGcm();
// initGoogleAnalytics();
// }
//
// private void initInject() {
// presentationComponent = DaggerPresentationComponent.builder()
// .presentationModule(new PresentationModule(this))
// .build();
// }
//
// private void initGcm() {
// RxGcm.Notifications.register(this, GcmMessageReceiver.class, GcmReceiverBackground.class)
// .subscribe(token -> {}, error -> {});
//
// RxGcm.Notifications.onRefreshToken(GcmTokenReceiver.class);
// }
//
// private void initGoogleAnalytics() {
// analytics = GoogleAnalytics.getInstance(this);
//
// if(BuildConfig.DEBUG) {
// // true = for log output, it does not sent data to Google Analytics
// analytics.setDryRun(true);
// // To enable debug logging on a device run:
// // adb shell setprop log.tag.GAv4 DEBUG
// // adb logcat -s GAv4
// // true = disable google analytics on the app
// // analytics.setAppOptOut(true);
// }
//
// tracker = analytics.newTracker(getString(R.string.ga_trackingId));
// tracker.enableExceptionReporting(true);
// tracker.enableAdvertisingIdCollection(true);
// tracker.enableAutoActivityTracking(false);
// }
//
// public Tracker getTracker() {
// return tracker;
// }
//
// public PresentationComponent getPresentationComponent() {
// return presentationComponent;
// }
//
// @Nullable public BaseActivity getLiveActivity(){
// return (BaseActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: app/src/main/java/app/presentation/sections/launch/LaunchActivity.java
// public class LaunchActivity extends BaseActivity {
// @Inject GoogleAnalyticsSender googleAnalytics;
//
// @Override protected void injectDagger() {
// getApplicationComponent().inject(this);
// }
//
// @Override protected void initViews() {
// super.initViews();
// wireframe.dashboard();
// googleAnalytics.send(this.getClass().getSimpleName());
// }
// }
// Path: app/src/androidTest/java/app/common/BaseTest.java
import android.app.Activity;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Before;
import org.junit.Rule;
import org.junit.runner.RunWith;
import app.presentation.foundation.BaseApp;
import app.presentation.sections.launch.LaunchActivity;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.common;
@RunWith(AndroidJUnit4.class)
public abstract class BaseTest {
public static final long SHORT_WAIT = 1000;
public static final long MEDIUM_WAIT = 2500;
public static final long LONG_WAIT = 5000;
public static void shortWait() {
waitTime(SHORT_WAIT);
}
public static void mediumWait() {
waitTime(MEDIUM_WAIT);
}
public static void longWait() {
waitTime(LONG_WAIT);
}
private static void waitTime(long time) {
try {Thread.sleep(time);
} catch (InterruptedException e) { e.printStackTrace();}
}
| @Rule public ActivityTestRule<LaunchActivity> mActivityRule = new ActivityTestRule<>(LaunchActivity.class); |
FuckBoilerplate/base_app_android | app/src/androidTest/java/app/common/BaseTest.java | // Path: app/src/main/java/app/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private PresentationComponent presentationComponent;
// private GoogleAnalytics analytics;
// private Tracker tracker;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// initGcm();
// initGoogleAnalytics();
// }
//
// private void initInject() {
// presentationComponent = DaggerPresentationComponent.builder()
// .presentationModule(new PresentationModule(this))
// .build();
// }
//
// private void initGcm() {
// RxGcm.Notifications.register(this, GcmMessageReceiver.class, GcmReceiverBackground.class)
// .subscribe(token -> {}, error -> {});
//
// RxGcm.Notifications.onRefreshToken(GcmTokenReceiver.class);
// }
//
// private void initGoogleAnalytics() {
// analytics = GoogleAnalytics.getInstance(this);
//
// if(BuildConfig.DEBUG) {
// // true = for log output, it does not sent data to Google Analytics
// analytics.setDryRun(true);
// // To enable debug logging on a device run:
// // adb shell setprop log.tag.GAv4 DEBUG
// // adb logcat -s GAv4
// // true = disable google analytics on the app
// // analytics.setAppOptOut(true);
// }
//
// tracker = analytics.newTracker(getString(R.string.ga_trackingId));
// tracker.enableExceptionReporting(true);
// tracker.enableAdvertisingIdCollection(true);
// tracker.enableAutoActivityTracking(false);
// }
//
// public Tracker getTracker() {
// return tracker;
// }
//
// public PresentationComponent getPresentationComponent() {
// return presentationComponent;
// }
//
// @Nullable public BaseActivity getLiveActivity(){
// return (BaseActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: app/src/main/java/app/presentation/sections/launch/LaunchActivity.java
// public class LaunchActivity extends BaseActivity {
// @Inject GoogleAnalyticsSender googleAnalytics;
//
// @Override protected void injectDagger() {
// getApplicationComponent().inject(this);
// }
//
// @Override protected void initViews() {
// super.initViews();
// wireframe.dashboard();
// googleAnalytics.send(this.getClass().getSimpleName());
// }
// }
| import android.app.Activity;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Before;
import org.junit.Rule;
import org.junit.runner.RunWith;
import app.presentation.foundation.BaseApp;
import app.presentation.sections.launch.LaunchActivity; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.common;
@RunWith(AndroidJUnit4.class)
public abstract class BaseTest {
public static final long SHORT_WAIT = 1000;
public static final long MEDIUM_WAIT = 2500;
public static final long LONG_WAIT = 5000;
public static void shortWait() {
waitTime(SHORT_WAIT);
}
public static void mediumWait() {
waitTime(MEDIUM_WAIT);
}
public static void longWait() {
waitTime(LONG_WAIT);
}
private static void waitTime(long time) {
try {Thread.sleep(time);
} catch (InterruptedException e) { e.printStackTrace();}
}
@Rule public ActivityTestRule<LaunchActivity> mActivityRule = new ActivityTestRule<>(LaunchActivity.class);
@Before public void init() {}
protected Activity getCurrentActivity() { | // Path: app/src/main/java/app/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private PresentationComponent presentationComponent;
// private GoogleAnalytics analytics;
// private Tracker tracker;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// initGcm();
// initGoogleAnalytics();
// }
//
// private void initInject() {
// presentationComponent = DaggerPresentationComponent.builder()
// .presentationModule(new PresentationModule(this))
// .build();
// }
//
// private void initGcm() {
// RxGcm.Notifications.register(this, GcmMessageReceiver.class, GcmReceiverBackground.class)
// .subscribe(token -> {}, error -> {});
//
// RxGcm.Notifications.onRefreshToken(GcmTokenReceiver.class);
// }
//
// private void initGoogleAnalytics() {
// analytics = GoogleAnalytics.getInstance(this);
//
// if(BuildConfig.DEBUG) {
// // true = for log output, it does not sent data to Google Analytics
// analytics.setDryRun(true);
// // To enable debug logging on a device run:
// // adb shell setprop log.tag.GAv4 DEBUG
// // adb logcat -s GAv4
// // true = disable google analytics on the app
// // analytics.setAppOptOut(true);
// }
//
// tracker = analytics.newTracker(getString(R.string.ga_trackingId));
// tracker.enableExceptionReporting(true);
// tracker.enableAdvertisingIdCollection(true);
// tracker.enableAutoActivityTracking(false);
// }
//
// public Tracker getTracker() {
// return tracker;
// }
//
// public PresentationComponent getPresentationComponent() {
// return presentationComponent;
// }
//
// @Nullable public BaseActivity getLiveActivity(){
// return (BaseActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: app/src/main/java/app/presentation/sections/launch/LaunchActivity.java
// public class LaunchActivity extends BaseActivity {
// @Inject GoogleAnalyticsSender googleAnalytics;
//
// @Override protected void injectDagger() {
// getApplicationComponent().inject(this);
// }
//
// @Override protected void initViews() {
// super.initViews();
// wireframe.dashboard();
// googleAnalytics.send(this.getClass().getSimpleName());
// }
// }
// Path: app/src/androidTest/java/app/common/BaseTest.java
import android.app.Activity;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Before;
import org.junit.Rule;
import org.junit.runner.RunWith;
import app.presentation.foundation.BaseApp;
import app.presentation.sections.launch.LaunchActivity;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.common;
@RunWith(AndroidJUnit4.class)
public abstract class BaseTest {
public static final long SHORT_WAIT = 1000;
public static final long MEDIUM_WAIT = 2500;
public static final long LONG_WAIT = 5000;
public static void shortWait() {
waitTime(SHORT_WAIT);
}
public static void mediumWait() {
waitTime(MEDIUM_WAIT);
}
public static void longWait() {
waitTime(LONG_WAIT);
}
private static void waitTime(long time) {
try {Thread.sleep(time);
} catch (InterruptedException e) { e.printStackTrace();}
}
@Rule public ActivityTestRule<LaunchActivity> mActivityRule = new ActivityTestRule<>(LaunchActivity.class);
@Before public void init() {}
protected Activity getCurrentActivity() { | BaseApp app = (BaseApp) InstrumentationRegistry.getTargetContext().getApplicationContext(); |
FuckBoilerplate/base_app_android | app/src/androidTest/java/app/sections/dashboard/DashboardTest.java | // Path: app/src/androidTest/java/app/common/BaseTest.java
// @RunWith(AndroidJUnit4.class)
// public abstract class BaseTest {
// public static final long SHORT_WAIT = 1000;
// public static final long MEDIUM_WAIT = 2500;
// public static final long LONG_WAIT = 5000;
//
// public static void shortWait() {
// waitTime(SHORT_WAIT);
// }
//
// public static void mediumWait() {
// waitTime(MEDIUM_WAIT);
// }
//
// public static void longWait() {
// waitTime(LONG_WAIT);
// }
//
// private static void waitTime(long time) {
// try {Thread.sleep(time);
// } catch (InterruptedException e) { e.printStackTrace();}
// }
//
// @Rule public ActivityTestRule<LaunchActivity> mActivityRule = new ActivityTestRule<>(LaunchActivity.class);
//
// @Before public void init() {}
//
// protected Activity getCurrentActivity() {
// BaseApp app = (BaseApp) InstrumentationRegistry.getTargetContext().getApplicationContext();
// return app.getLiveActivity();
// }
//
// }
//
// Path: app/src/androidTest/java/app/common/ViewActions.java
// public static ViewAction actionCloseDrawer() {
// return new ViewAction() {
// @Override public Matcher<View> getConstraints() {
// return isAssignableFrom(DrawerLayout.class);
// }
//
// @Override public String getDescription() {
// return "close drawer";
// }
//
// @Override public void perform(UiController uiController, View view) {
// ((DrawerLayout) view).closeDrawer(GravityCompat.START);
// }
// };
// }
//
// Path: app/src/androidTest/java/app/common/ViewActions.java
// public static ViewAction actionOpenDrawer() {
// return new ViewAction() {
// @Override public Matcher<View> getConstraints() {
// return isAssignableFrom(DrawerLayout.class);
// }
//
// @Override public String getDescription() {
// return "open drawer";
// }
//
// @Override public void perform(UiController uiController, View view) {
// ((DrawerLayout) view).openDrawer(GravityCompat.START);
// }
// };
// }
| import android.support.test.espresso.matcher.ViewMatchers;
import org.base_app_android.R;
import org.hamcrest.Matchers;
import org.junit.Test;
import app.common.BaseTest;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static app.common.ViewActions.actionCloseDrawer;
import static app.common.ViewActions.actionOpenDrawer; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.sections.dashboard;
public class DashboardTest extends BaseTest {
@Test public void Open_And_Close_Users() { | // Path: app/src/androidTest/java/app/common/BaseTest.java
// @RunWith(AndroidJUnit4.class)
// public abstract class BaseTest {
// public static final long SHORT_WAIT = 1000;
// public static final long MEDIUM_WAIT = 2500;
// public static final long LONG_WAIT = 5000;
//
// public static void shortWait() {
// waitTime(SHORT_WAIT);
// }
//
// public static void mediumWait() {
// waitTime(MEDIUM_WAIT);
// }
//
// public static void longWait() {
// waitTime(LONG_WAIT);
// }
//
// private static void waitTime(long time) {
// try {Thread.sleep(time);
// } catch (InterruptedException e) { e.printStackTrace();}
// }
//
// @Rule public ActivityTestRule<LaunchActivity> mActivityRule = new ActivityTestRule<>(LaunchActivity.class);
//
// @Before public void init() {}
//
// protected Activity getCurrentActivity() {
// BaseApp app = (BaseApp) InstrumentationRegistry.getTargetContext().getApplicationContext();
// return app.getLiveActivity();
// }
//
// }
//
// Path: app/src/androidTest/java/app/common/ViewActions.java
// public static ViewAction actionCloseDrawer() {
// return new ViewAction() {
// @Override public Matcher<View> getConstraints() {
// return isAssignableFrom(DrawerLayout.class);
// }
//
// @Override public String getDescription() {
// return "close drawer";
// }
//
// @Override public void perform(UiController uiController, View view) {
// ((DrawerLayout) view).closeDrawer(GravityCompat.START);
// }
// };
// }
//
// Path: app/src/androidTest/java/app/common/ViewActions.java
// public static ViewAction actionOpenDrawer() {
// return new ViewAction() {
// @Override public Matcher<View> getConstraints() {
// return isAssignableFrom(DrawerLayout.class);
// }
//
// @Override public String getDescription() {
// return "open drawer";
// }
//
// @Override public void perform(UiController uiController, View view) {
// ((DrawerLayout) view).openDrawer(GravityCompat.START);
// }
// };
// }
// Path: app/src/androidTest/java/app/sections/dashboard/DashboardTest.java
import android.support.test.espresso.matcher.ViewMatchers;
import org.base_app_android.R;
import org.hamcrest.Matchers;
import org.junit.Test;
import app.common.BaseTest;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static app.common.ViewActions.actionCloseDrawer;
import static app.common.ViewActions.actionOpenDrawer;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.sections.dashboard;
public class DashboardTest extends BaseTest {
@Test public void Open_And_Close_Users() { | onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer()); |
FuckBoilerplate/base_app_android | app/src/androidTest/java/app/sections/dashboard/DashboardTest.java | // Path: app/src/androidTest/java/app/common/BaseTest.java
// @RunWith(AndroidJUnit4.class)
// public abstract class BaseTest {
// public static final long SHORT_WAIT = 1000;
// public static final long MEDIUM_WAIT = 2500;
// public static final long LONG_WAIT = 5000;
//
// public static void shortWait() {
// waitTime(SHORT_WAIT);
// }
//
// public static void mediumWait() {
// waitTime(MEDIUM_WAIT);
// }
//
// public static void longWait() {
// waitTime(LONG_WAIT);
// }
//
// private static void waitTime(long time) {
// try {Thread.sleep(time);
// } catch (InterruptedException e) { e.printStackTrace();}
// }
//
// @Rule public ActivityTestRule<LaunchActivity> mActivityRule = new ActivityTestRule<>(LaunchActivity.class);
//
// @Before public void init() {}
//
// protected Activity getCurrentActivity() {
// BaseApp app = (BaseApp) InstrumentationRegistry.getTargetContext().getApplicationContext();
// return app.getLiveActivity();
// }
//
// }
//
// Path: app/src/androidTest/java/app/common/ViewActions.java
// public static ViewAction actionCloseDrawer() {
// return new ViewAction() {
// @Override public Matcher<View> getConstraints() {
// return isAssignableFrom(DrawerLayout.class);
// }
//
// @Override public String getDescription() {
// return "close drawer";
// }
//
// @Override public void perform(UiController uiController, View view) {
// ((DrawerLayout) view).closeDrawer(GravityCompat.START);
// }
// };
// }
//
// Path: app/src/androidTest/java/app/common/ViewActions.java
// public static ViewAction actionOpenDrawer() {
// return new ViewAction() {
// @Override public Matcher<View> getConstraints() {
// return isAssignableFrom(DrawerLayout.class);
// }
//
// @Override public String getDescription() {
// return "open drawer";
// }
//
// @Override public void perform(UiController uiController, View view) {
// ((DrawerLayout) view).openDrawer(GravityCompat.START);
// }
// };
// }
| import android.support.test.espresso.matcher.ViewMatchers;
import org.base_app_android.R;
import org.hamcrest.Matchers;
import org.junit.Test;
import app.common.BaseTest;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static app.common.ViewActions.actionCloseDrawer;
import static app.common.ViewActions.actionOpenDrawer; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.sections.dashboard;
public class DashboardTest extends BaseTest {
@Test public void Open_And_Close_Users() {
onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
mediumWait();
onView(Matchers.allOf(ViewMatchers.withId(R.id.navigation_view), ViewMatchers.hasDescendant(withText(R.string.users)))).perform(click());
| // Path: app/src/androidTest/java/app/common/BaseTest.java
// @RunWith(AndroidJUnit4.class)
// public abstract class BaseTest {
// public static final long SHORT_WAIT = 1000;
// public static final long MEDIUM_WAIT = 2500;
// public static final long LONG_WAIT = 5000;
//
// public static void shortWait() {
// waitTime(SHORT_WAIT);
// }
//
// public static void mediumWait() {
// waitTime(MEDIUM_WAIT);
// }
//
// public static void longWait() {
// waitTime(LONG_WAIT);
// }
//
// private static void waitTime(long time) {
// try {Thread.sleep(time);
// } catch (InterruptedException e) { e.printStackTrace();}
// }
//
// @Rule public ActivityTestRule<LaunchActivity> mActivityRule = new ActivityTestRule<>(LaunchActivity.class);
//
// @Before public void init() {}
//
// protected Activity getCurrentActivity() {
// BaseApp app = (BaseApp) InstrumentationRegistry.getTargetContext().getApplicationContext();
// return app.getLiveActivity();
// }
//
// }
//
// Path: app/src/androidTest/java/app/common/ViewActions.java
// public static ViewAction actionCloseDrawer() {
// return new ViewAction() {
// @Override public Matcher<View> getConstraints() {
// return isAssignableFrom(DrawerLayout.class);
// }
//
// @Override public String getDescription() {
// return "close drawer";
// }
//
// @Override public void perform(UiController uiController, View view) {
// ((DrawerLayout) view).closeDrawer(GravityCompat.START);
// }
// };
// }
//
// Path: app/src/androidTest/java/app/common/ViewActions.java
// public static ViewAction actionOpenDrawer() {
// return new ViewAction() {
// @Override public Matcher<View> getConstraints() {
// return isAssignableFrom(DrawerLayout.class);
// }
//
// @Override public String getDescription() {
// return "open drawer";
// }
//
// @Override public void perform(UiController uiController, View view) {
// ((DrawerLayout) view).openDrawer(GravityCompat.START);
// }
// };
// }
// Path: app/src/androidTest/java/app/sections/dashboard/DashboardTest.java
import android.support.test.espresso.matcher.ViewMatchers;
import org.base_app_android.R;
import org.hamcrest.Matchers;
import org.junit.Test;
import app.common.BaseTest;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static app.common.ViewActions.actionCloseDrawer;
import static app.common.ViewActions.actionOpenDrawer;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.sections.dashboard;
public class DashboardTest extends BaseTest {
@Test public void Open_And_Close_Users() {
onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
mediumWait();
onView(Matchers.allOf(ViewMatchers.withId(R.id.navigation_view), ViewMatchers.hasDescendant(withText(R.string.users)))).perform(click());
| onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer()); |
FuckBoilerplate/base_app_android | app/src/main/java/app/data/foundation/gcm/GcmMessageReceiver.java | // Path: app/src/main/java/app/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private PresentationComponent presentationComponent;
// private GoogleAnalytics analytics;
// private Tracker tracker;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// initGcm();
// initGoogleAnalytics();
// }
//
// private void initInject() {
// presentationComponent = DaggerPresentationComponent.builder()
// .presentationModule(new PresentationModule(this))
// .build();
// }
//
// private void initGcm() {
// RxGcm.Notifications.register(this, GcmMessageReceiver.class, GcmReceiverBackground.class)
// .subscribe(token -> {}, error -> {});
//
// RxGcm.Notifications.onRefreshToken(GcmTokenReceiver.class);
// }
//
// private void initGoogleAnalytics() {
// analytics = GoogleAnalytics.getInstance(this);
//
// if(BuildConfig.DEBUG) {
// // true = for log output, it does not sent data to Google Analytics
// analytics.setDryRun(true);
// // To enable debug logging on a device run:
// // adb shell setprop log.tag.GAv4 DEBUG
// // adb logcat -s GAv4
// // true = disable google analytics on the app
// // analytics.setAppOptOut(true);
// }
//
// tracker = analytics.newTracker(getString(R.string.ga_trackingId));
// tracker.enableExceptionReporting(true);
// tracker.enableAdvertisingIdCollection(true);
// tracker.enableAutoActivityTracking(false);
// }
//
// public Tracker getTracker() {
// return tracker;
// }
//
// public PresentationComponent getPresentationComponent() {
// return presentationComponent;
// }
//
// @Nullable public BaseActivity getLiveActivity(){
// return (BaseActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
| import app.presentation.foundation.BaseApp;
import rx.Observable;
import rx_gcm.GcmReceiverData;
import rx_gcm.Message; | package app.data.foundation.gcm;
/**
* Created by victor on 12/04/16.
*/
public final class GcmMessageReceiver implements GcmReceiverData {
@Override public Observable<Message> onNotification(Observable<Message> oMessage) {
return oMessage.flatMap(message -> { | // Path: app/src/main/java/app/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private PresentationComponent presentationComponent;
// private GoogleAnalytics analytics;
// private Tracker tracker;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// initGcm();
// initGoogleAnalytics();
// }
//
// private void initInject() {
// presentationComponent = DaggerPresentationComponent.builder()
// .presentationModule(new PresentationModule(this))
// .build();
// }
//
// private void initGcm() {
// RxGcm.Notifications.register(this, GcmMessageReceiver.class, GcmReceiverBackground.class)
// .subscribe(token -> {}, error -> {});
//
// RxGcm.Notifications.onRefreshToken(GcmTokenReceiver.class);
// }
//
// private void initGoogleAnalytics() {
// analytics = GoogleAnalytics.getInstance(this);
//
// if(BuildConfig.DEBUG) {
// // true = for log output, it does not sent data to Google Analytics
// analytics.setDryRun(true);
// // To enable debug logging on a device run:
// // adb shell setprop log.tag.GAv4 DEBUG
// // adb logcat -s GAv4
// // true = disable google analytics on the app
// // analytics.setAppOptOut(true);
// }
//
// tracker = analytics.newTracker(getString(R.string.ga_trackingId));
// tracker.enableExceptionReporting(true);
// tracker.enableAdvertisingIdCollection(true);
// tracker.enableAutoActivityTracking(false);
// }
//
// public Tracker getTracker() {
// return tracker;
// }
//
// public PresentationComponent getPresentationComponent() {
// return presentationComponent;
// }
//
// @Nullable public BaseActivity getLiveActivity(){
// return (BaseActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
// Path: app/src/main/java/app/data/foundation/gcm/GcmMessageReceiver.java
import app.presentation.foundation.BaseApp;
import rx.Observable;
import rx_gcm.GcmReceiverData;
import rx_gcm.Message;
package app.data.foundation.gcm;
/**
* Created by victor on 12/04/16.
*/
public final class GcmMessageReceiver implements GcmReceiverData {
@Override public Observable<Message> onNotification(Observable<Message> oMessage) {
return oMessage.flatMap(message -> { | BaseApp baseApp = (BaseApp) message.application(); |
FuckBoilerplate/base_app_android | app/src/main/java/app/presentation/foundation/views/BaseActivity.java | // Path: app/src/main/java/app/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private PresentationComponent presentationComponent;
// private GoogleAnalytics analytics;
// private Tracker tracker;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// initGcm();
// initGoogleAnalytics();
// }
//
// private void initInject() {
// presentationComponent = DaggerPresentationComponent.builder()
// .presentationModule(new PresentationModule(this))
// .build();
// }
//
// private void initGcm() {
// RxGcm.Notifications.register(this, GcmMessageReceiver.class, GcmReceiverBackground.class)
// .subscribe(token -> {}, error -> {});
//
// RxGcm.Notifications.onRefreshToken(GcmTokenReceiver.class);
// }
//
// private void initGoogleAnalytics() {
// analytics = GoogleAnalytics.getInstance(this);
//
// if(BuildConfig.DEBUG) {
// // true = for log output, it does not sent data to Google Analytics
// analytics.setDryRun(true);
// // To enable debug logging on a device run:
// // adb shell setprop log.tag.GAv4 DEBUG
// // adb logcat -s GAv4
// // true = disable google analytics on the app
// // analytics.setAppOptOut(true);
// }
//
// tracker = analytics.newTracker(getString(R.string.ga_trackingId));
// tracker.enableExceptionReporting(true);
// tracker.enableAdvertisingIdCollection(true);
// tracker.enableAutoActivityTracking(false);
// }
//
// public Tracker getTracker() {
// return tracker;
// }
//
// public PresentationComponent getPresentationComponent() {
// return presentationComponent;
// }
//
// @Nullable public BaseActivity getLiveActivity(){
// return (BaseActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: app/src/main/java/app/presentation/foundation/dagger/PresentationComponent.java
// @Singleton @Component(modules = {PresentationModule.class})
// public interface PresentationComponent {
// void inject(LaunchActivity launchActivity);
//
// void inject(DashBoardActivity dashBoardActivity);
// void inject(UserFragment userFragment);
// void inject(UsersFragment usersFragment);
// void inject(SearchUserFragment searchUserFragment);
//
// void inject(GcmTokenReceiver gcmTokenReceiver);
// void inject(GcmMessageReceiver gcmMessageReceiver);
// }
//
// Path: app/src/main/java/app/presentation/sections/Wireframe.java
// public class Wireframe {
// private final BaseApp baseApp;
//
// @Inject public Wireframe(BaseApp baseApp) {
// this.baseApp = baseApp;
// }
//
// public void dashboard() {
// baseApp.getLiveActivity().startActivity(new Intent(baseApp, DashBoardActivity.class));
// }
//
// public void userScreen() {
// Bundle bundle = new Bundle();
// bundle.putString(BaseActivity.Behaviour.TITLE_KEY, baseApp.getString(R.string.user));
// bundle.putSerializable(BaseActivity.Behaviour.FRAGMENT_CLASS_KEY, UserFragment.class);
//
// Intent intent = new Intent(baseApp, SingleActivity.class);
// intent.putExtras(bundle);
// baseApp.getLiveActivity().startActivity(intent);
// }
//
// public void searchUserScreen() {
// Bundle bundleFragment = new Bundle();
// bundleFragment.putString(SearchUserFragment.HELLO_FROM_BUNDLE_WIREFRAME_KEY, "Hi from wireframe bundle");
//
// Bundle bundle = new Bundle();
// bundle.putString(BaseActivity.Behaviour.TITLE_KEY, baseApp.getString(R.string.find_user));
// bundle.putSerializable(BaseActivity.Behaviour.FRAGMENT_CLASS_KEY, SearchUserFragment.class);
// bundle.putBundle(BaseActivity.Behaviour.BUNDLE_FOR_FRAGMENT, bundleFragment);
//
// Intent intent = new Intent(baseApp, SingleActivity.class);
// intent.putExtras(bundle);
// baseApp.getLiveActivity().startActivity(intent);
// }
//
//
// public void popCurrentScreen() {
// baseApp.getLiveActivity().onBackPressed();
// }
// }
| import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import com.afollestad.materialdialogs.MaterialDialog;
import org.base_app_android.R;
import java.io.Serializable;
import javax.inject.Inject;
import app.presentation.foundation.BaseApp;
import app.presentation.foundation.dagger.PresentationComponent;
import app.presentation.sections.Wireframe;
import butterknife.Bind;
import butterknife.ButterKnife;
import rx.Observable; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.presentation.foundation.views;
public abstract class BaseActivity extends AppCompatActivity {
@Nullable @Bind(R.id.app_bar) protected AppBarLayout app_bar;
@Nullable @Bind(R.id.toolbar) protected Toolbar toolbar; | // Path: app/src/main/java/app/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private PresentationComponent presentationComponent;
// private GoogleAnalytics analytics;
// private Tracker tracker;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// initGcm();
// initGoogleAnalytics();
// }
//
// private void initInject() {
// presentationComponent = DaggerPresentationComponent.builder()
// .presentationModule(new PresentationModule(this))
// .build();
// }
//
// private void initGcm() {
// RxGcm.Notifications.register(this, GcmMessageReceiver.class, GcmReceiverBackground.class)
// .subscribe(token -> {}, error -> {});
//
// RxGcm.Notifications.onRefreshToken(GcmTokenReceiver.class);
// }
//
// private void initGoogleAnalytics() {
// analytics = GoogleAnalytics.getInstance(this);
//
// if(BuildConfig.DEBUG) {
// // true = for log output, it does not sent data to Google Analytics
// analytics.setDryRun(true);
// // To enable debug logging on a device run:
// // adb shell setprop log.tag.GAv4 DEBUG
// // adb logcat -s GAv4
// // true = disable google analytics on the app
// // analytics.setAppOptOut(true);
// }
//
// tracker = analytics.newTracker(getString(R.string.ga_trackingId));
// tracker.enableExceptionReporting(true);
// tracker.enableAdvertisingIdCollection(true);
// tracker.enableAutoActivityTracking(false);
// }
//
// public Tracker getTracker() {
// return tracker;
// }
//
// public PresentationComponent getPresentationComponent() {
// return presentationComponent;
// }
//
// @Nullable public BaseActivity getLiveActivity(){
// return (BaseActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
//
// Path: app/src/main/java/app/presentation/foundation/dagger/PresentationComponent.java
// @Singleton @Component(modules = {PresentationModule.class})
// public interface PresentationComponent {
// void inject(LaunchActivity launchActivity);
//
// void inject(DashBoardActivity dashBoardActivity);
// void inject(UserFragment userFragment);
// void inject(UsersFragment usersFragment);
// void inject(SearchUserFragment searchUserFragment);
//
// void inject(GcmTokenReceiver gcmTokenReceiver);
// void inject(GcmMessageReceiver gcmMessageReceiver);
// }
//
// Path: app/src/main/java/app/presentation/sections/Wireframe.java
// public class Wireframe {
// private final BaseApp baseApp;
//
// @Inject public Wireframe(BaseApp baseApp) {
// this.baseApp = baseApp;
// }
//
// public void dashboard() {
// baseApp.getLiveActivity().startActivity(new Intent(baseApp, DashBoardActivity.class));
// }
//
// public void userScreen() {
// Bundle bundle = new Bundle();
// bundle.putString(BaseActivity.Behaviour.TITLE_KEY, baseApp.getString(R.string.user));
// bundle.putSerializable(BaseActivity.Behaviour.FRAGMENT_CLASS_KEY, UserFragment.class);
//
// Intent intent = new Intent(baseApp, SingleActivity.class);
// intent.putExtras(bundle);
// baseApp.getLiveActivity().startActivity(intent);
// }
//
// public void searchUserScreen() {
// Bundle bundleFragment = new Bundle();
// bundleFragment.putString(SearchUserFragment.HELLO_FROM_BUNDLE_WIREFRAME_KEY, "Hi from wireframe bundle");
//
// Bundle bundle = new Bundle();
// bundle.putString(BaseActivity.Behaviour.TITLE_KEY, baseApp.getString(R.string.find_user));
// bundle.putSerializable(BaseActivity.Behaviour.FRAGMENT_CLASS_KEY, SearchUserFragment.class);
// bundle.putBundle(BaseActivity.Behaviour.BUNDLE_FOR_FRAGMENT, bundleFragment);
//
// Intent intent = new Intent(baseApp, SingleActivity.class);
// intent.putExtras(bundle);
// baseApp.getLiveActivity().startActivity(intent);
// }
//
//
// public void popCurrentScreen() {
// baseApp.getLiveActivity().onBackPressed();
// }
// }
// Path: app/src/main/java/app/presentation/foundation/views/BaseActivity.java
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import com.afollestad.materialdialogs.MaterialDialog;
import org.base_app_android.R;
import java.io.Serializable;
import javax.inject.Inject;
import app.presentation.foundation.BaseApp;
import app.presentation.foundation.dagger.PresentationComponent;
import app.presentation.sections.Wireframe;
import butterknife.Bind;
import butterknife.ButterKnife;
import rx.Observable;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.presentation.foundation.views;
public abstract class BaseActivity extends AppCompatActivity {
@Nullable @Bind(R.id.app_bar) protected AppBarLayout app_bar;
@Nullable @Bind(R.id.toolbar) protected Toolbar toolbar; | @Inject protected Wireframe wireframe; |
FuckBoilerplate/base_app_android | app/src/main/java/app/presentation/sections/user_demo/list/UsersPresenter.java | // Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/sections/WireframeRepository.java
// public class WireframeRepository extends Repository {
//
// @Inject public WireframeRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// super(restApi, rxProviders, uiUtils);
// }
//
// public <T> Observable<T> getWireframeCurrentObject() {
// return rxProviders
// .<T>getWireframeCurrentObject(Observable.just(null), new EvictProvider(false))
// .doOnError(throwable -> {
// throw new WireframeException();
// });
// }
//
// public Observable<Void> setWireframeCurrentObject(Object object) {
// return rxProviders.getWireframeCurrentObject(Observable.just(object), new EvictProvider(true))
// .map(_I -> null);
// }
//
// public class WireframeException extends RuntimeException {
//
// public WireframeException() {
// super("There is not cached object in the wireframe");
// }
//
// }
// }
//
// Path: app/src/main/java/app/data/sections/user_demo/UserRepository.java
// public class UserRepository extends Repository {
// public static final int USERS_PER_PAGE = 50, MAX_USERS_TO_LOAD = 300;
//
// @Inject public UserRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// super(restApi, rxProviders, uiUtils);
// }
//
// @RxLogObservable
// public Observable<List<User>> getUsers(Integer lastIdQueried, final boolean refresh) {
// lastIdQueried = lastIdQueried == null ? FIRST_ID_QUERIED : lastIdQueried;
//
// Observable<List<User>> loader = restApi.getUsers(lastIdQueried, USERS_PER_PAGE).map(response -> {
// handleError(response);
// return response.body();
// });
//
//
// if (lastIdQueried == FIRST_ID_QUERIED) {
// loader = rxProviders.getUsers(loader, new DynamicKey(lastIdQueried), new EvictProvider(refresh));
// }
//
// return loader;
// }
//
// @RxLogObservable
// public Observable<User> searchByUserName(final String username) {
// return restApi.getUserByName(username).map(response -> {
// handleError(response);
// final User user = response.body();
// return user;
// });
// }
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
//
// Path: app/src/main/java/app/presentation/foundation/PresenterFragment.java
// public abstract class PresenterFragment {
// protected final WireframeRepository wireframeRepository;
// protected final UIUtils uiUtils;
//
// protected PresenterFragment(WireframeRepository wireframeRepository, UIUtils uiUtils) {
// this.wireframeRepository = wireframeRepository;
// this.uiUtils = uiUtils;
// }
//
// public Observable<Void> dataForNextScreen(Object data) {
// return wireframeRepository.setWireframeCurrentObject(data);
// }
// }
| import android.text.TextUtils;
import java.util.List;
import javax.inject.Inject;
import app.data.foundation.UIUtils;
import app.data.sections.WireframeRepository;
import app.data.sections.user_demo.UserRepository;
import app.domain.user_demo.User;
import app.presentation.foundation.PresenterFragment;
import rx.Observable; | package app.presentation.sections.user_demo.list;
/**
* Created by victor on 08/04/16.
*/
public class UsersPresenter extends PresenterFragment {
private final UserRepository repository;
| // Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/sections/WireframeRepository.java
// public class WireframeRepository extends Repository {
//
// @Inject public WireframeRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// super(restApi, rxProviders, uiUtils);
// }
//
// public <T> Observable<T> getWireframeCurrentObject() {
// return rxProviders
// .<T>getWireframeCurrentObject(Observable.just(null), new EvictProvider(false))
// .doOnError(throwable -> {
// throw new WireframeException();
// });
// }
//
// public Observable<Void> setWireframeCurrentObject(Object object) {
// return rxProviders.getWireframeCurrentObject(Observable.just(object), new EvictProvider(true))
// .map(_I -> null);
// }
//
// public class WireframeException extends RuntimeException {
//
// public WireframeException() {
// super("There is not cached object in the wireframe");
// }
//
// }
// }
//
// Path: app/src/main/java/app/data/sections/user_demo/UserRepository.java
// public class UserRepository extends Repository {
// public static final int USERS_PER_PAGE = 50, MAX_USERS_TO_LOAD = 300;
//
// @Inject public UserRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// super(restApi, rxProviders, uiUtils);
// }
//
// @RxLogObservable
// public Observable<List<User>> getUsers(Integer lastIdQueried, final boolean refresh) {
// lastIdQueried = lastIdQueried == null ? FIRST_ID_QUERIED : lastIdQueried;
//
// Observable<List<User>> loader = restApi.getUsers(lastIdQueried, USERS_PER_PAGE).map(response -> {
// handleError(response);
// return response.body();
// });
//
//
// if (lastIdQueried == FIRST_ID_QUERIED) {
// loader = rxProviders.getUsers(loader, new DynamicKey(lastIdQueried), new EvictProvider(refresh));
// }
//
// return loader;
// }
//
// @RxLogObservable
// public Observable<User> searchByUserName(final String username) {
// return restApi.getUserByName(username).map(response -> {
// handleError(response);
// final User user = response.body();
// return user;
// });
// }
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
//
// Path: app/src/main/java/app/presentation/foundation/PresenterFragment.java
// public abstract class PresenterFragment {
// protected final WireframeRepository wireframeRepository;
// protected final UIUtils uiUtils;
//
// protected PresenterFragment(WireframeRepository wireframeRepository, UIUtils uiUtils) {
// this.wireframeRepository = wireframeRepository;
// this.uiUtils = uiUtils;
// }
//
// public Observable<Void> dataForNextScreen(Object data) {
// return wireframeRepository.setWireframeCurrentObject(data);
// }
// }
// Path: app/src/main/java/app/presentation/sections/user_demo/list/UsersPresenter.java
import android.text.TextUtils;
import java.util.List;
import javax.inject.Inject;
import app.data.foundation.UIUtils;
import app.data.sections.WireframeRepository;
import app.data.sections.user_demo.UserRepository;
import app.domain.user_demo.User;
import app.presentation.foundation.PresenterFragment;
import rx.Observable;
package app.presentation.sections.user_demo.list;
/**
* Created by victor on 08/04/16.
*/
public class UsersPresenter extends PresenterFragment {
private final UserRepository repository;
| @Inject public UsersPresenter(WireframeRepository wireframeRepository, UserRepository repository, UIUtils uiUtils) { |
FuckBoilerplate/base_app_android | app/src/main/java/app/presentation/sections/user_demo/list/UsersPresenter.java | // Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/sections/WireframeRepository.java
// public class WireframeRepository extends Repository {
//
// @Inject public WireframeRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// super(restApi, rxProviders, uiUtils);
// }
//
// public <T> Observable<T> getWireframeCurrentObject() {
// return rxProviders
// .<T>getWireframeCurrentObject(Observable.just(null), new EvictProvider(false))
// .doOnError(throwable -> {
// throw new WireframeException();
// });
// }
//
// public Observable<Void> setWireframeCurrentObject(Object object) {
// return rxProviders.getWireframeCurrentObject(Observable.just(object), new EvictProvider(true))
// .map(_I -> null);
// }
//
// public class WireframeException extends RuntimeException {
//
// public WireframeException() {
// super("There is not cached object in the wireframe");
// }
//
// }
// }
//
// Path: app/src/main/java/app/data/sections/user_demo/UserRepository.java
// public class UserRepository extends Repository {
// public static final int USERS_PER_PAGE = 50, MAX_USERS_TO_LOAD = 300;
//
// @Inject public UserRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// super(restApi, rxProviders, uiUtils);
// }
//
// @RxLogObservable
// public Observable<List<User>> getUsers(Integer lastIdQueried, final boolean refresh) {
// lastIdQueried = lastIdQueried == null ? FIRST_ID_QUERIED : lastIdQueried;
//
// Observable<List<User>> loader = restApi.getUsers(lastIdQueried, USERS_PER_PAGE).map(response -> {
// handleError(response);
// return response.body();
// });
//
//
// if (lastIdQueried == FIRST_ID_QUERIED) {
// loader = rxProviders.getUsers(loader, new DynamicKey(lastIdQueried), new EvictProvider(refresh));
// }
//
// return loader;
// }
//
// @RxLogObservable
// public Observable<User> searchByUserName(final String username) {
// return restApi.getUserByName(username).map(response -> {
// handleError(response);
// final User user = response.body();
// return user;
// });
// }
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
//
// Path: app/src/main/java/app/presentation/foundation/PresenterFragment.java
// public abstract class PresenterFragment {
// protected final WireframeRepository wireframeRepository;
// protected final UIUtils uiUtils;
//
// protected PresenterFragment(WireframeRepository wireframeRepository, UIUtils uiUtils) {
// this.wireframeRepository = wireframeRepository;
// this.uiUtils = uiUtils;
// }
//
// public Observable<Void> dataForNextScreen(Object data) {
// return wireframeRepository.setWireframeCurrentObject(data);
// }
// }
| import android.text.TextUtils;
import java.util.List;
import javax.inject.Inject;
import app.data.foundation.UIUtils;
import app.data.sections.WireframeRepository;
import app.data.sections.user_demo.UserRepository;
import app.domain.user_demo.User;
import app.presentation.foundation.PresenterFragment;
import rx.Observable; | package app.presentation.sections.user_demo.list;
/**
* Created by victor on 08/04/16.
*/
public class UsersPresenter extends PresenterFragment {
private final UserRepository repository;
| // Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/sections/WireframeRepository.java
// public class WireframeRepository extends Repository {
//
// @Inject public WireframeRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// super(restApi, rxProviders, uiUtils);
// }
//
// public <T> Observable<T> getWireframeCurrentObject() {
// return rxProviders
// .<T>getWireframeCurrentObject(Observable.just(null), new EvictProvider(false))
// .doOnError(throwable -> {
// throw new WireframeException();
// });
// }
//
// public Observable<Void> setWireframeCurrentObject(Object object) {
// return rxProviders.getWireframeCurrentObject(Observable.just(object), new EvictProvider(true))
// .map(_I -> null);
// }
//
// public class WireframeException extends RuntimeException {
//
// public WireframeException() {
// super("There is not cached object in the wireframe");
// }
//
// }
// }
//
// Path: app/src/main/java/app/data/sections/user_demo/UserRepository.java
// public class UserRepository extends Repository {
// public static final int USERS_PER_PAGE = 50, MAX_USERS_TO_LOAD = 300;
//
// @Inject public UserRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// super(restApi, rxProviders, uiUtils);
// }
//
// @RxLogObservable
// public Observable<List<User>> getUsers(Integer lastIdQueried, final boolean refresh) {
// lastIdQueried = lastIdQueried == null ? FIRST_ID_QUERIED : lastIdQueried;
//
// Observable<List<User>> loader = restApi.getUsers(lastIdQueried, USERS_PER_PAGE).map(response -> {
// handleError(response);
// return response.body();
// });
//
//
// if (lastIdQueried == FIRST_ID_QUERIED) {
// loader = rxProviders.getUsers(loader, new DynamicKey(lastIdQueried), new EvictProvider(refresh));
// }
//
// return loader;
// }
//
// @RxLogObservable
// public Observable<User> searchByUserName(final String username) {
// return restApi.getUserByName(username).map(response -> {
// handleError(response);
// final User user = response.body();
// return user;
// });
// }
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
//
// Path: app/src/main/java/app/presentation/foundation/PresenterFragment.java
// public abstract class PresenterFragment {
// protected final WireframeRepository wireframeRepository;
// protected final UIUtils uiUtils;
//
// protected PresenterFragment(WireframeRepository wireframeRepository, UIUtils uiUtils) {
// this.wireframeRepository = wireframeRepository;
// this.uiUtils = uiUtils;
// }
//
// public Observable<Void> dataForNextScreen(Object data) {
// return wireframeRepository.setWireframeCurrentObject(data);
// }
// }
// Path: app/src/main/java/app/presentation/sections/user_demo/list/UsersPresenter.java
import android.text.TextUtils;
import java.util.List;
import javax.inject.Inject;
import app.data.foundation.UIUtils;
import app.data.sections.WireframeRepository;
import app.data.sections.user_demo.UserRepository;
import app.domain.user_demo.User;
import app.presentation.foundation.PresenterFragment;
import rx.Observable;
package app.presentation.sections.user_demo.list;
/**
* Created by victor on 08/04/16.
*/
public class UsersPresenter extends PresenterFragment {
private final UserRepository repository;
| @Inject public UsersPresenter(WireframeRepository wireframeRepository, UserRepository repository, UIUtils uiUtils) { |
FuckBoilerplate/base_app_android | app/src/main/java/app/presentation/sections/user_demo/list/UsersPresenter.java | // Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/sections/WireframeRepository.java
// public class WireframeRepository extends Repository {
//
// @Inject public WireframeRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// super(restApi, rxProviders, uiUtils);
// }
//
// public <T> Observable<T> getWireframeCurrentObject() {
// return rxProviders
// .<T>getWireframeCurrentObject(Observable.just(null), new EvictProvider(false))
// .doOnError(throwable -> {
// throw new WireframeException();
// });
// }
//
// public Observable<Void> setWireframeCurrentObject(Object object) {
// return rxProviders.getWireframeCurrentObject(Observable.just(object), new EvictProvider(true))
// .map(_I -> null);
// }
//
// public class WireframeException extends RuntimeException {
//
// public WireframeException() {
// super("There is not cached object in the wireframe");
// }
//
// }
// }
//
// Path: app/src/main/java/app/data/sections/user_demo/UserRepository.java
// public class UserRepository extends Repository {
// public static final int USERS_PER_PAGE = 50, MAX_USERS_TO_LOAD = 300;
//
// @Inject public UserRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// super(restApi, rxProviders, uiUtils);
// }
//
// @RxLogObservable
// public Observable<List<User>> getUsers(Integer lastIdQueried, final boolean refresh) {
// lastIdQueried = lastIdQueried == null ? FIRST_ID_QUERIED : lastIdQueried;
//
// Observable<List<User>> loader = restApi.getUsers(lastIdQueried, USERS_PER_PAGE).map(response -> {
// handleError(response);
// return response.body();
// });
//
//
// if (lastIdQueried == FIRST_ID_QUERIED) {
// loader = rxProviders.getUsers(loader, new DynamicKey(lastIdQueried), new EvictProvider(refresh));
// }
//
// return loader;
// }
//
// @RxLogObservable
// public Observable<User> searchByUserName(final String username) {
// return restApi.getUserByName(username).map(response -> {
// handleError(response);
// final User user = response.body();
// return user;
// });
// }
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
//
// Path: app/src/main/java/app/presentation/foundation/PresenterFragment.java
// public abstract class PresenterFragment {
// protected final WireframeRepository wireframeRepository;
// protected final UIUtils uiUtils;
//
// protected PresenterFragment(WireframeRepository wireframeRepository, UIUtils uiUtils) {
// this.wireframeRepository = wireframeRepository;
// this.uiUtils = uiUtils;
// }
//
// public Observable<Void> dataForNextScreen(Object data) {
// return wireframeRepository.setWireframeCurrentObject(data);
// }
// }
| import android.text.TextUtils;
import java.util.List;
import javax.inject.Inject;
import app.data.foundation.UIUtils;
import app.data.sections.WireframeRepository;
import app.data.sections.user_demo.UserRepository;
import app.domain.user_demo.User;
import app.presentation.foundation.PresenterFragment;
import rx.Observable; | package app.presentation.sections.user_demo.list;
/**
* Created by victor on 08/04/16.
*/
public class UsersPresenter extends PresenterFragment {
private final UserRepository repository;
@Inject public UsersPresenter(WireframeRepository wireframeRepository, UserRepository repository, UIUtils uiUtils) {
super(wireframeRepository, uiUtils);
this.repository = repository;
}
| // Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/sections/WireframeRepository.java
// public class WireframeRepository extends Repository {
//
// @Inject public WireframeRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// super(restApi, rxProviders, uiUtils);
// }
//
// public <T> Observable<T> getWireframeCurrentObject() {
// return rxProviders
// .<T>getWireframeCurrentObject(Observable.just(null), new EvictProvider(false))
// .doOnError(throwable -> {
// throw new WireframeException();
// });
// }
//
// public Observable<Void> setWireframeCurrentObject(Object object) {
// return rxProviders.getWireframeCurrentObject(Observable.just(object), new EvictProvider(true))
// .map(_I -> null);
// }
//
// public class WireframeException extends RuntimeException {
//
// public WireframeException() {
// super("There is not cached object in the wireframe");
// }
//
// }
// }
//
// Path: app/src/main/java/app/data/sections/user_demo/UserRepository.java
// public class UserRepository extends Repository {
// public static final int USERS_PER_PAGE = 50, MAX_USERS_TO_LOAD = 300;
//
// @Inject public UserRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// super(restApi, rxProviders, uiUtils);
// }
//
// @RxLogObservable
// public Observable<List<User>> getUsers(Integer lastIdQueried, final boolean refresh) {
// lastIdQueried = lastIdQueried == null ? FIRST_ID_QUERIED : lastIdQueried;
//
// Observable<List<User>> loader = restApi.getUsers(lastIdQueried, USERS_PER_PAGE).map(response -> {
// handleError(response);
// return response.body();
// });
//
//
// if (lastIdQueried == FIRST_ID_QUERIED) {
// loader = rxProviders.getUsers(loader, new DynamicKey(lastIdQueried), new EvictProvider(refresh));
// }
//
// return loader;
// }
//
// @RxLogObservable
// public Observable<User> searchByUserName(final String username) {
// return restApi.getUserByName(username).map(response -> {
// handleError(response);
// final User user = response.body();
// return user;
// });
// }
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
//
// Path: app/src/main/java/app/presentation/foundation/PresenterFragment.java
// public abstract class PresenterFragment {
// protected final WireframeRepository wireframeRepository;
// protected final UIUtils uiUtils;
//
// protected PresenterFragment(WireframeRepository wireframeRepository, UIUtils uiUtils) {
// this.wireframeRepository = wireframeRepository;
// this.uiUtils = uiUtils;
// }
//
// public Observable<Void> dataForNextScreen(Object data) {
// return wireframeRepository.setWireframeCurrentObject(data);
// }
// }
// Path: app/src/main/java/app/presentation/sections/user_demo/list/UsersPresenter.java
import android.text.TextUtils;
import java.util.List;
import javax.inject.Inject;
import app.data.foundation.UIUtils;
import app.data.sections.WireframeRepository;
import app.data.sections.user_demo.UserRepository;
import app.domain.user_demo.User;
import app.presentation.foundation.PresenterFragment;
import rx.Observable;
package app.presentation.sections.user_demo.list;
/**
* Created by victor on 08/04/16.
*/
public class UsersPresenter extends PresenterFragment {
private final UserRepository repository;
@Inject public UsersPresenter(WireframeRepository wireframeRepository, UserRepository repository, UIUtils uiUtils) {
super(wireframeRepository, uiUtils);
this.repository = repository;
}
| public Observable<List<User>> nextPage(User user, String query) { |
FuckBoilerplate/base_app_android | app/src/main/java/app/data/sections/user_demo/UserRepository.java | // Path: app/src/main/java/app/data/foundation/Repository.java
// public abstract class Repository {
// public static final int PER_PAGE = 50, FIRST_ID_QUERIED = 0;
// protected final RestApi restApi;
// protected final RxProviders rxProviders;
// protected final UIUtils uiUtils;
//
// public Repository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// this.restApi = restApi;
// this.rxProviders = rxProviders;
// this.uiUtils = uiUtils;
// }
//
// protected void handleError(Response response) {
// if (response.isSuccessful()) return;
//
// try {
// ResponseError responseError = new Gson().fromJson(response.errorBody().string(), ResponseError.class);
// throw new BadResponseException(responseError.getMessage());
// } catch (JsonParseException |IOException exception) {
// throw new RuntimeException(exception.getMessage());
// }
// }
//
// @Data private static class ResponseError {
// private final String message;
// }
// }
//
// Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/foundation/cache/RxProviders.java
// public interface RxProviders {
// <T> Observable<T> getWireframeCurrentObject(Observable<T> oObject, EvictProvider evictProvider);
// Observable<List<User>> getUsers(Observable<List<User>> oUsers, DynamicKey dynamicKey, EvictProvider evictProvider);
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import com.fernandocejas.frodo.annotation.RxLogObservable;
import java.util.List;
import javax.inject.Inject;
import app.data.foundation.Repository;
import app.data.foundation.UIUtils;
import app.data.foundation.cache.RxProviders;
import app.data.foundation.net.RestApi;
import app.domain.user_demo.User;
import io.rx_cache.DynamicKey;
import io.rx_cache.EvictProvider;
import rx.Observable; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.sections.user_demo;
public class UserRepository extends Repository {
public static final int USERS_PER_PAGE = 50, MAX_USERS_TO_LOAD = 300;
| // Path: app/src/main/java/app/data/foundation/Repository.java
// public abstract class Repository {
// public static final int PER_PAGE = 50, FIRST_ID_QUERIED = 0;
// protected final RestApi restApi;
// protected final RxProviders rxProviders;
// protected final UIUtils uiUtils;
//
// public Repository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// this.restApi = restApi;
// this.rxProviders = rxProviders;
// this.uiUtils = uiUtils;
// }
//
// protected void handleError(Response response) {
// if (response.isSuccessful()) return;
//
// try {
// ResponseError responseError = new Gson().fromJson(response.errorBody().string(), ResponseError.class);
// throw new BadResponseException(responseError.getMessage());
// } catch (JsonParseException |IOException exception) {
// throw new RuntimeException(exception.getMessage());
// }
// }
//
// @Data private static class ResponseError {
// private final String message;
// }
// }
//
// Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/foundation/cache/RxProviders.java
// public interface RxProviders {
// <T> Observable<T> getWireframeCurrentObject(Observable<T> oObject, EvictProvider evictProvider);
// Observable<List<User>> getUsers(Observable<List<User>> oUsers, DynamicKey dynamicKey, EvictProvider evictProvider);
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: app/src/main/java/app/data/sections/user_demo/UserRepository.java
import com.fernandocejas.frodo.annotation.RxLogObservable;
import java.util.List;
import javax.inject.Inject;
import app.data.foundation.Repository;
import app.data.foundation.UIUtils;
import app.data.foundation.cache.RxProviders;
import app.data.foundation.net.RestApi;
import app.domain.user_demo.User;
import io.rx_cache.DynamicKey;
import io.rx_cache.EvictProvider;
import rx.Observable;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.sections.user_demo;
public class UserRepository extends Repository {
public static final int USERS_PER_PAGE = 50, MAX_USERS_TO_LOAD = 300;
| @Inject public UserRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) { |
FuckBoilerplate/base_app_android | app/src/main/java/app/data/sections/user_demo/UserRepository.java | // Path: app/src/main/java/app/data/foundation/Repository.java
// public abstract class Repository {
// public static final int PER_PAGE = 50, FIRST_ID_QUERIED = 0;
// protected final RestApi restApi;
// protected final RxProviders rxProviders;
// protected final UIUtils uiUtils;
//
// public Repository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// this.restApi = restApi;
// this.rxProviders = rxProviders;
// this.uiUtils = uiUtils;
// }
//
// protected void handleError(Response response) {
// if (response.isSuccessful()) return;
//
// try {
// ResponseError responseError = new Gson().fromJson(response.errorBody().string(), ResponseError.class);
// throw new BadResponseException(responseError.getMessage());
// } catch (JsonParseException |IOException exception) {
// throw new RuntimeException(exception.getMessage());
// }
// }
//
// @Data private static class ResponseError {
// private final String message;
// }
// }
//
// Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/foundation/cache/RxProviders.java
// public interface RxProviders {
// <T> Observable<T> getWireframeCurrentObject(Observable<T> oObject, EvictProvider evictProvider);
// Observable<List<User>> getUsers(Observable<List<User>> oUsers, DynamicKey dynamicKey, EvictProvider evictProvider);
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import com.fernandocejas.frodo.annotation.RxLogObservable;
import java.util.List;
import javax.inject.Inject;
import app.data.foundation.Repository;
import app.data.foundation.UIUtils;
import app.data.foundation.cache.RxProviders;
import app.data.foundation.net.RestApi;
import app.domain.user_demo.User;
import io.rx_cache.DynamicKey;
import io.rx_cache.EvictProvider;
import rx.Observable; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.sections.user_demo;
public class UserRepository extends Repository {
public static final int USERS_PER_PAGE = 50, MAX_USERS_TO_LOAD = 300;
| // Path: app/src/main/java/app/data/foundation/Repository.java
// public abstract class Repository {
// public static final int PER_PAGE = 50, FIRST_ID_QUERIED = 0;
// protected final RestApi restApi;
// protected final RxProviders rxProviders;
// protected final UIUtils uiUtils;
//
// public Repository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// this.restApi = restApi;
// this.rxProviders = rxProviders;
// this.uiUtils = uiUtils;
// }
//
// protected void handleError(Response response) {
// if (response.isSuccessful()) return;
//
// try {
// ResponseError responseError = new Gson().fromJson(response.errorBody().string(), ResponseError.class);
// throw new BadResponseException(responseError.getMessage());
// } catch (JsonParseException |IOException exception) {
// throw new RuntimeException(exception.getMessage());
// }
// }
//
// @Data private static class ResponseError {
// private final String message;
// }
// }
//
// Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/foundation/cache/RxProviders.java
// public interface RxProviders {
// <T> Observable<T> getWireframeCurrentObject(Observable<T> oObject, EvictProvider evictProvider);
// Observable<List<User>> getUsers(Observable<List<User>> oUsers, DynamicKey dynamicKey, EvictProvider evictProvider);
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: app/src/main/java/app/data/sections/user_demo/UserRepository.java
import com.fernandocejas.frodo.annotation.RxLogObservable;
import java.util.List;
import javax.inject.Inject;
import app.data.foundation.Repository;
import app.data.foundation.UIUtils;
import app.data.foundation.cache.RxProviders;
import app.data.foundation.net.RestApi;
import app.domain.user_demo.User;
import io.rx_cache.DynamicKey;
import io.rx_cache.EvictProvider;
import rx.Observable;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.sections.user_demo;
public class UserRepository extends Repository {
public static final int USERS_PER_PAGE = 50, MAX_USERS_TO_LOAD = 300;
| @Inject public UserRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) { |
FuckBoilerplate/base_app_android | app/src/main/java/app/data/sections/user_demo/UserRepository.java | // Path: app/src/main/java/app/data/foundation/Repository.java
// public abstract class Repository {
// public static final int PER_PAGE = 50, FIRST_ID_QUERIED = 0;
// protected final RestApi restApi;
// protected final RxProviders rxProviders;
// protected final UIUtils uiUtils;
//
// public Repository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// this.restApi = restApi;
// this.rxProviders = rxProviders;
// this.uiUtils = uiUtils;
// }
//
// protected void handleError(Response response) {
// if (response.isSuccessful()) return;
//
// try {
// ResponseError responseError = new Gson().fromJson(response.errorBody().string(), ResponseError.class);
// throw new BadResponseException(responseError.getMessage());
// } catch (JsonParseException |IOException exception) {
// throw new RuntimeException(exception.getMessage());
// }
// }
//
// @Data private static class ResponseError {
// private final String message;
// }
// }
//
// Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/foundation/cache/RxProviders.java
// public interface RxProviders {
// <T> Observable<T> getWireframeCurrentObject(Observable<T> oObject, EvictProvider evictProvider);
// Observable<List<User>> getUsers(Observable<List<User>> oUsers, DynamicKey dynamicKey, EvictProvider evictProvider);
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import com.fernandocejas.frodo.annotation.RxLogObservable;
import java.util.List;
import javax.inject.Inject;
import app.data.foundation.Repository;
import app.data.foundation.UIUtils;
import app.data.foundation.cache.RxProviders;
import app.data.foundation.net.RestApi;
import app.domain.user_demo.User;
import io.rx_cache.DynamicKey;
import io.rx_cache.EvictProvider;
import rx.Observable; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.sections.user_demo;
public class UserRepository extends Repository {
public static final int USERS_PER_PAGE = 50, MAX_USERS_TO_LOAD = 300;
| // Path: app/src/main/java/app/data/foundation/Repository.java
// public abstract class Repository {
// public static final int PER_PAGE = 50, FIRST_ID_QUERIED = 0;
// protected final RestApi restApi;
// protected final RxProviders rxProviders;
// protected final UIUtils uiUtils;
//
// public Repository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// this.restApi = restApi;
// this.rxProviders = rxProviders;
// this.uiUtils = uiUtils;
// }
//
// protected void handleError(Response response) {
// if (response.isSuccessful()) return;
//
// try {
// ResponseError responseError = new Gson().fromJson(response.errorBody().string(), ResponseError.class);
// throw new BadResponseException(responseError.getMessage());
// } catch (JsonParseException |IOException exception) {
// throw new RuntimeException(exception.getMessage());
// }
// }
//
// @Data private static class ResponseError {
// private final String message;
// }
// }
//
// Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/foundation/cache/RxProviders.java
// public interface RxProviders {
// <T> Observable<T> getWireframeCurrentObject(Observable<T> oObject, EvictProvider evictProvider);
// Observable<List<User>> getUsers(Observable<List<User>> oUsers, DynamicKey dynamicKey, EvictProvider evictProvider);
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: app/src/main/java/app/data/sections/user_demo/UserRepository.java
import com.fernandocejas.frodo.annotation.RxLogObservable;
import java.util.List;
import javax.inject.Inject;
import app.data.foundation.Repository;
import app.data.foundation.UIUtils;
import app.data.foundation.cache.RxProviders;
import app.data.foundation.net.RestApi;
import app.domain.user_demo.User;
import io.rx_cache.DynamicKey;
import io.rx_cache.EvictProvider;
import rx.Observable;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.sections.user_demo;
public class UserRepository extends Repository {
public static final int USERS_PER_PAGE = 50, MAX_USERS_TO_LOAD = 300;
| @Inject public UserRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) { |
FuckBoilerplate/base_app_android | app/src/main/java/app/data/sections/user_demo/UserRepository.java | // Path: app/src/main/java/app/data/foundation/Repository.java
// public abstract class Repository {
// public static final int PER_PAGE = 50, FIRST_ID_QUERIED = 0;
// protected final RestApi restApi;
// protected final RxProviders rxProviders;
// protected final UIUtils uiUtils;
//
// public Repository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// this.restApi = restApi;
// this.rxProviders = rxProviders;
// this.uiUtils = uiUtils;
// }
//
// protected void handleError(Response response) {
// if (response.isSuccessful()) return;
//
// try {
// ResponseError responseError = new Gson().fromJson(response.errorBody().string(), ResponseError.class);
// throw new BadResponseException(responseError.getMessage());
// } catch (JsonParseException |IOException exception) {
// throw new RuntimeException(exception.getMessage());
// }
// }
//
// @Data private static class ResponseError {
// private final String message;
// }
// }
//
// Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/foundation/cache/RxProviders.java
// public interface RxProviders {
// <T> Observable<T> getWireframeCurrentObject(Observable<T> oObject, EvictProvider evictProvider);
// Observable<List<User>> getUsers(Observable<List<User>> oUsers, DynamicKey dynamicKey, EvictProvider evictProvider);
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import com.fernandocejas.frodo.annotation.RxLogObservable;
import java.util.List;
import javax.inject.Inject;
import app.data.foundation.Repository;
import app.data.foundation.UIUtils;
import app.data.foundation.cache.RxProviders;
import app.data.foundation.net.RestApi;
import app.domain.user_demo.User;
import io.rx_cache.DynamicKey;
import io.rx_cache.EvictProvider;
import rx.Observable; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.sections.user_demo;
public class UserRepository extends Repository {
public static final int USERS_PER_PAGE = 50, MAX_USERS_TO_LOAD = 300;
@Inject public UserRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
super(restApi, rxProviders, uiUtils);
}
@RxLogObservable | // Path: app/src/main/java/app/data/foundation/Repository.java
// public abstract class Repository {
// public static final int PER_PAGE = 50, FIRST_ID_QUERIED = 0;
// protected final RestApi restApi;
// protected final RxProviders rxProviders;
// protected final UIUtils uiUtils;
//
// public Repository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// this.restApi = restApi;
// this.rxProviders = rxProviders;
// this.uiUtils = uiUtils;
// }
//
// protected void handleError(Response response) {
// if (response.isSuccessful()) return;
//
// try {
// ResponseError responseError = new Gson().fromJson(response.errorBody().string(), ResponseError.class);
// throw new BadResponseException(responseError.getMessage());
// } catch (JsonParseException |IOException exception) {
// throw new RuntimeException(exception.getMessage());
// }
// }
//
// @Data private static class ResponseError {
// private final String message;
// }
// }
//
// Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/foundation/cache/RxProviders.java
// public interface RxProviders {
// <T> Observable<T> getWireframeCurrentObject(Observable<T> oObject, EvictProvider evictProvider);
// Observable<List<User>> getUsers(Observable<List<User>> oUsers, DynamicKey dynamicKey, EvictProvider evictProvider);
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: app/src/main/java/app/data/sections/user_demo/UserRepository.java
import com.fernandocejas.frodo.annotation.RxLogObservable;
import java.util.List;
import javax.inject.Inject;
import app.data.foundation.Repository;
import app.data.foundation.UIUtils;
import app.data.foundation.cache.RxProviders;
import app.data.foundation.net.RestApi;
import app.domain.user_demo.User;
import io.rx_cache.DynamicKey;
import io.rx_cache.EvictProvider;
import rx.Observable;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.sections.user_demo;
public class UserRepository extends Repository {
public static final int USERS_PER_PAGE = 50, MAX_USERS_TO_LOAD = 300;
@Inject public UserRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
super(restApi, rxProviders, uiUtils);
}
@RxLogObservable | public Observable<List<User>> getUsers(Integer lastIdQueried, final boolean refresh) { |
FuckBoilerplate/base_app_android | app/src/main/java/app/presentation/foundation/gcm/GcmReceiverBackground.java | // Path: app/src/main/java/app/domain/foundation/gcm/GcmNotification.java
// @Data public class GcmNotification<T> {
// private final T data;
// private final String title, body;
//
// public static GcmNotification getMessageFromGcmNotification(Message message) {
// return getMessageFromGcmNotification(Object.class, message);
// }
//
// public static <T> GcmNotification<T> getMessageFromGcmNotification(Class<T> classData, Message message) {
// String payload = message.payload().getString("payload");
// String title = message.payload().getString("title");
// String body = message.payload().getString("body");
//
// Type type = $Gson$Types.newParameterizedTypeWithOwner(null, classData);
// T data = new Gson().fromJson(payload, type);
//
// return new GcmNotification(data, title, body);
// }
//
// public static <T> GcmNotification<List<T>> getMessageArrayListFromGcmNotification(Class<T> classData, Message message) {
// String payload = message.payload().getString("payload");
// String title = message.payload().getString("title");
// String body = message.payload().getString("body");
//
// Type typeCollection = $Gson$Types.newParameterizedTypeWithOwner(null, ArrayList.class, classData);
//
// List<T> data = new GsonBuilder().create().fromJson(payload, typeCollection);
// return new GcmNotification(data, title, body);
// }
//
// public static <T> T getDataFromGcmNotification(@Nullable Class<T> classData, Message message) {
// return getMessageFromGcmNotification(classData, message).getData();
// }
//
// public static <T> List<T> getDataArrayListFromGcmNotification(@Nullable Class<T> classData, Message message) {
// return getMessageArrayListFromGcmNotification(classData, message).getData();
// }
// }
//
// Path: app/src/main/java/app/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private PresentationComponent presentationComponent;
// private GoogleAnalytics analytics;
// private Tracker tracker;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// initGcm();
// initGoogleAnalytics();
// }
//
// private void initInject() {
// presentationComponent = DaggerPresentationComponent.builder()
// .presentationModule(new PresentationModule(this))
// .build();
// }
//
// private void initGcm() {
// RxGcm.Notifications.register(this, GcmMessageReceiver.class, GcmReceiverBackground.class)
// .subscribe(token -> {}, error -> {});
//
// RxGcm.Notifications.onRefreshToken(GcmTokenReceiver.class);
// }
//
// private void initGoogleAnalytics() {
// analytics = GoogleAnalytics.getInstance(this);
//
// if(BuildConfig.DEBUG) {
// // true = for log output, it does not sent data to Google Analytics
// analytics.setDryRun(true);
// // To enable debug logging on a device run:
// // adb shell setprop log.tag.GAv4 DEBUG
// // adb logcat -s GAv4
// // true = disable google analytics on the app
// // analytics.setAppOptOut(true);
// }
//
// tracker = analytics.newTracker(getString(R.string.ga_trackingId));
// tracker.enableExceptionReporting(true);
// tracker.enableAdvertisingIdCollection(true);
// tracker.enableAutoActivityTracking(false);
// }
//
// public Tracker getTracker() {
// return tracker;
// }
//
// public PresentationComponent getPresentationComponent() {
// return presentationComponent;
// }
//
// @Nullable public BaseActivity getLiveActivity(){
// return (BaseActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
| import android.app.Application;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.support.v4.app.NotificationCompat;
import org.base_app_android.R;
import app.domain.foundation.gcm.GcmNotification;
import app.presentation.foundation.BaseApp;
import rx.Observable;
import rx_gcm.GcmReceiverUIBackground;
import rx_gcm.Message; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.presentation.foundation.gcm;
public class GcmReceiverBackground implements GcmReceiverUIBackground {
@Override public void onNotification(Observable<Message> oMessage) {
oMessage.subscribe(message -> { | // Path: app/src/main/java/app/domain/foundation/gcm/GcmNotification.java
// @Data public class GcmNotification<T> {
// private final T data;
// private final String title, body;
//
// public static GcmNotification getMessageFromGcmNotification(Message message) {
// return getMessageFromGcmNotification(Object.class, message);
// }
//
// public static <T> GcmNotification<T> getMessageFromGcmNotification(Class<T> classData, Message message) {
// String payload = message.payload().getString("payload");
// String title = message.payload().getString("title");
// String body = message.payload().getString("body");
//
// Type type = $Gson$Types.newParameterizedTypeWithOwner(null, classData);
// T data = new Gson().fromJson(payload, type);
//
// return new GcmNotification(data, title, body);
// }
//
// public static <T> GcmNotification<List<T>> getMessageArrayListFromGcmNotification(Class<T> classData, Message message) {
// String payload = message.payload().getString("payload");
// String title = message.payload().getString("title");
// String body = message.payload().getString("body");
//
// Type typeCollection = $Gson$Types.newParameterizedTypeWithOwner(null, ArrayList.class, classData);
//
// List<T> data = new GsonBuilder().create().fromJson(payload, typeCollection);
// return new GcmNotification(data, title, body);
// }
//
// public static <T> T getDataFromGcmNotification(@Nullable Class<T> classData, Message message) {
// return getMessageFromGcmNotification(classData, message).getData();
// }
//
// public static <T> List<T> getDataArrayListFromGcmNotification(@Nullable Class<T> classData, Message message) {
// return getMessageArrayListFromGcmNotification(classData, message).getData();
// }
// }
//
// Path: app/src/main/java/app/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private PresentationComponent presentationComponent;
// private GoogleAnalytics analytics;
// private Tracker tracker;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// initGcm();
// initGoogleAnalytics();
// }
//
// private void initInject() {
// presentationComponent = DaggerPresentationComponent.builder()
// .presentationModule(new PresentationModule(this))
// .build();
// }
//
// private void initGcm() {
// RxGcm.Notifications.register(this, GcmMessageReceiver.class, GcmReceiverBackground.class)
// .subscribe(token -> {}, error -> {});
//
// RxGcm.Notifications.onRefreshToken(GcmTokenReceiver.class);
// }
//
// private void initGoogleAnalytics() {
// analytics = GoogleAnalytics.getInstance(this);
//
// if(BuildConfig.DEBUG) {
// // true = for log output, it does not sent data to Google Analytics
// analytics.setDryRun(true);
// // To enable debug logging on a device run:
// // adb shell setprop log.tag.GAv4 DEBUG
// // adb logcat -s GAv4
// // true = disable google analytics on the app
// // analytics.setAppOptOut(true);
// }
//
// tracker = analytics.newTracker(getString(R.string.ga_trackingId));
// tracker.enableExceptionReporting(true);
// tracker.enableAdvertisingIdCollection(true);
// tracker.enableAutoActivityTracking(false);
// }
//
// public Tracker getTracker() {
// return tracker;
// }
//
// public PresentationComponent getPresentationComponent() {
// return presentationComponent;
// }
//
// @Nullable public BaseActivity getLiveActivity(){
// return (BaseActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
// Path: app/src/main/java/app/presentation/foundation/gcm/GcmReceiverBackground.java
import android.app.Application;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.support.v4.app.NotificationCompat;
import org.base_app_android.R;
import app.domain.foundation.gcm.GcmNotification;
import app.presentation.foundation.BaseApp;
import rx.Observable;
import rx_gcm.GcmReceiverUIBackground;
import rx_gcm.Message;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.presentation.foundation.gcm;
public class GcmReceiverBackground implements GcmReceiverUIBackground {
@Override public void onNotification(Observable<Message> oMessage) {
oMessage.subscribe(message -> { | BaseApp baseApp = (BaseApp) message.application(); |
FuckBoilerplate/base_app_android | app/src/main/java/app/presentation/foundation/gcm/GcmReceiverBackground.java | // Path: app/src/main/java/app/domain/foundation/gcm/GcmNotification.java
// @Data public class GcmNotification<T> {
// private final T data;
// private final String title, body;
//
// public static GcmNotification getMessageFromGcmNotification(Message message) {
// return getMessageFromGcmNotification(Object.class, message);
// }
//
// public static <T> GcmNotification<T> getMessageFromGcmNotification(Class<T> classData, Message message) {
// String payload = message.payload().getString("payload");
// String title = message.payload().getString("title");
// String body = message.payload().getString("body");
//
// Type type = $Gson$Types.newParameterizedTypeWithOwner(null, classData);
// T data = new Gson().fromJson(payload, type);
//
// return new GcmNotification(data, title, body);
// }
//
// public static <T> GcmNotification<List<T>> getMessageArrayListFromGcmNotification(Class<T> classData, Message message) {
// String payload = message.payload().getString("payload");
// String title = message.payload().getString("title");
// String body = message.payload().getString("body");
//
// Type typeCollection = $Gson$Types.newParameterizedTypeWithOwner(null, ArrayList.class, classData);
//
// List<T> data = new GsonBuilder().create().fromJson(payload, typeCollection);
// return new GcmNotification(data, title, body);
// }
//
// public static <T> T getDataFromGcmNotification(@Nullable Class<T> classData, Message message) {
// return getMessageFromGcmNotification(classData, message).getData();
// }
//
// public static <T> List<T> getDataArrayListFromGcmNotification(@Nullable Class<T> classData, Message message) {
// return getMessageArrayListFromGcmNotification(classData, message).getData();
// }
// }
//
// Path: app/src/main/java/app/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private PresentationComponent presentationComponent;
// private GoogleAnalytics analytics;
// private Tracker tracker;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// initGcm();
// initGoogleAnalytics();
// }
//
// private void initInject() {
// presentationComponent = DaggerPresentationComponent.builder()
// .presentationModule(new PresentationModule(this))
// .build();
// }
//
// private void initGcm() {
// RxGcm.Notifications.register(this, GcmMessageReceiver.class, GcmReceiverBackground.class)
// .subscribe(token -> {}, error -> {});
//
// RxGcm.Notifications.onRefreshToken(GcmTokenReceiver.class);
// }
//
// private void initGoogleAnalytics() {
// analytics = GoogleAnalytics.getInstance(this);
//
// if(BuildConfig.DEBUG) {
// // true = for log output, it does not sent data to Google Analytics
// analytics.setDryRun(true);
// // To enable debug logging on a device run:
// // adb shell setprop log.tag.GAv4 DEBUG
// // adb logcat -s GAv4
// // true = disable google analytics on the app
// // analytics.setAppOptOut(true);
// }
//
// tracker = analytics.newTracker(getString(R.string.ga_trackingId));
// tracker.enableExceptionReporting(true);
// tracker.enableAdvertisingIdCollection(true);
// tracker.enableAutoActivityTracking(false);
// }
//
// public Tracker getTracker() {
// return tracker;
// }
//
// public PresentationComponent getPresentationComponent() {
// return presentationComponent;
// }
//
// @Nullable public BaseActivity getLiveActivity(){
// return (BaseActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
| import android.app.Application;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.support.v4.app.NotificationCompat;
import org.base_app_android.R;
import app.domain.foundation.gcm.GcmNotification;
import app.presentation.foundation.BaseApp;
import rx.Observable;
import rx_gcm.GcmReceiverUIBackground;
import rx_gcm.Message; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.presentation.foundation.gcm;
public class GcmReceiverBackground implements GcmReceiverUIBackground {
@Override public void onNotification(Observable<Message> oMessage) {
oMessage.subscribe(message -> {
BaseApp baseApp = (BaseApp) message.application();
| // Path: app/src/main/java/app/domain/foundation/gcm/GcmNotification.java
// @Data public class GcmNotification<T> {
// private final T data;
// private final String title, body;
//
// public static GcmNotification getMessageFromGcmNotification(Message message) {
// return getMessageFromGcmNotification(Object.class, message);
// }
//
// public static <T> GcmNotification<T> getMessageFromGcmNotification(Class<T> classData, Message message) {
// String payload = message.payload().getString("payload");
// String title = message.payload().getString("title");
// String body = message.payload().getString("body");
//
// Type type = $Gson$Types.newParameterizedTypeWithOwner(null, classData);
// T data = new Gson().fromJson(payload, type);
//
// return new GcmNotification(data, title, body);
// }
//
// public static <T> GcmNotification<List<T>> getMessageArrayListFromGcmNotification(Class<T> classData, Message message) {
// String payload = message.payload().getString("payload");
// String title = message.payload().getString("title");
// String body = message.payload().getString("body");
//
// Type typeCollection = $Gson$Types.newParameterizedTypeWithOwner(null, ArrayList.class, classData);
//
// List<T> data = new GsonBuilder().create().fromJson(payload, typeCollection);
// return new GcmNotification(data, title, body);
// }
//
// public static <T> T getDataFromGcmNotification(@Nullable Class<T> classData, Message message) {
// return getMessageFromGcmNotification(classData, message).getData();
// }
//
// public static <T> List<T> getDataArrayListFromGcmNotification(@Nullable Class<T> classData, Message message) {
// return getMessageArrayListFromGcmNotification(classData, message).getData();
// }
// }
//
// Path: app/src/main/java/app/presentation/foundation/BaseApp.java
// public class BaseApp extends Application {
// private PresentationComponent presentationComponent;
// private GoogleAnalytics analytics;
// private Tracker tracker;
//
// @Override public void onCreate() {
// super.onCreate();
// initInject();
// AppCare.YesSir.takeCareOn(this);
// initGcm();
// initGoogleAnalytics();
// }
//
// private void initInject() {
// presentationComponent = DaggerPresentationComponent.builder()
// .presentationModule(new PresentationModule(this))
// .build();
// }
//
// private void initGcm() {
// RxGcm.Notifications.register(this, GcmMessageReceiver.class, GcmReceiverBackground.class)
// .subscribe(token -> {}, error -> {});
//
// RxGcm.Notifications.onRefreshToken(GcmTokenReceiver.class);
// }
//
// private void initGoogleAnalytics() {
// analytics = GoogleAnalytics.getInstance(this);
//
// if(BuildConfig.DEBUG) {
// // true = for log output, it does not sent data to Google Analytics
// analytics.setDryRun(true);
// // To enable debug logging on a device run:
// // adb shell setprop log.tag.GAv4 DEBUG
// // adb logcat -s GAv4
// // true = disable google analytics on the app
// // analytics.setAppOptOut(true);
// }
//
// tracker = analytics.newTracker(getString(R.string.ga_trackingId));
// tracker.enableExceptionReporting(true);
// tracker.enableAdvertisingIdCollection(true);
// tracker.enableAutoActivityTracking(false);
// }
//
// public Tracker getTracker() {
// return tracker;
// }
//
// public PresentationComponent getPresentationComponent() {
// return presentationComponent;
// }
//
// @Nullable public BaseActivity getLiveActivity(){
// return (BaseActivity) AppCare.YesSir.getLiveActivityOrNull();
// }
// }
// Path: app/src/main/java/app/presentation/foundation/gcm/GcmReceiverBackground.java
import android.app.Application;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.support.v4.app.NotificationCompat;
import org.base_app_android.R;
import app.domain.foundation.gcm.GcmNotification;
import app.presentation.foundation.BaseApp;
import rx.Observable;
import rx_gcm.GcmReceiverUIBackground;
import rx_gcm.Message;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.presentation.foundation.gcm;
public class GcmReceiverBackground implements GcmReceiverUIBackground {
@Override public void onNotification(Observable<Message> oMessage) {
oMessage.subscribe(message -> {
BaseApp baseApp = (BaseApp) message.application();
| GcmNotification gcmNotification = GcmNotification.getMessageFromGcmNotification(message); |
FuckBoilerplate/base_app_android | app/src/main/java/app/presentation/foundation/PresenterFragment.java | // Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/sections/WireframeRepository.java
// public class WireframeRepository extends Repository {
//
// @Inject public WireframeRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// super(restApi, rxProviders, uiUtils);
// }
//
// public <T> Observable<T> getWireframeCurrentObject() {
// return rxProviders
// .<T>getWireframeCurrentObject(Observable.just(null), new EvictProvider(false))
// .doOnError(throwable -> {
// throw new WireframeException();
// });
// }
//
// public Observable<Void> setWireframeCurrentObject(Object object) {
// return rxProviders.getWireframeCurrentObject(Observable.just(object), new EvictProvider(true))
// .map(_I -> null);
// }
//
// public class WireframeException extends RuntimeException {
//
// public WireframeException() {
// super("There is not cached object in the wireframe");
// }
//
// }
// }
| import app.data.foundation.UIUtils;
import app.data.sections.WireframeRepository;
import rx.Observable; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.presentation.foundation;
public abstract class PresenterFragment {
protected final WireframeRepository wireframeRepository; | // Path: app/src/main/java/app/data/foundation/UIUtils.java
// public interface UIUtils {
// String getLang();
// String getString(@StringRes int idResource);
// File getFilesDir();
// }
//
// Path: app/src/main/java/app/data/sections/WireframeRepository.java
// public class WireframeRepository extends Repository {
//
// @Inject public WireframeRepository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
// super(restApi, rxProviders, uiUtils);
// }
//
// public <T> Observable<T> getWireframeCurrentObject() {
// return rxProviders
// .<T>getWireframeCurrentObject(Observable.just(null), new EvictProvider(false))
// .doOnError(throwable -> {
// throw new WireframeException();
// });
// }
//
// public Observable<Void> setWireframeCurrentObject(Object object) {
// return rxProviders.getWireframeCurrentObject(Observable.just(object), new EvictProvider(true))
// .map(_I -> null);
// }
//
// public class WireframeException extends RuntimeException {
//
// public WireframeException() {
// super("There is not cached object in the wireframe");
// }
//
// }
// }
// Path: app/src/main/java/app/presentation/foundation/PresenterFragment.java
import app.data.foundation.UIUtils;
import app.data.sections.WireframeRepository;
import rx.Observable;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.presentation.foundation;
public abstract class PresenterFragment {
protected final WireframeRepository wireframeRepository; | protected final UIUtils uiUtils; |
FuckBoilerplate/base_app_android | app/src/androidTest/java/app/SuiteIntegration.java | // Path: app/src/androidTest/java/app/sections/dashboard/DashboardTest.java
// public class DashboardTest extends BaseTest {
//
// @Test public void Open_And_Close_Users() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(Matchers.allOf(ViewMatchers.withId(R.id.navigation_view), ViewMatchers.hasDescendant(withText(R.string.users)))).perform(click());
//
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// @Test public void Open_And_Close_User() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(Matchers.allOf(ViewMatchers.withId(R.id.navigation_view), ViewMatchers.hasDescendant(withText(R.string.user)))).perform(click());
//
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// @Test public void Open_And_Close_Search_User() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(Matchers.allOf(ViewMatchers.withId(R.id.navigation_view), ViewMatchers.hasDescendant(withText(R.string.find_user)))).perform(click());
//
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// }
//
// Path: app/src/androidTest/java/app/sections/user_demo/UsersTest.java
// @FixMethodOrder(MethodSorters.NAME_ASCENDING)
// public class UsersTest extends BaseTest {
// private static final int INDEX_LIST = 11, ID_USER = 18266463;
// private static final String USERNAME = "FuckBoilerplate";
//
// @Test public void _1_Get_Users() {
// mediumWait();
// onView(withId(android.R.id.list)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
// }
//
// @Test public void _2_Search_User() {
// mediumWait();
// onView(withId(android.R.id.list)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
//
// mediumWait();
// onView(withId(android.R.id.list)).perform(RecyclerViewActions.actionOnItemAtPosition(INDEX_LIST, click()));
//
// onView(withId(R.id.bt_go_to_search_user)).perform(click());
//
// onView(withId(R.id.et_name)).perform(click(), replaceText(USERNAME), closeSoftKeyboard());
// onView(withId(R.id.bt_find_user)).perform(click());
// mediumWait();
//
// onView(withId(R.id.tv_name)).check(matches(withText(containsString(ID_USER + ":" + USERNAME))));
// }
//
// }
| import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import app.sections.dashboard.DashboardTest;
import app.sections.user_demo.UsersTest; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app;
@RunWith(Suite.class)
@Suite.SuiteClasses({ | // Path: app/src/androidTest/java/app/sections/dashboard/DashboardTest.java
// public class DashboardTest extends BaseTest {
//
// @Test public void Open_And_Close_Users() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(Matchers.allOf(ViewMatchers.withId(R.id.navigation_view), ViewMatchers.hasDescendant(withText(R.string.users)))).perform(click());
//
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// @Test public void Open_And_Close_User() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(Matchers.allOf(ViewMatchers.withId(R.id.navigation_view), ViewMatchers.hasDescendant(withText(R.string.user)))).perform(click());
//
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// @Test public void Open_And_Close_Search_User() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(Matchers.allOf(ViewMatchers.withId(R.id.navigation_view), ViewMatchers.hasDescendant(withText(R.string.find_user)))).perform(click());
//
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// }
//
// Path: app/src/androidTest/java/app/sections/user_demo/UsersTest.java
// @FixMethodOrder(MethodSorters.NAME_ASCENDING)
// public class UsersTest extends BaseTest {
// private static final int INDEX_LIST = 11, ID_USER = 18266463;
// private static final String USERNAME = "FuckBoilerplate";
//
// @Test public void _1_Get_Users() {
// mediumWait();
// onView(withId(android.R.id.list)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
// }
//
// @Test public void _2_Search_User() {
// mediumWait();
// onView(withId(android.R.id.list)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
//
// mediumWait();
// onView(withId(android.R.id.list)).perform(RecyclerViewActions.actionOnItemAtPosition(INDEX_LIST, click()));
//
// onView(withId(R.id.bt_go_to_search_user)).perform(click());
//
// onView(withId(R.id.et_name)).perform(click(), replaceText(USERNAME), closeSoftKeyboard());
// onView(withId(R.id.bt_find_user)).perform(click());
// mediumWait();
//
// onView(withId(R.id.tv_name)).check(matches(withText(containsString(ID_USER + ":" + USERNAME))));
// }
//
// }
// Path: app/src/androidTest/java/app/SuiteIntegration.java
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import app.sections.dashboard.DashboardTest;
import app.sections.user_demo.UsersTest;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app;
@RunWith(Suite.class)
@Suite.SuiteClasses({ | DashboardTest.class, |
FuckBoilerplate/base_app_android | app/src/androidTest/java/app/SuiteIntegration.java | // Path: app/src/androidTest/java/app/sections/dashboard/DashboardTest.java
// public class DashboardTest extends BaseTest {
//
// @Test public void Open_And_Close_Users() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(Matchers.allOf(ViewMatchers.withId(R.id.navigation_view), ViewMatchers.hasDescendant(withText(R.string.users)))).perform(click());
//
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// @Test public void Open_And_Close_User() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(Matchers.allOf(ViewMatchers.withId(R.id.navigation_view), ViewMatchers.hasDescendant(withText(R.string.user)))).perform(click());
//
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// @Test public void Open_And_Close_Search_User() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(Matchers.allOf(ViewMatchers.withId(R.id.navigation_view), ViewMatchers.hasDescendant(withText(R.string.find_user)))).perform(click());
//
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// }
//
// Path: app/src/androidTest/java/app/sections/user_demo/UsersTest.java
// @FixMethodOrder(MethodSorters.NAME_ASCENDING)
// public class UsersTest extends BaseTest {
// private static final int INDEX_LIST = 11, ID_USER = 18266463;
// private static final String USERNAME = "FuckBoilerplate";
//
// @Test public void _1_Get_Users() {
// mediumWait();
// onView(withId(android.R.id.list)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
// }
//
// @Test public void _2_Search_User() {
// mediumWait();
// onView(withId(android.R.id.list)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
//
// mediumWait();
// onView(withId(android.R.id.list)).perform(RecyclerViewActions.actionOnItemAtPosition(INDEX_LIST, click()));
//
// onView(withId(R.id.bt_go_to_search_user)).perform(click());
//
// onView(withId(R.id.et_name)).perform(click(), replaceText(USERNAME), closeSoftKeyboard());
// onView(withId(R.id.bt_find_user)).perform(click());
// mediumWait();
//
// onView(withId(R.id.tv_name)).check(matches(withText(containsString(ID_USER + ":" + USERNAME))));
// }
//
// }
| import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import app.sections.dashboard.DashboardTest;
import app.sections.user_demo.UsersTest; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app;
@RunWith(Suite.class)
@Suite.SuiteClasses({
DashboardTest.class, | // Path: app/src/androidTest/java/app/sections/dashboard/DashboardTest.java
// public class DashboardTest extends BaseTest {
//
// @Test public void Open_And_Close_Users() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(Matchers.allOf(ViewMatchers.withId(R.id.navigation_view), ViewMatchers.hasDescendant(withText(R.string.users)))).perform(click());
//
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// @Test public void Open_And_Close_User() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(Matchers.allOf(ViewMatchers.withId(R.id.navigation_view), ViewMatchers.hasDescendant(withText(R.string.user)))).perform(click());
//
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// @Test public void Open_And_Close_Search_User() {
// onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
// mediumWait();
//
// onView(Matchers.allOf(ViewMatchers.withId(R.id.navigation_view), ViewMatchers.hasDescendant(withText(R.string.find_user)))).perform(click());
//
// onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
// }
//
// }
//
// Path: app/src/androidTest/java/app/sections/user_demo/UsersTest.java
// @FixMethodOrder(MethodSorters.NAME_ASCENDING)
// public class UsersTest extends BaseTest {
// private static final int INDEX_LIST = 11, ID_USER = 18266463;
// private static final String USERNAME = "FuckBoilerplate";
//
// @Test public void _1_Get_Users() {
// mediumWait();
// onView(withId(android.R.id.list)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
// }
//
// @Test public void _2_Search_User() {
// mediumWait();
// onView(withId(android.R.id.list)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));
//
// mediumWait();
// onView(withId(android.R.id.list)).perform(RecyclerViewActions.actionOnItemAtPosition(INDEX_LIST, click()));
//
// onView(withId(R.id.bt_go_to_search_user)).perform(click());
//
// onView(withId(R.id.et_name)).perform(click(), replaceText(USERNAME), closeSoftKeyboard());
// onView(withId(R.id.bt_find_user)).perform(click());
// mediumWait();
//
// onView(withId(R.id.tv_name)).check(matches(withText(containsString(ID_USER + ":" + USERNAME))));
// }
//
// }
// Path: app/src/androidTest/java/app/SuiteIntegration.java
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import app.sections.dashboard.DashboardTest;
import app.sections.user_demo.UsersTest;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app;
@RunWith(Suite.class)
@Suite.SuiteClasses({
DashboardTest.class, | UsersTest.class |
FuckBoilerplate/base_app_android | app/src/main/java/app/data/foundation/net/mock/RestApiMock.java | // Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import rx.Observable;
import rx.exceptions.Exceptions;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import app.data.foundation.net.RestApi;
import app.domain.user_demo.User;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okio.Buffer;
import retrofit2.Response;
import retrofit2.adapter.rxjava.HttpException;
import retrofit2.http.Path;
import retrofit2.http.Query; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.foundation.net.mock;
public class RestApiMock implements RestApi {
private final Seeder seeder;
private final Validator validator;
public RestApiMock() {
this.seeder = new Seeder();
validator = new Validator();
}
| // Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
//
// Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: app/src/main/java/app/data/foundation/net/mock/RestApiMock.java
import rx.Observable;
import rx.exceptions.Exceptions;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import app.data.foundation.net.RestApi;
import app.domain.user_demo.User;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okio.Buffer;
import retrofit2.Response;
import retrofit2.adapter.rxjava.HttpException;
import retrofit2.http.Path;
import retrofit2.http.Query;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.foundation.net.mock;
public class RestApiMock implements RestApi {
private final Seeder seeder;
private final Validator validator;
public RestApiMock() {
this.seeder = new Seeder();
validator = new Validator();
}
| @Override public Observable<Response<User>> getUserByName(@Path("username") String username) { |
FuckBoilerplate/base_app_android | app/src/main/java/app/data/foundation/Repository.java | // Path: app/src/main/java/app/data/foundation/cache/RxProviders.java
// public interface RxProviders {
// <T> Observable<T> getWireframeCurrentObject(Observable<T> oObject, EvictProvider evictProvider);
// Observable<List<User>> getUsers(Observable<List<User>> oUsers, DynamicKey dynamicKey, EvictProvider evictProvider);
// }
//
// Path: app/src/main/java/app/data/foundation/net/BadResponseException.java
// public class BadResponseException extends RuntimeException {
//
// public BadResponseException(String detailMessage) {
// super(detailMessage);
// }
//
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
| import app.data.foundation.cache.RxProviders;
import app.data.foundation.net.BadResponseException;
import app.data.foundation.net.RestApi;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
import java.io.IOException;
import lombok.Data;
import retrofit2.Response; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.foundation;
public abstract class Repository {
public static final int PER_PAGE = 50, FIRST_ID_QUERIED = 0; | // Path: app/src/main/java/app/data/foundation/cache/RxProviders.java
// public interface RxProviders {
// <T> Observable<T> getWireframeCurrentObject(Observable<T> oObject, EvictProvider evictProvider);
// Observable<List<User>> getUsers(Observable<List<User>> oUsers, DynamicKey dynamicKey, EvictProvider evictProvider);
// }
//
// Path: app/src/main/java/app/data/foundation/net/BadResponseException.java
// public class BadResponseException extends RuntimeException {
//
// public BadResponseException(String detailMessage) {
// super(detailMessage);
// }
//
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
// Path: app/src/main/java/app/data/foundation/Repository.java
import app.data.foundation.cache.RxProviders;
import app.data.foundation.net.BadResponseException;
import app.data.foundation.net.RestApi;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
import java.io.IOException;
import lombok.Data;
import retrofit2.Response;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.foundation;
public abstract class Repository {
public static final int PER_PAGE = 50, FIRST_ID_QUERIED = 0; | protected final RestApi restApi; |
FuckBoilerplate/base_app_android | app/src/main/java/app/data/foundation/Repository.java | // Path: app/src/main/java/app/data/foundation/cache/RxProviders.java
// public interface RxProviders {
// <T> Observable<T> getWireframeCurrentObject(Observable<T> oObject, EvictProvider evictProvider);
// Observable<List<User>> getUsers(Observable<List<User>> oUsers, DynamicKey dynamicKey, EvictProvider evictProvider);
// }
//
// Path: app/src/main/java/app/data/foundation/net/BadResponseException.java
// public class BadResponseException extends RuntimeException {
//
// public BadResponseException(String detailMessage) {
// super(detailMessage);
// }
//
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
| import app.data.foundation.cache.RxProviders;
import app.data.foundation.net.BadResponseException;
import app.data.foundation.net.RestApi;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
import java.io.IOException;
import lombok.Data;
import retrofit2.Response; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.foundation;
public abstract class Repository {
public static final int PER_PAGE = 50, FIRST_ID_QUERIED = 0;
protected final RestApi restApi; | // Path: app/src/main/java/app/data/foundation/cache/RxProviders.java
// public interface RxProviders {
// <T> Observable<T> getWireframeCurrentObject(Observable<T> oObject, EvictProvider evictProvider);
// Observable<List<User>> getUsers(Observable<List<User>> oUsers, DynamicKey dynamicKey, EvictProvider evictProvider);
// }
//
// Path: app/src/main/java/app/data/foundation/net/BadResponseException.java
// public class BadResponseException extends RuntimeException {
//
// public BadResponseException(String detailMessage) {
// super(detailMessage);
// }
//
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
// Path: app/src/main/java/app/data/foundation/Repository.java
import app.data.foundation.cache.RxProviders;
import app.data.foundation.net.BadResponseException;
import app.data.foundation.net.RestApi;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
import java.io.IOException;
import lombok.Data;
import retrofit2.Response;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.foundation;
public abstract class Repository {
public static final int PER_PAGE = 50, FIRST_ID_QUERIED = 0;
protected final RestApi restApi; | protected final RxProviders rxProviders; |
FuckBoilerplate/base_app_android | app/src/main/java/app/data/foundation/Repository.java | // Path: app/src/main/java/app/data/foundation/cache/RxProviders.java
// public interface RxProviders {
// <T> Observable<T> getWireframeCurrentObject(Observable<T> oObject, EvictProvider evictProvider);
// Observable<List<User>> getUsers(Observable<List<User>> oUsers, DynamicKey dynamicKey, EvictProvider evictProvider);
// }
//
// Path: app/src/main/java/app/data/foundation/net/BadResponseException.java
// public class BadResponseException extends RuntimeException {
//
// public BadResponseException(String detailMessage) {
// super(detailMessage);
// }
//
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
| import app.data.foundation.cache.RxProviders;
import app.data.foundation.net.BadResponseException;
import app.data.foundation.net.RestApi;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
import java.io.IOException;
import lombok.Data;
import retrofit2.Response; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.foundation;
public abstract class Repository {
public static final int PER_PAGE = 50, FIRST_ID_QUERIED = 0;
protected final RestApi restApi;
protected final RxProviders rxProviders;
protected final UIUtils uiUtils;
public Repository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
this.restApi = restApi;
this.rxProviders = rxProviders;
this.uiUtils = uiUtils;
}
protected void handleError(Response response) {
if (response.isSuccessful()) return;
try {
ResponseError responseError = new Gson().fromJson(response.errorBody().string(), ResponseError.class); | // Path: app/src/main/java/app/data/foundation/cache/RxProviders.java
// public interface RxProviders {
// <T> Observable<T> getWireframeCurrentObject(Observable<T> oObject, EvictProvider evictProvider);
// Observable<List<User>> getUsers(Observable<List<User>> oUsers, DynamicKey dynamicKey, EvictProvider evictProvider);
// }
//
// Path: app/src/main/java/app/data/foundation/net/BadResponseException.java
// public class BadResponseException extends RuntimeException {
//
// public BadResponseException(String detailMessage) {
// super(detailMessage);
// }
//
// }
//
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
// public interface RestApi {
// String URL_BASE = "https://api.github.com";
// String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
//
// @Headers({HEADER_API_VERSION})
// @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username);
//
// @Headers({HEADER_API_VERSION})
// @GET("/users") Observable<Response<List<User>>> getUsers(@Query("since") int lastIdQueried, @Query("per_page") int perPage);
// }
// Path: app/src/main/java/app/data/foundation/Repository.java
import app.data.foundation.cache.RxProviders;
import app.data.foundation.net.BadResponseException;
import app.data.foundation.net.RestApi;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
import java.io.IOException;
import lombok.Data;
import retrofit2.Response;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.foundation;
public abstract class Repository {
public static final int PER_PAGE = 50, FIRST_ID_QUERIED = 0;
protected final RestApi restApi;
protected final RxProviders rxProviders;
protected final UIUtils uiUtils;
public Repository(RestApi restApi, RxProviders rxProviders, UIUtils uiUtils) {
this.restApi = restApi;
this.rxProviders = rxProviders;
this.uiUtils = uiUtils;
}
protected void handleError(Response response) {
if (response.isSuccessful()) return;
try {
ResponseError responseError = new Gson().fromJson(response.errorBody().string(), ResponseError.class); | throw new BadResponseException(responseError.getMessage()); |
FuckBoilerplate/base_app_android | app/src/main/java/app/data/foundation/net/RestApi.java | // Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
| import java.util.List;
import app.domain.user_demo.User;
import retrofit2.Response;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.Path;
import retrofit2.http.Query;
import rx.Observable; | /*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.foundation.net;
/**
* Definition for Retrofit of every endpoint required by the Api.
*/
public interface RestApi {
String URL_BASE = "https://api.github.com";
String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
@Headers({HEADER_API_VERSION}) | // Path: app/src/main/java/app/domain/user_demo/User.java
// @Data
// public class User {
// private final int id;
// private String login;
// private String avatar_url = "";
//
// public String getAvatarUrl() {
// if (avatar_url.isEmpty()) return avatar_url;
// return avatar_url.split("\\?")[0];
// }
// }
// Path: app/src/main/java/app/data/foundation/net/RestApi.java
import java.util.List;
import app.domain.user_demo.User;
import retrofit2.Response;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.Path;
import retrofit2.http.Query;
import rx.Observable;
/*
* Copyright 2016 FuckBoilerplate
*
* 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 app.data.foundation.net;
/**
* Definition for Retrofit of every endpoint required by the Api.
*/
public interface RestApi {
String URL_BASE = "https://api.github.com";
String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
@Headers({HEADER_API_VERSION}) | @GET("/users/{username}") Observable<Response<User>> getUserByName(@Path("username") String username); |
alex-shpak/rx-jersey | rxjava-client/src/main/java/net/winterly/rxjersey/client/rxjava/RxJerseyClientFeature.java | // Path: core-client/src/main/java/net/winterly/rxjersey/client/inject/RemoteResolver.java
// @Singleton
// public class RemoteResolver implements InjectionResolver<Remote> {
//
// private InjectionManager injectionManager;
// private ClientMethodInvoker clientMethodInvoker;
// private Client client;
//
// public RemoteResolver(InjectionManager injectionManager, ClientMethodInvoker methodInvoker, Client client) {
// this.injectionManager = injectionManager;
// this.clientMethodInvoker = methodInvoker;
// this.client = client;
// }
//
// private static URI merge(String value, UriInfo uriInfo) {
// URI target = URI.create(value);
// if (target.getHost() == null) {
// target = UriBuilder.fromUri(uriInfo.getBaseUri()).uri(target).build();
// }
//
// return target;
// }
//
// /**
// * @return RxWebTarget or Proxy client of specified injectee interface
// * @throws IllegalStateException if uri is not correct or there is no sufficient injection resolved
// */
// @Override
// public Object resolve(Injectee injectee) {
// Remote remote = injectee.getParent().getAnnotation(Remote.class);
// UriInfo uriInfo = injectionManager.getInstance(UriInfo.class);
//
// URI target = merge(remote.value(), uriInfo);
// WebTarget webTarget = client.target(target);
// Type type = injectee.getRequiredType();
//
// if (type instanceof Class) {
// Class<?> required = (Class) type;
//
// if (WebTarget.class.isAssignableFrom(required)) {
// return webTarget;
// }
//
// if (required.isInterface()) {
// return WebResourceFactory.newResource(required, webTarget, clientMethodInvoker);
// }
// }
//
// throw new IllegalStateException(format("Can't find proper injection for %s", type));
// }
//
// @Override
// public boolean isConstructorParameterIndicator() {
// return true;
// }
//
// @Override
// public boolean isMethodParameterIndicator() {
// return true;
// }
//
// @Override
// public Class<Remote> getAnnotation() {
// return Remote.class;
// }
// }
//
// Path: core-client/src/main/java/net/winterly/rxjersey/client/inject/RxJerseyBinder.java
// public abstract class RxJerseyBinder extends AbstractBinder {
//
// private final Field injectionManagerField;
//
// public RxJerseyBinder() {
// try {
// // Damn private properties everywhere
// injectionManagerField = AbstractBinder.class.getDeclaredField("injectionManager");
// injectionManagerField.setAccessible(true);
// } catch (NoSuchFieldException e) {
// throw new RuntimeException(e);
// }
// }
//
// protected InjectionManager getInjectionManager() {
// try {
// return (InjectionManager) injectionManagerField.get(this);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
// }
| import net.winterly.rxjersey.client.inject.RemoteResolver;
import net.winterly.rxjersey.client.inject.RxJerseyBinder;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.rx.rxjava.RxObservableInvokerProvider;
import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext; | package net.winterly.rxjersey.client.rxjava;
/**
* Feature implementation to configure RxJava support for clients
*/
public class RxJerseyClientFeature implements Feature {
private Client client;
public RxJerseyClientFeature setClient(Client client) {
this.client = client;
return this;
}
@Override
public boolean configure(FeatureContext context) {
if (client == null) {
client = createClient();
}
client.register(RxBodyReader.class);
context.register(new Binder());
return true;
}
private Client createClient() {
int cores = Runtime.getRuntime().availableProcessors();
ClientConfig config = new ClientConfig();
config.connectorProvider(new GrizzlyConnectorProvider());
config.property(ClientProperties.ASYNC_THREADPOOL_SIZE, cores);
config.register(RxObservableInvokerProvider.class);
return ClientBuilder.newClient(config);
}
| // Path: core-client/src/main/java/net/winterly/rxjersey/client/inject/RemoteResolver.java
// @Singleton
// public class RemoteResolver implements InjectionResolver<Remote> {
//
// private InjectionManager injectionManager;
// private ClientMethodInvoker clientMethodInvoker;
// private Client client;
//
// public RemoteResolver(InjectionManager injectionManager, ClientMethodInvoker methodInvoker, Client client) {
// this.injectionManager = injectionManager;
// this.clientMethodInvoker = methodInvoker;
// this.client = client;
// }
//
// private static URI merge(String value, UriInfo uriInfo) {
// URI target = URI.create(value);
// if (target.getHost() == null) {
// target = UriBuilder.fromUri(uriInfo.getBaseUri()).uri(target).build();
// }
//
// return target;
// }
//
// /**
// * @return RxWebTarget or Proxy client of specified injectee interface
// * @throws IllegalStateException if uri is not correct or there is no sufficient injection resolved
// */
// @Override
// public Object resolve(Injectee injectee) {
// Remote remote = injectee.getParent().getAnnotation(Remote.class);
// UriInfo uriInfo = injectionManager.getInstance(UriInfo.class);
//
// URI target = merge(remote.value(), uriInfo);
// WebTarget webTarget = client.target(target);
// Type type = injectee.getRequiredType();
//
// if (type instanceof Class) {
// Class<?> required = (Class) type;
//
// if (WebTarget.class.isAssignableFrom(required)) {
// return webTarget;
// }
//
// if (required.isInterface()) {
// return WebResourceFactory.newResource(required, webTarget, clientMethodInvoker);
// }
// }
//
// throw new IllegalStateException(format("Can't find proper injection for %s", type));
// }
//
// @Override
// public boolean isConstructorParameterIndicator() {
// return true;
// }
//
// @Override
// public boolean isMethodParameterIndicator() {
// return true;
// }
//
// @Override
// public Class<Remote> getAnnotation() {
// return Remote.class;
// }
// }
//
// Path: core-client/src/main/java/net/winterly/rxjersey/client/inject/RxJerseyBinder.java
// public abstract class RxJerseyBinder extends AbstractBinder {
//
// private final Field injectionManagerField;
//
// public RxJerseyBinder() {
// try {
// // Damn private properties everywhere
// injectionManagerField = AbstractBinder.class.getDeclaredField("injectionManager");
// injectionManagerField.setAccessible(true);
// } catch (NoSuchFieldException e) {
// throw new RuntimeException(e);
// }
// }
//
// protected InjectionManager getInjectionManager() {
// try {
// return (InjectionManager) injectionManagerField.get(this);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
// }
// Path: rxjava-client/src/main/java/net/winterly/rxjersey/client/rxjava/RxJerseyClientFeature.java
import net.winterly.rxjersey.client.inject.RemoteResolver;
import net.winterly.rxjersey.client.inject.RxJerseyBinder;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.rx.rxjava.RxObservableInvokerProvider;
import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext;
package net.winterly.rxjersey.client.rxjava;
/**
* Feature implementation to configure RxJava support for clients
*/
public class RxJerseyClientFeature implements Feature {
private Client client;
public RxJerseyClientFeature setClient(Client client) {
this.client = client;
return this;
}
@Override
public boolean configure(FeatureContext context) {
if (client == null) {
client = createClient();
}
client.register(RxBodyReader.class);
context.register(new Binder());
return true;
}
private Client createClient() {
int cores = Runtime.getRuntime().availableProcessors();
ClientConfig config = new ClientConfig();
config.connectorProvider(new GrizzlyConnectorProvider());
config.property(ClientProperties.ASYNC_THREADPOOL_SIZE, cores);
config.register(RxObservableInvokerProvider.class);
return ClientBuilder.newClient(config);
}
| private class Binder extends RxJerseyBinder { |
alex-shpak/rx-jersey | rxjava-client/src/main/java/net/winterly/rxjersey/client/rxjava/RxJerseyClientFeature.java | // Path: core-client/src/main/java/net/winterly/rxjersey/client/inject/RemoteResolver.java
// @Singleton
// public class RemoteResolver implements InjectionResolver<Remote> {
//
// private InjectionManager injectionManager;
// private ClientMethodInvoker clientMethodInvoker;
// private Client client;
//
// public RemoteResolver(InjectionManager injectionManager, ClientMethodInvoker methodInvoker, Client client) {
// this.injectionManager = injectionManager;
// this.clientMethodInvoker = methodInvoker;
// this.client = client;
// }
//
// private static URI merge(String value, UriInfo uriInfo) {
// URI target = URI.create(value);
// if (target.getHost() == null) {
// target = UriBuilder.fromUri(uriInfo.getBaseUri()).uri(target).build();
// }
//
// return target;
// }
//
// /**
// * @return RxWebTarget or Proxy client of specified injectee interface
// * @throws IllegalStateException if uri is not correct or there is no sufficient injection resolved
// */
// @Override
// public Object resolve(Injectee injectee) {
// Remote remote = injectee.getParent().getAnnotation(Remote.class);
// UriInfo uriInfo = injectionManager.getInstance(UriInfo.class);
//
// URI target = merge(remote.value(), uriInfo);
// WebTarget webTarget = client.target(target);
// Type type = injectee.getRequiredType();
//
// if (type instanceof Class) {
// Class<?> required = (Class) type;
//
// if (WebTarget.class.isAssignableFrom(required)) {
// return webTarget;
// }
//
// if (required.isInterface()) {
// return WebResourceFactory.newResource(required, webTarget, clientMethodInvoker);
// }
// }
//
// throw new IllegalStateException(format("Can't find proper injection for %s", type));
// }
//
// @Override
// public boolean isConstructorParameterIndicator() {
// return true;
// }
//
// @Override
// public boolean isMethodParameterIndicator() {
// return true;
// }
//
// @Override
// public Class<Remote> getAnnotation() {
// return Remote.class;
// }
// }
//
// Path: core-client/src/main/java/net/winterly/rxjersey/client/inject/RxJerseyBinder.java
// public abstract class RxJerseyBinder extends AbstractBinder {
//
// private final Field injectionManagerField;
//
// public RxJerseyBinder() {
// try {
// // Damn private properties everywhere
// injectionManagerField = AbstractBinder.class.getDeclaredField("injectionManager");
// injectionManagerField.setAccessible(true);
// } catch (NoSuchFieldException e) {
// throw new RuntimeException(e);
// }
// }
//
// protected InjectionManager getInjectionManager() {
// try {
// return (InjectionManager) injectionManagerField.get(this);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
// }
| import net.winterly.rxjersey.client.inject.RemoteResolver;
import net.winterly.rxjersey.client.inject.RxJerseyBinder;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.rx.rxjava.RxObservableInvokerProvider;
import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext; | package net.winterly.rxjersey.client.rxjava;
/**
* Feature implementation to configure RxJava support for clients
*/
public class RxJerseyClientFeature implements Feature {
private Client client;
public RxJerseyClientFeature setClient(Client client) {
this.client = client;
return this;
}
@Override
public boolean configure(FeatureContext context) {
if (client == null) {
client = createClient();
}
client.register(RxBodyReader.class);
context.register(new Binder());
return true;
}
private Client createClient() {
int cores = Runtime.getRuntime().availableProcessors();
ClientConfig config = new ClientConfig();
config.connectorProvider(new GrizzlyConnectorProvider());
config.property(ClientProperties.ASYNC_THREADPOOL_SIZE, cores);
config.register(RxObservableInvokerProvider.class);
return ClientBuilder.newClient(config);
}
private class Binder extends RxJerseyBinder {
@Override
protected void configure() { | // Path: core-client/src/main/java/net/winterly/rxjersey/client/inject/RemoteResolver.java
// @Singleton
// public class RemoteResolver implements InjectionResolver<Remote> {
//
// private InjectionManager injectionManager;
// private ClientMethodInvoker clientMethodInvoker;
// private Client client;
//
// public RemoteResolver(InjectionManager injectionManager, ClientMethodInvoker methodInvoker, Client client) {
// this.injectionManager = injectionManager;
// this.clientMethodInvoker = methodInvoker;
// this.client = client;
// }
//
// private static URI merge(String value, UriInfo uriInfo) {
// URI target = URI.create(value);
// if (target.getHost() == null) {
// target = UriBuilder.fromUri(uriInfo.getBaseUri()).uri(target).build();
// }
//
// return target;
// }
//
// /**
// * @return RxWebTarget or Proxy client of specified injectee interface
// * @throws IllegalStateException if uri is not correct or there is no sufficient injection resolved
// */
// @Override
// public Object resolve(Injectee injectee) {
// Remote remote = injectee.getParent().getAnnotation(Remote.class);
// UriInfo uriInfo = injectionManager.getInstance(UriInfo.class);
//
// URI target = merge(remote.value(), uriInfo);
// WebTarget webTarget = client.target(target);
// Type type = injectee.getRequiredType();
//
// if (type instanceof Class) {
// Class<?> required = (Class) type;
//
// if (WebTarget.class.isAssignableFrom(required)) {
// return webTarget;
// }
//
// if (required.isInterface()) {
// return WebResourceFactory.newResource(required, webTarget, clientMethodInvoker);
// }
// }
//
// throw new IllegalStateException(format("Can't find proper injection for %s", type));
// }
//
// @Override
// public boolean isConstructorParameterIndicator() {
// return true;
// }
//
// @Override
// public boolean isMethodParameterIndicator() {
// return true;
// }
//
// @Override
// public Class<Remote> getAnnotation() {
// return Remote.class;
// }
// }
//
// Path: core-client/src/main/java/net/winterly/rxjersey/client/inject/RxJerseyBinder.java
// public abstract class RxJerseyBinder extends AbstractBinder {
//
// private final Field injectionManagerField;
//
// public RxJerseyBinder() {
// try {
// // Damn private properties everywhere
// injectionManagerField = AbstractBinder.class.getDeclaredField("injectionManager");
// injectionManagerField.setAccessible(true);
// } catch (NoSuchFieldException e) {
// throw new RuntimeException(e);
// }
// }
//
// protected InjectionManager getInjectionManager() {
// try {
// return (InjectionManager) injectionManagerField.get(this);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
// }
// Path: rxjava-client/src/main/java/net/winterly/rxjersey/client/rxjava/RxJerseyClientFeature.java
import net.winterly.rxjersey.client.inject.RemoteResolver;
import net.winterly.rxjersey.client.inject.RxJerseyBinder;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.rx.rxjava.RxObservableInvokerProvider;
import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext;
package net.winterly.rxjersey.client.rxjava;
/**
* Feature implementation to configure RxJava support for clients
*/
public class RxJerseyClientFeature implements Feature {
private Client client;
public RxJerseyClientFeature setClient(Client client) {
this.client = client;
return this;
}
@Override
public boolean configure(FeatureContext context) {
if (client == null) {
client = createClient();
}
client.register(RxBodyReader.class);
context.register(new Binder());
return true;
}
private Client createClient() {
int cores = Runtime.getRuntime().availableProcessors();
ClientConfig config = new ClientConfig();
config.connectorProvider(new GrizzlyConnectorProvider());
config.property(ClientProperties.ASYNC_THREADPOOL_SIZE, cores);
config.register(RxObservableInvokerProvider.class);
return ClientBuilder.newClient(config);
}
private class Binder extends RxJerseyBinder {
@Override
protected void configure() { | bind(new RemoteResolver( |
alex-shpak/rx-jersey | rxjava-server/src/test/java/InterceptorsTest.java | // Path: rxjava-server/src/main/java/net/winterly/rxjersey/server/rxjava/CompletableRequestInterceptor.java
// public interface CompletableRequestInterceptor extends RxRequestInterceptor<Completable> {
//
// }
| import net.winterly.rxjersey.server.rxjava.CompletableRequestInterceptor;
import org.glassfish.jersey.internal.inject.AbstractBinder;
import org.junit.Test;
import rx.Completable;
import rx.Observable;
import rx.Single;
import javax.inject.Singleton;
import javax.ws.rs.GET;
import javax.ws.rs.NotAuthorizedException;
import javax.ws.rs.Path;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.SecurityContext;
import java.util.stream.Stream;
import static org.junit.Assert.assertEquals; | .request()
.get(String.class);
assertEquals("intercepted", message);
}
@Test(expected = NotAuthorizedException.class)
public void shouldHandleInterceptorException() {
target("interceptors").path("error")
.request()
.header("throw", true)
.get(String.class);
}
@Path("/interceptors")
public static class EchoResource {
@GET
@Path("echo")
public Observable<String> echo(@Context ContainerRequestContext request) {
return Observable.just(request.getProperty("message").toString());
}
@GET
@Path("error")
public Observable<String> error() {
return Observable.just(null);
}
}
| // Path: rxjava-server/src/main/java/net/winterly/rxjersey/server/rxjava/CompletableRequestInterceptor.java
// public interface CompletableRequestInterceptor extends RxRequestInterceptor<Completable> {
//
// }
// Path: rxjava-server/src/test/java/InterceptorsTest.java
import net.winterly.rxjersey.server.rxjava.CompletableRequestInterceptor;
import org.glassfish.jersey.internal.inject.AbstractBinder;
import org.junit.Test;
import rx.Completable;
import rx.Observable;
import rx.Single;
import javax.inject.Singleton;
import javax.ws.rs.GET;
import javax.ws.rs.NotAuthorizedException;
import javax.ws.rs.Path;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.SecurityContext;
import java.util.stream.Stream;
import static org.junit.Assert.assertEquals;
.request()
.get(String.class);
assertEquals("intercepted", message);
}
@Test(expected = NotAuthorizedException.class)
public void shouldHandleInterceptorException() {
target("interceptors").path("error")
.request()
.header("throw", true)
.get(String.class);
}
@Path("/interceptors")
public static class EchoResource {
@GET
@Path("echo")
public Observable<String> echo(@Context ContainerRequestContext request) {
return Observable.just(request.getProperty("message").toString());
}
@GET
@Path("error")
public Observable<String> error() {
return Observable.just(null);
}
}
| public static class Interceptor implements CompletableRequestInterceptor { |
alex-shpak/rx-jersey | dropwizard/src/main/java/net/winterly/rxjersey/dropwizard/RxJerseyBundle.java | // Path: rxjava2-client/src/main/java/net/winterly/rxjersey/client/rxjava2/RxJerseyClientFeature.java
// public class RxJerseyClientFeature implements Feature {
//
// private Client client;
//
// public RxJerseyClientFeature setClient(Client client) {
// this.client = client;
// return this;
// }
//
// @Override
// public boolean configure(FeatureContext context) {
// if (client == null) {
// client = defaultClient();
// }
//
// client.register(RxBodyReader.class);
// context.register(new Binder());
//
// return true;
// }
//
// private Client defaultClient() {
// int cores = Runtime.getRuntime().availableProcessors();
// ClientConfig config = new ClientConfig();
// config.connectorProvider(new GrizzlyConnectorProvider());
// config.property(ClientProperties.ASYNC_THREADPOOL_SIZE, cores);
// config.register(RxFlowableInvokerProvider.class);
//
// return ClientBuilder.newClient(config);
// }
//
// private class Binder extends RxJerseyBinder {
//
// @Override
// protected void configure() {
// bind(new RemoteResolver(
// getInjectionManager(),
// new FlowableClientMethodInvoker(),
// client
// ));
//
// bind(client).to(Client.class);
// /*bind(create(RemoteResolver.class));
//
// bind(FlowableClientMethodInvoker.class)
// .to(ClientMethodInvoker.class)
// .in(Singleton.class);
//
// bind(client)
// .named(RemoteResolver.RX_JERSEY_CLIENT_NAME)
// .to(Client.class);*/
// }
// }
// }
//
// Path: rxjava2-server/src/main/java/net/winterly/rxjersey/server/rxjava2/CompletableRequestInterceptor.java
// public interface CompletableRequestInterceptor extends RxRequestInterceptor<Completable> {
//
// }
//
// Path: rxjava2-server/src/main/java/net/winterly/rxjersey/server/rxjava2/RxJerseyServerFeature.java
// public final class RxJerseyServerFeature implements Feature {
//
// private final List<Class<? extends CompletableRequestInterceptor>> interceptors = new LinkedList<>();
//
// public RxJerseyServerFeature register(Class<? extends CompletableRequestInterceptor> interceptor) {
// interceptors.add(interceptor);
// return this;
// }
//
// @Override
// public boolean configure(FeatureContext context) {
// context.register(RxBodyWriter.class);
// context.register(new Binder());
// return true;
// }
//
// private class Binder extends AbstractBinder {
//
// @Override
// protected void configure() {
// bind(MaybeInvocationHandlerProvider.class)
// .to(ResourceMethodInvocationHandlerProvider.class)
// .in(Singleton.class);
//
// interceptors.forEach(interceptor -> bind(interceptor)
// .to(CompletableRequestInterceptor.class)
// .in(Singleton.class)
// );
// }
// }
// }
| import io.dropwizard.Configuration;
import io.dropwizard.ConfiguredBundle;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.client.JerseyClientConfiguration;
import io.dropwizard.jersey.setup.JerseyEnvironment;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import net.winterly.rxjersey.client.rxjava2.RxJerseyClientFeature;
import net.winterly.rxjersey.server.rxjava2.CompletableRequestInterceptor;
import net.winterly.rxjersey.server.rxjava2.RxJerseyServerFeature;
import org.glassfish.jersey.client.rx.rxjava2.RxFlowableInvokerProvider;
import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider;
import javax.ws.rs.client.Client;
import java.util.function.Function; | package net.winterly.rxjersey.dropwizard;
public class RxJerseyBundle<T extends Configuration> implements ConfiguredBundle<T> {
private final RxJerseyServerFeature rxJerseyServerFeature = new RxJerseyServerFeature(); | // Path: rxjava2-client/src/main/java/net/winterly/rxjersey/client/rxjava2/RxJerseyClientFeature.java
// public class RxJerseyClientFeature implements Feature {
//
// private Client client;
//
// public RxJerseyClientFeature setClient(Client client) {
// this.client = client;
// return this;
// }
//
// @Override
// public boolean configure(FeatureContext context) {
// if (client == null) {
// client = defaultClient();
// }
//
// client.register(RxBodyReader.class);
// context.register(new Binder());
//
// return true;
// }
//
// private Client defaultClient() {
// int cores = Runtime.getRuntime().availableProcessors();
// ClientConfig config = new ClientConfig();
// config.connectorProvider(new GrizzlyConnectorProvider());
// config.property(ClientProperties.ASYNC_THREADPOOL_SIZE, cores);
// config.register(RxFlowableInvokerProvider.class);
//
// return ClientBuilder.newClient(config);
// }
//
// private class Binder extends RxJerseyBinder {
//
// @Override
// protected void configure() {
// bind(new RemoteResolver(
// getInjectionManager(),
// new FlowableClientMethodInvoker(),
// client
// ));
//
// bind(client).to(Client.class);
// /*bind(create(RemoteResolver.class));
//
// bind(FlowableClientMethodInvoker.class)
// .to(ClientMethodInvoker.class)
// .in(Singleton.class);
//
// bind(client)
// .named(RemoteResolver.RX_JERSEY_CLIENT_NAME)
// .to(Client.class);*/
// }
// }
// }
//
// Path: rxjava2-server/src/main/java/net/winterly/rxjersey/server/rxjava2/CompletableRequestInterceptor.java
// public interface CompletableRequestInterceptor extends RxRequestInterceptor<Completable> {
//
// }
//
// Path: rxjava2-server/src/main/java/net/winterly/rxjersey/server/rxjava2/RxJerseyServerFeature.java
// public final class RxJerseyServerFeature implements Feature {
//
// private final List<Class<? extends CompletableRequestInterceptor>> interceptors = new LinkedList<>();
//
// public RxJerseyServerFeature register(Class<? extends CompletableRequestInterceptor> interceptor) {
// interceptors.add(interceptor);
// return this;
// }
//
// @Override
// public boolean configure(FeatureContext context) {
// context.register(RxBodyWriter.class);
// context.register(new Binder());
// return true;
// }
//
// private class Binder extends AbstractBinder {
//
// @Override
// protected void configure() {
// bind(MaybeInvocationHandlerProvider.class)
// .to(ResourceMethodInvocationHandlerProvider.class)
// .in(Singleton.class);
//
// interceptors.forEach(interceptor -> bind(interceptor)
// .to(CompletableRequestInterceptor.class)
// .in(Singleton.class)
// );
// }
// }
// }
// Path: dropwizard/src/main/java/net/winterly/rxjersey/dropwizard/RxJerseyBundle.java
import io.dropwizard.Configuration;
import io.dropwizard.ConfiguredBundle;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.client.JerseyClientConfiguration;
import io.dropwizard.jersey.setup.JerseyEnvironment;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import net.winterly.rxjersey.client.rxjava2.RxJerseyClientFeature;
import net.winterly.rxjersey.server.rxjava2.CompletableRequestInterceptor;
import net.winterly.rxjersey.server.rxjava2.RxJerseyServerFeature;
import org.glassfish.jersey.client.rx.rxjava2.RxFlowableInvokerProvider;
import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider;
import javax.ws.rs.client.Client;
import java.util.function.Function;
package net.winterly.rxjersey.dropwizard;
public class RxJerseyBundle<T extends Configuration> implements ConfiguredBundle<T> {
private final RxJerseyServerFeature rxJerseyServerFeature = new RxJerseyServerFeature(); | private final RxJerseyClientFeature rxJerseyClientFeature = new RxJerseyClientFeature(); |
alex-shpak/rx-jersey | dropwizard/src/main/java/net/winterly/rxjersey/dropwizard/RxJerseyBundle.java | // Path: rxjava2-client/src/main/java/net/winterly/rxjersey/client/rxjava2/RxJerseyClientFeature.java
// public class RxJerseyClientFeature implements Feature {
//
// private Client client;
//
// public RxJerseyClientFeature setClient(Client client) {
// this.client = client;
// return this;
// }
//
// @Override
// public boolean configure(FeatureContext context) {
// if (client == null) {
// client = defaultClient();
// }
//
// client.register(RxBodyReader.class);
// context.register(new Binder());
//
// return true;
// }
//
// private Client defaultClient() {
// int cores = Runtime.getRuntime().availableProcessors();
// ClientConfig config = new ClientConfig();
// config.connectorProvider(new GrizzlyConnectorProvider());
// config.property(ClientProperties.ASYNC_THREADPOOL_SIZE, cores);
// config.register(RxFlowableInvokerProvider.class);
//
// return ClientBuilder.newClient(config);
// }
//
// private class Binder extends RxJerseyBinder {
//
// @Override
// protected void configure() {
// bind(new RemoteResolver(
// getInjectionManager(),
// new FlowableClientMethodInvoker(),
// client
// ));
//
// bind(client).to(Client.class);
// /*bind(create(RemoteResolver.class));
//
// bind(FlowableClientMethodInvoker.class)
// .to(ClientMethodInvoker.class)
// .in(Singleton.class);
//
// bind(client)
// .named(RemoteResolver.RX_JERSEY_CLIENT_NAME)
// .to(Client.class);*/
// }
// }
// }
//
// Path: rxjava2-server/src/main/java/net/winterly/rxjersey/server/rxjava2/CompletableRequestInterceptor.java
// public interface CompletableRequestInterceptor extends RxRequestInterceptor<Completable> {
//
// }
//
// Path: rxjava2-server/src/main/java/net/winterly/rxjersey/server/rxjava2/RxJerseyServerFeature.java
// public final class RxJerseyServerFeature implements Feature {
//
// private final List<Class<? extends CompletableRequestInterceptor>> interceptors = new LinkedList<>();
//
// public RxJerseyServerFeature register(Class<? extends CompletableRequestInterceptor> interceptor) {
// interceptors.add(interceptor);
// return this;
// }
//
// @Override
// public boolean configure(FeatureContext context) {
// context.register(RxBodyWriter.class);
// context.register(new Binder());
// return true;
// }
//
// private class Binder extends AbstractBinder {
//
// @Override
// protected void configure() {
// bind(MaybeInvocationHandlerProvider.class)
// .to(ResourceMethodInvocationHandlerProvider.class)
// .in(Singleton.class);
//
// interceptors.forEach(interceptor -> bind(interceptor)
// .to(CompletableRequestInterceptor.class)
// .in(Singleton.class)
// );
// }
// }
// }
| import io.dropwizard.Configuration;
import io.dropwizard.ConfiguredBundle;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.client.JerseyClientConfiguration;
import io.dropwizard.jersey.setup.JerseyEnvironment;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import net.winterly.rxjersey.client.rxjava2.RxJerseyClientFeature;
import net.winterly.rxjersey.server.rxjava2.CompletableRequestInterceptor;
import net.winterly.rxjersey.server.rxjava2.RxJerseyServerFeature;
import org.glassfish.jersey.client.rx.rxjava2.RxFlowableInvokerProvider;
import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider;
import javax.ws.rs.client.Client;
import java.util.function.Function; | public void run(T configuration, Environment environment) throws Exception {
JerseyEnvironment jersey = environment.jersey();
JerseyClientConfiguration clientConfiguration = clientConfigurationProvider.apply(configuration);
Client client = getClient(environment, clientConfiguration);
rxJerseyClientFeature.setClient(client);
jersey.register(rxJerseyServerFeature);
jersey.register(rxJerseyClientFeature);
}
@Override
public void initialize(Bootstrap<?> bootstrap) {
}
public RxJerseyClientFeature client() {
return rxJerseyClientFeature;
}
public RxJerseyServerFeature server() {
return rxJerseyServerFeature;
}
public RxJerseyBundle<T> setClientConfigurationProvider(Function<T, JerseyClientConfiguration> provider) {
clientConfigurationProvider = provider;
return this;
}
| // Path: rxjava2-client/src/main/java/net/winterly/rxjersey/client/rxjava2/RxJerseyClientFeature.java
// public class RxJerseyClientFeature implements Feature {
//
// private Client client;
//
// public RxJerseyClientFeature setClient(Client client) {
// this.client = client;
// return this;
// }
//
// @Override
// public boolean configure(FeatureContext context) {
// if (client == null) {
// client = defaultClient();
// }
//
// client.register(RxBodyReader.class);
// context.register(new Binder());
//
// return true;
// }
//
// private Client defaultClient() {
// int cores = Runtime.getRuntime().availableProcessors();
// ClientConfig config = new ClientConfig();
// config.connectorProvider(new GrizzlyConnectorProvider());
// config.property(ClientProperties.ASYNC_THREADPOOL_SIZE, cores);
// config.register(RxFlowableInvokerProvider.class);
//
// return ClientBuilder.newClient(config);
// }
//
// private class Binder extends RxJerseyBinder {
//
// @Override
// protected void configure() {
// bind(new RemoteResolver(
// getInjectionManager(),
// new FlowableClientMethodInvoker(),
// client
// ));
//
// bind(client).to(Client.class);
// /*bind(create(RemoteResolver.class));
//
// bind(FlowableClientMethodInvoker.class)
// .to(ClientMethodInvoker.class)
// .in(Singleton.class);
//
// bind(client)
// .named(RemoteResolver.RX_JERSEY_CLIENT_NAME)
// .to(Client.class);*/
// }
// }
// }
//
// Path: rxjava2-server/src/main/java/net/winterly/rxjersey/server/rxjava2/CompletableRequestInterceptor.java
// public interface CompletableRequestInterceptor extends RxRequestInterceptor<Completable> {
//
// }
//
// Path: rxjava2-server/src/main/java/net/winterly/rxjersey/server/rxjava2/RxJerseyServerFeature.java
// public final class RxJerseyServerFeature implements Feature {
//
// private final List<Class<? extends CompletableRequestInterceptor>> interceptors = new LinkedList<>();
//
// public RxJerseyServerFeature register(Class<? extends CompletableRequestInterceptor> interceptor) {
// interceptors.add(interceptor);
// return this;
// }
//
// @Override
// public boolean configure(FeatureContext context) {
// context.register(RxBodyWriter.class);
// context.register(new Binder());
// return true;
// }
//
// private class Binder extends AbstractBinder {
//
// @Override
// protected void configure() {
// bind(MaybeInvocationHandlerProvider.class)
// .to(ResourceMethodInvocationHandlerProvider.class)
// .in(Singleton.class);
//
// interceptors.forEach(interceptor -> bind(interceptor)
// .to(CompletableRequestInterceptor.class)
// .in(Singleton.class)
// );
// }
// }
// }
// Path: dropwizard/src/main/java/net/winterly/rxjersey/dropwizard/RxJerseyBundle.java
import io.dropwizard.Configuration;
import io.dropwizard.ConfiguredBundle;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.client.JerseyClientConfiguration;
import io.dropwizard.jersey.setup.JerseyEnvironment;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import net.winterly.rxjersey.client.rxjava2.RxJerseyClientFeature;
import net.winterly.rxjersey.server.rxjava2.CompletableRequestInterceptor;
import net.winterly.rxjersey.server.rxjava2.RxJerseyServerFeature;
import org.glassfish.jersey.client.rx.rxjava2.RxFlowableInvokerProvider;
import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider;
import javax.ws.rs.client.Client;
import java.util.function.Function;
public void run(T configuration, Environment environment) throws Exception {
JerseyEnvironment jersey = environment.jersey();
JerseyClientConfiguration clientConfiguration = clientConfigurationProvider.apply(configuration);
Client client = getClient(environment, clientConfiguration);
rxJerseyClientFeature.setClient(client);
jersey.register(rxJerseyServerFeature);
jersey.register(rxJerseyClientFeature);
}
@Override
public void initialize(Bootstrap<?> bootstrap) {
}
public RxJerseyClientFeature client() {
return rxJerseyClientFeature;
}
public RxJerseyServerFeature server() {
return rxJerseyServerFeature;
}
public RxJerseyBundle<T> setClientConfigurationProvider(Function<T, JerseyClientConfiguration> provider) {
clientConfigurationProvider = provider;
return this;
}
| public RxJerseyBundle<T> register(Class<? extends CompletableRequestInterceptor> interceptor) { |
alex-shpak/rx-jersey | rxjava2-server/src/test/java/InterceptorsTest.java | // Path: rxjava2-server/src/main/java/net/winterly/rxjersey/server/rxjava2/CompletableRequestInterceptor.java
// public interface CompletableRequestInterceptor extends RxRequestInterceptor<Completable> {
//
// }
| import io.reactivex.Completable;
import io.reactivex.Observable;
import io.reactivex.Single;
import net.winterly.rxjersey.server.rxjava2.CompletableRequestInterceptor;
import org.glassfish.jersey.internal.inject.AbstractBinder;
import org.junit.Test;
import javax.inject.Singleton;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.GET;
import javax.ws.rs.NotAuthorizedException;
import javax.ws.rs.Path;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.SecurityContext;
import java.util.stream.Stream;
import static org.junit.Assert.assertEquals; | target("interceptors").path("error")
.request()
.header("throw", true)
.get(String.class);
}
@Test(expected = BadRequestException.class)
public void shouldHandleInterceptorError() {
target("interceptors").path("error")
.request()
.header("error", true)
.get(String.class);
}
@Path("/interceptors")
public static class EchoResource {
@GET
@Path("echo")
public Observable<String> echo(@Context ContainerRequestContext request) {
return Observable.just(request.getProperty("message").toString());
}
@GET
@Path("error")
public Observable<String> error() {
return Observable.just(null);
}
}
| // Path: rxjava2-server/src/main/java/net/winterly/rxjersey/server/rxjava2/CompletableRequestInterceptor.java
// public interface CompletableRequestInterceptor extends RxRequestInterceptor<Completable> {
//
// }
// Path: rxjava2-server/src/test/java/InterceptorsTest.java
import io.reactivex.Completable;
import io.reactivex.Observable;
import io.reactivex.Single;
import net.winterly.rxjersey.server.rxjava2.CompletableRequestInterceptor;
import org.glassfish.jersey.internal.inject.AbstractBinder;
import org.junit.Test;
import javax.inject.Singleton;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.GET;
import javax.ws.rs.NotAuthorizedException;
import javax.ws.rs.Path;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.SecurityContext;
import java.util.stream.Stream;
import static org.junit.Assert.assertEquals;
target("interceptors").path("error")
.request()
.header("throw", true)
.get(String.class);
}
@Test(expected = BadRequestException.class)
public void shouldHandleInterceptorError() {
target("interceptors").path("error")
.request()
.header("error", true)
.get(String.class);
}
@Path("/interceptors")
public static class EchoResource {
@GET
@Path("echo")
public Observable<String> echo(@Context ContainerRequestContext request) {
return Observable.just(request.getProperty("message").toString());
}
@GET
@Path("error")
public Observable<String> error() {
return Observable.just(null);
}
}
| public static class Interceptor implements CompletableRequestInterceptor { |
alex-shpak/rx-jersey | rxjava2-server/src/test/java/RxJerseyTest.java | // Path: rxjava2-server/src/main/java/net/winterly/rxjersey/server/rxjava2/RxJerseyServerFeature.java
// public final class RxJerseyServerFeature implements Feature {
//
// private final List<Class<? extends CompletableRequestInterceptor>> interceptors = new LinkedList<>();
//
// public RxJerseyServerFeature register(Class<? extends CompletableRequestInterceptor> interceptor) {
// interceptors.add(interceptor);
// return this;
// }
//
// @Override
// public boolean configure(FeatureContext context) {
// context.register(RxBodyWriter.class);
// context.register(new Binder());
// return true;
// }
//
// private class Binder extends AbstractBinder {
//
// @Override
// protected void configure() {
// bind(MaybeInvocationHandlerProvider.class)
// .to(ResourceMethodInvocationHandlerProvider.class)
// .in(Singleton.class);
//
// interceptors.forEach(interceptor -> bind(interceptor)
// .to(CompletableRequestInterceptor.class)
// .in(Singleton.class)
// );
// }
// }
// }
| import net.winterly.rxjersey.server.rxjava2.RxJerseyServerFeature;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest; |
public class RxJerseyTest extends JerseyTest {
protected ResourceConfig config() {
return new ResourceConfig()
.register(JacksonFeature.class) | // Path: rxjava2-server/src/main/java/net/winterly/rxjersey/server/rxjava2/RxJerseyServerFeature.java
// public final class RxJerseyServerFeature implements Feature {
//
// private final List<Class<? extends CompletableRequestInterceptor>> interceptors = new LinkedList<>();
//
// public RxJerseyServerFeature register(Class<? extends CompletableRequestInterceptor> interceptor) {
// interceptors.add(interceptor);
// return this;
// }
//
// @Override
// public boolean configure(FeatureContext context) {
// context.register(RxBodyWriter.class);
// context.register(new Binder());
// return true;
// }
//
// private class Binder extends AbstractBinder {
//
// @Override
// protected void configure() {
// bind(MaybeInvocationHandlerProvider.class)
// .to(ResourceMethodInvocationHandlerProvider.class)
// .in(Singleton.class);
//
// interceptors.forEach(interceptor -> bind(interceptor)
// .to(CompletableRequestInterceptor.class)
// .in(Singleton.class)
// );
// }
// }
// }
// Path: rxjava2-server/src/test/java/RxJerseyTest.java
import net.winterly.rxjersey.server.rxjava2.RxJerseyServerFeature;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
public class RxJerseyTest extends JerseyTest {
protected ResourceConfig config() {
return new ResourceConfig()
.register(JacksonFeature.class) | .register(RxJerseyServerFeature.class); |
alex-shpak/rx-jersey | example/src/main/java/net/winterly/rxjersey/example/RxJerseyApplication.java | // Path: dropwizard/src/main/java/net/winterly/rxjersey/dropwizard/RxJerseyBundle.java
// public class RxJerseyBundle<T extends Configuration> implements ConfiguredBundle<T> {
//
// private final RxJerseyServerFeature rxJerseyServerFeature = new RxJerseyServerFeature();
// private final RxJerseyClientFeature rxJerseyClientFeature = new RxJerseyClientFeature();
//
// private Function<T, JerseyClientConfiguration> clientConfigurationProvider;
//
// public RxJerseyBundle() {
// setClientConfigurationProvider(configuration -> {
// int cores = Runtime.getRuntime().availableProcessors();
// JerseyClientConfiguration clientConfiguration = new JerseyClientConfiguration();
// clientConfiguration.setMaxThreads(cores);
//
// return clientConfiguration;
// });
// }
//
// @Override
// public void run(T configuration, Environment environment) throws Exception {
// JerseyEnvironment jersey = environment.jersey();
//
// JerseyClientConfiguration clientConfiguration = clientConfigurationProvider.apply(configuration);
// Client client = getClient(environment, clientConfiguration);
//
// rxJerseyClientFeature.setClient(client);
//
// jersey.register(rxJerseyServerFeature);
// jersey.register(rxJerseyClientFeature);
// }
//
// @Override
// public void initialize(Bootstrap<?> bootstrap) {
//
// }
//
// public RxJerseyClientFeature client() {
// return rxJerseyClientFeature;
// }
//
// public RxJerseyServerFeature server() {
// return rxJerseyServerFeature;
// }
//
// public RxJerseyBundle<T> setClientConfigurationProvider(Function<T, JerseyClientConfiguration> provider) {
// clientConfigurationProvider = provider;
// return this;
// }
//
// public RxJerseyBundle<T> register(Class<? extends CompletableRequestInterceptor> interceptor) {
// rxJerseyServerFeature.register(interceptor);
// return this;
// }
//
// private Client getClient(Environment environment, JerseyClientConfiguration jerseyClientConfiguration) {
// return new JerseyClientBuilder(environment)
// .using(jerseyClientConfiguration)
// .using(new GrizzlyConnectorProvider())
// .buildRx("rxJerseyClient", RxFlowableInvokerProvider.class);
// }
// }
| import com.fasterxml.jackson.databind.DeserializationFeature;
import io.dropwizard.Application;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import net.winterly.rxjersey.dropwizard.RxJerseyBundle; | package net.winterly.rxjersey.example;
public class RxJerseyApplication extends Application<RxJerseyConfiguration> {
public static void main(String[] args) throws Exception {
new RxJerseyApplication().run(args);
}
@Override
public void initialize(Bootstrap<RxJerseyConfiguration> bootstrap) {
bootstrap.getObjectMapper()
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
| // Path: dropwizard/src/main/java/net/winterly/rxjersey/dropwizard/RxJerseyBundle.java
// public class RxJerseyBundle<T extends Configuration> implements ConfiguredBundle<T> {
//
// private final RxJerseyServerFeature rxJerseyServerFeature = new RxJerseyServerFeature();
// private final RxJerseyClientFeature rxJerseyClientFeature = new RxJerseyClientFeature();
//
// private Function<T, JerseyClientConfiguration> clientConfigurationProvider;
//
// public RxJerseyBundle() {
// setClientConfigurationProvider(configuration -> {
// int cores = Runtime.getRuntime().availableProcessors();
// JerseyClientConfiguration clientConfiguration = new JerseyClientConfiguration();
// clientConfiguration.setMaxThreads(cores);
//
// return clientConfiguration;
// });
// }
//
// @Override
// public void run(T configuration, Environment environment) throws Exception {
// JerseyEnvironment jersey = environment.jersey();
//
// JerseyClientConfiguration clientConfiguration = clientConfigurationProvider.apply(configuration);
// Client client = getClient(environment, clientConfiguration);
//
// rxJerseyClientFeature.setClient(client);
//
// jersey.register(rxJerseyServerFeature);
// jersey.register(rxJerseyClientFeature);
// }
//
// @Override
// public void initialize(Bootstrap<?> bootstrap) {
//
// }
//
// public RxJerseyClientFeature client() {
// return rxJerseyClientFeature;
// }
//
// public RxJerseyServerFeature server() {
// return rxJerseyServerFeature;
// }
//
// public RxJerseyBundle<T> setClientConfigurationProvider(Function<T, JerseyClientConfiguration> provider) {
// clientConfigurationProvider = provider;
// return this;
// }
//
// public RxJerseyBundle<T> register(Class<? extends CompletableRequestInterceptor> interceptor) {
// rxJerseyServerFeature.register(interceptor);
// return this;
// }
//
// private Client getClient(Environment environment, JerseyClientConfiguration jerseyClientConfiguration) {
// return new JerseyClientBuilder(environment)
// .using(jerseyClientConfiguration)
// .using(new GrizzlyConnectorProvider())
// .buildRx("rxJerseyClient", RxFlowableInvokerProvider.class);
// }
// }
// Path: example/src/main/java/net/winterly/rxjersey/example/RxJerseyApplication.java
import com.fasterxml.jackson.databind.DeserializationFeature;
import io.dropwizard.Application;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import net.winterly.rxjersey.dropwizard.RxJerseyBundle;
package net.winterly.rxjersey.example;
public class RxJerseyApplication extends Application<RxJerseyConfiguration> {
public static void main(String[] args) throws Exception {
new RxJerseyApplication().run(args);
}
@Override
public void initialize(Bootstrap<RxJerseyConfiguration> bootstrap) {
bootstrap.getObjectMapper()
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
| bootstrap.addBundle(new RxJerseyBundle<RxJerseyConfiguration>() |
alex-shpak/rx-jersey | rxjava2-server/src/main/java/net/winterly/rxjersey/server/rxjava2/RxBodyWriter.java | // Path: core-server/src/main/java/net/winterly/rxjersey/server/RxGenericBodyWriter.java
// public abstract class RxGenericBodyWriter implements MessageBodyWriter<Object> {
//
// private final List<Class<?>> allowedTypes;
//
// @Inject
// private Provider<MessageBodyWorkers> workers;
//
// /**
// * @param allowedTypes list of types to be processed by this writer
// */
// protected RxGenericBodyWriter(Class<?>... allowedTypes) {
// this.allowedTypes = Arrays.asList(allowedTypes);
// }
//
// /**
// * @param type type to process
// * @return the raw type without generics
// */
// private static Class<?> raw(Type type) {
// if (type instanceof Class<?>) {
// return (Class<?>) type;
// }
//
// if (type instanceof ParameterizedType) {
// return (Class<?>) ((ParameterizedType) type).getRawType();
// }
//
// return null; // needs an assigning type to resolve TypeVariable or GenericArrayType
// }
//
// /**
// * @param genericType type to process
// * @return first type from generic list
// */
// private static Type actual(Type genericType) {
// final ParameterizedType actualGenericType = (ParameterizedType) genericType;
// return actualGenericType.getActualTypeArguments()[0];
// }
//
// @Override
// public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
// if (genericType instanceof ParameterizedType) {
// Class<?> rawType = raw(genericType);
//
// final Type actualTypeArgument = actual(genericType);
// final MessageBodyWriter<?> messageBodyWriter
// = workers.get().getMessageBodyWriter(raw(actualTypeArgument), actualTypeArgument, annotations, mediaType);
//
// return allowedTypes.contains(rawType) && messageBodyWriter != null;
// }
// return allowedTypes.contains(genericType);
// }
//
// @Override
// public long getSize(Object o, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
// return 0; //skip
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void writeTo(Object entity, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
// throws IOException, WebApplicationException {
//
// final Type actualTypeArgument = actual(genericType);
// final MessageBodyWriter writer = workers.get().getMessageBodyWriter(entity.getClass(), actualTypeArgument, annotations, mediaType);
//
// writer.writeTo(entity, entity.getClass(), actualTypeArgument, annotations, mediaType, httpHeaders, entityStream);
// }
// }
| import io.reactivex.*;
import net.winterly.rxjersey.server.RxGenericBodyWriter;
import javax.annotation.Priority;
import javax.inject.Singleton; | package net.winterly.rxjersey.server.rxjava2;
/**
* MessageBodyWriter accepting {@code io.reactivex.*} types
*
* @see Flowable
* @see Observable
* @see Single
* @see Completable
* @see Maybe
*/
@Singleton
@Priority(1) //Priority should be higher than JSON providers | // Path: core-server/src/main/java/net/winterly/rxjersey/server/RxGenericBodyWriter.java
// public abstract class RxGenericBodyWriter implements MessageBodyWriter<Object> {
//
// private final List<Class<?>> allowedTypes;
//
// @Inject
// private Provider<MessageBodyWorkers> workers;
//
// /**
// * @param allowedTypes list of types to be processed by this writer
// */
// protected RxGenericBodyWriter(Class<?>... allowedTypes) {
// this.allowedTypes = Arrays.asList(allowedTypes);
// }
//
// /**
// * @param type type to process
// * @return the raw type without generics
// */
// private static Class<?> raw(Type type) {
// if (type instanceof Class<?>) {
// return (Class<?>) type;
// }
//
// if (type instanceof ParameterizedType) {
// return (Class<?>) ((ParameterizedType) type).getRawType();
// }
//
// return null; // needs an assigning type to resolve TypeVariable or GenericArrayType
// }
//
// /**
// * @param genericType type to process
// * @return first type from generic list
// */
// private static Type actual(Type genericType) {
// final ParameterizedType actualGenericType = (ParameterizedType) genericType;
// return actualGenericType.getActualTypeArguments()[0];
// }
//
// @Override
// public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
// if (genericType instanceof ParameterizedType) {
// Class<?> rawType = raw(genericType);
//
// final Type actualTypeArgument = actual(genericType);
// final MessageBodyWriter<?> messageBodyWriter
// = workers.get().getMessageBodyWriter(raw(actualTypeArgument), actualTypeArgument, annotations, mediaType);
//
// return allowedTypes.contains(rawType) && messageBodyWriter != null;
// }
// return allowedTypes.contains(genericType);
// }
//
// @Override
// public long getSize(Object o, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
// return 0; //skip
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void writeTo(Object entity, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
// throws IOException, WebApplicationException {
//
// final Type actualTypeArgument = actual(genericType);
// final MessageBodyWriter writer = workers.get().getMessageBodyWriter(entity.getClass(), actualTypeArgument, annotations, mediaType);
//
// writer.writeTo(entity, entity.getClass(), actualTypeArgument, annotations, mediaType, httpHeaders, entityStream);
// }
// }
// Path: rxjava2-server/src/main/java/net/winterly/rxjersey/server/rxjava2/RxBodyWriter.java
import io.reactivex.*;
import net.winterly.rxjersey.server.RxGenericBodyWriter;
import javax.annotation.Priority;
import javax.inject.Singleton;
package net.winterly.rxjersey.server.rxjava2;
/**
* MessageBodyWriter accepting {@code io.reactivex.*} types
*
* @see Flowable
* @see Observable
* @see Single
* @see Completable
* @see Maybe
*/
@Singleton
@Priority(1) //Priority should be higher than JSON providers | public class RxBodyWriter extends RxGenericBodyWriter { |
alex-shpak/rx-jersey | rxjava-server/src/main/java/net/winterly/rxjersey/server/rxjava/RxBodyWriter.java | // Path: core-server/src/main/java/net/winterly/rxjersey/server/RxGenericBodyWriter.java
// public abstract class RxGenericBodyWriter implements MessageBodyWriter<Object> {
//
// private final List<Class<?>> allowedTypes;
//
// @Inject
// private Provider<MessageBodyWorkers> workers;
//
// /**
// * @param allowedTypes list of types to be processed by this writer
// */
// protected RxGenericBodyWriter(Class<?>... allowedTypes) {
// this.allowedTypes = Arrays.asList(allowedTypes);
// }
//
// /**
// * @param type type to process
// * @return the raw type without generics
// */
// private static Class<?> raw(Type type) {
// if (type instanceof Class<?>) {
// return (Class<?>) type;
// }
//
// if (type instanceof ParameterizedType) {
// return (Class<?>) ((ParameterizedType) type).getRawType();
// }
//
// return null; // needs an assigning type to resolve TypeVariable or GenericArrayType
// }
//
// /**
// * @param genericType type to process
// * @return first type from generic list
// */
// private static Type actual(Type genericType) {
// final ParameterizedType actualGenericType = (ParameterizedType) genericType;
// return actualGenericType.getActualTypeArguments()[0];
// }
//
// @Override
// public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
// if (genericType instanceof ParameterizedType) {
// Class<?> rawType = raw(genericType);
//
// final Type actualTypeArgument = actual(genericType);
// final MessageBodyWriter<?> messageBodyWriter
// = workers.get().getMessageBodyWriter(raw(actualTypeArgument), actualTypeArgument, annotations, mediaType);
//
// return allowedTypes.contains(rawType) && messageBodyWriter != null;
// }
// return allowedTypes.contains(genericType);
// }
//
// @Override
// public long getSize(Object o, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
// return 0; //skip
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void writeTo(Object entity, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
// throws IOException, WebApplicationException {
//
// final Type actualTypeArgument = actual(genericType);
// final MessageBodyWriter writer = workers.get().getMessageBodyWriter(entity.getClass(), actualTypeArgument, annotations, mediaType);
//
// writer.writeTo(entity, entity.getClass(), actualTypeArgument, annotations, mediaType, httpHeaders, entityStream);
// }
// }
| import net.winterly.rxjersey.server.RxGenericBodyWriter;
import rx.Completable;
import rx.Observable;
import rx.Single;
import javax.annotation.Priority;
import javax.inject.Singleton;
import javax.ws.rs.ext.MessageBodyWriter; | package net.winterly.rxjersey.server.rxjava;
/**
* {@link MessageBodyWriter} accepting {@link rx.Observable} or {@link rx.Single}
*
* @see Observable
* @see Single
*/
@Singleton
@Priority(1) //Priority should be higher than JSON providers | // Path: core-server/src/main/java/net/winterly/rxjersey/server/RxGenericBodyWriter.java
// public abstract class RxGenericBodyWriter implements MessageBodyWriter<Object> {
//
// private final List<Class<?>> allowedTypes;
//
// @Inject
// private Provider<MessageBodyWorkers> workers;
//
// /**
// * @param allowedTypes list of types to be processed by this writer
// */
// protected RxGenericBodyWriter(Class<?>... allowedTypes) {
// this.allowedTypes = Arrays.asList(allowedTypes);
// }
//
// /**
// * @param type type to process
// * @return the raw type without generics
// */
// private static Class<?> raw(Type type) {
// if (type instanceof Class<?>) {
// return (Class<?>) type;
// }
//
// if (type instanceof ParameterizedType) {
// return (Class<?>) ((ParameterizedType) type).getRawType();
// }
//
// return null; // needs an assigning type to resolve TypeVariable or GenericArrayType
// }
//
// /**
// * @param genericType type to process
// * @return first type from generic list
// */
// private static Type actual(Type genericType) {
// final ParameterizedType actualGenericType = (ParameterizedType) genericType;
// return actualGenericType.getActualTypeArguments()[0];
// }
//
// @Override
// public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
// if (genericType instanceof ParameterizedType) {
// Class<?> rawType = raw(genericType);
//
// final Type actualTypeArgument = actual(genericType);
// final MessageBodyWriter<?> messageBodyWriter
// = workers.get().getMessageBodyWriter(raw(actualTypeArgument), actualTypeArgument, annotations, mediaType);
//
// return allowedTypes.contains(rawType) && messageBodyWriter != null;
// }
// return allowedTypes.contains(genericType);
// }
//
// @Override
// public long getSize(Object o, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
// return 0; //skip
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void writeTo(Object entity, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
// throws IOException, WebApplicationException {
//
// final Type actualTypeArgument = actual(genericType);
// final MessageBodyWriter writer = workers.get().getMessageBodyWriter(entity.getClass(), actualTypeArgument, annotations, mediaType);
//
// writer.writeTo(entity, entity.getClass(), actualTypeArgument, annotations, mediaType, httpHeaders, entityStream);
// }
// }
// Path: rxjava-server/src/main/java/net/winterly/rxjersey/server/rxjava/RxBodyWriter.java
import net.winterly.rxjersey.server.RxGenericBodyWriter;
import rx.Completable;
import rx.Observable;
import rx.Single;
import javax.annotation.Priority;
import javax.inject.Singleton;
import javax.ws.rs.ext.MessageBodyWriter;
package net.winterly.rxjersey.server.rxjava;
/**
* {@link MessageBodyWriter} accepting {@link rx.Observable} or {@link rx.Single}
*
* @see Observable
* @see Single
*/
@Singleton
@Priority(1) //Priority should be higher than JSON providers | public class RxBodyWriter extends RxGenericBodyWriter { |
alex-shpak/rx-jersey | rxjava-server/src/test/java/RxJerseyTest.java | // Path: rxjava-server/src/main/java/net/winterly/rxjersey/server/rxjava/RxJerseyServerFeature.java
// public final class RxJerseyServerFeature implements Feature {
//
// private final List<Class<? extends CompletableRequestInterceptor>> interceptors = new LinkedList<>();
//
// public RxJerseyServerFeature register(Class<? extends CompletableRequestInterceptor> interceptor) {
// interceptors.add(interceptor);
// return this;
// }
//
// @Override
// public boolean configure(FeatureContext context) {
// context.register(RxBodyWriter.class);
// context.register(new Binder());
// return true;
// }
//
// private class Binder extends AbstractBinder {
//
// @Override
// protected void configure() {
// bind(SingleInvocationHandlerProvider.class)
// .to(ResourceMethodInvocationHandlerProvider.class)
// .in(Singleton.class);
//
// interceptors.forEach(interceptor -> bind(interceptor)
// .to(CompletableRequestInterceptor.class)
// .in(Singleton.class)
// );
// }
// }
// }
| import net.winterly.rxjersey.server.rxjava.RxJerseyServerFeature;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest; |
public class RxJerseyTest extends JerseyTest {
protected ResourceConfig config() {
return new ResourceConfig()
.register(JacksonFeature.class) | // Path: rxjava-server/src/main/java/net/winterly/rxjersey/server/rxjava/RxJerseyServerFeature.java
// public final class RxJerseyServerFeature implements Feature {
//
// private final List<Class<? extends CompletableRequestInterceptor>> interceptors = new LinkedList<>();
//
// public RxJerseyServerFeature register(Class<? extends CompletableRequestInterceptor> interceptor) {
// interceptors.add(interceptor);
// return this;
// }
//
// @Override
// public boolean configure(FeatureContext context) {
// context.register(RxBodyWriter.class);
// context.register(new Binder());
// return true;
// }
//
// private class Binder extends AbstractBinder {
//
// @Override
// protected void configure() {
// bind(SingleInvocationHandlerProvider.class)
// .to(ResourceMethodInvocationHandlerProvider.class)
// .in(Singleton.class);
//
// interceptors.forEach(interceptor -> bind(interceptor)
// .to(CompletableRequestInterceptor.class)
// .in(Singleton.class)
// );
// }
// }
// }
// Path: rxjava-server/src/test/java/RxJerseyTest.java
import net.winterly.rxjersey.server.rxjava.RxJerseyServerFeature;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
public class RxJerseyTest extends JerseyTest {
protected ResourceConfig config() {
return new ResourceConfig()
.register(JacksonFeature.class) | .register(RxJerseyServerFeature.class); |
alex-shpak/rx-jersey | rxjava2-client/src/main/java/net/winterly/rxjersey/client/rxjava2/RxJerseyClientFeature.java | // Path: core-client/src/main/java/net/winterly/rxjersey/client/inject/RemoteResolver.java
// @Singleton
// public class RemoteResolver implements InjectionResolver<Remote> {
//
// private InjectionManager injectionManager;
// private ClientMethodInvoker clientMethodInvoker;
// private Client client;
//
// public RemoteResolver(InjectionManager injectionManager, ClientMethodInvoker methodInvoker, Client client) {
// this.injectionManager = injectionManager;
// this.clientMethodInvoker = methodInvoker;
// this.client = client;
// }
//
// private static URI merge(String value, UriInfo uriInfo) {
// URI target = URI.create(value);
// if (target.getHost() == null) {
// target = UriBuilder.fromUri(uriInfo.getBaseUri()).uri(target).build();
// }
//
// return target;
// }
//
// /**
// * @return RxWebTarget or Proxy client of specified injectee interface
// * @throws IllegalStateException if uri is not correct or there is no sufficient injection resolved
// */
// @Override
// public Object resolve(Injectee injectee) {
// Remote remote = injectee.getParent().getAnnotation(Remote.class);
// UriInfo uriInfo = injectionManager.getInstance(UriInfo.class);
//
// URI target = merge(remote.value(), uriInfo);
// WebTarget webTarget = client.target(target);
// Type type = injectee.getRequiredType();
//
// if (type instanceof Class) {
// Class<?> required = (Class) type;
//
// if (WebTarget.class.isAssignableFrom(required)) {
// return webTarget;
// }
//
// if (required.isInterface()) {
// return WebResourceFactory.newResource(required, webTarget, clientMethodInvoker);
// }
// }
//
// throw new IllegalStateException(format("Can't find proper injection for %s", type));
// }
//
// @Override
// public boolean isConstructorParameterIndicator() {
// return true;
// }
//
// @Override
// public boolean isMethodParameterIndicator() {
// return true;
// }
//
// @Override
// public Class<Remote> getAnnotation() {
// return Remote.class;
// }
// }
//
// Path: core-client/src/main/java/net/winterly/rxjersey/client/inject/RxJerseyBinder.java
// public abstract class RxJerseyBinder extends AbstractBinder {
//
// private final Field injectionManagerField;
//
// public RxJerseyBinder() {
// try {
// // Damn private properties everywhere
// injectionManagerField = AbstractBinder.class.getDeclaredField("injectionManager");
// injectionManagerField.setAccessible(true);
// } catch (NoSuchFieldException e) {
// throw new RuntimeException(e);
// }
// }
//
// protected InjectionManager getInjectionManager() {
// try {
// return (InjectionManager) injectionManagerField.get(this);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
// }
| import net.winterly.rxjersey.client.inject.RemoteResolver;
import net.winterly.rxjersey.client.inject.RxJerseyBinder;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.rx.rxjava2.RxFlowableInvokerProvider;
import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext; | package net.winterly.rxjersey.client.rxjava2;
/**
* Feature implementation to configure RxJava support for clients
*/
public class RxJerseyClientFeature implements Feature {
private Client client;
public RxJerseyClientFeature setClient(Client client) {
this.client = client;
return this;
}
@Override
public boolean configure(FeatureContext context) {
if (client == null) {
client = defaultClient();
}
client.register(RxBodyReader.class);
context.register(new Binder());
return true;
}
private Client defaultClient() {
int cores = Runtime.getRuntime().availableProcessors();
ClientConfig config = new ClientConfig();
config.connectorProvider(new GrizzlyConnectorProvider());
config.property(ClientProperties.ASYNC_THREADPOOL_SIZE, cores);
config.register(RxFlowableInvokerProvider.class);
return ClientBuilder.newClient(config);
}
| // Path: core-client/src/main/java/net/winterly/rxjersey/client/inject/RemoteResolver.java
// @Singleton
// public class RemoteResolver implements InjectionResolver<Remote> {
//
// private InjectionManager injectionManager;
// private ClientMethodInvoker clientMethodInvoker;
// private Client client;
//
// public RemoteResolver(InjectionManager injectionManager, ClientMethodInvoker methodInvoker, Client client) {
// this.injectionManager = injectionManager;
// this.clientMethodInvoker = methodInvoker;
// this.client = client;
// }
//
// private static URI merge(String value, UriInfo uriInfo) {
// URI target = URI.create(value);
// if (target.getHost() == null) {
// target = UriBuilder.fromUri(uriInfo.getBaseUri()).uri(target).build();
// }
//
// return target;
// }
//
// /**
// * @return RxWebTarget or Proxy client of specified injectee interface
// * @throws IllegalStateException if uri is not correct or there is no sufficient injection resolved
// */
// @Override
// public Object resolve(Injectee injectee) {
// Remote remote = injectee.getParent().getAnnotation(Remote.class);
// UriInfo uriInfo = injectionManager.getInstance(UriInfo.class);
//
// URI target = merge(remote.value(), uriInfo);
// WebTarget webTarget = client.target(target);
// Type type = injectee.getRequiredType();
//
// if (type instanceof Class) {
// Class<?> required = (Class) type;
//
// if (WebTarget.class.isAssignableFrom(required)) {
// return webTarget;
// }
//
// if (required.isInterface()) {
// return WebResourceFactory.newResource(required, webTarget, clientMethodInvoker);
// }
// }
//
// throw new IllegalStateException(format("Can't find proper injection for %s", type));
// }
//
// @Override
// public boolean isConstructorParameterIndicator() {
// return true;
// }
//
// @Override
// public boolean isMethodParameterIndicator() {
// return true;
// }
//
// @Override
// public Class<Remote> getAnnotation() {
// return Remote.class;
// }
// }
//
// Path: core-client/src/main/java/net/winterly/rxjersey/client/inject/RxJerseyBinder.java
// public abstract class RxJerseyBinder extends AbstractBinder {
//
// private final Field injectionManagerField;
//
// public RxJerseyBinder() {
// try {
// // Damn private properties everywhere
// injectionManagerField = AbstractBinder.class.getDeclaredField("injectionManager");
// injectionManagerField.setAccessible(true);
// } catch (NoSuchFieldException e) {
// throw new RuntimeException(e);
// }
// }
//
// protected InjectionManager getInjectionManager() {
// try {
// return (InjectionManager) injectionManagerField.get(this);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
// }
// Path: rxjava2-client/src/main/java/net/winterly/rxjersey/client/rxjava2/RxJerseyClientFeature.java
import net.winterly.rxjersey.client.inject.RemoteResolver;
import net.winterly.rxjersey.client.inject.RxJerseyBinder;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.rx.rxjava2.RxFlowableInvokerProvider;
import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext;
package net.winterly.rxjersey.client.rxjava2;
/**
* Feature implementation to configure RxJava support for clients
*/
public class RxJerseyClientFeature implements Feature {
private Client client;
public RxJerseyClientFeature setClient(Client client) {
this.client = client;
return this;
}
@Override
public boolean configure(FeatureContext context) {
if (client == null) {
client = defaultClient();
}
client.register(RxBodyReader.class);
context.register(new Binder());
return true;
}
private Client defaultClient() {
int cores = Runtime.getRuntime().availableProcessors();
ClientConfig config = new ClientConfig();
config.connectorProvider(new GrizzlyConnectorProvider());
config.property(ClientProperties.ASYNC_THREADPOOL_SIZE, cores);
config.register(RxFlowableInvokerProvider.class);
return ClientBuilder.newClient(config);
}
| private class Binder extends RxJerseyBinder { |
alex-shpak/rx-jersey | rxjava2-client/src/main/java/net/winterly/rxjersey/client/rxjava2/RxJerseyClientFeature.java | // Path: core-client/src/main/java/net/winterly/rxjersey/client/inject/RemoteResolver.java
// @Singleton
// public class RemoteResolver implements InjectionResolver<Remote> {
//
// private InjectionManager injectionManager;
// private ClientMethodInvoker clientMethodInvoker;
// private Client client;
//
// public RemoteResolver(InjectionManager injectionManager, ClientMethodInvoker methodInvoker, Client client) {
// this.injectionManager = injectionManager;
// this.clientMethodInvoker = methodInvoker;
// this.client = client;
// }
//
// private static URI merge(String value, UriInfo uriInfo) {
// URI target = URI.create(value);
// if (target.getHost() == null) {
// target = UriBuilder.fromUri(uriInfo.getBaseUri()).uri(target).build();
// }
//
// return target;
// }
//
// /**
// * @return RxWebTarget or Proxy client of specified injectee interface
// * @throws IllegalStateException if uri is not correct or there is no sufficient injection resolved
// */
// @Override
// public Object resolve(Injectee injectee) {
// Remote remote = injectee.getParent().getAnnotation(Remote.class);
// UriInfo uriInfo = injectionManager.getInstance(UriInfo.class);
//
// URI target = merge(remote.value(), uriInfo);
// WebTarget webTarget = client.target(target);
// Type type = injectee.getRequiredType();
//
// if (type instanceof Class) {
// Class<?> required = (Class) type;
//
// if (WebTarget.class.isAssignableFrom(required)) {
// return webTarget;
// }
//
// if (required.isInterface()) {
// return WebResourceFactory.newResource(required, webTarget, clientMethodInvoker);
// }
// }
//
// throw new IllegalStateException(format("Can't find proper injection for %s", type));
// }
//
// @Override
// public boolean isConstructorParameterIndicator() {
// return true;
// }
//
// @Override
// public boolean isMethodParameterIndicator() {
// return true;
// }
//
// @Override
// public Class<Remote> getAnnotation() {
// return Remote.class;
// }
// }
//
// Path: core-client/src/main/java/net/winterly/rxjersey/client/inject/RxJerseyBinder.java
// public abstract class RxJerseyBinder extends AbstractBinder {
//
// private final Field injectionManagerField;
//
// public RxJerseyBinder() {
// try {
// // Damn private properties everywhere
// injectionManagerField = AbstractBinder.class.getDeclaredField("injectionManager");
// injectionManagerField.setAccessible(true);
// } catch (NoSuchFieldException e) {
// throw new RuntimeException(e);
// }
// }
//
// protected InjectionManager getInjectionManager() {
// try {
// return (InjectionManager) injectionManagerField.get(this);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
// }
| import net.winterly.rxjersey.client.inject.RemoteResolver;
import net.winterly.rxjersey.client.inject.RxJerseyBinder;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.rx.rxjava2.RxFlowableInvokerProvider;
import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext; | package net.winterly.rxjersey.client.rxjava2;
/**
* Feature implementation to configure RxJava support for clients
*/
public class RxJerseyClientFeature implements Feature {
private Client client;
public RxJerseyClientFeature setClient(Client client) {
this.client = client;
return this;
}
@Override
public boolean configure(FeatureContext context) {
if (client == null) {
client = defaultClient();
}
client.register(RxBodyReader.class);
context.register(new Binder());
return true;
}
private Client defaultClient() {
int cores = Runtime.getRuntime().availableProcessors();
ClientConfig config = new ClientConfig();
config.connectorProvider(new GrizzlyConnectorProvider());
config.property(ClientProperties.ASYNC_THREADPOOL_SIZE, cores);
config.register(RxFlowableInvokerProvider.class);
return ClientBuilder.newClient(config);
}
private class Binder extends RxJerseyBinder {
@Override
protected void configure() { | // Path: core-client/src/main/java/net/winterly/rxjersey/client/inject/RemoteResolver.java
// @Singleton
// public class RemoteResolver implements InjectionResolver<Remote> {
//
// private InjectionManager injectionManager;
// private ClientMethodInvoker clientMethodInvoker;
// private Client client;
//
// public RemoteResolver(InjectionManager injectionManager, ClientMethodInvoker methodInvoker, Client client) {
// this.injectionManager = injectionManager;
// this.clientMethodInvoker = methodInvoker;
// this.client = client;
// }
//
// private static URI merge(String value, UriInfo uriInfo) {
// URI target = URI.create(value);
// if (target.getHost() == null) {
// target = UriBuilder.fromUri(uriInfo.getBaseUri()).uri(target).build();
// }
//
// return target;
// }
//
// /**
// * @return RxWebTarget or Proxy client of specified injectee interface
// * @throws IllegalStateException if uri is not correct or there is no sufficient injection resolved
// */
// @Override
// public Object resolve(Injectee injectee) {
// Remote remote = injectee.getParent().getAnnotation(Remote.class);
// UriInfo uriInfo = injectionManager.getInstance(UriInfo.class);
//
// URI target = merge(remote.value(), uriInfo);
// WebTarget webTarget = client.target(target);
// Type type = injectee.getRequiredType();
//
// if (type instanceof Class) {
// Class<?> required = (Class) type;
//
// if (WebTarget.class.isAssignableFrom(required)) {
// return webTarget;
// }
//
// if (required.isInterface()) {
// return WebResourceFactory.newResource(required, webTarget, clientMethodInvoker);
// }
// }
//
// throw new IllegalStateException(format("Can't find proper injection for %s", type));
// }
//
// @Override
// public boolean isConstructorParameterIndicator() {
// return true;
// }
//
// @Override
// public boolean isMethodParameterIndicator() {
// return true;
// }
//
// @Override
// public Class<Remote> getAnnotation() {
// return Remote.class;
// }
// }
//
// Path: core-client/src/main/java/net/winterly/rxjersey/client/inject/RxJerseyBinder.java
// public abstract class RxJerseyBinder extends AbstractBinder {
//
// private final Field injectionManagerField;
//
// public RxJerseyBinder() {
// try {
// // Damn private properties everywhere
// injectionManagerField = AbstractBinder.class.getDeclaredField("injectionManager");
// injectionManagerField.setAccessible(true);
// } catch (NoSuchFieldException e) {
// throw new RuntimeException(e);
// }
// }
//
// protected InjectionManager getInjectionManager() {
// try {
// return (InjectionManager) injectionManagerField.get(this);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
// }
// Path: rxjava2-client/src/main/java/net/winterly/rxjersey/client/rxjava2/RxJerseyClientFeature.java
import net.winterly.rxjersey.client.inject.RemoteResolver;
import net.winterly.rxjersey.client.inject.RxJerseyBinder;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.rx.rxjava2.RxFlowableInvokerProvider;
import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext;
package net.winterly.rxjersey.client.rxjava2;
/**
* Feature implementation to configure RxJava support for clients
*/
public class RxJerseyClientFeature implements Feature {
private Client client;
public RxJerseyClientFeature setClient(Client client) {
this.client = client;
return this;
}
@Override
public boolean configure(FeatureContext context) {
if (client == null) {
client = defaultClient();
}
client.register(RxBodyReader.class);
context.register(new Binder());
return true;
}
private Client defaultClient() {
int cores = Runtime.getRuntime().availableProcessors();
ClientConfig config = new ClientConfig();
config.connectorProvider(new GrizzlyConnectorProvider());
config.property(ClientProperties.ASYNC_THREADPOOL_SIZE, cores);
config.register(RxFlowableInvokerProvider.class);
return ClientBuilder.newClient(config);
}
private class Binder extends RxJerseyBinder {
@Override
protected void configure() { | bind(new RemoteResolver( |
ericleong/forceengine | Force Engine/src/forceengine/math/CircleMath.java | // Path: Force Engine/src/forceengine/objects/Circle.java
// public interface Circle extends Rect {
// /**
// * (double) getRadius
// *
// * @return the radius
// */
// public double getRadius();
//
// /**
// * (double) getRadius
// *
// * @return the radius squared (radius^2)
// */
// public double getRadiusSq();
//
//
// /**
// * Sets the radius of the circle.
// *
// * @param radius
// * The new radius of this circle.
// */
// public void setRadius(double radius);
//
// }
//
// Path: Force Engine/src/forceengine/objects/StaticCircle.java
// public class StaticCircle extends Point implements Circle {
// protected double radius;
// protected double radiussq;
//
// public StaticCircle(double x, double y, double radius){
// super(x, y);
// this.radius = radius;
// this.radiussq = radius * radius;
// }
// public StaticCircle(Point p, double radius){
// super(p);
// setRadius(radius);
// }
// @Override
// public boolean equals(Object obj){
// if(this == obj)
// return true;
// if(!super.equals(obj))
// return false;
// if(getClass() != obj.getClass())
// return false;
// StaticCircle other = (StaticCircle)obj;
// if(java.lang.Double.doubleToLongBits(radius) != java.lang.Double.doubleToLongBits(other.radius))
// return false;
// return true;
// }
// @Override
// public Rect getBounds() {
// return StaticRect.fromUpperLeft((int)(x - radius), (int)(y - radius), (int)(2 * radius), (int)(2 * radius));
// }
//
// @Override
// public double getMaxX() {
// return x + radius;
// }
// @Override
// public double getMaxY() {
// return y + radius;
// }
//
// @Override
// public double getMinX() {
// return x - radius;
// }
// @Override
// public double getMinY() {
// return y - radius;
// }
// @Override
// public double getRadius(){
// return radius;
// }
// @Override
// public double getRadiusSq(){
// return radiussq;
// }
// @Override
// public int hashCode(){
// final int prime = 31;
// int result = super.hashCode();
// result = (int)(prime * result + java.lang.Double.doubleToLongBits(radius));
// return result;
// }
// @Override
// public void setRadius(double radius){
// radius = Math.abs(radius);
// this.radius = radius;
// this.radiussq = radius * radius;
// }
// @Override
// public String toString(){
// return "(" + this.x + ", " + this.y + "); r = " + this.radius;
// }
// @Override
// public double getHeight() {
// return 2 * radius;
// }
// @Override
// public double getWidth() {
// return 2 * radius;
// }
// @Override
// public void setHeight(double height) {
// setRadius(height / 2);
// }
// @Override
// public void setWidth(double width) {
// setRadius(width / 2);
// }
// }
| import java.util.ArrayList;
import forceengine.objects.Circle;
import forceengine.objects.StaticCircle; | package forceengine.math;
public class CircleMath {
/**
* checks whether or not 2 circles have collided with each other
*
* @param circle1
* the first circle
* @param circle2
* the second circle
* @return whether or not they have collided
*/
public static final boolean checkcirclecollide(Circle circle1,
Circle circle2) {
return checkcirclecollide(circle1.getX(), circle1.getY(),
circle1.getRadius(), circle2.getX(), circle2.getY(),
circle2.getRadius());
}
/**
* checks whether or not 2 circles have collided
*
* @param x1
* the x value of the first circle
* @param y1
* the y value of the first circle
* @param radius1
* the radius of the first circle
* @param x2
* the x value of the second circle
* @param y2
* the y value of the second circle
* @param radius2
* the radius of the second circle
* @return whether or not they have collided
*/
public static final boolean checkcirclecollide(double x1, double y1,
double radius1, double x2, double y2, double radius2) {
return Math.abs((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) < (radius1 + radius2)
* (radius1 + radius2);
}
/**
* Checks whether or not an array of Circles has collided with a circle.
*
* @param circles
* The <code>ArrayList</code> of <code>Circle</code>.
* @param circle
* The <code>Circle</code> that collision is to be done with.
* @return The index of the <code>Circle</code> in circles that collided
* with circle.
*/
public static final ArrayList<Integer> checkcirclescollide(
ArrayList<Circle> circles, Circle circle) {
ArrayList<Integer> collisionindex = new ArrayList<Integer>(
(int) Math.ceil(circles.size() / 10));
for (int i = 0; i < circles.size(); i++) {
if (checkcirclecollide(circles.get(i), circle)) { // they
// intersect
collisionindex.add(i);
}
}
return collisionindex;
}
/**
* Checks whether or not an array of StaticCircles has collided with a
* circle.
*
* @param circles
* The <code>ArrayList</code> of <code>StaticCircle</code>.
* @param circle
* The <code>StaticCircle</code> that collision is to be done
* with.
* @return The index of the <code>StaticCircle</code> in circles that
* collided with circle.
*/
public static final ArrayList<Integer> checkstaticcirclescollide( | // Path: Force Engine/src/forceengine/objects/Circle.java
// public interface Circle extends Rect {
// /**
// * (double) getRadius
// *
// * @return the radius
// */
// public double getRadius();
//
// /**
// * (double) getRadius
// *
// * @return the radius squared (radius^2)
// */
// public double getRadiusSq();
//
//
// /**
// * Sets the radius of the circle.
// *
// * @param radius
// * The new radius of this circle.
// */
// public void setRadius(double radius);
//
// }
//
// Path: Force Engine/src/forceengine/objects/StaticCircle.java
// public class StaticCircle extends Point implements Circle {
// protected double radius;
// protected double radiussq;
//
// public StaticCircle(double x, double y, double radius){
// super(x, y);
// this.radius = radius;
// this.radiussq = radius * radius;
// }
// public StaticCircle(Point p, double radius){
// super(p);
// setRadius(radius);
// }
// @Override
// public boolean equals(Object obj){
// if(this == obj)
// return true;
// if(!super.equals(obj))
// return false;
// if(getClass() != obj.getClass())
// return false;
// StaticCircle other = (StaticCircle)obj;
// if(java.lang.Double.doubleToLongBits(radius) != java.lang.Double.doubleToLongBits(other.radius))
// return false;
// return true;
// }
// @Override
// public Rect getBounds() {
// return StaticRect.fromUpperLeft((int)(x - radius), (int)(y - radius), (int)(2 * radius), (int)(2 * radius));
// }
//
// @Override
// public double getMaxX() {
// return x + radius;
// }
// @Override
// public double getMaxY() {
// return y + radius;
// }
//
// @Override
// public double getMinX() {
// return x - radius;
// }
// @Override
// public double getMinY() {
// return y - radius;
// }
// @Override
// public double getRadius(){
// return radius;
// }
// @Override
// public double getRadiusSq(){
// return radiussq;
// }
// @Override
// public int hashCode(){
// final int prime = 31;
// int result = super.hashCode();
// result = (int)(prime * result + java.lang.Double.doubleToLongBits(radius));
// return result;
// }
// @Override
// public void setRadius(double radius){
// radius = Math.abs(radius);
// this.radius = radius;
// this.radiussq = radius * radius;
// }
// @Override
// public String toString(){
// return "(" + this.x + ", " + this.y + "); r = " + this.radius;
// }
// @Override
// public double getHeight() {
// return 2 * radius;
// }
// @Override
// public double getWidth() {
// return 2 * radius;
// }
// @Override
// public void setHeight(double height) {
// setRadius(height / 2);
// }
// @Override
// public void setWidth(double width) {
// setRadius(width / 2);
// }
// }
// Path: Force Engine/src/forceengine/math/CircleMath.java
import java.util.ArrayList;
import forceengine.objects.Circle;
import forceengine.objects.StaticCircle;
package forceengine.math;
public class CircleMath {
/**
* checks whether or not 2 circles have collided with each other
*
* @param circle1
* the first circle
* @param circle2
* the second circle
* @return whether or not they have collided
*/
public static final boolean checkcirclecollide(Circle circle1,
Circle circle2) {
return checkcirclecollide(circle1.getX(), circle1.getY(),
circle1.getRadius(), circle2.getX(), circle2.getY(),
circle2.getRadius());
}
/**
* checks whether or not 2 circles have collided
*
* @param x1
* the x value of the first circle
* @param y1
* the y value of the first circle
* @param radius1
* the radius of the first circle
* @param x2
* the x value of the second circle
* @param y2
* the y value of the second circle
* @param radius2
* the radius of the second circle
* @return whether or not they have collided
*/
public static final boolean checkcirclecollide(double x1, double y1,
double radius1, double x2, double y2, double radius2) {
return Math.abs((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) < (radius1 + radius2)
* (radius1 + radius2);
}
/**
* Checks whether or not an array of Circles has collided with a circle.
*
* @param circles
* The <code>ArrayList</code> of <code>Circle</code>.
* @param circle
* The <code>Circle</code> that collision is to be done with.
* @return The index of the <code>Circle</code> in circles that collided
* with circle.
*/
public static final ArrayList<Integer> checkcirclescollide(
ArrayList<Circle> circles, Circle circle) {
ArrayList<Integer> collisionindex = new ArrayList<Integer>(
(int) Math.ceil(circles.size() / 10));
for (int i = 0; i < circles.size(); i++) {
if (checkcirclecollide(circles.get(i), circle)) { // they
// intersect
collisionindex.add(i);
}
}
return collisionindex;
}
/**
* Checks whether or not an array of StaticCircles has collided with a
* circle.
*
* @param circles
* The <code>ArrayList</code> of <code>StaticCircle</code>.
* @param circle
* The <code>StaticCircle</code> that collision is to be done
* with.
* @return The index of the <code>StaticCircle</code> in circles that
* collided with circle.
*/
public static final ArrayList<Integer> checkstaticcirclescollide( | ArrayList<StaticCircle> circles, Circle circle) { |
ericleong/forceengine | Force Engine/src/forceengine/math/IntersectMath.java | // Path: Force Engine/src/forceengine/objects/Circle.java
// public interface Circle extends Rect {
// /**
// * (double) getRadius
// *
// * @return the radius
// */
// public double getRadius();
//
// /**
// * (double) getRadius
// *
// * @return the radius squared (radius^2)
// */
// public double getRadiusSq();
//
//
// /**
// * Sets the radius of the circle.
// *
// * @param radius
// * The new radius of this circle.
// */
// public void setRadius(double radius);
//
// }
//
// Path: Force Engine/src/forceengine/objects/StaticLine.java
// public class StaticLine extends Point implements Line {
// private double x2, y2;
//
// public StaticLine(double x1, double y1, double x2, double y2) {
// super(x1, y1);
// this.x2 = x2;
// this.y2 = y2;
// }
//
// public Point getClosestPointOnLine(double x, double y) {
// return VectorMath.closestpointonline(this.getX1(), this.getY1(),
// this.getX2(), this.getY2(), x, y);
// }
//
// public Point getClosestPointOnLine(Point p) {
// return VectorMath.closestpointonline(this, p);
// }
//
// @Override
// public Rect getBounds() {
// return StaticRect.fromUpperLeft((int) Math.min(getX1(), getX2()), (int) Math.min(getY1(), getY2()), (int) Math.max(getX1(), getX2()),
// (int) Math.max(getY1(), getY2()));
// }
//
// @Override
// public Point getP1() {
// return new Point(getX1(), getY1());
// }
//
// @Override
// public Point getP2() {
// return new Point(getX2(), getY2());
// }
//
// @Override
// public double getX1() {
// return x;
// }
//
// @Override
// public double getX2() {
// return x2;
// }
//
// @Override
// public double getY1() {
// return y;
// }
//
// @Override
// public double getY2() {
// return y2;
// }
//
// @Override
// public void setLine(double x1, double y1, double x2, double y2) {
// x = x1;
// y = y1;
// this.x2 = x2;
// this.y2 = y2;
// }
// }
| import forceengine.objects.Circle;
import forceengine.objects.StaticLine; | package forceengine.math;
public class IntersectMath {
/**
* checks whether or not a circle and a line have intersected
*
* @param circle
* the circle
* @param line
* the line
* @return whether or not they have intersected
*/
public static final boolean checkcirclelinecollide(Circle circle, | // Path: Force Engine/src/forceengine/objects/Circle.java
// public interface Circle extends Rect {
// /**
// * (double) getRadius
// *
// * @return the radius
// */
// public double getRadius();
//
// /**
// * (double) getRadius
// *
// * @return the radius squared (radius^2)
// */
// public double getRadiusSq();
//
//
// /**
// * Sets the radius of the circle.
// *
// * @param radius
// * The new radius of this circle.
// */
// public void setRadius(double radius);
//
// }
//
// Path: Force Engine/src/forceengine/objects/StaticLine.java
// public class StaticLine extends Point implements Line {
// private double x2, y2;
//
// public StaticLine(double x1, double y1, double x2, double y2) {
// super(x1, y1);
// this.x2 = x2;
// this.y2 = y2;
// }
//
// public Point getClosestPointOnLine(double x, double y) {
// return VectorMath.closestpointonline(this.getX1(), this.getY1(),
// this.getX2(), this.getY2(), x, y);
// }
//
// public Point getClosestPointOnLine(Point p) {
// return VectorMath.closestpointonline(this, p);
// }
//
// @Override
// public Rect getBounds() {
// return StaticRect.fromUpperLeft((int) Math.min(getX1(), getX2()), (int) Math.min(getY1(), getY2()), (int) Math.max(getX1(), getX2()),
// (int) Math.max(getY1(), getY2()));
// }
//
// @Override
// public Point getP1() {
// return new Point(getX1(), getY1());
// }
//
// @Override
// public Point getP2() {
// return new Point(getX2(), getY2());
// }
//
// @Override
// public double getX1() {
// return x;
// }
//
// @Override
// public double getX2() {
// return x2;
// }
//
// @Override
// public double getY1() {
// return y;
// }
//
// @Override
// public double getY2() {
// return y2;
// }
//
// @Override
// public void setLine(double x1, double y1, double x2, double y2) {
// x = x1;
// y = y1;
// this.x2 = x2;
// this.y2 = y2;
// }
// }
// Path: Force Engine/src/forceengine/math/IntersectMath.java
import forceengine.objects.Circle;
import forceengine.objects.StaticLine;
package forceengine.math;
public class IntersectMath {
/**
* checks whether or not a circle and a line have intersected
*
* @param circle
* the circle
* @param line
* the line
* @return whether or not they have intersected
*/
public static final boolean checkcirclelinecollide(Circle circle, | StaticLine line) { |
onyxbits/TradeTrax | src/main/java/de/onyxbits/tradetrax/services/DevelopmentModule.java | // Path: src/main/java/de/onyxbits/tradetrax/main/AppConstants.java
// public class AppConstants {
//
// /**
// * The human readable version name without any prefixes (e.g. "v") or suffixes
// * (e.g. "-SNAPSHOT-DEV")
// */
// public static final String VERSION;
//
// /**
// * Init Parameter Name "Ledger": the parameter name by which to configure the
// * ledger path in web.xml
// */
// public static final String IPNLEDGERPATH = "ledger";
//
// static {
// String tmp = "UNKNOWN";
// try {
// // TODO: Ideally this would somehow come from pom.xml, but there doesn't
// // seem to be a good way to transport it from there that works for the JAR
// // as well as the WAR version.
// tmp = "1.6";
// }
// catch (Exception e) {
// }
// VERSION = tmp;
// }
// }
| import org.apache.tapestry5.*;
import org.apache.tapestry5.ioc.MappedConfiguration;
import de.onyxbits.tradetrax.main.AppConstants; | package de.onyxbits.tradetrax.services;
/**
* This module is automatically included as part of the Tapestry IoC Registry if
* <em>tapestry.execution-mode</em> includes <code>development</code>.
*/
public class DevelopmentModule {
public static void contributeApplicationDefaults(MappedConfiguration<String, Object> configuration) {
// The factory default is true but during the early stages of an application
// overriding to false is a good idea. In addition, this is often overridden
// on the command line as -Dtapestry.production-mode=false
configuration.add(SymbolConstants.PRODUCTION_MODE, false);
// The application version number is incorprated into URLs for some
// assets. Web browsers will cache assets because of the far future expires
// header. If existing assets are changed, the version number should also
// change, to force the browser to download new versions. | // Path: src/main/java/de/onyxbits/tradetrax/main/AppConstants.java
// public class AppConstants {
//
// /**
// * The human readable version name without any prefixes (e.g. "v") or suffixes
// * (e.g. "-SNAPSHOT-DEV")
// */
// public static final String VERSION;
//
// /**
// * Init Parameter Name "Ledger": the parameter name by which to configure the
// * ledger path in web.xml
// */
// public static final String IPNLEDGERPATH = "ledger";
//
// static {
// String tmp = "UNKNOWN";
// try {
// // TODO: Ideally this would somehow come from pom.xml, but there doesn't
// // seem to be a good way to transport it from there that works for the JAR
// // as well as the WAR version.
// tmp = "1.6";
// }
// catch (Exception e) {
// }
// VERSION = tmp;
// }
// }
// Path: src/main/java/de/onyxbits/tradetrax/services/DevelopmentModule.java
import org.apache.tapestry5.*;
import org.apache.tapestry5.ioc.MappedConfiguration;
import de.onyxbits.tradetrax.main.AppConstants;
package de.onyxbits.tradetrax.services;
/**
* This module is automatically included as part of the Tapestry IoC Registry if
* <em>tapestry.execution-mode</em> includes <code>development</code>.
*/
public class DevelopmentModule {
public static void contributeApplicationDefaults(MappedConfiguration<String, Object> configuration) {
// The factory default is true but during the early stages of an application
// overriding to false is a good idea. In addition, this is often overridden
// on the command line as -Dtapestry.production-mode=false
configuration.add(SymbolConstants.PRODUCTION_MODE, false);
// The application version number is incorprated into URLs for some
// assets. Web browsers will cache assets because of the far future expires
// header. If existing assets are changed, the version number should also
// change, to force the browser to download new versions. | configuration.add(SymbolConstants.APPLICATION_VERSION, "v"+AppConstants.VERSION + "-SNAPSHOT-DEV"); |
onyxbits/TradeTrax | src/main/java/de/onyxbits/tradetrax/components/CurrencysymbolValue.java | // Path: src/main/java/de/onyxbits/tradetrax/services/MoneyRepresentation.java
// public interface MoneyRepresentation {
//
// /**
// * Scaling factor
// */
// public static final long FACTOR = 10 * 10 * 10 * 10;
//
// /**
// * @return the currencySymbol
// */
// public abstract String getCurrencySymbol();
//
// /**
// * Converts a user submitted value to internal representation
// *
// * @param value
// * a string such as "2.99", "4,99" or "-1"
// * @param units
// * unitcount (in case the user is submitting the price for a stack of
// * items). No safety checks are performed. Especially not for
// * division by zero.
// * @return the value as an integer
// * @throws ParseException
// */
// public abstract long userToDatabase(String value, int units) throws ParseException;
//
// /**
// * Convert from internal representation to human readable
// *
// * @param value
// * an integer such as 499
// * @param precise
// * false to clip digits, true to print the full value.
// * @param addSymbol
// * true to add the currencysymbol
// * @return a string such as $4.99
// */
// public abstract String databaseToUser(long value, boolean precise, boolean addSymbol);
//
// }
| import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.ioc.annotations.Inject;
import de.onyxbits.tradetrax.services.MoneyRepresentation; | package de.onyxbits.tradetrax.components;
/**
* Just print the ledger's currency symbol.
*
* @author patrick
*
*/
public class CurrencysymbolValue {
@Inject | // Path: src/main/java/de/onyxbits/tradetrax/services/MoneyRepresentation.java
// public interface MoneyRepresentation {
//
// /**
// * Scaling factor
// */
// public static final long FACTOR = 10 * 10 * 10 * 10;
//
// /**
// * @return the currencySymbol
// */
// public abstract String getCurrencySymbol();
//
// /**
// * Converts a user submitted value to internal representation
// *
// * @param value
// * a string such as "2.99", "4,99" or "-1"
// * @param units
// * unitcount (in case the user is submitting the price for a stack of
// * items). No safety checks are performed. Especially not for
// * division by zero.
// * @return the value as an integer
// * @throws ParseException
// */
// public abstract long userToDatabase(String value, int units) throws ParseException;
//
// /**
// * Convert from internal representation to human readable
// *
// * @param value
// * an integer such as 499
// * @param precise
// * false to clip digits, true to print the full value.
// * @param addSymbol
// * true to add the currencysymbol
// * @return a string such as $4.99
// */
// public abstract String databaseToUser(long value, boolean precise, boolean addSymbol);
//
// }
// Path: src/main/java/de/onyxbits/tradetrax/components/CurrencysymbolValue.java
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.ioc.annotations.Inject;
import de.onyxbits.tradetrax.services.MoneyRepresentation;
package de.onyxbits.tradetrax.components;
/**
* Just print the ledger's currency symbol.
*
* @author patrick
*
*/
public class CurrencysymbolValue {
@Inject | private MoneyRepresentation moneyRepresentation; |
onyxbits/TradeTrax | src/main/java/de/onyxbits/tradetrax/services/AppModule.java | // Path: src/main/java/de/onyxbits/tradetrax/main/AppConstants.java
// public class AppConstants {
//
// /**
// * The human readable version name without any prefixes (e.g. "v") or suffixes
// * (e.g. "-SNAPSHOT-DEV")
// */
// public static final String VERSION;
//
// /**
// * Init Parameter Name "Ledger": the parameter name by which to configure the
// * ledger path in web.xml
// */
// public static final String IPNLEDGERPATH = "ledger";
//
// static {
// String tmp = "UNKNOWN";
// try {
// // TODO: Ideally this would somehow come from pom.xml, but there doesn't
// // seem to be a good way to transport it from there that works for the JAR
// // as well as the WAR version.
// tmp = "1.6";
// }
// catch (Exception e) {
// }
// VERSION = tmp;
// }
// }
| import java.io.File;
import org.apache.tapestry5.*;
import org.apache.tapestry5.hibernate.HibernateConfigurer;
import org.apache.tapestry5.hibernate.HibernateSymbols;
import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.ioc.OrderedConfiguration;
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.ApplicationGlobals;
import de.onyxbits.tradetrax.main.AppConstants; | package de.onyxbits.tradetrax.services;
/**
* This module is automatically included as part of the Tapestry IoC Registry,
* it's a good place to configure and extend Tapestry, or to place your own
* service definitions.
*/
public class AppModule {
public static void bind(ServiceBinder binder) {
// binder.bind(MyServiceInterface.class, MyServiceImpl.class);
// Make bind() calls on the binder object to define most IoC services.
// Use service builder methods (example below) when the implementation
// is provided inline, or requires more initialization than simply
// invoking the constructor.
binder.bind(SettingsStore.class);
binder.bind(EventLogger.class);
binder.bind(MoneyRepresentation.class);
}
public static void contributeFactoryDefaults(MappedConfiguration<String, Object> configuration) {
// The application version number is incorprated into URLs for some
// assets. Web browsers will cache assets because of the far future expires
// header. If existing assets are changed, the version number should also
// change, to force the browser to download new versions. This overrides
// Tapesty's default
// (a random hexadecimal number), but may be further overriden by
// DevelopmentModule or
// QaModule. | // Path: src/main/java/de/onyxbits/tradetrax/main/AppConstants.java
// public class AppConstants {
//
// /**
// * The human readable version name without any prefixes (e.g. "v") or suffixes
// * (e.g. "-SNAPSHOT-DEV")
// */
// public static final String VERSION;
//
// /**
// * Init Parameter Name "Ledger": the parameter name by which to configure the
// * ledger path in web.xml
// */
// public static final String IPNLEDGERPATH = "ledger";
//
// static {
// String tmp = "UNKNOWN";
// try {
// // TODO: Ideally this would somehow come from pom.xml, but there doesn't
// // seem to be a good way to transport it from there that works for the JAR
// // as well as the WAR version.
// tmp = "1.6";
// }
// catch (Exception e) {
// }
// VERSION = tmp;
// }
// }
// Path: src/main/java/de/onyxbits/tradetrax/services/AppModule.java
import java.io.File;
import org.apache.tapestry5.*;
import org.apache.tapestry5.hibernate.HibernateConfigurer;
import org.apache.tapestry5.hibernate.HibernateSymbols;
import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.ioc.OrderedConfiguration;
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.ApplicationGlobals;
import de.onyxbits.tradetrax.main.AppConstants;
package de.onyxbits.tradetrax.services;
/**
* This module is automatically included as part of the Tapestry IoC Registry,
* it's a good place to configure and extend Tapestry, or to place your own
* service definitions.
*/
public class AppModule {
public static void bind(ServiceBinder binder) {
// binder.bind(MyServiceInterface.class, MyServiceImpl.class);
// Make bind() calls on the binder object to define most IoC services.
// Use service builder methods (example below) when the implementation
// is provided inline, or requires more initialization than simply
// invoking the constructor.
binder.bind(SettingsStore.class);
binder.bind(EventLogger.class);
binder.bind(MoneyRepresentation.class);
}
public static void contributeFactoryDefaults(MappedConfiguration<String, Object> configuration) {
// The application version number is incorprated into URLs for some
// assets. Web browsers will cache assets because of the far future expires
// header. If existing assets are changed, the version number should also
// change, to force the browser to download new versions. This overrides
// Tapesty's default
// (a random hexadecimal number), but may be further overriden by
// DevelopmentModule or
// QaModule. | configuration.override(SymbolConstants.APPLICATION_VERSION, "v"+AppConstants.VERSION); |
onyxbits/TradeTrax | src/main/java/de/onyxbits/tradetrax/remix/LogEntryPagedGridDataSource.java | // Path: src/main/java/de/onyxbits/tradetrax/entities/LogEntry.java
// @Entity
// @Table(name = "log")
// public class LogEntry implements Serializable {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Row index
// */
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// /**
// * What happened? This should be a category label (e.g. "ASSET BOUGHT").
// */
// private String what;
//
// /**
// * When did it happen?
// */
// @Type(type = "timestamp")
// private Date timestamp;
//
// /**
// * Detail message. This should tell the user what actually happened.
// */
// private String details;
//
// /**
// * @return the id
// */
// public long getId() {
// return id;
// }
//
// /**
// * @return the what
// */
// public String getWhat() {
// return what;
// }
//
// /**
// * @return the timestamp
// */
// public Date getTimestamp() {
// return timestamp;
// }
//
// /**
// * @return the details
// */
// public String getDetails() {
// return details;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(long id) {
// this.id = id;
// }
//
// /**
// * @param what the what to set
// */
// public void setWhat(String what) {
// this.what = what;
// }
//
// /**
// * @param timestamp the timestamp to set
// */
// public void setTimestamp(Date timestamp) {
// this.timestamp = timestamp;
// }
//
// /**
// * @param details the details to set
// */
// public void setDetails(String details) {
// this.details = details;
// }
//
//
// }
| import java.util.List;
import org.apache.tapestry5.grid.GridDataSource;
import org.apache.tapestry5.grid.SortConstraint;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import de.onyxbits.tradetrax.entities.LogEntry; | package de.onyxbits.tradetrax.remix;
public class LogEntryPagedGridDataSource implements GridDataSource {
private String filter;
private Session session; | // Path: src/main/java/de/onyxbits/tradetrax/entities/LogEntry.java
// @Entity
// @Table(name = "log")
// public class LogEntry implements Serializable {
//
// /**
// *
// */
// private static final long serialVersionUID = 1L;
//
// /**
// * Row index
// */
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private long id;
//
// /**
// * What happened? This should be a category label (e.g. "ASSET BOUGHT").
// */
// private String what;
//
// /**
// * When did it happen?
// */
// @Type(type = "timestamp")
// private Date timestamp;
//
// /**
// * Detail message. This should tell the user what actually happened.
// */
// private String details;
//
// /**
// * @return the id
// */
// public long getId() {
// return id;
// }
//
// /**
// * @return the what
// */
// public String getWhat() {
// return what;
// }
//
// /**
// * @return the timestamp
// */
// public Date getTimestamp() {
// return timestamp;
// }
//
// /**
// * @return the details
// */
// public String getDetails() {
// return details;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(long id) {
// this.id = id;
// }
//
// /**
// * @param what the what to set
// */
// public void setWhat(String what) {
// this.what = what;
// }
//
// /**
// * @param timestamp the timestamp to set
// */
// public void setTimestamp(Date timestamp) {
// this.timestamp = timestamp;
// }
//
// /**
// * @param details the details to set
// */
// public void setDetails(String details) {
// this.details = details;
// }
//
//
// }
// Path: src/main/java/de/onyxbits/tradetrax/remix/LogEntryPagedGridDataSource.java
import java.util.List;
import org.apache.tapestry5.grid.GridDataSource;
import org.apache.tapestry5.grid.SortConstraint;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import de.onyxbits.tradetrax.entities.LogEntry;
package de.onyxbits.tradetrax.remix;
public class LogEntryPagedGridDataSource implements GridDataSource {
private String filter;
private Session session; | private List<LogEntry> preparedResults; |
onyxbits/TradeTrax | src/main/java/de/onyxbits/tradetrax/components/MoneyValue.java | // Path: src/main/java/de/onyxbits/tradetrax/services/MoneyRepresentation.java
// public interface MoneyRepresentation {
//
// /**
// * Scaling factor
// */
// public static final long FACTOR = 10 * 10 * 10 * 10;
//
// /**
// * @return the currencySymbol
// */
// public abstract String getCurrencySymbol();
//
// /**
// * Converts a user submitted value to internal representation
// *
// * @param value
// * a string such as "2.99", "4,99" or "-1"
// * @param units
// * unitcount (in case the user is submitting the price for a stack of
// * items). No safety checks are performed. Especially not for
// * division by zero.
// * @return the value as an integer
// * @throws ParseException
// */
// public abstract long userToDatabase(String value, int units) throws ParseException;
//
// /**
// * Convert from internal representation to human readable
// *
// * @param value
// * an integer such as 499
// * @param precise
// * false to clip digits, true to print the full value.
// * @param addSymbol
// * true to add the currencysymbol
// * @return a string such as $4.99
// */
// public abstract String databaseToUser(long value, boolean precise, boolean addSymbol);
//
// }
//
// Path: src/main/java/de/onyxbits/tradetrax/services/SettingsStore.java
// public interface SettingsStore {
//
// /**
// * The (visual) string that represents the currency of the ledger.
// */
// public static final String CURRENCYSYMBOL = "currencysymbol";
//
// /**
// * How many digits to display by default.
// */
// public static final String DECIMALS = "decimals";
//
// /**
// * Human readable name of the ledger
// */
// public static final String LEDGERTITLE = "ledgertitle";
//
// /**
// * Whether or not to show the instructionsblock in the sidebar.
// */
// public static final String HIDEINSTRUCTIONS = "hideinstructions";
//
// /**
// * Whether or not to show the calculator in the sidebar
// */
// public static final String SHOWCALCULATOR = "showcalculator";
//
// /**
// * Columns to show for the tradecenter ledger.
// */
// public static final String TCLCOLUMNS = "tclcolumns";
//
// /**
// * Fields to show on the tradecenter acquisition form.
// */
// public static final String TCACFIELDS = "tcafields";
//
// /**
// * When the ledger was created
// */
// public static final String CREATED = "created";
//
// /**
// * How wide the page may be
// */
// public static final String PAGEWIDTH = "pagewidth";
//
// /**
// * Get a setting
// *
// * @param key
// * the kay of the setting
// * @param value
// * default value if key does not exist
// * @return the value
// */
// public String get(String key, String value);
//
// /**
// * Enter a setting into the storage
// *
// * @param key
// * key name
// * @param value
// * value
// */
// public void set(String key, String value);
// }
| import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import de.onyxbits.tradetrax.services.MoneyRepresentation;
import de.onyxbits.tradetrax.services.SettingsStore; | package de.onyxbits.tradetrax.components;
/**
* Convert a monetary value from database to user format and wrap it in a
* loss/profit CSS container before printing it.
*
* @author patrick
*
*/
public class MoneyValue {
/**
* Monetary value in database format.
*/
@Parameter(required = true)
private long amount;
/**
* Include the currency symbol when printing?
*/
@Parameter
private boolean addSymbol = true;
/**
* Cut off decimals to get a fixed length fraction?
*/
@Parameter
private boolean precise;
@Property
private String value;
@Property
private boolean loss;
@Inject | // Path: src/main/java/de/onyxbits/tradetrax/services/MoneyRepresentation.java
// public interface MoneyRepresentation {
//
// /**
// * Scaling factor
// */
// public static final long FACTOR = 10 * 10 * 10 * 10;
//
// /**
// * @return the currencySymbol
// */
// public abstract String getCurrencySymbol();
//
// /**
// * Converts a user submitted value to internal representation
// *
// * @param value
// * a string such as "2.99", "4,99" or "-1"
// * @param units
// * unitcount (in case the user is submitting the price for a stack of
// * items). No safety checks are performed. Especially not for
// * division by zero.
// * @return the value as an integer
// * @throws ParseException
// */
// public abstract long userToDatabase(String value, int units) throws ParseException;
//
// /**
// * Convert from internal representation to human readable
// *
// * @param value
// * an integer such as 499
// * @param precise
// * false to clip digits, true to print the full value.
// * @param addSymbol
// * true to add the currencysymbol
// * @return a string such as $4.99
// */
// public abstract String databaseToUser(long value, boolean precise, boolean addSymbol);
//
// }
//
// Path: src/main/java/de/onyxbits/tradetrax/services/SettingsStore.java
// public interface SettingsStore {
//
// /**
// * The (visual) string that represents the currency of the ledger.
// */
// public static final String CURRENCYSYMBOL = "currencysymbol";
//
// /**
// * How many digits to display by default.
// */
// public static final String DECIMALS = "decimals";
//
// /**
// * Human readable name of the ledger
// */
// public static final String LEDGERTITLE = "ledgertitle";
//
// /**
// * Whether or not to show the instructionsblock in the sidebar.
// */
// public static final String HIDEINSTRUCTIONS = "hideinstructions";
//
// /**
// * Whether or not to show the calculator in the sidebar
// */
// public static final String SHOWCALCULATOR = "showcalculator";
//
// /**
// * Columns to show for the tradecenter ledger.
// */
// public static final String TCLCOLUMNS = "tclcolumns";
//
// /**
// * Fields to show on the tradecenter acquisition form.
// */
// public static final String TCACFIELDS = "tcafields";
//
// /**
// * When the ledger was created
// */
// public static final String CREATED = "created";
//
// /**
// * How wide the page may be
// */
// public static final String PAGEWIDTH = "pagewidth";
//
// /**
// * Get a setting
// *
// * @param key
// * the kay of the setting
// * @param value
// * default value if key does not exist
// * @return the value
// */
// public String get(String key, String value);
//
// /**
// * Enter a setting into the storage
// *
// * @param key
// * key name
// * @param value
// * value
// */
// public void set(String key, String value);
// }
// Path: src/main/java/de/onyxbits/tradetrax/components/MoneyValue.java
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import de.onyxbits.tradetrax.services.MoneyRepresentation;
import de.onyxbits.tradetrax.services.SettingsStore;
package de.onyxbits.tradetrax.components;
/**
* Convert a monetary value from database to user format and wrap it in a
* loss/profit CSS container before printing it.
*
* @author patrick
*
*/
public class MoneyValue {
/**
* Monetary value in database format.
*/
@Parameter(required = true)
private long amount;
/**
* Include the currency symbol when printing?
*/
@Parameter
private boolean addSymbol = true;
/**
* Cut off decimals to get a fixed length fraction?
*/
@Parameter
private boolean precise;
@Property
private String value;
@Property
private boolean loss;
@Inject | private SettingsStore settings; |
onyxbits/TradeTrax | src/main/java/de/onyxbits/tradetrax/components/MoneyValue.java | // Path: src/main/java/de/onyxbits/tradetrax/services/MoneyRepresentation.java
// public interface MoneyRepresentation {
//
// /**
// * Scaling factor
// */
// public static final long FACTOR = 10 * 10 * 10 * 10;
//
// /**
// * @return the currencySymbol
// */
// public abstract String getCurrencySymbol();
//
// /**
// * Converts a user submitted value to internal representation
// *
// * @param value
// * a string such as "2.99", "4,99" or "-1"
// * @param units
// * unitcount (in case the user is submitting the price for a stack of
// * items). No safety checks are performed. Especially not for
// * division by zero.
// * @return the value as an integer
// * @throws ParseException
// */
// public abstract long userToDatabase(String value, int units) throws ParseException;
//
// /**
// * Convert from internal representation to human readable
// *
// * @param value
// * an integer such as 499
// * @param precise
// * false to clip digits, true to print the full value.
// * @param addSymbol
// * true to add the currencysymbol
// * @return a string such as $4.99
// */
// public abstract String databaseToUser(long value, boolean precise, boolean addSymbol);
//
// }
//
// Path: src/main/java/de/onyxbits/tradetrax/services/SettingsStore.java
// public interface SettingsStore {
//
// /**
// * The (visual) string that represents the currency of the ledger.
// */
// public static final String CURRENCYSYMBOL = "currencysymbol";
//
// /**
// * How many digits to display by default.
// */
// public static final String DECIMALS = "decimals";
//
// /**
// * Human readable name of the ledger
// */
// public static final String LEDGERTITLE = "ledgertitle";
//
// /**
// * Whether or not to show the instructionsblock in the sidebar.
// */
// public static final String HIDEINSTRUCTIONS = "hideinstructions";
//
// /**
// * Whether or not to show the calculator in the sidebar
// */
// public static final String SHOWCALCULATOR = "showcalculator";
//
// /**
// * Columns to show for the tradecenter ledger.
// */
// public static final String TCLCOLUMNS = "tclcolumns";
//
// /**
// * Fields to show on the tradecenter acquisition form.
// */
// public static final String TCACFIELDS = "tcafields";
//
// /**
// * When the ledger was created
// */
// public static final String CREATED = "created";
//
// /**
// * How wide the page may be
// */
// public static final String PAGEWIDTH = "pagewidth";
//
// /**
// * Get a setting
// *
// * @param key
// * the kay of the setting
// * @param value
// * default value if key does not exist
// * @return the value
// */
// public String get(String key, String value);
//
// /**
// * Enter a setting into the storage
// *
// * @param key
// * key name
// * @param value
// * value
// */
// public void set(String key, String value);
// }
| import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import de.onyxbits.tradetrax.services.MoneyRepresentation;
import de.onyxbits.tradetrax.services.SettingsStore; | package de.onyxbits.tradetrax.components;
/**
* Convert a monetary value from database to user format and wrap it in a
* loss/profit CSS container before printing it.
*
* @author patrick
*
*/
public class MoneyValue {
/**
* Monetary value in database format.
*/
@Parameter(required = true)
private long amount;
/**
* Include the currency symbol when printing?
*/
@Parameter
private boolean addSymbol = true;
/**
* Cut off decimals to get a fixed length fraction?
*/
@Parameter
private boolean precise;
@Property
private String value;
@Property
private boolean loss;
@Inject
private SettingsStore settings;
@Inject | // Path: src/main/java/de/onyxbits/tradetrax/services/MoneyRepresentation.java
// public interface MoneyRepresentation {
//
// /**
// * Scaling factor
// */
// public static final long FACTOR = 10 * 10 * 10 * 10;
//
// /**
// * @return the currencySymbol
// */
// public abstract String getCurrencySymbol();
//
// /**
// * Converts a user submitted value to internal representation
// *
// * @param value
// * a string such as "2.99", "4,99" or "-1"
// * @param units
// * unitcount (in case the user is submitting the price for a stack of
// * items). No safety checks are performed. Especially not for
// * division by zero.
// * @return the value as an integer
// * @throws ParseException
// */
// public abstract long userToDatabase(String value, int units) throws ParseException;
//
// /**
// * Convert from internal representation to human readable
// *
// * @param value
// * an integer such as 499
// * @param precise
// * false to clip digits, true to print the full value.
// * @param addSymbol
// * true to add the currencysymbol
// * @return a string such as $4.99
// */
// public abstract String databaseToUser(long value, boolean precise, boolean addSymbol);
//
// }
//
// Path: src/main/java/de/onyxbits/tradetrax/services/SettingsStore.java
// public interface SettingsStore {
//
// /**
// * The (visual) string that represents the currency of the ledger.
// */
// public static final String CURRENCYSYMBOL = "currencysymbol";
//
// /**
// * How many digits to display by default.
// */
// public static final String DECIMALS = "decimals";
//
// /**
// * Human readable name of the ledger
// */
// public static final String LEDGERTITLE = "ledgertitle";
//
// /**
// * Whether or not to show the instructionsblock in the sidebar.
// */
// public static final String HIDEINSTRUCTIONS = "hideinstructions";
//
// /**
// * Whether or not to show the calculator in the sidebar
// */
// public static final String SHOWCALCULATOR = "showcalculator";
//
// /**
// * Columns to show for the tradecenter ledger.
// */
// public static final String TCLCOLUMNS = "tclcolumns";
//
// /**
// * Fields to show on the tradecenter acquisition form.
// */
// public static final String TCACFIELDS = "tcafields";
//
// /**
// * When the ledger was created
// */
// public static final String CREATED = "created";
//
// /**
// * How wide the page may be
// */
// public static final String PAGEWIDTH = "pagewidth";
//
// /**
// * Get a setting
// *
// * @param key
// * the kay of the setting
// * @param value
// * default value if key does not exist
// * @return the value
// */
// public String get(String key, String value);
//
// /**
// * Enter a setting into the storage
// *
// * @param key
// * key name
// * @param value
// * value
// */
// public void set(String key, String value);
// }
// Path: src/main/java/de/onyxbits/tradetrax/components/MoneyValue.java
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import de.onyxbits.tradetrax.services.MoneyRepresentation;
import de.onyxbits.tradetrax.services.SettingsStore;
package de.onyxbits.tradetrax.components;
/**
* Convert a monetary value from database to user format and wrap it in a
* loss/profit CSS container before printing it.
*
* @author patrick
*
*/
public class MoneyValue {
/**
* Monetary value in database format.
*/
@Parameter(required = true)
private long amount;
/**
* Include the currency symbol when printing?
*/
@Parameter
private boolean addSymbol = true;
/**
* Cut off decimals to get a fixed length fraction?
*/
@Parameter
private boolean precise;
@Property
private String value;
@Property
private boolean loss;
@Inject
private SettingsStore settings;
@Inject | private MoneyRepresentation moneyRepresentation; |
onyxbits/TradeTrax | src/main/java/de/onyxbits/tradetrax/services/QaModule.java | // Path: src/main/java/de/onyxbits/tradetrax/main/AppConstants.java
// public class AppConstants {
//
// /**
// * The human readable version name without any prefixes (e.g. "v") or suffixes
// * (e.g. "-SNAPSHOT-DEV")
// */
// public static final String VERSION;
//
// /**
// * Init Parameter Name "Ledger": the parameter name by which to configure the
// * ledger path in web.xml
// */
// public static final String IPNLEDGERPATH = "ledger";
//
// static {
// String tmp = "UNKNOWN";
// try {
// // TODO: Ideally this would somehow come from pom.xml, but there doesn't
// // seem to be a good way to transport it from there that works for the JAR
// // as well as the WAR version.
// tmp = "1.6";
// }
// catch (Exception e) {
// }
// VERSION = tmp;
// }
// }
| import java.io.IOException;
import org.apache.tapestry5.*;
import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.ioc.OrderedConfiguration;
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.Local;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.RequestFilter;
import org.apache.tapestry5.services.RequestHandler;
import org.apache.tapestry5.services.Response;
import org.slf4j.Logger;
import de.onyxbits.tradetrax.main.AppConstants; | package de.onyxbits.tradetrax.services;
/**
* This module is automatically included as part of the Tapestry IoC Registry if <em>tapestry.execution-mode</em>
* includes <code>qa</code> ("quality assurance").
*/
public class QaModule
{
public static void bind(ServiceBinder binder)
{
// Bind any services needed by the QA team to produce their reports
// binder.bind(MyServiceMonitorInterface.class, MyServiceMonitorImpl.class);
}
public static void contributeApplicationDefaults(
MappedConfiguration<String, Object> configuration)
{
// The factory default is true but during the early stages of an application
// overriding to false is a good idea. In addition, this is often overridden
// on the command line as -Dtapestry.production-mode=false
configuration.add(SymbolConstants.PRODUCTION_MODE, false);
// The application version number is incorprated into URLs for some
// assets. Web browsers will cache assets because of the far future expires
// header. If existing assets are changed, the version number should also
// change, to force the browser to download new versions. | // Path: src/main/java/de/onyxbits/tradetrax/main/AppConstants.java
// public class AppConstants {
//
// /**
// * The human readable version name without any prefixes (e.g. "v") or suffixes
// * (e.g. "-SNAPSHOT-DEV")
// */
// public static final String VERSION;
//
// /**
// * Init Parameter Name "Ledger": the parameter name by which to configure the
// * ledger path in web.xml
// */
// public static final String IPNLEDGERPATH = "ledger";
//
// static {
// String tmp = "UNKNOWN";
// try {
// // TODO: Ideally this would somehow come from pom.xml, but there doesn't
// // seem to be a good way to transport it from there that works for the JAR
// // as well as the WAR version.
// tmp = "1.6";
// }
// catch (Exception e) {
// }
// VERSION = tmp;
// }
// }
// Path: src/main/java/de/onyxbits/tradetrax/services/QaModule.java
import java.io.IOException;
import org.apache.tapestry5.*;
import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.ioc.OrderedConfiguration;
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.Local;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.RequestFilter;
import org.apache.tapestry5.services.RequestHandler;
import org.apache.tapestry5.services.Response;
import org.slf4j.Logger;
import de.onyxbits.tradetrax.main.AppConstants;
package de.onyxbits.tradetrax.services;
/**
* This module is automatically included as part of the Tapestry IoC Registry if <em>tapestry.execution-mode</em>
* includes <code>qa</code> ("quality assurance").
*/
public class QaModule
{
public static void bind(ServiceBinder binder)
{
// Bind any services needed by the QA team to produce their reports
// binder.bind(MyServiceMonitorInterface.class, MyServiceMonitorImpl.class);
}
public static void contributeApplicationDefaults(
MappedConfiguration<String, Object> configuration)
{
// The factory default is true but during the early stages of an application
// overriding to false is a good idea. In addition, this is often overridden
// on the command line as -Dtapestry.production-mode=false
configuration.add(SymbolConstants.PRODUCTION_MODE, false);
// The application version number is incorprated into URLs for some
// assets. Web browsers will cache assets because of the far future expires
// header. If existing assets are changed, the version number should also
// change, to force the browser to download new versions. | configuration.add(SymbolConstants.APPLICATION_VERSION, "v"+AppConstants.VERSION+"-SNAPSHOT-QA"); |
onyxbits/TradeTrax | src/main/java/de/onyxbits/tradetrax/main/TradeTraxFilter.java | // Path: src/main/java/de/onyxbits/tradetrax/services/SettingsStore.java
// public interface SettingsStore {
//
// /**
// * The (visual) string that represents the currency of the ledger.
// */
// public static final String CURRENCYSYMBOL = "currencysymbol";
//
// /**
// * How many digits to display by default.
// */
// public static final String DECIMALS = "decimals";
//
// /**
// * Human readable name of the ledger
// */
// public static final String LEDGERTITLE = "ledgertitle";
//
// /**
// * Whether or not to show the instructionsblock in the sidebar.
// */
// public static final String HIDEINSTRUCTIONS = "hideinstructions";
//
// /**
// * Whether or not to show the calculator in the sidebar
// */
// public static final String SHOWCALCULATOR = "showcalculator";
//
// /**
// * Columns to show for the tradecenter ledger.
// */
// public static final String TCLCOLUMNS = "tclcolumns";
//
// /**
// * Fields to show on the tradecenter acquisition form.
// */
// public static final String TCACFIELDS = "tcafields";
//
// /**
// * When the ledger was created
// */
// public static final String CREATED = "created";
//
// /**
// * How wide the page may be
// */
// public static final String PAGEWIDTH = "pagewidth";
//
// /**
// * Get a setting
// *
// * @param key
// * the kay of the setting
// * @param value
// * default value if key does not exist
// * @return the value
// */
// public String get(String key, String value);
//
// /**
// * Enter a setting into the storage
// *
// * @param key
// * key name
// * @param value
// * value
// */
// public void set(String key, String value);
// }
| import java.sql.Timestamp;
import javax.servlet.ServletException;
import org.apache.tapestry5.TapestryFilter;
import org.apache.tapestry5.ioc.Registry;
import de.onyxbits.tradetrax.services.SettingsStore; | package de.onyxbits.tradetrax.main;
/**
* Servlet Bootup class
* @author patrick
*
*/
public class TradeTraxFilter extends TapestryFilter {
protected void init(Registry registry) throws ServletException {
| // Path: src/main/java/de/onyxbits/tradetrax/services/SettingsStore.java
// public interface SettingsStore {
//
// /**
// * The (visual) string that represents the currency of the ledger.
// */
// public static final String CURRENCYSYMBOL = "currencysymbol";
//
// /**
// * How many digits to display by default.
// */
// public static final String DECIMALS = "decimals";
//
// /**
// * Human readable name of the ledger
// */
// public static final String LEDGERTITLE = "ledgertitle";
//
// /**
// * Whether or not to show the instructionsblock in the sidebar.
// */
// public static final String HIDEINSTRUCTIONS = "hideinstructions";
//
// /**
// * Whether or not to show the calculator in the sidebar
// */
// public static final String SHOWCALCULATOR = "showcalculator";
//
// /**
// * Columns to show for the tradecenter ledger.
// */
// public static final String TCLCOLUMNS = "tclcolumns";
//
// /**
// * Fields to show on the tradecenter acquisition form.
// */
// public static final String TCACFIELDS = "tcafields";
//
// /**
// * When the ledger was created
// */
// public static final String CREATED = "created";
//
// /**
// * How wide the page may be
// */
// public static final String PAGEWIDTH = "pagewidth";
//
// /**
// * Get a setting
// *
// * @param key
// * the kay of the setting
// * @param value
// * default value if key does not exist
// * @return the value
// */
// public String get(String key, String value);
//
// /**
// * Enter a setting into the storage
// *
// * @param key
// * key name
// * @param value
// * value
// */
// public void set(String key, String value);
// }
// Path: src/main/java/de/onyxbits/tradetrax/main/TradeTraxFilter.java
import java.sql.Timestamp;
import javax.servlet.ServletException;
import org.apache.tapestry5.TapestryFilter;
import org.apache.tapestry5.ioc.Registry;
import de.onyxbits.tradetrax.services.SettingsStore;
package de.onyxbits.tradetrax.main;
/**
* Servlet Bootup class
* @author patrick
*
*/
public class TradeTraxFilter extends TapestryFilter {
protected void init(Registry registry) throws ServletException {
| SettingsStore ss = registry.getService(SettingsStore.class); |
wrey75/WaveCleaner | src/main/java/com/oxande/xmlswing/AttributesController.java | // Path: src/main/java/com/oxande/xmlswing/jcode/JavaMethod.java
// public class JavaMethod extends JavaBlock {
// // JavaBlock contents = new JavaBlock();
// JavaComments comments = new JavaComments();
// String name;
// JavaType returnType = new JavaType( "void" );
//
// /**
// * @return the returnType
// */
// public JavaType getReturnType() {
// return returnType;
// }
//
// /**
// * @param returnType the returnType to set
// */
// public void setReturnType(JavaType returnType) {
// this.returnType = returnType;
// }
//
// List<JavaParam> params = new ArrayList<JavaParam>();
// /**
// * @return the params
// */
// public JavaParam[] getParams() {
// return params.toArray(new JavaParam[0]);
// }
//
// public JavaComments getComments(){
// return this.comments;
// }
//
// public void setComments( JavaComments comments ){
// this.comments = comments;
// }
//
// public void setComments( String comments ){
// this.comments = new JavaComments(comments);
// }
//
// /**
// * @param params the params to set
// */
// public void setParams(JavaParam ... params) {
// this.params = Arrays.asList( params );
// }
//
//
// public JavaMethod(){
// }
//
// public JavaMethod( String name ){
// this();
// this.name = name;
// }
//
// public JavaMethod( String name, JavaParam ... params ){
// this(name);
// setParams(params);
// }
//
//
//
// // public void addCode( JavaCode code ){
// // contents.addCode(code);
// // }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
//
// @Override
// protected void writeCode(Writer writer, int tabs) throws IOException {
// String tab = getTabulations(tabs);
// if( comments != null) comments.writeCode(writer, tabs);
// writer.write( tab + returnType + " " + getName() + "(" );
// boolean firstParam = true;
// for( JavaParam param : params ){
// if( !firstParam ){
// writer.write(", ");
// }
// writer.write( param.toString() );
// firstParam = false;
// }
// writer.write( ")" + CRLF );
// super.writeCode(writer, tabs);
// }
//
// /**
// * Add a line comment in the method. The
// * comment starts with "//" and it is added
// * at the end of the current code.
// *
// * @param comment the comment line to add.
// * @see #setComments(JavaComments) to set
// * the comments of the method.
// */
// public void addLineComment( String comment ){
// JavaComments cmt = new JavaComments();
// cmt.setJavaDoc(false);
// cmt.add(comment);
// addCode(cmt);
// }
//
// }
| import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.w3c.dom.Element;
import com.oxande.xmlswing.jcode.JavaMethod;
| package com.oxande.xmlswing;
public class AttributesController {
List<AttributeDefinition> list = new ArrayList<AttributeDefinition>();
AttributesController parent = null;
public AttributesController( AttributesController parent, AttributeDefinition[] arr ){
this.parent = parent;
this.list.addAll( Arrays.asList(arr) );
}
public AttributesController( AttributeDefinition[] arr ){
this(null,arr);
}
/**
* @return the parent
*/
public AttributesController getParent() {
return parent;
}
/**
* @param parent the parent to set
*/
public void setParent(AttributesController parent) {
this.parent = parent;
}
| // Path: src/main/java/com/oxande/xmlswing/jcode/JavaMethod.java
// public class JavaMethod extends JavaBlock {
// // JavaBlock contents = new JavaBlock();
// JavaComments comments = new JavaComments();
// String name;
// JavaType returnType = new JavaType( "void" );
//
// /**
// * @return the returnType
// */
// public JavaType getReturnType() {
// return returnType;
// }
//
// /**
// * @param returnType the returnType to set
// */
// public void setReturnType(JavaType returnType) {
// this.returnType = returnType;
// }
//
// List<JavaParam> params = new ArrayList<JavaParam>();
// /**
// * @return the params
// */
// public JavaParam[] getParams() {
// return params.toArray(new JavaParam[0]);
// }
//
// public JavaComments getComments(){
// return this.comments;
// }
//
// public void setComments( JavaComments comments ){
// this.comments = comments;
// }
//
// public void setComments( String comments ){
// this.comments = new JavaComments(comments);
// }
//
// /**
// * @param params the params to set
// */
// public void setParams(JavaParam ... params) {
// this.params = Arrays.asList( params );
// }
//
//
// public JavaMethod(){
// }
//
// public JavaMethod( String name ){
// this();
// this.name = name;
// }
//
// public JavaMethod( String name, JavaParam ... params ){
// this(name);
// setParams(params);
// }
//
//
//
// // public void addCode( JavaCode code ){
// // contents.addCode(code);
// // }
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// }
//
//
// @Override
// protected void writeCode(Writer writer, int tabs) throws IOException {
// String tab = getTabulations(tabs);
// if( comments != null) comments.writeCode(writer, tabs);
// writer.write( tab + returnType + " " + getName() + "(" );
// boolean firstParam = true;
// for( JavaParam param : params ){
// if( !firstParam ){
// writer.write(", ");
// }
// writer.write( param.toString() );
// firstParam = false;
// }
// writer.write( ")" + CRLF );
// super.writeCode(writer, tabs);
// }
//
// /**
// * Add a line comment in the method. The
// * comment starts with "//" and it is added
// * at the end of the current code.
// *
// * @param comment the comment line to add.
// * @see #setComments(JavaComments) to set
// * the comments of the method.
// */
// public void addLineComment( String comment ){
// JavaComments cmt = new JavaComments();
// cmt.setJavaDoc(false);
// cmt.add(comment);
// addCode(cmt);
// }
//
// }
// Path: src/main/java/com/oxande/xmlswing/AttributesController.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.w3c.dom.Element;
import com.oxande.xmlswing.jcode.JavaMethod;
package com.oxande.xmlswing;
public class AttributesController {
List<AttributeDefinition> list = new ArrayList<AttributeDefinition>();
AttributesController parent = null;
public AttributesController( AttributesController parent, AttributeDefinition[] arr ){
this.parent = parent;
this.list.addAll( Arrays.asList(arr) );
}
public AttributesController( AttributeDefinition[] arr ){
this(null,arr);
}
/**
* @return the parent
*/
public AttributesController getParent() {
return parent;
}
/**
* @param parent the parent to set
*/
public void setParent(AttributesController parent) {
this.parent = parent;
}
| public void addToMethod( JavaMethod jmethod, Element e, String varName ) throws UnexpectedTag{
|
wrey75/WaveCleaner | src/main/java/com/oxande/wavecleaner/ui/VUMeterComponent.java | // Path: src/main/java/com/oxande/wavecleaner/util/logging/LogFactory.java
// public class LogFactory {
// public static final Logger getLog(final Class<?> clazz) {
// Logger log = LogManager.getLogger(clazz);
// return log;
// }
// }
| import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JComponent;
import org.apache.logging.log4j.Logger;
import com.oxande.wavecleaner.util.logging.LogFactory;
| package com.oxande.wavecleaner.ui;
/**
* A component for displaying information about the RMS and peak levels. The
* VUMeter stores its status which is not the way to do, but this should be
* sufficient.
*
* You have to set the sample rate and push each sample. The analysis is as
* fast as possible. Mainly used by the preamplifier with the output including
* the gain (which can explain some saturation). Only peaks level are displayed.
* By construction, the level is calculated for the last 20 milliseconds. When the
* level is higher than the peak, the peak is stored for 2 seconds. Thoses values could
* be changed (see code for reference).
*
* @author wrey75
*
*/
@SuppressWarnings("serial")
public class VUMeterComponent extends JComponent {
| // Path: src/main/java/com/oxande/wavecleaner/util/logging/LogFactory.java
// public class LogFactory {
// public static final Logger getLog(final Class<?> clazz) {
// Logger log = LogManager.getLogger(clazz);
// return log;
// }
// }
// Path: src/main/java/com/oxande/wavecleaner/ui/VUMeterComponent.java
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JComponent;
import org.apache.logging.log4j.Logger;
import com.oxande.wavecleaner.util.logging.LogFactory;
package com.oxande.wavecleaner.ui;
/**
* A component for displaying information about the RMS and peak levels. The
* VUMeter stores its status which is not the way to do, but this should be
* sufficient.
*
* You have to set the sample rate and push each sample. The analysis is as
* fast as possible. Mainly used by the preamplifier with the output including
* the gain (which can explain some saturation). Only peaks level are displayed.
* By construction, the level is calculated for the last 20 milliseconds. When the
* level is higher than the peak, the peak is stored for 2 seconds. Thoses values could
* be changed (see code for reference).
*
* @author wrey75
*
*/
@SuppressWarnings("serial")
public class VUMeterComponent extends JComponent {
| private static Logger LOG = LogFactory.getLog(VUMeterComponent.class);
|
wrey75/WaveCleaner | src/main/java/com/oxande/wavecleaner/AudioProject.java | // Path: src/main/java/com/oxande/wavecleaner/util/ListenerManager.java
// public class ListenerManager<T> {
// private static Logger LOG = LogFactory.getLog(ListenerManager.class);
// private List<ListenerInfo<T>> listenerInfos = new ArrayList<>();
//
// /**
// * We keep information on the listener
// *
// *
// */
// private static class ListenerInfo<T> {
// AtomicInteger mutex = new AtomicInteger(0);
// T listener;
// int skipped = 0;
// int calls = 0;
//
// public ListenerInfo(T listener){
// this.listener = listener;
// }
//
// /**
// * We invoke the listener but only if a call is not already
// * in the queue. This avoid multiple calls. Note only the
// * first call is, in this case, used. The other calls are
// * dimissed.
// *
// * @param val the value for invocation.
// */
// public void invoke(Consumer<T> fnct){
// calls++;
// if( mutex.getAndIncrement() < 1 ){
// // We can run the code in the SWING thread...
// // the value is now "1" (means: waiting)
// // we boost once
// mutex.incrementAndGet();
// SwingUtilities.invokeLater( () -> {
// // LOG.debug("invoked.");
// fnct.accept(this.listener);
// mutex.decrementAndGet();
// });
// }
// else {
// // for debugging purposes
// skipped++;
// if( skipped % 1000 == 0 ){
// int ratio = (int)(100.0 * (calls - skipped) / calls);
// LOG.debug("Listener {} called {} times ({}%).", this.listener.getClass().getSimpleName(), (calls - skipped), ratio);
// }
// }
// mutex.decrementAndGet();
// }
//
// T getListener(){
// return listener;
// }
// }
//
// /**
// * Very basic constructor
// */
// public ListenerManager() {
// }
//
//
// /**
// * Notify all the listeners. We use a {@link Function}
// * to keep the code simple. Note the listener
// *
// */
// public void publishOnce(Consumer<T> function){
// for(ListenerInfo<T> infos : this.listenerInfos){
// infos.invoke(function);
// }
// }
//
// /**
// * Force to publish.
// *
// * @param function the code to call.
// */
// public void publish(final Consumer<T> function){
// for(ListenerInfo<T> infos : this.listenerInfos){
// SwingUtilities.invokeLater( () -> {
// function.accept(infos.getListener());
// });
// }
// }
//
// /**
// * Send directly on the current thread.
// *
// * @param function the code to call.
// */
// public void send(final Consumer<T> function){
// for(ListenerInfo<T> infos : this.listenerInfos){
// function.accept(infos.getListener());
// }
// }
//
// /**
// * Add a new listener for this manager. If the listener was already there,
// * it is replaced.
// *
// * @param listener the listener to add.
// */
// public void add(T listener ) {
// synchronized(this.listenerInfos){
// this.listenerInfos.remove(listener); // in case already there!
// ListenerInfo<T> infos = new ListenerInfo<T>(listener);
// this.listenerInfos.add(infos);
// }
// }
//
// /**
// * Remove the specified listener.
// *
// * @param listener
// */
// public void remove(T listener ) {
// synchronized(this.listenerInfos){
// this.listenerInfos.remove(listener);
// }
// }
//
// }
//
// Path: src/main/java/com/oxande/wavecleaner/util/NumberUtils.java
// public class NumberUtils {
// public static final int toInt(String value, int defaultValue){
// try {
// return Integer.parseInt(value);
// }
// catch(NumberFormatException ex ){
// return defaultValue;
// }
// }
// }
| import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import com.oxande.wavecleaner.util.ListenerManager;
import com.oxande.wavecleaner.util.NumberUtils;
| package com.oxande.wavecleaner;
/**
* A project is a simple class to store information about the project.
*
* @author wrey75
*
*/
public class AudioProject {
public static String DEFAULT_EXT = ".wclean";
private String name;
private boolean saved;
| // Path: src/main/java/com/oxande/wavecleaner/util/ListenerManager.java
// public class ListenerManager<T> {
// private static Logger LOG = LogFactory.getLog(ListenerManager.class);
// private List<ListenerInfo<T>> listenerInfos = new ArrayList<>();
//
// /**
// * We keep information on the listener
// *
// *
// */
// private static class ListenerInfo<T> {
// AtomicInteger mutex = new AtomicInteger(0);
// T listener;
// int skipped = 0;
// int calls = 0;
//
// public ListenerInfo(T listener){
// this.listener = listener;
// }
//
// /**
// * We invoke the listener but only if a call is not already
// * in the queue. This avoid multiple calls. Note only the
// * first call is, in this case, used. The other calls are
// * dimissed.
// *
// * @param val the value for invocation.
// */
// public void invoke(Consumer<T> fnct){
// calls++;
// if( mutex.getAndIncrement() < 1 ){
// // We can run the code in the SWING thread...
// // the value is now "1" (means: waiting)
// // we boost once
// mutex.incrementAndGet();
// SwingUtilities.invokeLater( () -> {
// // LOG.debug("invoked.");
// fnct.accept(this.listener);
// mutex.decrementAndGet();
// });
// }
// else {
// // for debugging purposes
// skipped++;
// if( skipped % 1000 == 0 ){
// int ratio = (int)(100.0 * (calls - skipped) / calls);
// LOG.debug("Listener {} called {} times ({}%).", this.listener.getClass().getSimpleName(), (calls - skipped), ratio);
// }
// }
// mutex.decrementAndGet();
// }
//
// T getListener(){
// return listener;
// }
// }
//
// /**
// * Very basic constructor
// */
// public ListenerManager() {
// }
//
//
// /**
// * Notify all the listeners. We use a {@link Function}
// * to keep the code simple. Note the listener
// *
// */
// public void publishOnce(Consumer<T> function){
// for(ListenerInfo<T> infos : this.listenerInfos){
// infos.invoke(function);
// }
// }
//
// /**
// * Force to publish.
// *
// * @param function the code to call.
// */
// public void publish(final Consumer<T> function){
// for(ListenerInfo<T> infos : this.listenerInfos){
// SwingUtilities.invokeLater( () -> {
// function.accept(infos.getListener());
// });
// }
// }
//
// /**
// * Send directly on the current thread.
// *
// * @param function the code to call.
// */
// public void send(final Consumer<T> function){
// for(ListenerInfo<T> infos : this.listenerInfos){
// function.accept(infos.getListener());
// }
// }
//
// /**
// * Add a new listener for this manager. If the listener was already there,
// * it is replaced.
// *
// * @param listener the listener to add.
// */
// public void add(T listener ) {
// synchronized(this.listenerInfos){
// this.listenerInfos.remove(listener); // in case already there!
// ListenerInfo<T> infos = new ListenerInfo<T>(listener);
// this.listenerInfos.add(infos);
// }
// }
//
// /**
// * Remove the specified listener.
// *
// * @param listener
// */
// public void remove(T listener ) {
// synchronized(this.listenerInfos){
// this.listenerInfos.remove(listener);
// }
// }
//
// }
//
// Path: src/main/java/com/oxande/wavecleaner/util/NumberUtils.java
// public class NumberUtils {
// public static final int toInt(String value, int defaultValue){
// try {
// return Integer.parseInt(value);
// }
// catch(NumberFormatException ex ){
// return defaultValue;
// }
// }
// }
// Path: src/main/java/com/oxande/wavecleaner/AudioProject.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import com.oxande.wavecleaner.util.ListenerManager;
import com.oxande.wavecleaner.util.NumberUtils;
package com.oxande.wavecleaner;
/**
* A project is a simple class to store information about the project.
*
* @author wrey75
*
*/
public class AudioProject {
public static String DEFAULT_EXT = ".wclean";
private String name;
private boolean saved;
| private ListenerManager<ProjectListener> listenerManager = new ListenerManager<>();
|
wrey75/WaveCleaner | src/main/java/com/oxande/wavecleaner/AudioProject.java | // Path: src/main/java/com/oxande/wavecleaner/util/ListenerManager.java
// public class ListenerManager<T> {
// private static Logger LOG = LogFactory.getLog(ListenerManager.class);
// private List<ListenerInfo<T>> listenerInfos = new ArrayList<>();
//
// /**
// * We keep information on the listener
// *
// *
// */
// private static class ListenerInfo<T> {
// AtomicInteger mutex = new AtomicInteger(0);
// T listener;
// int skipped = 0;
// int calls = 0;
//
// public ListenerInfo(T listener){
// this.listener = listener;
// }
//
// /**
// * We invoke the listener but only if a call is not already
// * in the queue. This avoid multiple calls. Note only the
// * first call is, in this case, used. The other calls are
// * dimissed.
// *
// * @param val the value for invocation.
// */
// public void invoke(Consumer<T> fnct){
// calls++;
// if( mutex.getAndIncrement() < 1 ){
// // We can run the code in the SWING thread...
// // the value is now "1" (means: waiting)
// // we boost once
// mutex.incrementAndGet();
// SwingUtilities.invokeLater( () -> {
// // LOG.debug("invoked.");
// fnct.accept(this.listener);
// mutex.decrementAndGet();
// });
// }
// else {
// // for debugging purposes
// skipped++;
// if( skipped % 1000 == 0 ){
// int ratio = (int)(100.0 * (calls - skipped) / calls);
// LOG.debug("Listener {} called {} times ({}%).", this.listener.getClass().getSimpleName(), (calls - skipped), ratio);
// }
// }
// mutex.decrementAndGet();
// }
//
// T getListener(){
// return listener;
// }
// }
//
// /**
// * Very basic constructor
// */
// public ListenerManager() {
// }
//
//
// /**
// * Notify all the listeners. We use a {@link Function}
// * to keep the code simple. Note the listener
// *
// */
// public void publishOnce(Consumer<T> function){
// for(ListenerInfo<T> infos : this.listenerInfos){
// infos.invoke(function);
// }
// }
//
// /**
// * Force to publish.
// *
// * @param function the code to call.
// */
// public void publish(final Consumer<T> function){
// for(ListenerInfo<T> infos : this.listenerInfos){
// SwingUtilities.invokeLater( () -> {
// function.accept(infos.getListener());
// });
// }
// }
//
// /**
// * Send directly on the current thread.
// *
// * @param function the code to call.
// */
// public void send(final Consumer<T> function){
// for(ListenerInfo<T> infos : this.listenerInfos){
// function.accept(infos.getListener());
// }
// }
//
// /**
// * Add a new listener for this manager. If the listener was already there,
// * it is replaced.
// *
// * @param listener the listener to add.
// */
// public void add(T listener ) {
// synchronized(this.listenerInfos){
// this.listenerInfos.remove(listener); // in case already there!
// ListenerInfo<T> infos = new ListenerInfo<T>(listener);
// this.listenerInfos.add(infos);
// }
// }
//
// /**
// * Remove the specified listener.
// *
// * @param listener
// */
// public void remove(T listener ) {
// synchronized(this.listenerInfos){
// this.listenerInfos.remove(listener);
// }
// }
//
// }
//
// Path: src/main/java/com/oxande/wavecleaner/util/NumberUtils.java
// public class NumberUtils {
// public static final int toInt(String value, int defaultValue){
// try {
// return Integer.parseInt(value);
// }
// catch(NumberFormatException ex ){
// return defaultValue;
// }
// }
// }
| import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import com.oxande.wavecleaner.util.ListenerManager;
import com.oxande.wavecleaner.util.NumberUtils;
| this.parts.add(source);
this.updated();
}
public void loadProject(String fileName) throws IOException {
InputStream input = new FileInputStream(fileName);
Properties config = new Properties();
config.load(input);
try {
int fileStructure = Integer.parseInt(config.getProperty("struct"));
switch(fileStructure){
case 1:
loadVersion1(config);
break;
}
throw new IOException("The audio project has been saved by a newer version. We can not load it.");
}
catch(NumberFormatException ex ){
throw new IOException("Not a valid audio project.");
}
}
/**
* Load the information stored in the configuration file.
*
* @param config the configuration file
*/
private void loadVersion1(Properties config){
this.parts.clear();
this.name = config.getProperty("name");
| // Path: src/main/java/com/oxande/wavecleaner/util/ListenerManager.java
// public class ListenerManager<T> {
// private static Logger LOG = LogFactory.getLog(ListenerManager.class);
// private List<ListenerInfo<T>> listenerInfos = new ArrayList<>();
//
// /**
// * We keep information on the listener
// *
// *
// */
// private static class ListenerInfo<T> {
// AtomicInteger mutex = new AtomicInteger(0);
// T listener;
// int skipped = 0;
// int calls = 0;
//
// public ListenerInfo(T listener){
// this.listener = listener;
// }
//
// /**
// * We invoke the listener but only if a call is not already
// * in the queue. This avoid multiple calls. Note only the
// * first call is, in this case, used. The other calls are
// * dimissed.
// *
// * @param val the value for invocation.
// */
// public void invoke(Consumer<T> fnct){
// calls++;
// if( mutex.getAndIncrement() < 1 ){
// // We can run the code in the SWING thread...
// // the value is now "1" (means: waiting)
// // we boost once
// mutex.incrementAndGet();
// SwingUtilities.invokeLater( () -> {
// // LOG.debug("invoked.");
// fnct.accept(this.listener);
// mutex.decrementAndGet();
// });
// }
// else {
// // for debugging purposes
// skipped++;
// if( skipped % 1000 == 0 ){
// int ratio = (int)(100.0 * (calls - skipped) / calls);
// LOG.debug("Listener {} called {} times ({}%).", this.listener.getClass().getSimpleName(), (calls - skipped), ratio);
// }
// }
// mutex.decrementAndGet();
// }
//
// T getListener(){
// return listener;
// }
// }
//
// /**
// * Very basic constructor
// */
// public ListenerManager() {
// }
//
//
// /**
// * Notify all the listeners. We use a {@link Function}
// * to keep the code simple. Note the listener
// *
// */
// public void publishOnce(Consumer<T> function){
// for(ListenerInfo<T> infos : this.listenerInfos){
// infos.invoke(function);
// }
// }
//
// /**
// * Force to publish.
// *
// * @param function the code to call.
// */
// public void publish(final Consumer<T> function){
// for(ListenerInfo<T> infos : this.listenerInfos){
// SwingUtilities.invokeLater( () -> {
// function.accept(infos.getListener());
// });
// }
// }
//
// /**
// * Send directly on the current thread.
// *
// * @param function the code to call.
// */
// public void send(final Consumer<T> function){
// for(ListenerInfo<T> infos : this.listenerInfos){
// function.accept(infos.getListener());
// }
// }
//
// /**
// * Add a new listener for this manager. If the listener was already there,
// * it is replaced.
// *
// * @param listener the listener to add.
// */
// public void add(T listener ) {
// synchronized(this.listenerInfos){
// this.listenerInfos.remove(listener); // in case already there!
// ListenerInfo<T> infos = new ListenerInfo<T>(listener);
// this.listenerInfos.add(infos);
// }
// }
//
// /**
// * Remove the specified listener.
// *
// * @param listener
// */
// public void remove(T listener ) {
// synchronized(this.listenerInfos){
// this.listenerInfos.remove(listener);
// }
// }
//
// }
//
// Path: src/main/java/com/oxande/wavecleaner/util/NumberUtils.java
// public class NumberUtils {
// public static final int toInt(String value, int defaultValue){
// try {
// return Integer.parseInt(value);
// }
// catch(NumberFormatException ex ){
// return defaultValue;
// }
// }
// }
// Path: src/main/java/com/oxande/wavecleaner/AudioProject.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import com.oxande.wavecleaner.util.ListenerManager;
import com.oxande.wavecleaner.util.NumberUtils;
this.parts.add(source);
this.updated();
}
public void loadProject(String fileName) throws IOException {
InputStream input = new FileInputStream(fileName);
Properties config = new Properties();
config.load(input);
try {
int fileStructure = Integer.parseInt(config.getProperty("struct"));
switch(fileStructure){
case 1:
loadVersion1(config);
break;
}
throw new IOException("The audio project has been saved by a newer version. We can not load it.");
}
catch(NumberFormatException ex ){
throw new IOException("Not a valid audio project.");
}
}
/**
* Load the information stored in the configuration file.
*
* @param config the configuration file
*/
private void loadVersion1(Properties config){
this.parts.clear();
this.name = config.getProperty("name");
| int sides = NumberUtils.toInt(config.getProperty("sides"), 0);
|
wrey75/WaveCleaner | src/main/java/com/oxande/wavecleaner/ui/RealtimeWaveComponent.java | // Path: src/main/java/com/oxande/wavecleaner/util/logging/LogFactory.java
// public class LogFactory {
// public static final Logger getLog(final Class<?> clazz) {
// Logger log = LogManager.getLogger(clazz);
// return log;
// }
// }
| import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import org.apache.logging.log4j.Logger;
import com.oxande.wavecleaner.util.logging.LogFactory; | package com.oxande.wavecleaner.ui;
/**
* This is to display a "real time" waveform. Mainly used for recording purposes.
*
* @author wrey75
*
*/
@SuppressWarnings("serial")
public class RealtimeWaveComponent extends JComponent { | // Path: src/main/java/com/oxande/wavecleaner/util/logging/LogFactory.java
// public class LogFactory {
// public static final Logger getLog(final Class<?> clazz) {
// Logger log = LogManager.getLogger(clazz);
// return log;
// }
// }
// Path: src/main/java/com/oxande/wavecleaner/ui/RealtimeWaveComponent.java
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import org.apache.logging.log4j.Logger;
import com.oxande.wavecleaner.util.logging.LogFactory;
package com.oxande.wavecleaner.ui;
/**
* This is to display a "real time" waveform. Mainly used for recording purposes.
*
* @author wrey75
*
*/
@SuppressWarnings("serial")
public class RealtimeWaveComponent extends JComponent { | private static Logger LOG = LogFactory.getLog(RealtimeWaveComponent.class); |
wrey75/WaveCleaner | src/main/java/com/oxande/swing/JFlashLabel.java | // Path: src/main/java/com/oxande/wavecleaner/util/logging/LogFactory.java
// public class LogFactory {
// public static final Logger getLog(final Class<?> clazz) {
// Logger log = LogManager.getLogger(clazz);
// return log;
// }
// }
| import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import org.apache.logging.log4j.Logger;
import com.oxande.wavecleaner.util.logging.LogFactory; | package com.oxande.swing;
@SuppressWarnings("serial")
public class JFlashLabel extends JLabel implements ActionListener { | // Path: src/main/java/com/oxande/wavecleaner/util/logging/LogFactory.java
// public class LogFactory {
// public static final Logger getLog(final Class<?> clazz) {
// Logger log = LogManager.getLogger(clazz);
// return log;
// }
// }
// Path: src/main/java/com/oxande/swing/JFlashLabel.java
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import org.apache.logging.log4j.Logger;
import com.oxande.wavecleaner.util.logging.LogFactory;
package com.oxande.swing;
@SuppressWarnings("serial")
public class JFlashLabel extends JLabel implements ActionListener { | private static Logger LOG = LogFactory.getLog(JFlashLabel.class); |
wrey75/WaveCleaner | src/main/java/com/oxande/wavecleaner/RMSSample.java | // Path: src/main/java/com/oxande/wavecleaner/util/Assert.java
// final public class Assert {
// public final static void isTrue( boolean value ){
// if(!value){
// throw new IllegalArgumentException("Expected value is false.");
// }
// }
//
// public final static void notNull( Object o ){
// if(o == null){
// throw new IllegalArgumentException("Expected value is null.");
// }
// }
//
// public final static void isEventDispatchThread(){
// if(!SwingUtilities.isEventDispatchThread()){
// throw new IllegalStateException("You must run this in the AWT Thread.");
// }
// }
//
// public final static void equals( Object a, Object b){
// if(!Objects.equals(a, b)){
// throw new IllegalArgumentException("Expected values must be equal.");
// }
// }
// }
| import com.oxande.wavecleaner.util.Assert; | /*****************************************************************************
* Gnome Wave Cleaner Version 0.19
* Copyright (C) 2001 Jeffrey J. Welty
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*******************************************************************************/
package com.oxande.wavecleaner;
/**
* A basic sample which contains the level and the peak for left and right.
*
* @author wrey
*
*/
public class RMSSample {
public float levelL;
public float levelR;
public float peakL;
public float peakR;
public RMSSample(float levL, float levR, float peakL, float peakR) {
this.peakR = peakR;
this.peakL = peakL;
this.levelR = levR;
this.levelL = levL;
}
/**
* Create a wave sample from samples.
*
* @param sampL
* the left samples
* @param sampR
* the right samples
*/
public static RMSSample create(float[] sampL, float[] sampR) { | // Path: src/main/java/com/oxande/wavecleaner/util/Assert.java
// final public class Assert {
// public final static void isTrue( boolean value ){
// if(!value){
// throw new IllegalArgumentException("Expected value is false.");
// }
// }
//
// public final static void notNull( Object o ){
// if(o == null){
// throw new IllegalArgumentException("Expected value is null.");
// }
// }
//
// public final static void isEventDispatchThread(){
// if(!SwingUtilities.isEventDispatchThread()){
// throw new IllegalStateException("You must run this in the AWT Thread.");
// }
// }
//
// public final static void equals( Object a, Object b){
// if(!Objects.equals(a, b)){
// throw new IllegalArgumentException("Expected values must be equal.");
// }
// }
// }
// Path: src/main/java/com/oxande/wavecleaner/RMSSample.java
import com.oxande.wavecleaner.util.Assert;
/*****************************************************************************
* Gnome Wave Cleaner Version 0.19
* Copyright (C) 2001 Jeffrey J. Welty
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*******************************************************************************/
package com.oxande.wavecleaner;
/**
* A basic sample which contains the level and the peak for left and right.
*
* @author wrey
*
*/
public class RMSSample {
public float levelL;
public float levelR;
public float peakL;
public float peakR;
public RMSSample(float levL, float levR, float peakL, float peakR) {
this.peakR = peakR;
this.peakL = peakL;
this.levelR = levR;
this.levelL = levL;
}
/**
* Create a wave sample from samples.
*
* @param sampL
* the left samples
* @param sampR
* the right samples
*/
public static RMSSample create(float[] sampL, float[] sampR) { | Assert.isTrue(sampL != null); |
mengdd/HelloActivityAndFragment | app/src/main/java/com/example/ddmeng/helloactivityandfragment/state/StateRestoreDemoActivity.java | // Path: app/src/main/java/com/example/ddmeng/helloactivityandfragment/activity/BasicActivityA.java
// public class BasicActivityA extends Activity {
// private static final String LOG_TAG = "Basic Activity";
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// Log.i(LOG_TAG, this.getClass().getSimpleName() + " onCreate(): " + savedInstanceState);
// super.onCreate(savedInstanceState);
// setContentView(R.layout.basic_activity_a);
//
// ButterKnife.bind(this);
// }
//
// @OnClick(R.id.basic_turn_to_b_button)
// void turnToBActivity() {
// Intent intent = new Intent();
// intent.setClass(BasicActivityA.this, BasicActivityB.class);
// startActivity(intent);
// }
//
// @OnClick(R.id.basic_finish_a_button)
// void finishA() {
// finish();
// }
//
// @Override
// protected void onRestart() {
// Log.i(LOG_TAG, this.getClass().getSimpleName() + " onRestart()");
// super.onRestart();
// }
//
// @Override
// protected void onStart() {
// Log.i(LOG_TAG, this.getClass().getSimpleName() + " onStart()");
// super.onStart();
// }
//
// @Override
// public void onStateNotSaved() {
// super.onStateNotSaved();
// Log.d(LOG_TAG, this.getClass().getSimpleName() + " onStateNotSaved");
// }
//
// @Override
// protected void onRestoreInstanceState(Bundle savedInstanceState) {
// Log.d(LOG_TAG, this.getClass().getSimpleName() + " onRestoreInstanceState(): " + savedInstanceState);
// super.onRestoreInstanceState(savedInstanceState);
// }
//
// @Override
// protected void onResume() {
// Log.i(LOG_TAG, this.getClass().getSimpleName() + " onResume()");
// super.onResume();
// }
//
// @Override
// protected void onPause() {
// Log.i(LOG_TAG, this.getClass().getSimpleName() + " onPause()");
// super.onPause();
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// Log.d(LOG_TAG, this.getClass().getSimpleName() + " onSaveInstanceState(): " + outState);
// }
//
// @Override
// protected void onStop() {
// Log.i(LOG_TAG, this.getClass().getSimpleName() + " onStop()");
// super.onStop();
// }
//
// @Override
// protected void onDestroy() {
// Log.i(LOG_TAG, this.getClass().getSimpleName() + " onDestroy()");
// super.onDestroy();
// }
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.util.SparseArray;
import com.example.ddmeng.helloactivityandfragment.R;
import com.example.ddmeng.helloactivityandfragment.activity.BasicActivityA;
import butterknife.ButterKnife;
import butterknife.OnClick;
import icepick.Icepick;
import icepick.State; | super.onRestoreInstanceState(savedInstanceState);
}
@Override
protected void onResume() {
Log.i(TAG, "onResume()");
super.onResume();
}
@Override
protected void onPause() {
Log.i(TAG, "onPause()");
super.onPause();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Log.e(TAG, "onSaveInstanceState(): " + outState);
Icepick.saveInstanceState(this, outState);
}
@Override
protected void onStop() {
Log.i(TAG, "onStop()");
super.onStop();
}
@OnClick(R.id.button_open_another_activity)
void onOpenAnotherActivity() { | // Path: app/src/main/java/com/example/ddmeng/helloactivityandfragment/activity/BasicActivityA.java
// public class BasicActivityA extends Activity {
// private static final String LOG_TAG = "Basic Activity";
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// Log.i(LOG_TAG, this.getClass().getSimpleName() + " onCreate(): " + savedInstanceState);
// super.onCreate(savedInstanceState);
// setContentView(R.layout.basic_activity_a);
//
// ButterKnife.bind(this);
// }
//
// @OnClick(R.id.basic_turn_to_b_button)
// void turnToBActivity() {
// Intent intent = new Intent();
// intent.setClass(BasicActivityA.this, BasicActivityB.class);
// startActivity(intent);
// }
//
// @OnClick(R.id.basic_finish_a_button)
// void finishA() {
// finish();
// }
//
// @Override
// protected void onRestart() {
// Log.i(LOG_TAG, this.getClass().getSimpleName() + " onRestart()");
// super.onRestart();
// }
//
// @Override
// protected void onStart() {
// Log.i(LOG_TAG, this.getClass().getSimpleName() + " onStart()");
// super.onStart();
// }
//
// @Override
// public void onStateNotSaved() {
// super.onStateNotSaved();
// Log.d(LOG_TAG, this.getClass().getSimpleName() + " onStateNotSaved");
// }
//
// @Override
// protected void onRestoreInstanceState(Bundle savedInstanceState) {
// Log.d(LOG_TAG, this.getClass().getSimpleName() + " onRestoreInstanceState(): " + savedInstanceState);
// super.onRestoreInstanceState(savedInstanceState);
// }
//
// @Override
// protected void onResume() {
// Log.i(LOG_TAG, this.getClass().getSimpleName() + " onResume()");
// super.onResume();
// }
//
// @Override
// protected void onPause() {
// Log.i(LOG_TAG, this.getClass().getSimpleName() + " onPause()");
// super.onPause();
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// Log.d(LOG_TAG, this.getClass().getSimpleName() + " onSaveInstanceState(): " + outState);
// }
//
// @Override
// protected void onStop() {
// Log.i(LOG_TAG, this.getClass().getSimpleName() + " onStop()");
// super.onStop();
// }
//
// @Override
// protected void onDestroy() {
// Log.i(LOG_TAG, this.getClass().getSimpleName() + " onDestroy()");
// super.onDestroy();
// }
// }
// Path: app/src/main/java/com/example/ddmeng/helloactivityandfragment/state/StateRestoreDemoActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.util.SparseArray;
import com.example.ddmeng.helloactivityandfragment.R;
import com.example.ddmeng.helloactivityandfragment.activity.BasicActivityA;
import butterknife.ButterKnife;
import butterknife.OnClick;
import icepick.Icepick;
import icepick.State;
super.onRestoreInstanceState(savedInstanceState);
}
@Override
protected void onResume() {
Log.i(TAG, "onResume()");
super.onResume();
}
@Override
protected void onPause() {
Log.i(TAG, "onPause()");
super.onPause();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Log.e(TAG, "onSaveInstanceState(): " + outState);
Icepick.saveInstanceState(this, outState);
}
@Override
protected void onStop() {
Log.i(TAG, "onStop()");
super.onStop();
}
@OnClick(R.id.button_open_another_activity)
void onOpenAnotherActivity() { | startActivity(new Intent(this, BasicActivityA.class)); |
mengdd/HelloActivityAndFragment | app/src/main/java/com/example/ddmeng/helloactivityandfragment/fragment/FragmentG.java | // Path: app/src/main/java/com/example/ddmeng/helloactivityandfragment/activity/StartForResultActivityTwo.java
// public class StartForResultActivityTwo extends AppCompatActivity {
// private static final String LOG_TAG = StartForResultActivityTwo.class.getSimpleName();
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// Log.i(LOG_TAG, "onCreate(): " + savedInstanceState);
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_start_for_result_activity_two);
//
// ButterKnife.bind(this);
// }
//
//
// @OnClick(R.id.set_result_ok)
// void onOkClick() {
// setResult(RESULT_OK);
// finish();
// }
//
// @OnClick(R.id.set_result_cancel)
// void onCancelClick() {
// setResult(RESULT_CANCELED);
// finish();
// }
//
//
// @Override
// protected void onRestart() {
// Log.i(LOG_TAG, "onRestart()");
// super.onRestart();
// }
//
// @Override
// protected void onStart() {
// Log.i(LOG_TAG, "onStart()");
// super.onStart();
// }
//
// @Override
// public void onStateNotSaved() {
// super.onStateNotSaved();
// Log.d(LOG_TAG, "onStateNotSaved");
// }
//
// @Override
// protected void onRestoreInstanceState(Bundle savedInstanceState) {
// Log.d(LOG_TAG, "onRestoreInstanceState(): " + savedInstanceState);
// super.onRestoreInstanceState(savedInstanceState);
// }
//
// @Override
// protected void onResume() {
// Log.i(LOG_TAG, "onResume()");
// super.onResume();
// }
//
// @Override
// protected void onPause() {
// Log.i(LOG_TAG, "onPause()");
// super.onPause();
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// Log.d(LOG_TAG, "onSaveInstanceState(): " + outState);
// }
//
// @Override
// protected void onStop() {
// Log.i(LOG_TAG, "onStop()");
// super.onStop();
// }
//
// @Override
// protected void onDestroy() {
// Log.i(LOG_TAG, "onDestroy()");
// super.onDestroy();
// }
// }
| import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.ddmeng.helloactivityandfragment.R;
import com.example.ddmeng.helloactivityandfragment.activity.StartForResultActivityTwo;
import butterknife.ButterKnife;
import butterknife.OnClick; | return inflater.inflate(R.layout.fragment_g, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
Log.i(LOG_TAG, "onViewCreated()");
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this, view);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
Log.i(LOG_TAG, "onActivityCreated()");
super.onActivityCreated(savedInstanceState);
}
@OnClick(R.id.add_child_fragment)
void addChildFragment() {
Fragment fragmentByTag = getChildFragmentManager().findFragmentByTag(FragmentG.TAG);
if (fragmentByTag == null) {
getChildFragmentManager().beginTransaction()
.add(R.id.container, FragmentG.createInstance("child", 34), FragmentG.TAG).commit();
}
}
@OnClick(R.id.start_activity_for_result)
void turnToAnotherActivity() {
| // Path: app/src/main/java/com/example/ddmeng/helloactivityandfragment/activity/StartForResultActivityTwo.java
// public class StartForResultActivityTwo extends AppCompatActivity {
// private static final String LOG_TAG = StartForResultActivityTwo.class.getSimpleName();
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// Log.i(LOG_TAG, "onCreate(): " + savedInstanceState);
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_start_for_result_activity_two);
//
// ButterKnife.bind(this);
// }
//
//
// @OnClick(R.id.set_result_ok)
// void onOkClick() {
// setResult(RESULT_OK);
// finish();
// }
//
// @OnClick(R.id.set_result_cancel)
// void onCancelClick() {
// setResult(RESULT_CANCELED);
// finish();
// }
//
//
// @Override
// protected void onRestart() {
// Log.i(LOG_TAG, "onRestart()");
// super.onRestart();
// }
//
// @Override
// protected void onStart() {
// Log.i(LOG_TAG, "onStart()");
// super.onStart();
// }
//
// @Override
// public void onStateNotSaved() {
// super.onStateNotSaved();
// Log.d(LOG_TAG, "onStateNotSaved");
// }
//
// @Override
// protected void onRestoreInstanceState(Bundle savedInstanceState) {
// Log.d(LOG_TAG, "onRestoreInstanceState(): " + savedInstanceState);
// super.onRestoreInstanceState(savedInstanceState);
// }
//
// @Override
// protected void onResume() {
// Log.i(LOG_TAG, "onResume()");
// super.onResume();
// }
//
// @Override
// protected void onPause() {
// Log.i(LOG_TAG, "onPause()");
// super.onPause();
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// Log.d(LOG_TAG, "onSaveInstanceState(): " + outState);
// }
//
// @Override
// protected void onStop() {
// Log.i(LOG_TAG, "onStop()");
// super.onStop();
// }
//
// @Override
// protected void onDestroy() {
// Log.i(LOG_TAG, "onDestroy()");
// super.onDestroy();
// }
// }
// Path: app/src/main/java/com/example/ddmeng/helloactivityandfragment/fragment/FragmentG.java
import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.ddmeng.helloactivityandfragment.R;
import com.example.ddmeng.helloactivityandfragment.activity.StartForResultActivityTwo;
import butterknife.ButterKnife;
import butterknife.OnClick;
return inflater.inflate(R.layout.fragment_g, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
Log.i(LOG_TAG, "onViewCreated()");
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this, view);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
Log.i(LOG_TAG, "onActivityCreated()");
super.onActivityCreated(savedInstanceState);
}
@OnClick(R.id.add_child_fragment)
void addChildFragment() {
Fragment fragmentByTag = getChildFragmentManager().findFragmentByTag(FragmentG.TAG);
if (fragmentByTag == null) {
getChildFragmentManager().beginTransaction()
.add(R.id.container, FragmentG.createInstance("child", 34), FragmentG.TAG).commit();
}
}
@OnClick(R.id.start_activity_for_result)
void turnToAnotherActivity() {
| startActivityForResult(new Intent(getActivity(), StartForResultActivityTwo.class), requestCode); |
mengdd/HelloActivityAndFragment | app/src/main/java/com/example/ddmeng/helloactivityandfragment/launchmode/StandardActivity.java | // Path: app/src/main/java/com/example/ddmeng/helloactivityandfragment/utils/TaskUtils.java
// public class TaskUtils {
//
// private static final String LOG_TAG = "Stack";
//
// public static String getCurrentTopActivityName(Context context) {
//
// ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
//
// //this method requires android.permission.GET_TASKS
// List<ActivityManager.RunningTaskInfo> runningTasks = activityManager.getRunningTasks(2);
// //this method was deprecated in API level 21
// ComponentName topActivity = runningTasks.get(0).topActivity;
// Log.i(LOG_TAG, "top Activity: " + topActivity.getShortClassName());
// return topActivity.getShortClassName();
//
// }
// }
| import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Button;
import android.widget.TextView;
import com.example.ddmeng.helloactivityandfragment.R;
import com.example.ddmeng.helloactivityandfragment.utils.TaskUtils;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick; | Intent intent = new Intent();
intent.setClass(StandardActivity.this, SingleTopActivity.class);
startActivity(intent);
}
@OnClick(R.id.launch_mode_start_single_task_button)
void startSingleTaskActivity() {
Log.i(LOG_TAG, "start single task button click");
Intent intent = new Intent();
intent.setClass(StandardActivity.this, SingleTaskActivity.class);
startActivity(intent);
// If the singleTask want to be in a different task, taskAffinity should be specified.
// every time start a new singleTask activity from here, new task id++
}
@OnClick(R.id.launch_mode_start_single_instance_button)
void startSingleInstanceActivity() {
Log.i(LOG_TAG, "start single instance button click");
Intent intent = new Intent();
intent.setClass(StandardActivity.this, SingleInstanceActivity.class);
startActivity(intent);
}
@OnClick(R.id.launch_mode_update_stack_info)
void updateStackInfoButtonClick() {
updateStackInfo();
}
private void updateStackInfo() { | // Path: app/src/main/java/com/example/ddmeng/helloactivityandfragment/utils/TaskUtils.java
// public class TaskUtils {
//
// private static final String LOG_TAG = "Stack";
//
// public static String getCurrentTopActivityName(Context context) {
//
// ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
//
// //this method requires android.permission.GET_TASKS
// List<ActivityManager.RunningTaskInfo> runningTasks = activityManager.getRunningTasks(2);
// //this method was deprecated in API level 21
// ComponentName topActivity = runningTasks.get(0).topActivity;
// Log.i(LOG_TAG, "top Activity: " + topActivity.getShortClassName());
// return topActivity.getShortClassName();
//
// }
// }
// Path: app/src/main/java/com/example/ddmeng/helloactivityandfragment/launchmode/StandardActivity.java
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Button;
import android.widget.TextView;
import com.example.ddmeng.helloactivityandfragment.R;
import com.example.ddmeng.helloactivityandfragment.utils.TaskUtils;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
Intent intent = new Intent();
intent.setClass(StandardActivity.this, SingleTopActivity.class);
startActivity(intent);
}
@OnClick(R.id.launch_mode_start_single_task_button)
void startSingleTaskActivity() {
Log.i(LOG_TAG, "start single task button click");
Intent intent = new Intent();
intent.setClass(StandardActivity.this, SingleTaskActivity.class);
startActivity(intent);
// If the singleTask want to be in a different task, taskAffinity should be specified.
// every time start a new singleTask activity from here, new task id++
}
@OnClick(R.id.launch_mode_start_single_instance_button)
void startSingleInstanceActivity() {
Log.i(LOG_TAG, "start single instance button click");
Intent intent = new Intent();
intent.setClass(StandardActivity.this, SingleInstanceActivity.class);
startActivity(intent);
}
@OnClick(R.id.launch_mode_update_stack_info)
void updateStackInfoButtonClick() {
updateStackInfo();
}
private void updateStackInfo() { | String currentTopActivityName = TaskUtils.getCurrentTopActivityName(this); |
mengdd/HelloActivityAndFragment | app/src/main/java/com/example/ddmeng/helloactivityandfragment/launchmode/SingleTopActivity.java | // Path: app/src/main/java/com/example/ddmeng/helloactivityandfragment/utils/TaskUtils.java
// public class TaskUtils {
//
// private static final String LOG_TAG = "Stack";
//
// public static String getCurrentTopActivityName(Context context) {
//
// ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
//
// //this method requires android.permission.GET_TASKS
// List<ActivityManager.RunningTaskInfo> runningTasks = activityManager.getRunningTasks(2);
// //this method was deprecated in API level 21
// ComponentName topActivity = runningTasks.get(0).topActivity;
// Log.i(LOG_TAG, "top Activity: " + topActivity.getShortClassName());
// return topActivity.getShortClassName();
//
// }
// }
| import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import com.example.ddmeng.helloactivityandfragment.R;
import com.example.ddmeng.helloactivityandfragment.utils.TaskUtils;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick; | package com.example.ddmeng.helloactivityandfragment.launchmode;
public class SingleTopActivity extends Activity {
private static final String LOG_TAG = "Launch Mode";
@BindView(R.id.current_task)
TextView mTaskText;
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.launch_mode_single_top_activity);
super.onCreate(savedInstanceState);
ButterKnife.bind(this);
Log.i(LOG_TAG, "Single Top Activity, onCreate(), " + this.hashCode());
Log.i(LOG_TAG, "task id: " + this.getTaskId());
mTaskText.setText("Currrent Task: " + this.getTaskId());
//strange phenomenon:
// When start this activity, startActivity() is called twice deliberately
// then the onCreate() is called once (right).
// But when press back, the onCreate() is called again (strange)
// So using normal eyes, the singleTop activity appear two times.
//Conclusions: Do NOT call startActivity() twice
// Because before onCreate() invoked, the singleTop activity are still not considered as on the top of the stack
| // Path: app/src/main/java/com/example/ddmeng/helloactivityandfragment/utils/TaskUtils.java
// public class TaskUtils {
//
// private static final String LOG_TAG = "Stack";
//
// public static String getCurrentTopActivityName(Context context) {
//
// ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
//
// //this method requires android.permission.GET_TASKS
// List<ActivityManager.RunningTaskInfo> runningTasks = activityManager.getRunningTasks(2);
// //this method was deprecated in API level 21
// ComponentName topActivity = runningTasks.get(0).topActivity;
// Log.i(LOG_TAG, "top Activity: " + topActivity.getShortClassName());
// return topActivity.getShortClassName();
//
// }
// }
// Path: app/src/main/java/com/example/ddmeng/helloactivityandfragment/launchmode/SingleTopActivity.java
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import com.example.ddmeng.helloactivityandfragment.R;
import com.example.ddmeng.helloactivityandfragment.utils.TaskUtils;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
package com.example.ddmeng.helloactivityandfragment.launchmode;
public class SingleTopActivity extends Activity {
private static final String LOG_TAG = "Launch Mode";
@BindView(R.id.current_task)
TextView mTaskText;
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.launch_mode_single_top_activity);
super.onCreate(savedInstanceState);
ButterKnife.bind(this);
Log.i(LOG_TAG, "Single Top Activity, onCreate(), " + this.hashCode());
Log.i(LOG_TAG, "task id: " + this.getTaskId());
mTaskText.setText("Currrent Task: " + this.getTaskId());
//strange phenomenon:
// When start this activity, startActivity() is called twice deliberately
// then the onCreate() is called once (right).
// But when press back, the onCreate() is called again (strange)
// So using normal eyes, the singleTop activity appear two times.
//Conclusions: Do NOT call startActivity() twice
// Because before onCreate() invoked, the singleTop activity are still not considered as on the top of the stack
| TaskUtils.getCurrentTopActivityName(this); |
Bodo1981/appkit | rx2/src/main/java/com/christianbahl/appkit/rx2/presenter/CBLceRx2Presenter.java | // Path: rx2/src/main/java/com/christianbahl/appkit/rx2/CBFlowableTransformer.java
// public class CBFlowableTransformer<T> implements FlowableTransformer<T, T> {
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
// }
// }
| import android.support.annotation.NonNull;
import com.christianbahl.appkit.rx2.CBFlowableTransformer;
import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
import com.hannesdorfmann.mosby3.mvp.lce.MvpLceView;
import io.reactivex.Flowable;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.subscribers.ResourceSubscriber; | /*
* Copyright 2015 Christian Bahl
*
* 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.christianbahl.appkit.rx2.presenter;
/**
* <p>
* Mvp Lce presenter which handles subscribing and unsubscribing for {@link Flowable}.
* </p>
*
* <p>
* The functions for Lce are called automatically when calling {@link #subscribe(Flowable, boolean)}.
* </p>
*
* @author Christian Bahl
* @see MvpBasePresenter
*/
public class CBLceRx2Presenter<V extends MvpLceView<M>, M> extends MvpBasePresenter<V> {
protected CompositeDisposable compositeDisposable = new CompositeDisposable(); | // Path: rx2/src/main/java/com/christianbahl/appkit/rx2/CBFlowableTransformer.java
// public class CBFlowableTransformer<T> implements FlowableTransformer<T, T> {
// @Override public Publisher<T> apply(Flowable<T> upstream) {
// return upstream.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
// }
// }
// Path: rx2/src/main/java/com/christianbahl/appkit/rx2/presenter/CBLceRx2Presenter.java
import android.support.annotation.NonNull;
import com.christianbahl.appkit.rx2.CBFlowableTransformer;
import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
import com.hannesdorfmann.mosby3.mvp.lce.MvpLceView;
import io.reactivex.Flowable;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.subscribers.ResourceSubscriber;
/*
* Copyright 2015 Christian Bahl
*
* 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.christianbahl.appkit.rx2.presenter;
/**
* <p>
* Mvp Lce presenter which handles subscribing and unsubscribing for {@link Flowable}.
* </p>
*
* <p>
* The functions for Lce are called automatically when calling {@link #subscribe(Flowable, boolean)}.
* </p>
*
* @author Christian Bahl
* @see MvpBasePresenter
*/
public class CBLceRx2Presenter<V extends MvpLceView<M>, M> extends MvpBasePresenter<V> {
protected CompositeDisposable compositeDisposable = new CompositeDisposable(); | protected CBFlowableTransformer<M> flowableTransformer; |
Bodo1981/appkit | sample-core/src/main/java/com/christianbahl/appkit/samplecore/activity_toolbar_fragment_mvp/ActivityToolbarFragmentMvp.java | // Path: core/src/main/java/com/christianbahl/appkit/core/activity/CBActivityMvpToolbarFragment.java
// public abstract class CBActivityMvpToolbarFragment<CV extends View, M, V extends MvpLceView<M>, P extends MvpPresenter<V>>
// extends CBActivityMvpToolbar<CV, M, V, P> {
//
// @Override protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// if (savedInstanceState == null) {
// Fragment fragment = createFragmentToDisplay();
//
// if (fragment == null) {
// throw new NullPointerException("Fragment is null. Did you return null in createFragmentToDisplay()?");
// }
//
// getSupportFragmentManager().beginTransaction().replace(getFragmentContainerViewRes(), fragment).commit();
// }
// }
//
// @Override @NonNull protected Integer getLayoutRes() {
// return R.layout.cb_activity_mvp_toolbar_fragment;
// }
//
// /**
// * <p>
// * Provide the content view res id for the fragment container.
// * </p>
// *
// * <p>
// * <b>Default: </b> <code>R.id.contentView</code>
// * </p>
// */
// @NonNull protected Integer getFragmentContainerViewRes() {
// return R.id.contentView;
// }
//
// /**
// * <p>
// * Returns the {@link Fragment} which should be displayed by this activity.
// * </p>
// *
// * @return {@link Fragment}
// */
// @NonNull protected abstract Fragment createFragmentToDisplay();
// }
//
// Path: sample-core/src/main/java/com/christianbahl/appkit/samplecore/activity_fragment/FragmentToDisplay.java
// public class FragmentToDisplay extends Fragment {
//
// public static FragmentToDisplay newInstance() {
// return new FragmentToDisplay();
// }
//
// @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Bundle savedInstanceState) {
// View v = inflater.inflate(R.layout.fragment_to_display, container, false);
//
// ((TextView)v.findViewById(R.id.textView)).setText("Fragment");
//
// return v;
// }
// }
//
// Path: sample-core/src/main/java/com/christianbahl/appkit/samplecore/common/StringPresenter.java
// public class StringPresenter extends MvpBasePresenter<MvpLceView<String>> {
//
// public void loadData(boolean contentPresent) {
// if (isViewAttached()) {
// getView().showLoading(contentPresent);
// }
//
// if (new Random().nextInt(10) % 3 == 0) {
// if (isViewAttached()) {
// getView().showError(new NullPointerException("No Data found!"), contentPresent);
// }
// } else {
// if (isViewAttached()) {
// getView().setData("Activity Toolbar Mvp data loaded");
// getView().showContent();
// }
// }
// }
// }
| import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.widget.FrameLayout;
import android.widget.Toast;
import com.christianbahl.appkit.core.activity.CBActivityMvpToolbarFragment;
import com.christianbahl.appkit.samplecore.activity_fragment.FragmentToDisplay;
import com.christianbahl.appkit.samplecore.common.StringPresenter;
import com.hannesdorfmann.mosby3.mvp.lce.MvpLceView; | package com.christianbahl.appkit.samplecore.activity_toolbar_fragment_mvp;
/**
* @author Christian Bahl
*/
public class ActivityToolbarFragmentMvp
extends CBActivityMvpToolbarFragment<FrameLayout, String, MvpLceView<String>, StringPresenter> {
public static Intent getStartIntent(Context context) {
return new Intent(context, ActivityToolbarFragmentMvp.class);
}
@NonNull @Override protected Fragment createFragmentToDisplay() { | // Path: core/src/main/java/com/christianbahl/appkit/core/activity/CBActivityMvpToolbarFragment.java
// public abstract class CBActivityMvpToolbarFragment<CV extends View, M, V extends MvpLceView<M>, P extends MvpPresenter<V>>
// extends CBActivityMvpToolbar<CV, M, V, P> {
//
// @Override protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// if (savedInstanceState == null) {
// Fragment fragment = createFragmentToDisplay();
//
// if (fragment == null) {
// throw new NullPointerException("Fragment is null. Did you return null in createFragmentToDisplay()?");
// }
//
// getSupportFragmentManager().beginTransaction().replace(getFragmentContainerViewRes(), fragment).commit();
// }
// }
//
// @Override @NonNull protected Integer getLayoutRes() {
// return R.layout.cb_activity_mvp_toolbar_fragment;
// }
//
// /**
// * <p>
// * Provide the content view res id for the fragment container.
// * </p>
// *
// * <p>
// * <b>Default: </b> <code>R.id.contentView</code>
// * </p>
// */
// @NonNull protected Integer getFragmentContainerViewRes() {
// return R.id.contentView;
// }
//
// /**
// * <p>
// * Returns the {@link Fragment} which should be displayed by this activity.
// * </p>
// *
// * @return {@link Fragment}
// */
// @NonNull protected abstract Fragment createFragmentToDisplay();
// }
//
// Path: sample-core/src/main/java/com/christianbahl/appkit/samplecore/activity_fragment/FragmentToDisplay.java
// public class FragmentToDisplay extends Fragment {
//
// public static FragmentToDisplay newInstance() {
// return new FragmentToDisplay();
// }
//
// @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Bundle savedInstanceState) {
// View v = inflater.inflate(R.layout.fragment_to_display, container, false);
//
// ((TextView)v.findViewById(R.id.textView)).setText("Fragment");
//
// return v;
// }
// }
//
// Path: sample-core/src/main/java/com/christianbahl/appkit/samplecore/common/StringPresenter.java
// public class StringPresenter extends MvpBasePresenter<MvpLceView<String>> {
//
// public void loadData(boolean contentPresent) {
// if (isViewAttached()) {
// getView().showLoading(contentPresent);
// }
//
// if (new Random().nextInt(10) % 3 == 0) {
// if (isViewAttached()) {
// getView().showError(new NullPointerException("No Data found!"), contentPresent);
// }
// } else {
// if (isViewAttached()) {
// getView().setData("Activity Toolbar Mvp data loaded");
// getView().showContent();
// }
// }
// }
// }
// Path: sample-core/src/main/java/com/christianbahl/appkit/samplecore/activity_toolbar_fragment_mvp/ActivityToolbarFragmentMvp.java
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.widget.FrameLayout;
import android.widget.Toast;
import com.christianbahl.appkit.core.activity.CBActivityMvpToolbarFragment;
import com.christianbahl.appkit.samplecore.activity_fragment.FragmentToDisplay;
import com.christianbahl.appkit.samplecore.common.StringPresenter;
import com.hannesdorfmann.mosby3.mvp.lce.MvpLceView;
package com.christianbahl.appkit.samplecore.activity_toolbar_fragment_mvp;
/**
* @author Christian Bahl
*/
public class ActivityToolbarFragmentMvp
extends CBActivityMvpToolbarFragment<FrameLayout, String, MvpLceView<String>, StringPresenter> {
public static Intent getStartIntent(Context context) {
return new Intent(context, ActivityToolbarFragmentMvp.class);
}
@NonNull @Override protected Fragment createFragmentToDisplay() { | return FragmentToDisplay.newInstance(); |
Bodo1981/appkit | rx/src/main/java/com/christianbahl/appkit/rx/presenter/CBLceRxPresenter.java | // Path: rx/src/main/java/com/christianbahl/appkit/rx/CBObservableTransformer.java
// public class CBObservableTransformer<T> implements Observable.Transformer<T, T> {
// @NonNull public Observable<T> call(Observable<T> observable) {
// return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
// }
// }
| import android.support.annotation.NonNull;
import com.christianbahl.appkit.rx.CBObservableTransformer;
import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
import com.hannesdorfmann.mosby3.mvp.lce.MvpLceView;
import rx.Observable;
import rx.Subscriber;
import rx.subscriptions.CompositeSubscription; | /*
* Copyright 2015 Christian Bahl
*
* 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.christianbahl.appkit.rx.presenter;
/**
* <p>
* Mvp Lce presenter which handles subscribing and unsubscribing for {@link Observable}.
* </p>
*
* <p>
* The functions for Lce are called automatically when calling {@link #subscribe(Observable, boolean)}.
* </p>
*
* @author Christian Bahl
* @see MvpBasePresenter
*/
public class CBLceRxPresenter<V extends MvpLceView<M>, M> extends MvpBasePresenter<V> {
protected CompositeSubscription compositeSubscription; | // Path: rx/src/main/java/com/christianbahl/appkit/rx/CBObservableTransformer.java
// public class CBObservableTransformer<T> implements Observable.Transformer<T, T> {
// @NonNull public Observable<T> call(Observable<T> observable) {
// return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
// }
// }
// Path: rx/src/main/java/com/christianbahl/appkit/rx/presenter/CBLceRxPresenter.java
import android.support.annotation.NonNull;
import com.christianbahl.appkit.rx.CBObservableTransformer;
import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
import com.hannesdorfmann.mosby3.mvp.lce.MvpLceView;
import rx.Observable;
import rx.Subscriber;
import rx.subscriptions.CompositeSubscription;
/*
* Copyright 2015 Christian Bahl
*
* 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.christianbahl.appkit.rx.presenter;
/**
* <p>
* Mvp Lce presenter which handles subscribing and unsubscribing for {@link Observable}.
* </p>
*
* <p>
* The functions for Lce are called automatically when calling {@link #subscribe(Observable, boolean)}.
* </p>
*
* @author Christian Bahl
* @see MvpBasePresenter
*/
public class CBLceRxPresenter<V extends MvpLceView<M>, M> extends MvpBasePresenter<V> {
protected CompositeSubscription compositeSubscription; | protected CBObservableTransformer<M> transformer; |
Bodo1981/appkit | sample-core/src/main/java/com/christianbahl/appkit/samplecore/activity_toolbar_fragment/ActivityToolbarFragment.java | // Path: core/src/main/java/com/christianbahl/appkit/core/activity/CBActivityToolbarFragment.java
// public abstract class CBActivityToolbarFragment extends CBActivityToolbar {
//
// @Override protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// if (savedInstanceState == null) {
// Fragment fragment = createFragmentToDisplay();
//
// if (fragment == null) {
// throw new NullPointerException("Fragment is null. Did you return null in createFragmentToDisplay()?");
// }
//
// getSupportFragmentManager().beginTransaction().replace(getFragmentContainerViewRes(), fragment).commit();
// }
// }
//
// @Override @NonNull protected Integer getLayoutRes() {
// return R.layout.cb_activity_toolbar_fragment;
// }
//
// /**
// * <p>
// * Provide the content view res id for the fragment container.
// * </p>
// *
// * <p>
// * <b>Default: </b> <code>R.id.contentView</code>
// * </p>
// */
// @NonNull protected Integer getFragmentContainerViewRes() {
// return R.id.contentView;
// }
//
// /**
// * Returns the {@link Fragment} which should be displayed by this activity.
// *
// * @return {@link Fragment}
// */
// @NonNull protected abstract Fragment createFragmentToDisplay();
// }
//
// Path: sample-core/src/main/java/com/christianbahl/appkit/samplecore/activity_fragment/FragmentToDisplay.java
// public class FragmentToDisplay extends Fragment {
//
// public static FragmentToDisplay newInstance() {
// return new FragmentToDisplay();
// }
//
// @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Bundle savedInstanceState) {
// View v = inflater.inflate(R.layout.fragment_to_display, container, false);
//
// ((TextView)v.findViewById(R.id.textView)).setText("Fragment");
//
// return v;
// }
// }
| import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import com.christianbahl.appkit.core.activity.CBActivityToolbarFragment;
import com.christianbahl.appkit.samplecore.activity_fragment.FragmentToDisplay; | package com.christianbahl.appkit.samplecore.activity_toolbar_fragment;
/**
* @author Christian Bahl
*/
public class ActivityToolbarFragment extends CBActivityToolbarFragment {
public static Intent getStartIntent(Context context) {
return new Intent(context, ActivityToolbarFragment.class);
}
@NonNull @Override protected Fragment createFragmentToDisplay() { | // Path: core/src/main/java/com/christianbahl/appkit/core/activity/CBActivityToolbarFragment.java
// public abstract class CBActivityToolbarFragment extends CBActivityToolbar {
//
// @Override protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// if (savedInstanceState == null) {
// Fragment fragment = createFragmentToDisplay();
//
// if (fragment == null) {
// throw new NullPointerException("Fragment is null. Did you return null in createFragmentToDisplay()?");
// }
//
// getSupportFragmentManager().beginTransaction().replace(getFragmentContainerViewRes(), fragment).commit();
// }
// }
//
// @Override @NonNull protected Integer getLayoutRes() {
// return R.layout.cb_activity_toolbar_fragment;
// }
//
// /**
// * <p>
// * Provide the content view res id for the fragment container.
// * </p>
// *
// * <p>
// * <b>Default: </b> <code>R.id.contentView</code>
// * </p>
// */
// @NonNull protected Integer getFragmentContainerViewRes() {
// return R.id.contentView;
// }
//
// /**
// * Returns the {@link Fragment} which should be displayed by this activity.
// *
// * @return {@link Fragment}
// */
// @NonNull protected abstract Fragment createFragmentToDisplay();
// }
//
// Path: sample-core/src/main/java/com/christianbahl/appkit/samplecore/activity_fragment/FragmentToDisplay.java
// public class FragmentToDisplay extends Fragment {
//
// public static FragmentToDisplay newInstance() {
// return new FragmentToDisplay();
// }
//
// @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Bundle savedInstanceState) {
// View v = inflater.inflate(R.layout.fragment_to_display, container, false);
//
// ((TextView)v.findViewById(R.id.textView)).setText("Fragment");
//
// return v;
// }
// }
// Path: sample-core/src/main/java/com/christianbahl/appkit/samplecore/activity_toolbar_fragment/ActivityToolbarFragment.java
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import com.christianbahl.appkit.core.activity.CBActivityToolbarFragment;
import com.christianbahl.appkit.samplecore.activity_fragment.FragmentToDisplay;
package com.christianbahl.appkit.samplecore.activity_toolbar_fragment;
/**
* @author Christian Bahl
*/
public class ActivityToolbarFragment extends CBActivityToolbarFragment {
public static Intent getStartIntent(Context context) {
return new Intent(context, ActivityToolbarFragment.class);
}
@NonNull @Override protected Fragment createFragmentToDisplay() { | return FragmentToDisplay.newInstance(); |
dschadow/JavaSecurity | crypto-shiro/src/main/java/de/dominikschadow/javasecurity/Keystore.java | // Path: crypto-java/src/main/java/de/dominikschadow/javasecurity/symmetric/AES.java
// public class AES {
// private final SecretKeySpec secretKeySpec;
// private final Cipher cipher;
//
// public AES(SecretKeySpec secretKeySpec, String algorithm) throws NoSuchPaddingException, NoSuchAlgorithmException {
// cipher = Cipher.getInstance(algorithm);
//
// this.secretKeySpec = secretKeySpec;
// }
//
// public byte[] encrypt(String initialText) throws
// BadPaddingException, IllegalBlockSizeException, InvalidKeyException {
// cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
//
// return cipher.doFinal(initialText.getBytes(StandardCharsets.UTF_8));
// }
//
// public byte[] decrypt(byte[] ciphertext) throws
// BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException, InvalidKeyException {
// cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(cipher.getIV()));
// return cipher.doFinal(ciphertext);
// }
// }
| import de.dominikschadow.javasecurity.symmetric.AES;
import java.io.IOException;
import java.io.InputStream;
import java.security.*;
import java.security.cert.CertificateException; | package de.dominikschadow.javasecurity;
public class Keystore {
private static final String KEYSTORE_PATH = "/samples.ks";
public static KeyStore loadKeystore(char[] keystorePassword) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException { | // Path: crypto-java/src/main/java/de/dominikschadow/javasecurity/symmetric/AES.java
// public class AES {
// private final SecretKeySpec secretKeySpec;
// private final Cipher cipher;
//
// public AES(SecretKeySpec secretKeySpec, String algorithm) throws NoSuchPaddingException, NoSuchAlgorithmException {
// cipher = Cipher.getInstance(algorithm);
//
// this.secretKeySpec = secretKeySpec;
// }
//
// public byte[] encrypt(String initialText) throws
// BadPaddingException, IllegalBlockSizeException, InvalidKeyException {
// cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
//
// return cipher.doFinal(initialText.getBytes(StandardCharsets.UTF_8));
// }
//
// public byte[] decrypt(byte[] ciphertext) throws
// BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException, InvalidKeyException {
// cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(cipher.getIV()));
// return cipher.doFinal(ciphertext);
// }
// }
// Path: crypto-shiro/src/main/java/de/dominikschadow/javasecurity/Keystore.java
import de.dominikschadow.javasecurity.symmetric.AES;
import java.io.IOException;
import java.io.InputStream;
import java.security.*;
import java.security.cert.CertificateException;
package de.dominikschadow.javasecurity;
public class Keystore {
private static final String KEYSTORE_PATH = "/samples.ks";
public static KeyStore loadKeystore(char[] keystorePassword) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException { | try (InputStream keystoreStream = AES.class.getResourceAsStream(KEYSTORE_PATH)) { |
dschadow/JavaSecurity | crypto-java/src/main/java/de/dominikschadow/javasecurity/Keystore.java | // Path: crypto-java/src/main/java/de/dominikschadow/javasecurity/asymmetric/DSA.java
// public class DSA {
// private static final String ALGORITHM = "SHA1withDSA";
//
// public byte[] sign(PrivateKey privateKey, String initialText) throws NoSuchAlgorithmException,
// InvalidKeyException, SignatureException {
// Signature dsa = Signature.getInstance(ALGORITHM);
// dsa.initSign(privateKey);
// dsa.update(initialText.getBytes(StandardCharsets.UTF_8));
// return dsa.sign();
// }
//
// public boolean verify(PublicKey publicKey, byte[] signature, String initialText) throws
// NoSuchAlgorithmException, InvalidKeyException, SignatureException {
// Signature dsa = Signature.getInstance(ALGORITHM);
// dsa.initVerify(publicKey);
// dsa.update(initialText.getBytes(StandardCharsets.UTF_8));
// return dsa.verify(signature);
// }
// }
| import de.dominikschadow.javasecurity.asymmetric.DSA;
import javax.crypto.spec.SecretKeySpec;
import java.io.IOException;
import java.io.InputStream;
import java.security.*;
import java.security.cert.CertificateException; | package de.dominikschadow.javasecurity;
public class Keystore {
private static final String KEYSTORE_PATH = "/samples.ks";
public static KeyStore loadKeystore(char[] keystorePassword) throws KeyStoreException,
CertificateException, NoSuchAlgorithmException, IOException { | // Path: crypto-java/src/main/java/de/dominikschadow/javasecurity/asymmetric/DSA.java
// public class DSA {
// private static final String ALGORITHM = "SHA1withDSA";
//
// public byte[] sign(PrivateKey privateKey, String initialText) throws NoSuchAlgorithmException,
// InvalidKeyException, SignatureException {
// Signature dsa = Signature.getInstance(ALGORITHM);
// dsa.initSign(privateKey);
// dsa.update(initialText.getBytes(StandardCharsets.UTF_8));
// return dsa.sign();
// }
//
// public boolean verify(PublicKey publicKey, byte[] signature, String initialText) throws
// NoSuchAlgorithmException, InvalidKeyException, SignatureException {
// Signature dsa = Signature.getInstance(ALGORITHM);
// dsa.initVerify(publicKey);
// dsa.update(initialText.getBytes(StandardCharsets.UTF_8));
// return dsa.verify(signature);
// }
// }
// Path: crypto-java/src/main/java/de/dominikschadow/javasecurity/Keystore.java
import de.dominikschadow.javasecurity.asymmetric.DSA;
import javax.crypto.spec.SecretKeySpec;
import java.io.IOException;
import java.io.InputStream;
import java.security.*;
import java.security.cert.CertificateException;
package de.dominikschadow.javasecurity;
public class Keystore {
private static final String KEYSTORE_PATH = "/samples.ks";
public static KeyStore loadKeystore(char[] keystorePassword) throws KeyStoreException,
CertificateException, NoSuchAlgorithmException, IOException { | try (InputStream keystoreStream = DSA.class.getResourceAsStream(KEYSTORE_PATH)) { |
dschadow/JavaSecurity | crypto-shiro/src/test/java/de/dominikschadow/javasecurity/symmetric/AESTest.java | // Path: crypto-shiro/src/main/java/de/dominikschadow/javasecurity/Keystore.java
// public class Keystore {
// private static final String KEYSTORE_PATH = "/samples.ks";
//
// public static KeyStore loadKeystore(char[] keystorePassword) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
// try (InputStream keystoreStream = AES.class.getResourceAsStream(KEYSTORE_PATH)) {
// KeyStore ks = KeyStore.getInstance("JCEKS");
// ks.load(keystoreStream, keystorePassword);
//
// return ks;
// }
// }
//
// public static Key loadKey(KeyStore ks, String keyAlias, char[] keyPassword) throws KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException {
// if (!ks.containsAlias(keyAlias)) {
// throw new UnrecoverableKeyException("Secret key " + keyAlias + " not found in keystore");
// }
//
// return ks.getKey(keyAlias, keyPassword);
// }
// }
| import de.dominikschadow.javasecurity.Keystore;
import org.apache.shiro.codec.CodecSupport;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.security.Key;
import java.security.KeyStore;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals; | /*
* Copyright (C) 2022 Dominik Schadow, [email protected]
*
* This file is part of the Java Security 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 de.dominikschadow.javasecurity.symmetric;
class AESTest {
private final AES aes = new AES();
private Key key;
@BeforeEach
protected void setup() throws Exception {
final char[] keystorePassword = "samples".toCharArray();
final String keyAlias = "symmetric-sample";
final char[] keyPassword = "symmetric-sample".toCharArray();
| // Path: crypto-shiro/src/main/java/de/dominikschadow/javasecurity/Keystore.java
// public class Keystore {
// private static final String KEYSTORE_PATH = "/samples.ks";
//
// public static KeyStore loadKeystore(char[] keystorePassword) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
// try (InputStream keystoreStream = AES.class.getResourceAsStream(KEYSTORE_PATH)) {
// KeyStore ks = KeyStore.getInstance("JCEKS");
// ks.load(keystoreStream, keystorePassword);
//
// return ks;
// }
// }
//
// public static Key loadKey(KeyStore ks, String keyAlias, char[] keyPassword) throws KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException {
// if (!ks.containsAlias(keyAlias)) {
// throw new UnrecoverableKeyException("Secret key " + keyAlias + " not found in keystore");
// }
//
// return ks.getKey(keyAlias, keyPassword);
// }
// }
// Path: crypto-shiro/src/test/java/de/dominikschadow/javasecurity/symmetric/AESTest.java
import de.dominikschadow.javasecurity.Keystore;
import org.apache.shiro.codec.CodecSupport;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.security.Key;
import java.security.KeyStore;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
/*
* Copyright (C) 2022 Dominik Schadow, [email protected]
*
* This file is part of the Java Security 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 de.dominikschadow.javasecurity.symmetric;
class AESTest {
private final AES aes = new AES();
private Key key;
@BeforeEach
protected void setup() throws Exception {
final char[] keystorePassword = "samples".toCharArray();
final String keyAlias = "symmetric-sample";
final char[] keyPassword = "symmetric-sample".toCharArray();
| KeyStore ks = Keystore.loadKeystore(keystorePassword); |
dschadow/JavaSecurity | crypto-java/src/test/java/de/dominikschadow/javasecurity/asymmetric/DSATest.java | // Path: crypto-shiro/src/main/java/de/dominikschadow/javasecurity/Keystore.java
// public class Keystore {
// private static final String KEYSTORE_PATH = "/samples.ks";
//
// public static KeyStore loadKeystore(char[] keystorePassword) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
// try (InputStream keystoreStream = AES.class.getResourceAsStream(KEYSTORE_PATH)) {
// KeyStore ks = KeyStore.getInstance("JCEKS");
// ks.load(keystoreStream, keystorePassword);
//
// return ks;
// }
// }
//
// public static Key loadKey(KeyStore ks, String keyAlias, char[] keyPassword) throws KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException {
// if (!ks.containsAlias(keyAlias)) {
// throw new UnrecoverableKeyException("Secret key " + keyAlias + " not found in keystore");
// }
//
// return ks.getKey(keyAlias, keyPassword);
// }
// }
| import de.dominikschadow.javasecurity.Keystore;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.PublicKey;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue; | /*
* Copyright (C) 2022 Dominik Schadow, [email protected]
*
* This file is part of the Java Security 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 de.dominikschadow.javasecurity.asymmetric;
class DSATest {
private final DSA dsa = new DSA();
private PrivateKey privateKey;
private PublicKey publicKey;
@BeforeEach
protected void setup() throws Exception {
final char[] keystorePassword = "samples".toCharArray();
final String keyAlias = "asymmetric-sample-dsa";
final char[] keyPassword = "asymmetric-sample-dsa".toCharArray();
| // Path: crypto-shiro/src/main/java/de/dominikschadow/javasecurity/Keystore.java
// public class Keystore {
// private static final String KEYSTORE_PATH = "/samples.ks";
//
// public static KeyStore loadKeystore(char[] keystorePassword) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
// try (InputStream keystoreStream = AES.class.getResourceAsStream(KEYSTORE_PATH)) {
// KeyStore ks = KeyStore.getInstance("JCEKS");
// ks.load(keystoreStream, keystorePassword);
//
// return ks;
// }
// }
//
// public static Key loadKey(KeyStore ks, String keyAlias, char[] keyPassword) throws KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException {
// if (!ks.containsAlias(keyAlias)) {
// throw new UnrecoverableKeyException("Secret key " + keyAlias + " not found in keystore");
// }
//
// return ks.getKey(keyAlias, keyPassword);
// }
// }
// Path: crypto-java/src/test/java/de/dominikschadow/javasecurity/asymmetric/DSATest.java
import de.dominikschadow.javasecurity.Keystore;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.PublicKey;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
/*
* Copyright (C) 2022 Dominik Schadow, [email protected]
*
* This file is part of the Java Security 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 de.dominikschadow.javasecurity.asymmetric;
class DSATest {
private final DSA dsa = new DSA();
private PrivateKey privateKey;
private PublicKey publicKey;
@BeforeEach
protected void setup() throws Exception {
final char[] keystorePassword = "samples".toCharArray();
final String keyAlias = "asymmetric-sample-dsa";
final char[] keyPassword = "asymmetric-sample-dsa".toCharArray();
| KeyStore ks = Keystore.loadKeystore(keystorePassword); |
dschadow/JavaSecurity | crypto-java/src/test/java/de/dominikschadow/javasecurity/symmetric/AESTest.java | // Path: crypto-shiro/src/main/java/de/dominikschadow/javasecurity/Keystore.java
// public class Keystore {
// private static final String KEYSTORE_PATH = "/samples.ks";
//
// public static KeyStore loadKeystore(char[] keystorePassword) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
// try (InputStream keystoreStream = AES.class.getResourceAsStream(KEYSTORE_PATH)) {
// KeyStore ks = KeyStore.getInstance("JCEKS");
// ks.load(keystoreStream, keystorePassword);
//
// return ks;
// }
// }
//
// public static Key loadKey(KeyStore ks, String keyAlias, char[] keyPassword) throws KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException {
// if (!ks.containsAlias(keyAlias)) {
// throw new UnrecoverableKeyException("Secret key " + keyAlias + " not found in keystore");
// }
//
// return ks.getKey(keyAlias, keyPassword);
// }
// }
| import de.dominikschadow.javasecurity.Keystore;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import javax.crypto.spec.SecretKeySpec;
import java.security.Key;
import java.security.KeyStore;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals; | package de.dominikschadow.javasecurity.symmetric;
class AESTest {
private AES aes;
@BeforeEach
protected void setup() throws Exception {
final char[] keystorePassword = "samples".toCharArray();
final String keyAlias = "symmetric-sample";
final char[] keyPassword = "symmetric-sample".toCharArray();
| // Path: crypto-shiro/src/main/java/de/dominikschadow/javasecurity/Keystore.java
// public class Keystore {
// private static final String KEYSTORE_PATH = "/samples.ks";
//
// public static KeyStore loadKeystore(char[] keystorePassword) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
// try (InputStream keystoreStream = AES.class.getResourceAsStream(KEYSTORE_PATH)) {
// KeyStore ks = KeyStore.getInstance("JCEKS");
// ks.load(keystoreStream, keystorePassword);
//
// return ks;
// }
// }
//
// public static Key loadKey(KeyStore ks, String keyAlias, char[] keyPassword) throws KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException {
// if (!ks.containsAlias(keyAlias)) {
// throw new UnrecoverableKeyException("Secret key " + keyAlias + " not found in keystore");
// }
//
// return ks.getKey(keyAlias, keyPassword);
// }
// }
// Path: crypto-java/src/test/java/de/dominikschadow/javasecurity/symmetric/AESTest.java
import de.dominikschadow.javasecurity.Keystore;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import javax.crypto.spec.SecretKeySpec;
import java.security.Key;
import java.security.KeyStore;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
package de.dominikschadow.javasecurity.symmetric;
class AESTest {
private AES aes;
@BeforeEach
protected void setup() throws Exception {
final char[] keystorePassword = "samples".toCharArray();
final String keyAlias = "symmetric-sample";
final char[] keyPassword = "symmetric-sample".toCharArray();
| KeyStore ks = Keystore.loadKeystore(keystorePassword); |
dschadow/JavaSecurity | crypto-java/src/test/java/de/dominikschadow/javasecurity/asymmetric/RSATest.java | // Path: crypto-shiro/src/main/java/de/dominikschadow/javasecurity/Keystore.java
// public class Keystore {
// private static final String KEYSTORE_PATH = "/samples.ks";
//
// public static KeyStore loadKeystore(char[] keystorePassword) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
// try (InputStream keystoreStream = AES.class.getResourceAsStream(KEYSTORE_PATH)) {
// KeyStore ks = KeyStore.getInstance("JCEKS");
// ks.load(keystoreStream, keystorePassword);
//
// return ks;
// }
// }
//
// public static Key loadKey(KeyStore ks, String keyAlias, char[] keyPassword) throws KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException {
// if (!ks.containsAlias(keyAlias)) {
// throw new UnrecoverableKeyException("Secret key " + keyAlias + " not found in keystore");
// }
//
// return ks.getKey(keyAlias, keyPassword);
// }
// }
| import de.dominikschadow.javasecurity.Keystore;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.PublicKey;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals; | package de.dominikschadow.javasecurity.asymmetric;
class RSATest {
private final RSA rsa = new RSA();
private PrivateKey privateKey;
private PublicKey publicKey;
@BeforeEach
protected void setup() throws Exception {
final char[] keystorePassword = "samples".toCharArray();
final String keyAlias = "asymmetric-sample-rsa";
final char[] keyPassword = "asymmetric-sample-rsa".toCharArray();
| // Path: crypto-shiro/src/main/java/de/dominikschadow/javasecurity/Keystore.java
// public class Keystore {
// private static final String KEYSTORE_PATH = "/samples.ks";
//
// public static KeyStore loadKeystore(char[] keystorePassword) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
// try (InputStream keystoreStream = AES.class.getResourceAsStream(KEYSTORE_PATH)) {
// KeyStore ks = KeyStore.getInstance("JCEKS");
// ks.load(keystoreStream, keystorePassword);
//
// return ks;
// }
// }
//
// public static Key loadKey(KeyStore ks, String keyAlias, char[] keyPassword) throws KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException {
// if (!ks.containsAlias(keyAlias)) {
// throw new UnrecoverableKeyException("Secret key " + keyAlias + " not found in keystore");
// }
//
// return ks.getKey(keyAlias, keyPassword);
// }
// }
// Path: crypto-java/src/test/java/de/dominikschadow/javasecurity/asymmetric/RSATest.java
import de.dominikschadow.javasecurity.Keystore;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.PublicKey;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
package de.dominikschadow.javasecurity.asymmetric;
class RSATest {
private final RSA rsa = new RSA();
private PrivateKey privateKey;
private PublicKey publicKey;
@BeforeEach
protected void setup() throws Exception {
final char[] keystorePassword = "samples".toCharArray();
final String keyAlias = "asymmetric-sample-rsa";
final char[] keyPassword = "asymmetric-sample-rsa".toCharArray();
| KeyStore ks = Keystore.loadKeystore(keystorePassword); |
jeperon/freqtrade-java | src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeServiceImpl.java | // Path: src/main/java/ch/urbanfox/freqtrade/analyze/indicator/BuySignalIndicator.java
// public class BuySignalIndicator extends CachedIndicator<Boolean> {
//
// private static final long serialVersionUID = 1L;
//
// private static final Logger LOGGER = LoggerFactory.getLogger(BuySignalIndicator.class);
//
// private final UpSwingIndicator upSwingIndicator;
// private final SwapIndicator swapIndicator;
// private final AverageDirectionalMovementIndicator adxIndicator;
//
// private final Decimal momentum;
//
// public BuySignalIndicator(TimeSeries series, int timeframe, Decimal momentum) {
// super(series);
//
// this.momentum = momentum;
//
// ClosePriceIndicator closePriceIndicator = new ClosePriceIndicator(series);
//
// EMAIndicator emaIndicator = new EMAIndicator(closePriceIndicator, timeframe);
// ParabolicSarIndicator sarIndicator = new ParabolicSarIndicator(series, timeframe);
// this.adxIndicator = new AverageDirectionalMovementIndicator(series, timeframe);
//
// // wait for stable turn from bearish to bullish market
// this.swapIndicator = new SwapIndicator(closePriceIndicator, sarIndicator);
//
// // consider prices above ema to be in upswing
// this.upSwingIndicator = new UpSwingIndicator(closePriceIndicator, emaIndicator);
// }
//
// @Override
// protected Boolean calculate(int index) {
//
// Boolean upSwing = upSwingIndicator.getValue(index);
// Boolean swap = swapIndicator.getValue(index);
// Decimal adxValue = adxIndicator.getValue(index);
// Boolean adx = adxValue.isGreaterThan(momentum);
//
// LOGGER.debug("@index={} upSwing={} swap={} adx={} (value={}, momentum={})", index, upSwing, swap, adx, adxValue,
// momentum);
//
// return upSwing && swap && adx;
// }
//
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import ch.urbanfox.freqtrade.analyze.indicator.BuySignalIndicator;
import eu.verdelhan.ta4j.Decimal;
import eu.verdelhan.ta4j.TimeSeries; | package ch.urbanfox.freqtrade.analyze;
@Service
public class AnalyzeServiceImpl implements AnalyzeService {
private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeServiceImpl.class);
@Override
public boolean getBuySignal(TimeSeries tickers) {
| // Path: src/main/java/ch/urbanfox/freqtrade/analyze/indicator/BuySignalIndicator.java
// public class BuySignalIndicator extends CachedIndicator<Boolean> {
//
// private static final long serialVersionUID = 1L;
//
// private static final Logger LOGGER = LoggerFactory.getLogger(BuySignalIndicator.class);
//
// private final UpSwingIndicator upSwingIndicator;
// private final SwapIndicator swapIndicator;
// private final AverageDirectionalMovementIndicator adxIndicator;
//
// private final Decimal momentum;
//
// public BuySignalIndicator(TimeSeries series, int timeframe, Decimal momentum) {
// super(series);
//
// this.momentum = momentum;
//
// ClosePriceIndicator closePriceIndicator = new ClosePriceIndicator(series);
//
// EMAIndicator emaIndicator = new EMAIndicator(closePriceIndicator, timeframe);
// ParabolicSarIndicator sarIndicator = new ParabolicSarIndicator(series, timeframe);
// this.adxIndicator = new AverageDirectionalMovementIndicator(series, timeframe);
//
// // wait for stable turn from bearish to bullish market
// this.swapIndicator = new SwapIndicator(closePriceIndicator, sarIndicator);
//
// // consider prices above ema to be in upswing
// this.upSwingIndicator = new UpSwingIndicator(closePriceIndicator, emaIndicator);
// }
//
// @Override
// protected Boolean calculate(int index) {
//
// Boolean upSwing = upSwingIndicator.getValue(index);
// Boolean swap = swapIndicator.getValue(index);
// Decimal adxValue = adxIndicator.getValue(index);
// Boolean adx = adxValue.isGreaterThan(momentum);
//
// LOGGER.debug("@index={} upSwing={} swap={} adx={} (value={}, momentum={})", index, upSwing, swap, adx, adxValue,
// momentum);
//
// return upSwing && swap && adx;
// }
//
// }
// Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeServiceImpl.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import ch.urbanfox.freqtrade.analyze.indicator.BuySignalIndicator;
import eu.verdelhan.ta4j.Decimal;
import eu.verdelhan.ta4j.TimeSeries;
package ch.urbanfox.freqtrade.analyze;
@Service
public class AnalyzeServiceImpl implements AnalyzeService {
private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeServiceImpl.class);
@Override
public boolean getBuySignal(TimeSeries tickers) {
| BuySignalIndicator buySignal = new BuySignalIndicator(tickers, 33, Decimal.valueOf(0.25)); |
jeperon/freqtrade-java | src/main/java/ch/urbanfox/freqtrade/event/CommandEventListener.java | // Path: src/main/java/ch/urbanfox/freqtrade/event/model/CommandEvent.java
// public class CommandEvent {
//
// private final String command;
//
// private final String[] params;
//
// public CommandEvent(String command, String... params) {
// this.command = command;
// this.params = params;
// }
//
// public String getCommand() {
// return command;
// }
//
// public String[] getParams() {
// return params;
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/telegram/TelegramService.java
// public interface TelegramService {
//
// /**
// * Sends a message to the user of the application
// *
// * @param message the content of the message
// * @throws TelegramApiException if any error occurs while using Telegram API
// */
// void sendMessage(String message) throws TelegramApiException;
//
// void sendMessage(String message, String parseMode) throws TelegramApiException;
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/telegram/command/CommandHandler.java
// public interface CommandHandler {
//
// String getCommandName();
//
// }
| import java.util.Set;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import org.telegram.telegrambots.exceptions.TelegramApiException;
import ch.urbanfox.freqtrade.event.model.CommandEvent;
import ch.urbanfox.freqtrade.telegram.TelegramService;
import ch.urbanfox.freqtrade.telegram.command.CommandHandler; | package ch.urbanfox.freqtrade.event;
@Component
public class CommandEventListener {
private static final Logger LOGGER = LoggerFactory.getLogger(CommandEventListener.class);
| // Path: src/main/java/ch/urbanfox/freqtrade/event/model/CommandEvent.java
// public class CommandEvent {
//
// private final String command;
//
// private final String[] params;
//
// public CommandEvent(String command, String... params) {
// this.command = command;
// this.params = params;
// }
//
// public String getCommand() {
// return command;
// }
//
// public String[] getParams() {
// return params;
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/telegram/TelegramService.java
// public interface TelegramService {
//
// /**
// * Sends a message to the user of the application
// *
// * @param message the content of the message
// * @throws TelegramApiException if any error occurs while using Telegram API
// */
// void sendMessage(String message) throws TelegramApiException;
//
// void sendMessage(String message, String parseMode) throws TelegramApiException;
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/telegram/command/CommandHandler.java
// public interface CommandHandler {
//
// String getCommandName();
//
// }
// Path: src/main/java/ch/urbanfox/freqtrade/event/CommandEventListener.java
import java.util.Set;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import org.telegram.telegrambots.exceptions.TelegramApiException;
import ch.urbanfox.freqtrade.event.model.CommandEvent;
import ch.urbanfox.freqtrade.telegram.TelegramService;
import ch.urbanfox.freqtrade.telegram.command.CommandHandler;
package ch.urbanfox.freqtrade.event;
@Component
public class CommandEventListener {
private static final Logger LOGGER = LoggerFactory.getLogger(CommandEventListener.class);
| private final TelegramService telegramService; |
jeperon/freqtrade-java | src/main/java/ch/urbanfox/freqtrade/event/CommandEventListener.java | // Path: src/main/java/ch/urbanfox/freqtrade/event/model/CommandEvent.java
// public class CommandEvent {
//
// private final String command;
//
// private final String[] params;
//
// public CommandEvent(String command, String... params) {
// this.command = command;
// this.params = params;
// }
//
// public String getCommand() {
// return command;
// }
//
// public String[] getParams() {
// return params;
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/telegram/TelegramService.java
// public interface TelegramService {
//
// /**
// * Sends a message to the user of the application
// *
// * @param message the content of the message
// * @throws TelegramApiException if any error occurs while using Telegram API
// */
// void sendMessage(String message) throws TelegramApiException;
//
// void sendMessage(String message, String parseMode) throws TelegramApiException;
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/telegram/command/CommandHandler.java
// public interface CommandHandler {
//
// String getCommandName();
//
// }
| import java.util.Set;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import org.telegram.telegrambots.exceptions.TelegramApiException;
import ch.urbanfox.freqtrade.event.model.CommandEvent;
import ch.urbanfox.freqtrade.telegram.TelegramService;
import ch.urbanfox.freqtrade.telegram.command.CommandHandler; | package ch.urbanfox.freqtrade.event;
@Component
public class CommandEventListener {
private static final Logger LOGGER = LoggerFactory.getLogger(CommandEventListener.class);
private final TelegramService telegramService;
private final Set<String> availableCommandNames;
@Autowired | // Path: src/main/java/ch/urbanfox/freqtrade/event/model/CommandEvent.java
// public class CommandEvent {
//
// private final String command;
//
// private final String[] params;
//
// public CommandEvent(String command, String... params) {
// this.command = command;
// this.params = params;
// }
//
// public String getCommand() {
// return command;
// }
//
// public String[] getParams() {
// return params;
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/telegram/TelegramService.java
// public interface TelegramService {
//
// /**
// * Sends a message to the user of the application
// *
// * @param message the content of the message
// * @throws TelegramApiException if any error occurs while using Telegram API
// */
// void sendMessage(String message) throws TelegramApiException;
//
// void sendMessage(String message, String parseMode) throws TelegramApiException;
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/telegram/command/CommandHandler.java
// public interface CommandHandler {
//
// String getCommandName();
//
// }
// Path: src/main/java/ch/urbanfox/freqtrade/event/CommandEventListener.java
import java.util.Set;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import org.telegram.telegrambots.exceptions.TelegramApiException;
import ch.urbanfox.freqtrade.event.model.CommandEvent;
import ch.urbanfox.freqtrade.telegram.TelegramService;
import ch.urbanfox.freqtrade.telegram.command.CommandHandler;
package ch.urbanfox.freqtrade.event;
@Component
public class CommandEventListener {
private static final Logger LOGGER = LoggerFactory.getLogger(CommandEventListener.class);
private final TelegramService telegramService;
private final Set<String> availableCommandNames;
@Autowired | public CommandEventListener(TelegramService telegramService, Set<CommandHandler> handlers) { |
jeperon/freqtrade-java | src/main/java/ch/urbanfox/freqtrade/event/CommandEventListener.java | // Path: src/main/java/ch/urbanfox/freqtrade/event/model/CommandEvent.java
// public class CommandEvent {
//
// private final String command;
//
// private final String[] params;
//
// public CommandEvent(String command, String... params) {
// this.command = command;
// this.params = params;
// }
//
// public String getCommand() {
// return command;
// }
//
// public String[] getParams() {
// return params;
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/telegram/TelegramService.java
// public interface TelegramService {
//
// /**
// * Sends a message to the user of the application
// *
// * @param message the content of the message
// * @throws TelegramApiException if any error occurs while using Telegram API
// */
// void sendMessage(String message) throws TelegramApiException;
//
// void sendMessage(String message, String parseMode) throws TelegramApiException;
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/telegram/command/CommandHandler.java
// public interface CommandHandler {
//
// String getCommandName();
//
// }
| import java.util.Set;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import org.telegram.telegrambots.exceptions.TelegramApiException;
import ch.urbanfox.freqtrade.event.model.CommandEvent;
import ch.urbanfox.freqtrade.telegram.TelegramService;
import ch.urbanfox.freqtrade.telegram.command.CommandHandler; | package ch.urbanfox.freqtrade.event;
@Component
public class CommandEventListener {
private static final Logger LOGGER = LoggerFactory.getLogger(CommandEventListener.class);
private final TelegramService telegramService;
private final Set<String> availableCommandNames;
@Autowired
public CommandEventListener(TelegramService telegramService, Set<CommandHandler> handlers) {
this.telegramService = telegramService;
this.availableCommandNames = handlers.stream()
.map(CommandHandler::getCommandName)
.collect(Collectors.toSet());
}
@EventListener | // Path: src/main/java/ch/urbanfox/freqtrade/event/model/CommandEvent.java
// public class CommandEvent {
//
// private final String command;
//
// private final String[] params;
//
// public CommandEvent(String command, String... params) {
// this.command = command;
// this.params = params;
// }
//
// public String getCommand() {
// return command;
// }
//
// public String[] getParams() {
// return params;
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/telegram/TelegramService.java
// public interface TelegramService {
//
// /**
// * Sends a message to the user of the application
// *
// * @param message the content of the message
// * @throws TelegramApiException if any error occurs while using Telegram API
// */
// void sendMessage(String message) throws TelegramApiException;
//
// void sendMessage(String message, String parseMode) throws TelegramApiException;
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/telegram/command/CommandHandler.java
// public interface CommandHandler {
//
// String getCommandName();
//
// }
// Path: src/main/java/ch/urbanfox/freqtrade/event/CommandEventListener.java
import java.util.Set;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import org.telegram.telegrambots.exceptions.TelegramApiException;
import ch.urbanfox.freqtrade.event.model.CommandEvent;
import ch.urbanfox.freqtrade.telegram.TelegramService;
import ch.urbanfox.freqtrade.telegram.command.CommandHandler;
package ch.urbanfox.freqtrade.event;
@Component
public class CommandEventListener {
private static final Logger LOGGER = LoggerFactory.getLogger(CommandEventListener.class);
private final TelegramService telegramService;
private final Set<String> availableCommandNames;
@Autowired
public CommandEventListener(TelegramService telegramService, Set<CommandHandler> handlers) {
this.telegramService = telegramService;
this.availableCommandNames = handlers.stream()
.map(CommandHandler::getCommandName)
.collect(Collectors.toSet());
}
@EventListener | public void onCommandEvent(CommandEvent event) { |
jeperon/freqtrade-java | src/test/java/ch/urbanfox/freqtrade/tester/StrategyTester.java | // Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeService.java
// public interface AnalyzeService {
//
// /**
// * Calculates a buy signal based several technical analysis indicators
// *
// * @param tickers the tickers to analyze
// * @return true if pair is good for buying, false otherwise
// */
// boolean getBuySignal(TimeSeries tickers);
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeServiceImpl.java
// @Service
// public class AnalyzeServiceImpl implements AnalyzeService {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeServiceImpl.class);
//
// @Override
// public boolean getBuySignal(TimeSeries tickers) {
//
// BuySignalIndicator buySignal = new BuySignalIndicator(tickers, 33, Decimal.valueOf(0.25));
//
// // Need to go through all index to initialize indicators
// for (int i = tickers.getBeginIndex(); i <= tickers.getEndIndex(); i++) {
// buySignal.getValue(i);
// }
//
// boolean signal = buySignal.getValue(tickers.getEndIndex());
// LOGGER.debug("buy_trigger: {} (end time={})", signal, tickers.getLastTick().getEndTime());
// return signal;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/converter/BittrexDataConverter.java
// public class BittrexDataConverter {
//
// public TimeSeries parseRawTickers(List<BittrexChartData> rawData) {
//
// List<Tick> ticks = rawData.stream()
// .map(this::convertTick)
// .collect(Collectors.toList());
//
// return new BaseTimeSeries(ticks);
// }
//
// private BaseTick convertTick(BittrexChartData data) {
//
// return new BaseTick(ZonedDateTime.ofInstant(data.getTimeStamp().toInstant(), ZoneId.systemDefault()),
// Decimal.valueOf(data.getOpen().toString()),
// Decimal.valueOf(data.getHigh().toString()),
// Decimal.valueOf(data.getLow().toString()),
// Decimal.valueOf(data.getClose().toString()),
// Decimal.valueOf(data.getVolume().toString()));
// }
//
// }
| import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import ch.urbanfox.freqtrade.analyze.AnalyzeService;
import ch.urbanfox.freqtrade.analyze.AnalyzeServiceImpl;
import ch.urbanfox.freqtrade.exchange.converter.BittrexDataConverter;
import eu.verdelhan.ta4j.TimeSeries;
| package ch.urbanfox.freqtrade.tester;
public class StrategyTester {
private static final Logger LOGGER = LoggerFactory.getLogger(StrategyTester.class);
private static final int WINDOW_SIZE = 72;
public static void main(String[] args) throws IOException {
byte[] jsonAsBytes = Files.readAllBytes(Paths.get("src", "test", "resources", "data", "ETH_BTC.json"));
ObjectMapper mapper = new ObjectMapper();
List<BittrexChartData> result = mapper.readValue(jsonAsBytes, new TypeReference<List<BittrexChartData>>() {});
LOGGER.info("Parsed json file: {} ticks", result.size());
| // Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeService.java
// public interface AnalyzeService {
//
// /**
// * Calculates a buy signal based several technical analysis indicators
// *
// * @param tickers the tickers to analyze
// * @return true if pair is good for buying, false otherwise
// */
// boolean getBuySignal(TimeSeries tickers);
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeServiceImpl.java
// @Service
// public class AnalyzeServiceImpl implements AnalyzeService {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeServiceImpl.class);
//
// @Override
// public boolean getBuySignal(TimeSeries tickers) {
//
// BuySignalIndicator buySignal = new BuySignalIndicator(tickers, 33, Decimal.valueOf(0.25));
//
// // Need to go through all index to initialize indicators
// for (int i = tickers.getBeginIndex(); i <= tickers.getEndIndex(); i++) {
// buySignal.getValue(i);
// }
//
// boolean signal = buySignal.getValue(tickers.getEndIndex());
// LOGGER.debug("buy_trigger: {} (end time={})", signal, tickers.getLastTick().getEndTime());
// return signal;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/converter/BittrexDataConverter.java
// public class BittrexDataConverter {
//
// public TimeSeries parseRawTickers(List<BittrexChartData> rawData) {
//
// List<Tick> ticks = rawData.stream()
// .map(this::convertTick)
// .collect(Collectors.toList());
//
// return new BaseTimeSeries(ticks);
// }
//
// private BaseTick convertTick(BittrexChartData data) {
//
// return new BaseTick(ZonedDateTime.ofInstant(data.getTimeStamp().toInstant(), ZoneId.systemDefault()),
// Decimal.valueOf(data.getOpen().toString()),
// Decimal.valueOf(data.getHigh().toString()),
// Decimal.valueOf(data.getLow().toString()),
// Decimal.valueOf(data.getClose().toString()),
// Decimal.valueOf(data.getVolume().toString()));
// }
//
// }
// Path: src/test/java/ch/urbanfox/freqtrade/tester/StrategyTester.java
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import ch.urbanfox.freqtrade.analyze.AnalyzeService;
import ch.urbanfox.freqtrade.analyze.AnalyzeServiceImpl;
import ch.urbanfox.freqtrade.exchange.converter.BittrexDataConverter;
import eu.verdelhan.ta4j.TimeSeries;
package ch.urbanfox.freqtrade.tester;
public class StrategyTester {
private static final Logger LOGGER = LoggerFactory.getLogger(StrategyTester.class);
private static final int WINDOW_SIZE = 72;
public static void main(String[] args) throws IOException {
byte[] jsonAsBytes = Files.readAllBytes(Paths.get("src", "test", "resources", "data", "ETH_BTC.json"));
ObjectMapper mapper = new ObjectMapper();
List<BittrexChartData> result = mapper.readValue(jsonAsBytes, new TypeReference<List<BittrexChartData>>() {});
LOGGER.info("Parsed json file: {} ticks", result.size());
| AnalyzeService analyzeService = new AnalyzeServiceImpl();
|
jeperon/freqtrade-java | src/test/java/ch/urbanfox/freqtrade/tester/StrategyTester.java | // Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeService.java
// public interface AnalyzeService {
//
// /**
// * Calculates a buy signal based several technical analysis indicators
// *
// * @param tickers the tickers to analyze
// * @return true if pair is good for buying, false otherwise
// */
// boolean getBuySignal(TimeSeries tickers);
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeServiceImpl.java
// @Service
// public class AnalyzeServiceImpl implements AnalyzeService {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeServiceImpl.class);
//
// @Override
// public boolean getBuySignal(TimeSeries tickers) {
//
// BuySignalIndicator buySignal = new BuySignalIndicator(tickers, 33, Decimal.valueOf(0.25));
//
// // Need to go through all index to initialize indicators
// for (int i = tickers.getBeginIndex(); i <= tickers.getEndIndex(); i++) {
// buySignal.getValue(i);
// }
//
// boolean signal = buySignal.getValue(tickers.getEndIndex());
// LOGGER.debug("buy_trigger: {} (end time={})", signal, tickers.getLastTick().getEndTime());
// return signal;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/converter/BittrexDataConverter.java
// public class BittrexDataConverter {
//
// public TimeSeries parseRawTickers(List<BittrexChartData> rawData) {
//
// List<Tick> ticks = rawData.stream()
// .map(this::convertTick)
// .collect(Collectors.toList());
//
// return new BaseTimeSeries(ticks);
// }
//
// private BaseTick convertTick(BittrexChartData data) {
//
// return new BaseTick(ZonedDateTime.ofInstant(data.getTimeStamp().toInstant(), ZoneId.systemDefault()),
// Decimal.valueOf(data.getOpen().toString()),
// Decimal.valueOf(data.getHigh().toString()),
// Decimal.valueOf(data.getLow().toString()),
// Decimal.valueOf(data.getClose().toString()),
// Decimal.valueOf(data.getVolume().toString()));
// }
//
// }
| import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import ch.urbanfox.freqtrade.analyze.AnalyzeService;
import ch.urbanfox.freqtrade.analyze.AnalyzeServiceImpl;
import ch.urbanfox.freqtrade.exchange.converter.BittrexDataConverter;
import eu.verdelhan.ta4j.TimeSeries;
| package ch.urbanfox.freqtrade.tester;
public class StrategyTester {
private static final Logger LOGGER = LoggerFactory.getLogger(StrategyTester.class);
private static final int WINDOW_SIZE = 72;
public static void main(String[] args) throws IOException {
byte[] jsonAsBytes = Files.readAllBytes(Paths.get("src", "test", "resources", "data", "ETH_BTC.json"));
ObjectMapper mapper = new ObjectMapper();
List<BittrexChartData> result = mapper.readValue(jsonAsBytes, new TypeReference<List<BittrexChartData>>() {});
LOGGER.info("Parsed json file: {} ticks", result.size());
| // Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeService.java
// public interface AnalyzeService {
//
// /**
// * Calculates a buy signal based several technical analysis indicators
// *
// * @param tickers the tickers to analyze
// * @return true if pair is good for buying, false otherwise
// */
// boolean getBuySignal(TimeSeries tickers);
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeServiceImpl.java
// @Service
// public class AnalyzeServiceImpl implements AnalyzeService {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeServiceImpl.class);
//
// @Override
// public boolean getBuySignal(TimeSeries tickers) {
//
// BuySignalIndicator buySignal = new BuySignalIndicator(tickers, 33, Decimal.valueOf(0.25));
//
// // Need to go through all index to initialize indicators
// for (int i = tickers.getBeginIndex(); i <= tickers.getEndIndex(); i++) {
// buySignal.getValue(i);
// }
//
// boolean signal = buySignal.getValue(tickers.getEndIndex());
// LOGGER.debug("buy_trigger: {} (end time={})", signal, tickers.getLastTick().getEndTime());
// return signal;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/converter/BittrexDataConverter.java
// public class BittrexDataConverter {
//
// public TimeSeries parseRawTickers(List<BittrexChartData> rawData) {
//
// List<Tick> ticks = rawData.stream()
// .map(this::convertTick)
// .collect(Collectors.toList());
//
// return new BaseTimeSeries(ticks);
// }
//
// private BaseTick convertTick(BittrexChartData data) {
//
// return new BaseTick(ZonedDateTime.ofInstant(data.getTimeStamp().toInstant(), ZoneId.systemDefault()),
// Decimal.valueOf(data.getOpen().toString()),
// Decimal.valueOf(data.getHigh().toString()),
// Decimal.valueOf(data.getLow().toString()),
// Decimal.valueOf(data.getClose().toString()),
// Decimal.valueOf(data.getVolume().toString()));
// }
//
// }
// Path: src/test/java/ch/urbanfox/freqtrade/tester/StrategyTester.java
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import ch.urbanfox.freqtrade.analyze.AnalyzeService;
import ch.urbanfox.freqtrade.analyze.AnalyzeServiceImpl;
import ch.urbanfox.freqtrade.exchange.converter.BittrexDataConverter;
import eu.verdelhan.ta4j.TimeSeries;
package ch.urbanfox.freqtrade.tester;
public class StrategyTester {
private static final Logger LOGGER = LoggerFactory.getLogger(StrategyTester.class);
private static final int WINDOW_SIZE = 72;
public static void main(String[] args) throws IOException {
byte[] jsonAsBytes = Files.readAllBytes(Paths.get("src", "test", "resources", "data", "ETH_BTC.json"));
ObjectMapper mapper = new ObjectMapper();
List<BittrexChartData> result = mapper.readValue(jsonAsBytes, new TypeReference<List<BittrexChartData>>() {});
LOGGER.info("Parsed json file: {} ticks", result.size());
| AnalyzeService analyzeService = new AnalyzeServiceImpl();
|
jeperon/freqtrade-java | src/test/java/ch/urbanfox/freqtrade/tester/StrategyTester.java | // Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeService.java
// public interface AnalyzeService {
//
// /**
// * Calculates a buy signal based several technical analysis indicators
// *
// * @param tickers the tickers to analyze
// * @return true if pair is good for buying, false otherwise
// */
// boolean getBuySignal(TimeSeries tickers);
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeServiceImpl.java
// @Service
// public class AnalyzeServiceImpl implements AnalyzeService {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeServiceImpl.class);
//
// @Override
// public boolean getBuySignal(TimeSeries tickers) {
//
// BuySignalIndicator buySignal = new BuySignalIndicator(tickers, 33, Decimal.valueOf(0.25));
//
// // Need to go through all index to initialize indicators
// for (int i = tickers.getBeginIndex(); i <= tickers.getEndIndex(); i++) {
// buySignal.getValue(i);
// }
//
// boolean signal = buySignal.getValue(tickers.getEndIndex());
// LOGGER.debug("buy_trigger: {} (end time={})", signal, tickers.getLastTick().getEndTime());
// return signal;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/converter/BittrexDataConverter.java
// public class BittrexDataConverter {
//
// public TimeSeries parseRawTickers(List<BittrexChartData> rawData) {
//
// List<Tick> ticks = rawData.stream()
// .map(this::convertTick)
// .collect(Collectors.toList());
//
// return new BaseTimeSeries(ticks);
// }
//
// private BaseTick convertTick(BittrexChartData data) {
//
// return new BaseTick(ZonedDateTime.ofInstant(data.getTimeStamp().toInstant(), ZoneId.systemDefault()),
// Decimal.valueOf(data.getOpen().toString()),
// Decimal.valueOf(data.getHigh().toString()),
// Decimal.valueOf(data.getLow().toString()),
// Decimal.valueOf(data.getClose().toString()),
// Decimal.valueOf(data.getVolume().toString()));
// }
//
// }
| import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import ch.urbanfox.freqtrade.analyze.AnalyzeService;
import ch.urbanfox.freqtrade.analyze.AnalyzeServiceImpl;
import ch.urbanfox.freqtrade.exchange.converter.BittrexDataConverter;
import eu.verdelhan.ta4j.TimeSeries;
| package ch.urbanfox.freqtrade.tester;
public class StrategyTester {
private static final Logger LOGGER = LoggerFactory.getLogger(StrategyTester.class);
private static final int WINDOW_SIZE = 72;
public static void main(String[] args) throws IOException {
byte[] jsonAsBytes = Files.readAllBytes(Paths.get("src", "test", "resources", "data", "ETH_BTC.json"));
ObjectMapper mapper = new ObjectMapper();
List<BittrexChartData> result = mapper.readValue(jsonAsBytes, new TypeReference<List<BittrexChartData>>() {});
LOGGER.info("Parsed json file: {} ticks", result.size());
AnalyzeService analyzeService = new AnalyzeServiceImpl();
| // Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeService.java
// public interface AnalyzeService {
//
// /**
// * Calculates a buy signal based several technical analysis indicators
// *
// * @param tickers the tickers to analyze
// * @return true if pair is good for buying, false otherwise
// */
// boolean getBuySignal(TimeSeries tickers);
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeServiceImpl.java
// @Service
// public class AnalyzeServiceImpl implements AnalyzeService {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeServiceImpl.class);
//
// @Override
// public boolean getBuySignal(TimeSeries tickers) {
//
// BuySignalIndicator buySignal = new BuySignalIndicator(tickers, 33, Decimal.valueOf(0.25));
//
// // Need to go through all index to initialize indicators
// for (int i = tickers.getBeginIndex(); i <= tickers.getEndIndex(); i++) {
// buySignal.getValue(i);
// }
//
// boolean signal = buySignal.getValue(tickers.getEndIndex());
// LOGGER.debug("buy_trigger: {} (end time={})", signal, tickers.getLastTick().getEndTime());
// return signal;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/converter/BittrexDataConverter.java
// public class BittrexDataConverter {
//
// public TimeSeries parseRawTickers(List<BittrexChartData> rawData) {
//
// List<Tick> ticks = rawData.stream()
// .map(this::convertTick)
// .collect(Collectors.toList());
//
// return new BaseTimeSeries(ticks);
// }
//
// private BaseTick convertTick(BittrexChartData data) {
//
// return new BaseTick(ZonedDateTime.ofInstant(data.getTimeStamp().toInstant(), ZoneId.systemDefault()),
// Decimal.valueOf(data.getOpen().toString()),
// Decimal.valueOf(data.getHigh().toString()),
// Decimal.valueOf(data.getLow().toString()),
// Decimal.valueOf(data.getClose().toString()),
// Decimal.valueOf(data.getVolume().toString()));
// }
//
// }
// Path: src/test/java/ch/urbanfox/freqtrade/tester/StrategyTester.java
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import ch.urbanfox.freqtrade.analyze.AnalyzeService;
import ch.urbanfox.freqtrade.analyze.AnalyzeServiceImpl;
import ch.urbanfox.freqtrade.exchange.converter.BittrexDataConverter;
import eu.verdelhan.ta4j.TimeSeries;
package ch.urbanfox.freqtrade.tester;
public class StrategyTester {
private static final Logger LOGGER = LoggerFactory.getLogger(StrategyTester.class);
private static final int WINDOW_SIZE = 72;
public static void main(String[] args) throws IOException {
byte[] jsonAsBytes = Files.readAllBytes(Paths.get("src", "test", "resources", "data", "ETH_BTC.json"));
ObjectMapper mapper = new ObjectMapper();
List<BittrexChartData> result = mapper.readValue(jsonAsBytes, new TypeReference<List<BittrexChartData>>() {});
LOGGER.info("Parsed json file: {} ticks", result.size());
AnalyzeService analyzeService = new AnalyzeServiceImpl();
| BittrexDataConverter converter = new BittrexDataConverter();
|
jeperon/freqtrade-java | src/main/java/ch/urbanfox/freqtrade/FreqTradeProperties.java | // Path: src/main/java/ch/urbanfox/freqtrade/telegram/TelegramProperties.java
// public class TelegramProperties {
//
// private Boolean enabled;
//
// private String token;
//
// private Long chatId;
//
// private String botName;
//
// public Boolean getEnabled() {
// return enabled;
// }
//
// public void setEnabled(Boolean enabled) {
// this.enabled = enabled;
// }
//
// public String getToken() {
// return token;
// }
//
// public void setToken(String token) {
// this.token = token;
// }
//
// public Long getChatId() {
// return chatId;
// }
//
// public void setChatId(Long chatId) {
// this.chatId = chatId;
// }
//
// public String getBotName() {
// return botName;
// }
//
// public void setBotName(String botName) {
// this.botName = botName;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/type/State.java
// public enum State {
//
// RUNNING,
//
// SLEEP,
//
// STOPPED
//
// }
| import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.knowm.xchange.currency.Currency;
import org.knowm.xchange.currency.CurrencyPair;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import ch.urbanfox.freqtrade.telegram.TelegramProperties;
import ch.urbanfox.freqtrade.type.State; | package ch.urbanfox.freqtrade;
/**
* FreqTrade configuration properties
*/
@Configuration
@ConfigurationProperties(prefix = "freqtrade")
public class FreqTradeProperties {
| // Path: src/main/java/ch/urbanfox/freqtrade/telegram/TelegramProperties.java
// public class TelegramProperties {
//
// private Boolean enabled;
//
// private String token;
//
// private Long chatId;
//
// private String botName;
//
// public Boolean getEnabled() {
// return enabled;
// }
//
// public void setEnabled(Boolean enabled) {
// this.enabled = enabled;
// }
//
// public String getToken() {
// return token;
// }
//
// public void setToken(String token) {
// this.token = token;
// }
//
// public Long getChatId() {
// return chatId;
// }
//
// public void setChatId(Long chatId) {
// this.chatId = chatId;
// }
//
// public String getBotName() {
// return botName;
// }
//
// public void setBotName(String botName) {
// this.botName = botName;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/type/State.java
// public enum State {
//
// RUNNING,
//
// SLEEP,
//
// STOPPED
//
// }
// Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeProperties.java
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.knowm.xchange.currency.Currency;
import org.knowm.xchange.currency.CurrencyPair;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import ch.urbanfox.freqtrade.telegram.TelegramProperties;
import ch.urbanfox.freqtrade.type.State;
package ch.urbanfox.freqtrade;
/**
* FreqTrade configuration properties
*/
@Configuration
@ConfigurationProperties(prefix = "freqtrade")
public class FreqTradeProperties {
| private State initialState; |
jeperon/freqtrade-java | src/main/java/ch/urbanfox/freqtrade/FreqTradeProperties.java | // Path: src/main/java/ch/urbanfox/freqtrade/telegram/TelegramProperties.java
// public class TelegramProperties {
//
// private Boolean enabled;
//
// private String token;
//
// private Long chatId;
//
// private String botName;
//
// public Boolean getEnabled() {
// return enabled;
// }
//
// public void setEnabled(Boolean enabled) {
// this.enabled = enabled;
// }
//
// public String getToken() {
// return token;
// }
//
// public void setToken(String token) {
// this.token = token;
// }
//
// public Long getChatId() {
// return chatId;
// }
//
// public void setChatId(Long chatId) {
// this.chatId = chatId;
// }
//
// public String getBotName() {
// return botName;
// }
//
// public void setBotName(String botName) {
// this.botName = botName;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/type/State.java
// public enum State {
//
// RUNNING,
//
// SLEEP,
//
// STOPPED
//
// }
| import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.knowm.xchange.currency.Currency;
import org.knowm.xchange.currency.CurrencyPair;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import ch.urbanfox.freqtrade.telegram.TelegramProperties;
import ch.urbanfox.freqtrade.type.State; | package ch.urbanfox.freqtrade;
/**
* FreqTrade configuration properties
*/
@Configuration
@ConfigurationProperties(prefix = "freqtrade")
public class FreqTradeProperties {
private State initialState;
private int maxOpenTrades;
private Currency stakeCurrency;
private BigDecimal stakeAmount;
private boolean dryRun = false;
private Map<Long, BigDecimal> minimalRoi = new TreeMap<>();
private BigDecimal stopLoss;
private List<CurrencyPair> pairWhitelist = new ArrayList<>();
private BittrexProperties bittrex;
| // Path: src/main/java/ch/urbanfox/freqtrade/telegram/TelegramProperties.java
// public class TelegramProperties {
//
// private Boolean enabled;
//
// private String token;
//
// private Long chatId;
//
// private String botName;
//
// public Boolean getEnabled() {
// return enabled;
// }
//
// public void setEnabled(Boolean enabled) {
// this.enabled = enabled;
// }
//
// public String getToken() {
// return token;
// }
//
// public void setToken(String token) {
// this.token = token;
// }
//
// public Long getChatId() {
// return chatId;
// }
//
// public void setChatId(Long chatId) {
// this.chatId = chatId;
// }
//
// public String getBotName() {
// return botName;
// }
//
// public void setBotName(String botName) {
// this.botName = botName;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/type/State.java
// public enum State {
//
// RUNNING,
//
// SLEEP,
//
// STOPPED
//
// }
// Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeProperties.java
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.knowm.xchange.currency.Currency;
import org.knowm.xchange.currency.CurrencyPair;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import ch.urbanfox.freqtrade.telegram.TelegramProperties;
import ch.urbanfox.freqtrade.type.State;
package ch.urbanfox.freqtrade;
/**
* FreqTrade configuration properties
*/
@Configuration
@ConfigurationProperties(prefix = "freqtrade")
public class FreqTradeProperties {
private State initialState;
private int maxOpenTrades;
private Currency stakeCurrency;
private BigDecimal stakeAmount;
private boolean dryRun = false;
private Map<Long, BigDecimal> minimalRoi = new TreeMap<>();
private BigDecimal stopLoss;
private List<CurrencyPair> pairWhitelist = new ArrayList<>();
private BittrexProperties bittrex;
| private TelegramProperties telegram; |
jeperon/freqtrade-java | src/main/java/ch/urbanfox/freqtrade/tester/AnalyzeServiceTester.java | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeApplication.java
// @SpringBootApplication
// public class FreqTradeApplication {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeApplication.class);
//
// public static void main(String[] args) throws InterruptedException, TelegramApiException {
// LOGGER.info("Starting freqtrade...");
//
// ConfigurableApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
//
// LOGGER.info("freqtrade started.");
//
// FreqTradeMainRunner runner = context.getBean(FreqTradeMainRunner.class);
// runner.main();
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeService.java
// public interface AnalyzeService {
//
// /**
// * Calculates a buy signal based several technical analysis indicators
// *
// * @param tickers the tickers to analyze
// * @return true if pair is good for buying, false otherwise
// */
// boolean getBuySignal(TimeSeries tickers);
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeService.java
// public interface FreqTradeExchangeService {
//
// /**
// * Places a limit buy order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to purchase
// * @return orderId of the placed buy order
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// String buy(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get Ticker for given pair.
// *
// * @param pair Pair as str, format: BTC_ETC
// * @return the ticker
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// Ticker getTicker(CurrencyPair pair) throws IOException;
//
// /**
// * Places a limit sell order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to sell
// * @return the order ID
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// String sell(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get all open orders for given pair.
// *
// * @param pair the currency pair
// * @return list of orders
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// List<LimitOrder> getOpenOrders(CurrencyPair pair) throws IOException;
//
// /**
// * Returns the market detail url for the given pair
// *
// * @param pair pair as a String, format: BTC_ANT
// * @return url as a string
// */
// String getPairDetailUrl(String pair);
//
// /**
// * Get account balance.
// *
// * @param currency currency as str, format: BTC
// * @return balance
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// BigDecimal getBalance(Currency currency) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair, ZonedDateTime minimumDate) throws IOException;
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/converter/BittrexDataConverter.java
// public class BittrexDataConverter {
//
// public TimeSeries parseRawTickers(List<BittrexChartData> rawData) {
//
// List<Tick> ticks = rawData.stream()
// .map(this::convertTick)
// .collect(Collectors.toList());
//
// return new BaseTimeSeries(ticks);
// }
//
// private BaseTick convertTick(BittrexChartData data) {
//
// return new BaseTick(ZonedDateTime.ofInstant(data.getTimeStamp().toInstant(), ZoneId.systemDefault()),
// Decimal.valueOf(data.getOpen().toString()),
// Decimal.valueOf(data.getHigh().toString()),
// Decimal.valueOf(data.getLow().toString()),
// Decimal.valueOf(data.getClose().toString()),
// Decimal.valueOf(data.getVolume().toString()));
// }
//
// }
| import java.time.ZonedDateTime;
import java.util.List;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.knowm.xchange.currency.CurrencyPair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import ch.urbanfox.freqtrade.FreqTradeApplication;
import ch.urbanfox.freqtrade.analyze.AnalyzeService;
import ch.urbanfox.freqtrade.exchange.FreqTradeExchangeService;
import ch.urbanfox.freqtrade.exchange.converter.BittrexDataConverter;
import eu.verdelhan.ta4j.TimeSeries; | package ch.urbanfox.freqtrade.tester;
public class AnalyzeServiceTester {
private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeServiceTester.class);
public static void main(String[] args) throws Exception { | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeApplication.java
// @SpringBootApplication
// public class FreqTradeApplication {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeApplication.class);
//
// public static void main(String[] args) throws InterruptedException, TelegramApiException {
// LOGGER.info("Starting freqtrade...");
//
// ConfigurableApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
//
// LOGGER.info("freqtrade started.");
//
// FreqTradeMainRunner runner = context.getBean(FreqTradeMainRunner.class);
// runner.main();
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeService.java
// public interface AnalyzeService {
//
// /**
// * Calculates a buy signal based several technical analysis indicators
// *
// * @param tickers the tickers to analyze
// * @return true if pair is good for buying, false otherwise
// */
// boolean getBuySignal(TimeSeries tickers);
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeService.java
// public interface FreqTradeExchangeService {
//
// /**
// * Places a limit buy order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to purchase
// * @return orderId of the placed buy order
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// String buy(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get Ticker for given pair.
// *
// * @param pair Pair as str, format: BTC_ETC
// * @return the ticker
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// Ticker getTicker(CurrencyPair pair) throws IOException;
//
// /**
// * Places a limit sell order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to sell
// * @return the order ID
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// String sell(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get all open orders for given pair.
// *
// * @param pair the currency pair
// * @return list of orders
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// List<LimitOrder> getOpenOrders(CurrencyPair pair) throws IOException;
//
// /**
// * Returns the market detail url for the given pair
// *
// * @param pair pair as a String, format: BTC_ANT
// * @return url as a string
// */
// String getPairDetailUrl(String pair);
//
// /**
// * Get account balance.
// *
// * @param currency currency as str, format: BTC
// * @return balance
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// BigDecimal getBalance(Currency currency) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair, ZonedDateTime minimumDate) throws IOException;
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/converter/BittrexDataConverter.java
// public class BittrexDataConverter {
//
// public TimeSeries parseRawTickers(List<BittrexChartData> rawData) {
//
// List<Tick> ticks = rawData.stream()
// .map(this::convertTick)
// .collect(Collectors.toList());
//
// return new BaseTimeSeries(ticks);
// }
//
// private BaseTick convertTick(BittrexChartData data) {
//
// return new BaseTick(ZonedDateTime.ofInstant(data.getTimeStamp().toInstant(), ZoneId.systemDefault()),
// Decimal.valueOf(data.getOpen().toString()),
// Decimal.valueOf(data.getHigh().toString()),
// Decimal.valueOf(data.getLow().toString()),
// Decimal.valueOf(data.getClose().toString()),
// Decimal.valueOf(data.getVolume().toString()));
// }
//
// }
// Path: src/main/java/ch/urbanfox/freqtrade/tester/AnalyzeServiceTester.java
import java.time.ZonedDateTime;
import java.util.List;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.knowm.xchange.currency.CurrencyPair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import ch.urbanfox.freqtrade.FreqTradeApplication;
import ch.urbanfox.freqtrade.analyze.AnalyzeService;
import ch.urbanfox.freqtrade.exchange.FreqTradeExchangeService;
import ch.urbanfox.freqtrade.exchange.converter.BittrexDataConverter;
import eu.verdelhan.ta4j.TimeSeries;
package ch.urbanfox.freqtrade.tester;
public class AnalyzeServiceTester {
private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeServiceTester.class);
public static void main(String[] args) throws Exception { | ApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args); |
jeperon/freqtrade-java | src/main/java/ch/urbanfox/freqtrade/tester/AnalyzeServiceTester.java | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeApplication.java
// @SpringBootApplication
// public class FreqTradeApplication {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeApplication.class);
//
// public static void main(String[] args) throws InterruptedException, TelegramApiException {
// LOGGER.info("Starting freqtrade...");
//
// ConfigurableApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
//
// LOGGER.info("freqtrade started.");
//
// FreqTradeMainRunner runner = context.getBean(FreqTradeMainRunner.class);
// runner.main();
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeService.java
// public interface AnalyzeService {
//
// /**
// * Calculates a buy signal based several technical analysis indicators
// *
// * @param tickers the tickers to analyze
// * @return true if pair is good for buying, false otherwise
// */
// boolean getBuySignal(TimeSeries tickers);
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeService.java
// public interface FreqTradeExchangeService {
//
// /**
// * Places a limit buy order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to purchase
// * @return orderId of the placed buy order
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// String buy(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get Ticker for given pair.
// *
// * @param pair Pair as str, format: BTC_ETC
// * @return the ticker
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// Ticker getTicker(CurrencyPair pair) throws IOException;
//
// /**
// * Places a limit sell order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to sell
// * @return the order ID
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// String sell(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get all open orders for given pair.
// *
// * @param pair the currency pair
// * @return list of orders
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// List<LimitOrder> getOpenOrders(CurrencyPair pair) throws IOException;
//
// /**
// * Returns the market detail url for the given pair
// *
// * @param pair pair as a String, format: BTC_ANT
// * @return url as a string
// */
// String getPairDetailUrl(String pair);
//
// /**
// * Get account balance.
// *
// * @param currency currency as str, format: BTC
// * @return balance
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// BigDecimal getBalance(Currency currency) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair, ZonedDateTime minimumDate) throws IOException;
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/converter/BittrexDataConverter.java
// public class BittrexDataConverter {
//
// public TimeSeries parseRawTickers(List<BittrexChartData> rawData) {
//
// List<Tick> ticks = rawData.stream()
// .map(this::convertTick)
// .collect(Collectors.toList());
//
// return new BaseTimeSeries(ticks);
// }
//
// private BaseTick convertTick(BittrexChartData data) {
//
// return new BaseTick(ZonedDateTime.ofInstant(data.getTimeStamp().toInstant(), ZoneId.systemDefault()),
// Decimal.valueOf(data.getOpen().toString()),
// Decimal.valueOf(data.getHigh().toString()),
// Decimal.valueOf(data.getLow().toString()),
// Decimal.valueOf(data.getClose().toString()),
// Decimal.valueOf(data.getVolume().toString()));
// }
//
// }
| import java.time.ZonedDateTime;
import java.util.List;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.knowm.xchange.currency.CurrencyPair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import ch.urbanfox.freqtrade.FreqTradeApplication;
import ch.urbanfox.freqtrade.analyze.AnalyzeService;
import ch.urbanfox.freqtrade.exchange.FreqTradeExchangeService;
import ch.urbanfox.freqtrade.exchange.converter.BittrexDataConverter;
import eu.verdelhan.ta4j.TimeSeries; | package ch.urbanfox.freqtrade.tester;
public class AnalyzeServiceTester {
private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeServiceTester.class);
public static void main(String[] args) throws Exception {
ApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
| // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeApplication.java
// @SpringBootApplication
// public class FreqTradeApplication {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeApplication.class);
//
// public static void main(String[] args) throws InterruptedException, TelegramApiException {
// LOGGER.info("Starting freqtrade...");
//
// ConfigurableApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
//
// LOGGER.info("freqtrade started.");
//
// FreqTradeMainRunner runner = context.getBean(FreqTradeMainRunner.class);
// runner.main();
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeService.java
// public interface AnalyzeService {
//
// /**
// * Calculates a buy signal based several technical analysis indicators
// *
// * @param tickers the tickers to analyze
// * @return true if pair is good for buying, false otherwise
// */
// boolean getBuySignal(TimeSeries tickers);
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeService.java
// public interface FreqTradeExchangeService {
//
// /**
// * Places a limit buy order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to purchase
// * @return orderId of the placed buy order
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// String buy(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get Ticker for given pair.
// *
// * @param pair Pair as str, format: BTC_ETC
// * @return the ticker
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// Ticker getTicker(CurrencyPair pair) throws IOException;
//
// /**
// * Places a limit sell order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to sell
// * @return the order ID
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// String sell(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get all open orders for given pair.
// *
// * @param pair the currency pair
// * @return list of orders
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// List<LimitOrder> getOpenOrders(CurrencyPair pair) throws IOException;
//
// /**
// * Returns the market detail url for the given pair
// *
// * @param pair pair as a String, format: BTC_ANT
// * @return url as a string
// */
// String getPairDetailUrl(String pair);
//
// /**
// * Get account balance.
// *
// * @param currency currency as str, format: BTC
// * @return balance
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// BigDecimal getBalance(Currency currency) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair, ZonedDateTime minimumDate) throws IOException;
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/converter/BittrexDataConverter.java
// public class BittrexDataConverter {
//
// public TimeSeries parseRawTickers(List<BittrexChartData> rawData) {
//
// List<Tick> ticks = rawData.stream()
// .map(this::convertTick)
// .collect(Collectors.toList());
//
// return new BaseTimeSeries(ticks);
// }
//
// private BaseTick convertTick(BittrexChartData data) {
//
// return new BaseTick(ZonedDateTime.ofInstant(data.getTimeStamp().toInstant(), ZoneId.systemDefault()),
// Decimal.valueOf(data.getOpen().toString()),
// Decimal.valueOf(data.getHigh().toString()),
// Decimal.valueOf(data.getLow().toString()),
// Decimal.valueOf(data.getClose().toString()),
// Decimal.valueOf(data.getVolume().toString()));
// }
//
// }
// Path: src/main/java/ch/urbanfox/freqtrade/tester/AnalyzeServiceTester.java
import java.time.ZonedDateTime;
import java.util.List;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.knowm.xchange.currency.CurrencyPair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import ch.urbanfox.freqtrade.FreqTradeApplication;
import ch.urbanfox.freqtrade.analyze.AnalyzeService;
import ch.urbanfox.freqtrade.exchange.FreqTradeExchangeService;
import ch.urbanfox.freqtrade.exchange.converter.BittrexDataConverter;
import eu.verdelhan.ta4j.TimeSeries;
package ch.urbanfox.freqtrade.tester;
public class AnalyzeServiceTester {
private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeServiceTester.class);
public static void main(String[] args) throws Exception {
ApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
| FreqTradeExchangeService exchangeService = context.getBean(FreqTradeExchangeService.class); |
jeperon/freqtrade-java | src/main/java/ch/urbanfox/freqtrade/tester/AnalyzeServiceTester.java | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeApplication.java
// @SpringBootApplication
// public class FreqTradeApplication {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeApplication.class);
//
// public static void main(String[] args) throws InterruptedException, TelegramApiException {
// LOGGER.info("Starting freqtrade...");
//
// ConfigurableApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
//
// LOGGER.info("freqtrade started.");
//
// FreqTradeMainRunner runner = context.getBean(FreqTradeMainRunner.class);
// runner.main();
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeService.java
// public interface AnalyzeService {
//
// /**
// * Calculates a buy signal based several technical analysis indicators
// *
// * @param tickers the tickers to analyze
// * @return true if pair is good for buying, false otherwise
// */
// boolean getBuySignal(TimeSeries tickers);
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeService.java
// public interface FreqTradeExchangeService {
//
// /**
// * Places a limit buy order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to purchase
// * @return orderId of the placed buy order
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// String buy(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get Ticker for given pair.
// *
// * @param pair Pair as str, format: BTC_ETC
// * @return the ticker
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// Ticker getTicker(CurrencyPair pair) throws IOException;
//
// /**
// * Places a limit sell order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to sell
// * @return the order ID
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// String sell(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get all open orders for given pair.
// *
// * @param pair the currency pair
// * @return list of orders
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// List<LimitOrder> getOpenOrders(CurrencyPair pair) throws IOException;
//
// /**
// * Returns the market detail url for the given pair
// *
// * @param pair pair as a String, format: BTC_ANT
// * @return url as a string
// */
// String getPairDetailUrl(String pair);
//
// /**
// * Get account balance.
// *
// * @param currency currency as str, format: BTC
// * @return balance
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// BigDecimal getBalance(Currency currency) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair, ZonedDateTime minimumDate) throws IOException;
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/converter/BittrexDataConverter.java
// public class BittrexDataConverter {
//
// public TimeSeries parseRawTickers(List<BittrexChartData> rawData) {
//
// List<Tick> ticks = rawData.stream()
// .map(this::convertTick)
// .collect(Collectors.toList());
//
// return new BaseTimeSeries(ticks);
// }
//
// private BaseTick convertTick(BittrexChartData data) {
//
// return new BaseTick(ZonedDateTime.ofInstant(data.getTimeStamp().toInstant(), ZoneId.systemDefault()),
// Decimal.valueOf(data.getOpen().toString()),
// Decimal.valueOf(data.getHigh().toString()),
// Decimal.valueOf(data.getLow().toString()),
// Decimal.valueOf(data.getClose().toString()),
// Decimal.valueOf(data.getVolume().toString()));
// }
//
// }
| import java.time.ZonedDateTime;
import java.util.List;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.knowm.xchange.currency.CurrencyPair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import ch.urbanfox.freqtrade.FreqTradeApplication;
import ch.urbanfox.freqtrade.analyze.AnalyzeService;
import ch.urbanfox.freqtrade.exchange.FreqTradeExchangeService;
import ch.urbanfox.freqtrade.exchange.converter.BittrexDataConverter;
import eu.verdelhan.ta4j.TimeSeries; | package ch.urbanfox.freqtrade.tester;
public class AnalyzeServiceTester {
private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeServiceTester.class);
public static void main(String[] args) throws Exception {
ApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
FreqTradeExchangeService exchangeService = context.getBean(FreqTradeExchangeService.class); | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeApplication.java
// @SpringBootApplication
// public class FreqTradeApplication {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeApplication.class);
//
// public static void main(String[] args) throws InterruptedException, TelegramApiException {
// LOGGER.info("Starting freqtrade...");
//
// ConfigurableApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
//
// LOGGER.info("freqtrade started.");
//
// FreqTradeMainRunner runner = context.getBean(FreqTradeMainRunner.class);
// runner.main();
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeService.java
// public interface AnalyzeService {
//
// /**
// * Calculates a buy signal based several technical analysis indicators
// *
// * @param tickers the tickers to analyze
// * @return true if pair is good for buying, false otherwise
// */
// boolean getBuySignal(TimeSeries tickers);
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeService.java
// public interface FreqTradeExchangeService {
//
// /**
// * Places a limit buy order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to purchase
// * @return orderId of the placed buy order
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// String buy(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get Ticker for given pair.
// *
// * @param pair Pair as str, format: BTC_ETC
// * @return the ticker
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// Ticker getTicker(CurrencyPair pair) throws IOException;
//
// /**
// * Places a limit sell order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to sell
// * @return the order ID
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// String sell(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get all open orders for given pair.
// *
// * @param pair the currency pair
// * @return list of orders
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// List<LimitOrder> getOpenOrders(CurrencyPair pair) throws IOException;
//
// /**
// * Returns the market detail url for the given pair
// *
// * @param pair pair as a String, format: BTC_ANT
// * @return url as a string
// */
// String getPairDetailUrl(String pair);
//
// /**
// * Get account balance.
// *
// * @param currency currency as str, format: BTC
// * @return balance
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// BigDecimal getBalance(Currency currency) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair, ZonedDateTime minimumDate) throws IOException;
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/converter/BittrexDataConverter.java
// public class BittrexDataConverter {
//
// public TimeSeries parseRawTickers(List<BittrexChartData> rawData) {
//
// List<Tick> ticks = rawData.stream()
// .map(this::convertTick)
// .collect(Collectors.toList());
//
// return new BaseTimeSeries(ticks);
// }
//
// private BaseTick convertTick(BittrexChartData data) {
//
// return new BaseTick(ZonedDateTime.ofInstant(data.getTimeStamp().toInstant(), ZoneId.systemDefault()),
// Decimal.valueOf(data.getOpen().toString()),
// Decimal.valueOf(data.getHigh().toString()),
// Decimal.valueOf(data.getLow().toString()),
// Decimal.valueOf(data.getClose().toString()),
// Decimal.valueOf(data.getVolume().toString()));
// }
//
// }
// Path: src/main/java/ch/urbanfox/freqtrade/tester/AnalyzeServiceTester.java
import java.time.ZonedDateTime;
import java.util.List;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.knowm.xchange.currency.CurrencyPair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import ch.urbanfox.freqtrade.FreqTradeApplication;
import ch.urbanfox.freqtrade.analyze.AnalyzeService;
import ch.urbanfox.freqtrade.exchange.FreqTradeExchangeService;
import ch.urbanfox.freqtrade.exchange.converter.BittrexDataConverter;
import eu.verdelhan.ta4j.TimeSeries;
package ch.urbanfox.freqtrade.tester;
public class AnalyzeServiceTester {
private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeServiceTester.class);
public static void main(String[] args) throws Exception {
ApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
FreqTradeExchangeService exchangeService = context.getBean(FreqTradeExchangeService.class); | AnalyzeService analyzeService = context.getBean(AnalyzeService.class); |
jeperon/freqtrade-java | src/main/java/ch/urbanfox/freqtrade/tester/AnalyzeServiceTester.java | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeApplication.java
// @SpringBootApplication
// public class FreqTradeApplication {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeApplication.class);
//
// public static void main(String[] args) throws InterruptedException, TelegramApiException {
// LOGGER.info("Starting freqtrade...");
//
// ConfigurableApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
//
// LOGGER.info("freqtrade started.");
//
// FreqTradeMainRunner runner = context.getBean(FreqTradeMainRunner.class);
// runner.main();
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeService.java
// public interface AnalyzeService {
//
// /**
// * Calculates a buy signal based several technical analysis indicators
// *
// * @param tickers the tickers to analyze
// * @return true if pair is good for buying, false otherwise
// */
// boolean getBuySignal(TimeSeries tickers);
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeService.java
// public interface FreqTradeExchangeService {
//
// /**
// * Places a limit buy order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to purchase
// * @return orderId of the placed buy order
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// String buy(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get Ticker for given pair.
// *
// * @param pair Pair as str, format: BTC_ETC
// * @return the ticker
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// Ticker getTicker(CurrencyPair pair) throws IOException;
//
// /**
// * Places a limit sell order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to sell
// * @return the order ID
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// String sell(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get all open orders for given pair.
// *
// * @param pair the currency pair
// * @return list of orders
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// List<LimitOrder> getOpenOrders(CurrencyPair pair) throws IOException;
//
// /**
// * Returns the market detail url for the given pair
// *
// * @param pair pair as a String, format: BTC_ANT
// * @return url as a string
// */
// String getPairDetailUrl(String pair);
//
// /**
// * Get account balance.
// *
// * @param currency currency as str, format: BTC
// * @return balance
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// BigDecimal getBalance(Currency currency) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair, ZonedDateTime minimumDate) throws IOException;
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/converter/BittrexDataConverter.java
// public class BittrexDataConverter {
//
// public TimeSeries parseRawTickers(List<BittrexChartData> rawData) {
//
// List<Tick> ticks = rawData.stream()
// .map(this::convertTick)
// .collect(Collectors.toList());
//
// return new BaseTimeSeries(ticks);
// }
//
// private BaseTick convertTick(BittrexChartData data) {
//
// return new BaseTick(ZonedDateTime.ofInstant(data.getTimeStamp().toInstant(), ZoneId.systemDefault()),
// Decimal.valueOf(data.getOpen().toString()),
// Decimal.valueOf(data.getHigh().toString()),
// Decimal.valueOf(data.getLow().toString()),
// Decimal.valueOf(data.getClose().toString()),
// Decimal.valueOf(data.getVolume().toString()));
// }
//
// }
| import java.time.ZonedDateTime;
import java.util.List;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.knowm.xchange.currency.CurrencyPair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import ch.urbanfox.freqtrade.FreqTradeApplication;
import ch.urbanfox.freqtrade.analyze.AnalyzeService;
import ch.urbanfox.freqtrade.exchange.FreqTradeExchangeService;
import ch.urbanfox.freqtrade.exchange.converter.BittrexDataConverter;
import eu.verdelhan.ta4j.TimeSeries; | package ch.urbanfox.freqtrade.tester;
public class AnalyzeServiceTester {
private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeServiceTester.class);
public static void main(String[] args) throws Exception {
ApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
FreqTradeExchangeService exchangeService = context.getBean(FreqTradeExchangeService.class);
AnalyzeService analyzeService = context.getBean(AnalyzeService.class);
ZonedDateTime minimumDate = ZonedDateTime.now().minusHours(6);
List<BittrexChartData> rawTickers = exchangeService.fetchRawticker(new CurrencyPair("ETH/BTC"), minimumDate); | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeApplication.java
// @SpringBootApplication
// public class FreqTradeApplication {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeApplication.class);
//
// public static void main(String[] args) throws InterruptedException, TelegramApiException {
// LOGGER.info("Starting freqtrade...");
//
// ConfigurableApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
//
// LOGGER.info("freqtrade started.");
//
// FreqTradeMainRunner runner = context.getBean(FreqTradeMainRunner.class);
// runner.main();
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/analyze/AnalyzeService.java
// public interface AnalyzeService {
//
// /**
// * Calculates a buy signal based several technical analysis indicators
// *
// * @param tickers the tickers to analyze
// * @return true if pair is good for buying, false otherwise
// */
// boolean getBuySignal(TimeSeries tickers);
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeService.java
// public interface FreqTradeExchangeService {
//
// /**
// * Places a limit buy order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to purchase
// * @return orderId of the placed buy order
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// String buy(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get Ticker for given pair.
// *
// * @param pair Pair as str, format: BTC_ETC
// * @return the ticker
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// Ticker getTicker(CurrencyPair pair) throws IOException;
//
// /**
// * Places a limit sell order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to sell
// * @return the order ID
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// String sell(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get all open orders for given pair.
// *
// * @param pair the currency pair
// * @return list of orders
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// List<LimitOrder> getOpenOrders(CurrencyPair pair) throws IOException;
//
// /**
// * Returns the market detail url for the given pair
// *
// * @param pair pair as a String, format: BTC_ANT
// * @return url as a string
// */
// String getPairDetailUrl(String pair);
//
// /**
// * Get account balance.
// *
// * @param currency currency as str, format: BTC
// * @return balance
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// BigDecimal getBalance(Currency currency) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair, ZonedDateTime minimumDate) throws IOException;
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/converter/BittrexDataConverter.java
// public class BittrexDataConverter {
//
// public TimeSeries parseRawTickers(List<BittrexChartData> rawData) {
//
// List<Tick> ticks = rawData.stream()
// .map(this::convertTick)
// .collect(Collectors.toList());
//
// return new BaseTimeSeries(ticks);
// }
//
// private BaseTick convertTick(BittrexChartData data) {
//
// return new BaseTick(ZonedDateTime.ofInstant(data.getTimeStamp().toInstant(), ZoneId.systemDefault()),
// Decimal.valueOf(data.getOpen().toString()),
// Decimal.valueOf(data.getHigh().toString()),
// Decimal.valueOf(data.getLow().toString()),
// Decimal.valueOf(data.getClose().toString()),
// Decimal.valueOf(data.getVolume().toString()));
// }
//
// }
// Path: src/main/java/ch/urbanfox/freqtrade/tester/AnalyzeServiceTester.java
import java.time.ZonedDateTime;
import java.util.List;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.knowm.xchange.currency.CurrencyPair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import ch.urbanfox.freqtrade.FreqTradeApplication;
import ch.urbanfox.freqtrade.analyze.AnalyzeService;
import ch.urbanfox.freqtrade.exchange.FreqTradeExchangeService;
import ch.urbanfox.freqtrade.exchange.converter.BittrexDataConverter;
import eu.verdelhan.ta4j.TimeSeries;
package ch.urbanfox.freqtrade.tester;
public class AnalyzeServiceTester {
private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeServiceTester.class);
public static void main(String[] args) throws Exception {
ApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
FreqTradeExchangeService exchangeService = context.getBean(FreqTradeExchangeService.class);
AnalyzeService analyzeService = context.getBean(AnalyzeService.class);
ZonedDateTime minimumDate = ZonedDateTime.now().minusHours(6);
List<BittrexChartData> rawTickers = exchangeService.fetchRawticker(new CurrencyPair("ETH/BTC"), minimumDate); | TimeSeries tickers = new BittrexDataConverter().parseRawTickers(rawTickers); |
jeperon/freqtrade-java | src/test/java/ch/urbanfox/freqtrade/telegram/TelegramServiceTester.java | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeApplication.java
// @SpringBootApplication
// public class FreqTradeApplication {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeApplication.class);
//
// public static void main(String[] args) throws InterruptedException, TelegramApiException {
// LOGGER.info("Starting freqtrade...");
//
// ConfigurableApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
//
// LOGGER.info("freqtrade started.");
//
// FreqTradeMainRunner runner = context.getBean(FreqTradeMainRunner.class);
// runner.main();
// }
//
// }
| import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import ch.urbanfox.freqtrade.FreqTradeApplication; | package ch.urbanfox.freqtrade.telegram;
/**
* Simple application to test you telegram configuration
*/
public class TelegramServiceTester {
public static void main(String[] args) throws Exception { | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeApplication.java
// @SpringBootApplication
// public class FreqTradeApplication {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeApplication.class);
//
// public static void main(String[] args) throws InterruptedException, TelegramApiException {
// LOGGER.info("Starting freqtrade...");
//
// ConfigurableApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
//
// LOGGER.info("freqtrade started.");
//
// FreqTradeMainRunner runner = context.getBean(FreqTradeMainRunner.class);
// runner.main();
// }
//
// }
// Path: src/test/java/ch/urbanfox/freqtrade/telegram/TelegramServiceTester.java
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import ch.urbanfox.freqtrade.FreqTradeApplication;
package ch.urbanfox.freqtrade.telegram;
/**
* Simple application to test you telegram configuration
*/
public class TelegramServiceTester {
public static void main(String[] args) throws Exception { | ApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args); |
jeperon/freqtrade-java | src/main/java/ch/urbanfox/freqtrade/trade/TradeServiceImpl.java | // Path: src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeService.java
// public interface FreqTradeExchangeService {
//
// /**
// * Places a limit buy order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to purchase
// * @return orderId of the placed buy order
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// String buy(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get Ticker for given pair.
// *
// * @param pair Pair as str, format: BTC_ETC
// * @return the ticker
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// Ticker getTicker(CurrencyPair pair) throws IOException;
//
// /**
// * Places a limit sell order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to sell
// * @return the order ID
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// String sell(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get all open orders for given pair.
// *
// * @param pair the currency pair
// * @return list of orders
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// List<LimitOrder> getOpenOrders(CurrencyPair pair) throws IOException;
//
// /**
// * Returns the market detail url for the given pair
// *
// * @param pair pair as a String, format: BTC_ANT
// * @return url as a string
// */
// String getPairDetailUrl(String pair);
//
// /**
// * Get account balance.
// *
// * @param currency currency as str, format: BTC
// * @return balance
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// BigDecimal getBalance(Currency currency) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair, ZonedDateTime minimumDate) throws IOException;
//
// }
| import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
import org.knowm.xchange.currency.CurrencyPair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ch.urbanfox.freqtrade.exchange.FreqTradeExchangeService; | package ch.urbanfox.freqtrade.trade;
@Service
@Transactional
public class TradeServiceImpl implements TradeService {
@Autowired
private TradeRepository tradeRepository;
@Autowired | // Path: src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeService.java
// public interface FreqTradeExchangeService {
//
// /**
// * Places a limit buy order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to purchase
// * @return orderId of the placed buy order
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// String buy(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get Ticker for given pair.
// *
// * @param pair Pair as str, format: BTC_ETC
// * @return the ticker
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// Ticker getTicker(CurrencyPair pair) throws IOException;
//
// /**
// * Places a limit sell order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to sell
// * @return the order ID
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// String sell(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get all open orders for given pair.
// *
// * @param pair the currency pair
// * @return list of orders
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// List<LimitOrder> getOpenOrders(CurrencyPair pair) throws IOException;
//
// /**
// * Returns the market detail url for the given pair
// *
// * @param pair pair as a String, format: BTC_ANT
// * @return url as a string
// */
// String getPairDetailUrl(String pair);
//
// /**
// * Get account balance.
// *
// * @param currency currency as str, format: BTC
// * @return balance
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// BigDecimal getBalance(Currency currency) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair, ZonedDateTime minimumDate) throws IOException;
//
// }
// Path: src/main/java/ch/urbanfox/freqtrade/trade/TradeServiceImpl.java
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
import org.knowm.xchange.currency.CurrencyPair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ch.urbanfox.freqtrade.exchange.FreqTradeExchangeService;
package ch.urbanfox.freqtrade.trade;
@Service
@Transactional
public class TradeServiceImpl implements TradeService {
@Autowired
private TradeRepository tradeRepository;
@Autowired | private FreqTradeExchangeService exchangeService; |
jeperon/freqtrade-java | src/main/java/ch/urbanfox/freqtrade/telegram/TelegramServiceImpl.java | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeProperties.java
// @Configuration
// @ConfigurationProperties(prefix = "freqtrade")
// public class FreqTradeProperties {
//
// private State initialState;
//
// private int maxOpenTrades;
//
// private Currency stakeCurrency;
//
// private BigDecimal stakeAmount;
//
// private boolean dryRun = false;
//
// private Map<Long, BigDecimal> minimalRoi = new TreeMap<>();
//
// private BigDecimal stopLoss;
//
// private List<CurrencyPair> pairWhitelist = new ArrayList<>();
//
// private BittrexProperties bittrex;
//
// private TelegramProperties telegram;
//
// public State getInitialState() {
// return initialState;
// }
//
// public void setInitialState(State initialState) {
// this.initialState = initialState;
// }
//
// public int getMaxOpenTrades() {
// return maxOpenTrades;
// }
//
// public void setMaxOpenTrades(int maxOpenTrades) {
// this.maxOpenTrades = maxOpenTrades;
// }
//
// public Currency getStakeCurrency() {
// return stakeCurrency;
// }
//
// public void setStakeCurrency(Currency stakeCurrency) {
// this.stakeCurrency = stakeCurrency;
// }
//
// public BigDecimal getStakeAmount() {
// return stakeAmount;
// }
//
// public void setStakeAmount(BigDecimal stakeAmount) {
// this.stakeAmount = stakeAmount;
// }
//
// public boolean isDryRun() {
// return dryRun;
// }
//
// public void setDryRun(boolean dryRun) {
// this.dryRun = dryRun;
// }
//
// public Map<Long, BigDecimal> getMinimalRoi() {
// return minimalRoi;
// }
//
// public void setMinimalRoi(Map<Long, BigDecimal> minimalRoi) {
// this.minimalRoi = minimalRoi;
// }
//
// public BigDecimal getStopLoss() {
// return stopLoss;
// }
//
// public void setStopLoss(BigDecimal stopLoss) {
// this.stopLoss = stopLoss;
// }
//
// public List<CurrencyPair> getPairWhitelist() {
// return pairWhitelist;
// }
//
// public void setPairWhitelist(List<CurrencyPair> pairWhitelist) {
// this.pairWhitelist = pairWhitelist;
// }
//
// public BittrexProperties getBittrex() {
// return bittrex;
// }
//
// public void setBittrex(BittrexProperties bittrex) {
// this.bittrex = bittrex;
// }
//
// public TelegramProperties getTelegram() {
// return telegram;
// }
//
// public void setTelegram(TelegramProperties telegram) {
// this.telegram = telegram;
// }
//
// }
| import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.telegram.telegrambots.ApiContextInitializer;
import org.telegram.telegrambots.TelegramBotsApi;
import org.telegram.telegrambots.api.methods.ParseMode;
import org.telegram.telegrambots.api.methods.send.SendMessage;
import org.telegram.telegrambots.exceptions.TelegramApiException;
import org.telegram.telegrambots.exceptions.TelegramApiRequestException;
import ch.urbanfox.freqtrade.FreqTradeProperties; | package ch.urbanfox.freqtrade.telegram;
/**
* Default implementation of the telegram service
*/
@Service
public class TelegramServiceImpl implements TelegramService {
private static final Logger LOGGER = LoggerFactory.getLogger(TelegramServiceImpl.class);
private final ApplicationContext context;
| // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeProperties.java
// @Configuration
// @ConfigurationProperties(prefix = "freqtrade")
// public class FreqTradeProperties {
//
// private State initialState;
//
// private int maxOpenTrades;
//
// private Currency stakeCurrency;
//
// private BigDecimal stakeAmount;
//
// private boolean dryRun = false;
//
// private Map<Long, BigDecimal> minimalRoi = new TreeMap<>();
//
// private BigDecimal stopLoss;
//
// private List<CurrencyPair> pairWhitelist = new ArrayList<>();
//
// private BittrexProperties bittrex;
//
// private TelegramProperties telegram;
//
// public State getInitialState() {
// return initialState;
// }
//
// public void setInitialState(State initialState) {
// this.initialState = initialState;
// }
//
// public int getMaxOpenTrades() {
// return maxOpenTrades;
// }
//
// public void setMaxOpenTrades(int maxOpenTrades) {
// this.maxOpenTrades = maxOpenTrades;
// }
//
// public Currency getStakeCurrency() {
// return stakeCurrency;
// }
//
// public void setStakeCurrency(Currency stakeCurrency) {
// this.stakeCurrency = stakeCurrency;
// }
//
// public BigDecimal getStakeAmount() {
// return stakeAmount;
// }
//
// public void setStakeAmount(BigDecimal stakeAmount) {
// this.stakeAmount = stakeAmount;
// }
//
// public boolean isDryRun() {
// return dryRun;
// }
//
// public void setDryRun(boolean dryRun) {
// this.dryRun = dryRun;
// }
//
// public Map<Long, BigDecimal> getMinimalRoi() {
// return minimalRoi;
// }
//
// public void setMinimalRoi(Map<Long, BigDecimal> minimalRoi) {
// this.minimalRoi = minimalRoi;
// }
//
// public BigDecimal getStopLoss() {
// return stopLoss;
// }
//
// public void setStopLoss(BigDecimal stopLoss) {
// this.stopLoss = stopLoss;
// }
//
// public List<CurrencyPair> getPairWhitelist() {
// return pairWhitelist;
// }
//
// public void setPairWhitelist(List<CurrencyPair> pairWhitelist) {
// this.pairWhitelist = pairWhitelist;
// }
//
// public BittrexProperties getBittrex() {
// return bittrex;
// }
//
// public void setBittrex(BittrexProperties bittrex) {
// this.bittrex = bittrex;
// }
//
// public TelegramProperties getTelegram() {
// return telegram;
// }
//
// public void setTelegram(TelegramProperties telegram) {
// this.telegram = telegram;
// }
//
// }
// Path: src/main/java/ch/urbanfox/freqtrade/telegram/TelegramServiceImpl.java
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.telegram.telegrambots.ApiContextInitializer;
import org.telegram.telegrambots.TelegramBotsApi;
import org.telegram.telegrambots.api.methods.ParseMode;
import org.telegram.telegrambots.api.methods.send.SendMessage;
import org.telegram.telegrambots.exceptions.TelegramApiException;
import org.telegram.telegrambots.exceptions.TelegramApiRequestException;
import ch.urbanfox.freqtrade.FreqTradeProperties;
package ch.urbanfox.freqtrade.telegram;
/**
* Default implementation of the telegram service
*/
@Service
public class TelegramServiceImpl implements TelegramService {
private static final Logger LOGGER = LoggerFactory.getLogger(TelegramServiceImpl.class);
private final ApplicationContext context;
| private final FreqTradeProperties properties; |
jeperon/freqtrade-java | src/main/java/ch/urbanfox/freqtrade/telegram/FreqTradeTelegramBot.java | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeProperties.java
// @Configuration
// @ConfigurationProperties(prefix = "freqtrade")
// public class FreqTradeProperties {
//
// private State initialState;
//
// private int maxOpenTrades;
//
// private Currency stakeCurrency;
//
// private BigDecimal stakeAmount;
//
// private boolean dryRun = false;
//
// private Map<Long, BigDecimal> minimalRoi = new TreeMap<>();
//
// private BigDecimal stopLoss;
//
// private List<CurrencyPair> pairWhitelist = new ArrayList<>();
//
// private BittrexProperties bittrex;
//
// private TelegramProperties telegram;
//
// public State getInitialState() {
// return initialState;
// }
//
// public void setInitialState(State initialState) {
// this.initialState = initialState;
// }
//
// public int getMaxOpenTrades() {
// return maxOpenTrades;
// }
//
// public void setMaxOpenTrades(int maxOpenTrades) {
// this.maxOpenTrades = maxOpenTrades;
// }
//
// public Currency getStakeCurrency() {
// return stakeCurrency;
// }
//
// public void setStakeCurrency(Currency stakeCurrency) {
// this.stakeCurrency = stakeCurrency;
// }
//
// public BigDecimal getStakeAmount() {
// return stakeAmount;
// }
//
// public void setStakeAmount(BigDecimal stakeAmount) {
// this.stakeAmount = stakeAmount;
// }
//
// public boolean isDryRun() {
// return dryRun;
// }
//
// public void setDryRun(boolean dryRun) {
// this.dryRun = dryRun;
// }
//
// public Map<Long, BigDecimal> getMinimalRoi() {
// return minimalRoi;
// }
//
// public void setMinimalRoi(Map<Long, BigDecimal> minimalRoi) {
// this.minimalRoi = minimalRoi;
// }
//
// public BigDecimal getStopLoss() {
// return stopLoss;
// }
//
// public void setStopLoss(BigDecimal stopLoss) {
// this.stopLoss = stopLoss;
// }
//
// public List<CurrencyPair> getPairWhitelist() {
// return pairWhitelist;
// }
//
// public void setPairWhitelist(List<CurrencyPair> pairWhitelist) {
// this.pairWhitelist = pairWhitelist;
// }
//
// public BittrexProperties getBittrex() {
// return bittrex;
// }
//
// public void setBittrex(BittrexProperties bittrex) {
// this.bittrex = bittrex;
// }
//
// public TelegramProperties getTelegram() {
// return telegram;
// }
//
// public void setTelegram(TelegramProperties telegram) {
// this.telegram = telegram;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/event/model/CommandEvent.java
// public class CommandEvent {
//
// private final String command;
//
// private final String[] params;
//
// public CommandEvent(String command, String... params) {
// this.command = command;
// this.params = params;
// }
//
// public String getCommand() {
// return command;
// }
//
// public String[] getParams() {
// return params;
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
// }
| import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.telegram.telegrambots.api.objects.Message;
import org.telegram.telegrambots.api.objects.Update;
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
import ch.urbanfox.freqtrade.FreqTradeProperties;
import ch.urbanfox.freqtrade.event.model.CommandEvent; | package ch.urbanfox.freqtrade.telegram;
public class FreqTradeTelegramBot extends TelegramLongPollingBot {
private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeTelegramBot.class);
private final ApplicationContext context;
private final TelegramProperties telegramProperties;
public FreqTradeTelegramBot(ApplicationContext context) {
this.context = context; | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeProperties.java
// @Configuration
// @ConfigurationProperties(prefix = "freqtrade")
// public class FreqTradeProperties {
//
// private State initialState;
//
// private int maxOpenTrades;
//
// private Currency stakeCurrency;
//
// private BigDecimal stakeAmount;
//
// private boolean dryRun = false;
//
// private Map<Long, BigDecimal> minimalRoi = new TreeMap<>();
//
// private BigDecimal stopLoss;
//
// private List<CurrencyPair> pairWhitelist = new ArrayList<>();
//
// private BittrexProperties bittrex;
//
// private TelegramProperties telegram;
//
// public State getInitialState() {
// return initialState;
// }
//
// public void setInitialState(State initialState) {
// this.initialState = initialState;
// }
//
// public int getMaxOpenTrades() {
// return maxOpenTrades;
// }
//
// public void setMaxOpenTrades(int maxOpenTrades) {
// this.maxOpenTrades = maxOpenTrades;
// }
//
// public Currency getStakeCurrency() {
// return stakeCurrency;
// }
//
// public void setStakeCurrency(Currency stakeCurrency) {
// this.stakeCurrency = stakeCurrency;
// }
//
// public BigDecimal getStakeAmount() {
// return stakeAmount;
// }
//
// public void setStakeAmount(BigDecimal stakeAmount) {
// this.stakeAmount = stakeAmount;
// }
//
// public boolean isDryRun() {
// return dryRun;
// }
//
// public void setDryRun(boolean dryRun) {
// this.dryRun = dryRun;
// }
//
// public Map<Long, BigDecimal> getMinimalRoi() {
// return minimalRoi;
// }
//
// public void setMinimalRoi(Map<Long, BigDecimal> minimalRoi) {
// this.minimalRoi = minimalRoi;
// }
//
// public BigDecimal getStopLoss() {
// return stopLoss;
// }
//
// public void setStopLoss(BigDecimal stopLoss) {
// this.stopLoss = stopLoss;
// }
//
// public List<CurrencyPair> getPairWhitelist() {
// return pairWhitelist;
// }
//
// public void setPairWhitelist(List<CurrencyPair> pairWhitelist) {
// this.pairWhitelist = pairWhitelist;
// }
//
// public BittrexProperties getBittrex() {
// return bittrex;
// }
//
// public void setBittrex(BittrexProperties bittrex) {
// this.bittrex = bittrex;
// }
//
// public TelegramProperties getTelegram() {
// return telegram;
// }
//
// public void setTelegram(TelegramProperties telegram) {
// this.telegram = telegram;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/event/model/CommandEvent.java
// public class CommandEvent {
//
// private final String command;
//
// private final String[] params;
//
// public CommandEvent(String command, String... params) {
// this.command = command;
// this.params = params;
// }
//
// public String getCommand() {
// return command;
// }
//
// public String[] getParams() {
// return params;
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
// }
// Path: src/main/java/ch/urbanfox/freqtrade/telegram/FreqTradeTelegramBot.java
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.telegram.telegrambots.api.objects.Message;
import org.telegram.telegrambots.api.objects.Update;
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
import ch.urbanfox.freqtrade.FreqTradeProperties;
import ch.urbanfox.freqtrade.event.model.CommandEvent;
package ch.urbanfox.freqtrade.telegram;
public class FreqTradeTelegramBot extends TelegramLongPollingBot {
private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeTelegramBot.class);
private final ApplicationContext context;
private final TelegramProperties telegramProperties;
public FreqTradeTelegramBot(ApplicationContext context) {
this.context = context; | FreqTradeProperties properties = context.getBean(FreqTradeProperties.class); |
jeperon/freqtrade-java | src/main/java/ch/urbanfox/freqtrade/telegram/FreqTradeTelegramBot.java | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeProperties.java
// @Configuration
// @ConfigurationProperties(prefix = "freqtrade")
// public class FreqTradeProperties {
//
// private State initialState;
//
// private int maxOpenTrades;
//
// private Currency stakeCurrency;
//
// private BigDecimal stakeAmount;
//
// private boolean dryRun = false;
//
// private Map<Long, BigDecimal> minimalRoi = new TreeMap<>();
//
// private BigDecimal stopLoss;
//
// private List<CurrencyPair> pairWhitelist = new ArrayList<>();
//
// private BittrexProperties bittrex;
//
// private TelegramProperties telegram;
//
// public State getInitialState() {
// return initialState;
// }
//
// public void setInitialState(State initialState) {
// this.initialState = initialState;
// }
//
// public int getMaxOpenTrades() {
// return maxOpenTrades;
// }
//
// public void setMaxOpenTrades(int maxOpenTrades) {
// this.maxOpenTrades = maxOpenTrades;
// }
//
// public Currency getStakeCurrency() {
// return stakeCurrency;
// }
//
// public void setStakeCurrency(Currency stakeCurrency) {
// this.stakeCurrency = stakeCurrency;
// }
//
// public BigDecimal getStakeAmount() {
// return stakeAmount;
// }
//
// public void setStakeAmount(BigDecimal stakeAmount) {
// this.stakeAmount = stakeAmount;
// }
//
// public boolean isDryRun() {
// return dryRun;
// }
//
// public void setDryRun(boolean dryRun) {
// this.dryRun = dryRun;
// }
//
// public Map<Long, BigDecimal> getMinimalRoi() {
// return minimalRoi;
// }
//
// public void setMinimalRoi(Map<Long, BigDecimal> minimalRoi) {
// this.minimalRoi = minimalRoi;
// }
//
// public BigDecimal getStopLoss() {
// return stopLoss;
// }
//
// public void setStopLoss(BigDecimal stopLoss) {
// this.stopLoss = stopLoss;
// }
//
// public List<CurrencyPair> getPairWhitelist() {
// return pairWhitelist;
// }
//
// public void setPairWhitelist(List<CurrencyPair> pairWhitelist) {
// this.pairWhitelist = pairWhitelist;
// }
//
// public BittrexProperties getBittrex() {
// return bittrex;
// }
//
// public void setBittrex(BittrexProperties bittrex) {
// this.bittrex = bittrex;
// }
//
// public TelegramProperties getTelegram() {
// return telegram;
// }
//
// public void setTelegram(TelegramProperties telegram) {
// this.telegram = telegram;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/event/model/CommandEvent.java
// public class CommandEvent {
//
// private final String command;
//
// private final String[] params;
//
// public CommandEvent(String command, String... params) {
// this.command = command;
// this.params = params;
// }
//
// public String getCommand() {
// return command;
// }
//
// public String[] getParams() {
// return params;
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
// }
| import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.telegram.telegrambots.api.objects.Message;
import org.telegram.telegrambots.api.objects.Update;
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
import ch.urbanfox.freqtrade.FreqTradeProperties;
import ch.urbanfox.freqtrade.event.model.CommandEvent; | package ch.urbanfox.freqtrade.telegram;
public class FreqTradeTelegramBot extends TelegramLongPollingBot {
private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeTelegramBot.class);
private final ApplicationContext context;
private final TelegramProperties telegramProperties;
public FreqTradeTelegramBot(ApplicationContext context) {
this.context = context;
FreqTradeProperties properties = context.getBean(FreqTradeProperties.class);
this.telegramProperties = properties.getTelegram();
}
@Override
public void onUpdateReceived(Update update) {
LOGGER.debug("Received: {}", update);
final Message message = Optional.ofNullable(update.getMessage()).orElse(update.getEditedMessage());
final Long chatId = message.getChatId();
if (!telegramProperties.getChatId().equals(chatId)) {
LOGGER.debug("Unauthorized access, ignoring (chat_id: {}, expected: {})", update.getMessage().getChatId(), telegramProperties.getChatId());
return;
}
final String command = message.getText(); | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeProperties.java
// @Configuration
// @ConfigurationProperties(prefix = "freqtrade")
// public class FreqTradeProperties {
//
// private State initialState;
//
// private int maxOpenTrades;
//
// private Currency stakeCurrency;
//
// private BigDecimal stakeAmount;
//
// private boolean dryRun = false;
//
// private Map<Long, BigDecimal> minimalRoi = new TreeMap<>();
//
// private BigDecimal stopLoss;
//
// private List<CurrencyPair> pairWhitelist = new ArrayList<>();
//
// private BittrexProperties bittrex;
//
// private TelegramProperties telegram;
//
// public State getInitialState() {
// return initialState;
// }
//
// public void setInitialState(State initialState) {
// this.initialState = initialState;
// }
//
// public int getMaxOpenTrades() {
// return maxOpenTrades;
// }
//
// public void setMaxOpenTrades(int maxOpenTrades) {
// this.maxOpenTrades = maxOpenTrades;
// }
//
// public Currency getStakeCurrency() {
// return stakeCurrency;
// }
//
// public void setStakeCurrency(Currency stakeCurrency) {
// this.stakeCurrency = stakeCurrency;
// }
//
// public BigDecimal getStakeAmount() {
// return stakeAmount;
// }
//
// public void setStakeAmount(BigDecimal stakeAmount) {
// this.stakeAmount = stakeAmount;
// }
//
// public boolean isDryRun() {
// return dryRun;
// }
//
// public void setDryRun(boolean dryRun) {
// this.dryRun = dryRun;
// }
//
// public Map<Long, BigDecimal> getMinimalRoi() {
// return minimalRoi;
// }
//
// public void setMinimalRoi(Map<Long, BigDecimal> minimalRoi) {
// this.minimalRoi = minimalRoi;
// }
//
// public BigDecimal getStopLoss() {
// return stopLoss;
// }
//
// public void setStopLoss(BigDecimal stopLoss) {
// this.stopLoss = stopLoss;
// }
//
// public List<CurrencyPair> getPairWhitelist() {
// return pairWhitelist;
// }
//
// public void setPairWhitelist(List<CurrencyPair> pairWhitelist) {
// this.pairWhitelist = pairWhitelist;
// }
//
// public BittrexProperties getBittrex() {
// return bittrex;
// }
//
// public void setBittrex(BittrexProperties bittrex) {
// this.bittrex = bittrex;
// }
//
// public TelegramProperties getTelegram() {
// return telegram;
// }
//
// public void setTelegram(TelegramProperties telegram) {
// this.telegram = telegram;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/event/model/CommandEvent.java
// public class CommandEvent {
//
// private final String command;
//
// private final String[] params;
//
// public CommandEvent(String command, String... params) {
// this.command = command;
// this.params = params;
// }
//
// public String getCommand() {
// return command;
// }
//
// public String[] getParams() {
// return params;
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
// }
// Path: src/main/java/ch/urbanfox/freqtrade/telegram/FreqTradeTelegramBot.java
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.telegram.telegrambots.api.objects.Message;
import org.telegram.telegrambots.api.objects.Update;
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
import ch.urbanfox.freqtrade.FreqTradeProperties;
import ch.urbanfox.freqtrade.event.model.CommandEvent;
package ch.urbanfox.freqtrade.telegram;
public class FreqTradeTelegramBot extends TelegramLongPollingBot {
private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeTelegramBot.class);
private final ApplicationContext context;
private final TelegramProperties telegramProperties;
public FreqTradeTelegramBot(ApplicationContext context) {
this.context = context;
FreqTradeProperties properties = context.getBean(FreqTradeProperties.class);
this.telegramProperties = properties.getTelegram();
}
@Override
public void onUpdateReceived(Update update) {
LOGGER.debug("Received: {}", update);
final Message message = Optional.ofNullable(update.getMessage()).orElse(update.getEditedMessage());
final Long chatId = message.getChatId();
if (!telegramProperties.getChatId().equals(chatId)) {
LOGGER.debug("Unauthorized access, ignoring (chat_id: {}, expected: {})", update.getMessage().getChatId(), telegramProperties.getChatId());
return;
}
final String command = message.getText(); | context.publishEvent(new CommandEvent(command)); |
jeperon/freqtrade-java | src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeServiceImpl.java | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeProperties.java
// @Configuration
// @ConfigurationProperties(prefix = "freqtrade")
// public class FreqTradeProperties {
//
// private State initialState;
//
// private int maxOpenTrades;
//
// private Currency stakeCurrency;
//
// private BigDecimal stakeAmount;
//
// private boolean dryRun = false;
//
// private Map<Long, BigDecimal> minimalRoi = new TreeMap<>();
//
// private BigDecimal stopLoss;
//
// private List<CurrencyPair> pairWhitelist = new ArrayList<>();
//
// private BittrexProperties bittrex;
//
// private TelegramProperties telegram;
//
// public State getInitialState() {
// return initialState;
// }
//
// public void setInitialState(State initialState) {
// this.initialState = initialState;
// }
//
// public int getMaxOpenTrades() {
// return maxOpenTrades;
// }
//
// public void setMaxOpenTrades(int maxOpenTrades) {
// this.maxOpenTrades = maxOpenTrades;
// }
//
// public Currency getStakeCurrency() {
// return stakeCurrency;
// }
//
// public void setStakeCurrency(Currency stakeCurrency) {
// this.stakeCurrency = stakeCurrency;
// }
//
// public BigDecimal getStakeAmount() {
// return stakeAmount;
// }
//
// public void setStakeAmount(BigDecimal stakeAmount) {
// this.stakeAmount = stakeAmount;
// }
//
// public boolean isDryRun() {
// return dryRun;
// }
//
// public void setDryRun(boolean dryRun) {
// this.dryRun = dryRun;
// }
//
// public Map<Long, BigDecimal> getMinimalRoi() {
// return minimalRoi;
// }
//
// public void setMinimalRoi(Map<Long, BigDecimal> minimalRoi) {
// this.minimalRoi = minimalRoi;
// }
//
// public BigDecimal getStopLoss() {
// return stopLoss;
// }
//
// public void setStopLoss(BigDecimal stopLoss) {
// this.stopLoss = stopLoss;
// }
//
// public List<CurrencyPair> getPairWhitelist() {
// return pairWhitelist;
// }
//
// public void setPairWhitelist(List<CurrencyPair> pairWhitelist) {
// this.pairWhitelist = pairWhitelist;
// }
//
// public BittrexProperties getBittrex() {
// return bittrex;
// }
//
// public void setBittrex(BittrexProperties bittrex) {
// this.bittrex = bittrex;
// }
//
// public TelegramProperties getTelegram() {
// return telegram;
// }
//
// public void setTelegram(TelegramProperties telegram) {
// this.telegram = telegram;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/exception/FreqTradeExchangeInitializationException.java
// public class FreqTradeExchangeInitializationException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public FreqTradeExchangeInitializationException(String message) {
// super(message);
// }
//
// }
| import java.io.IOException;
import java.math.BigDecimal;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import org.knowm.xchange.Exchange;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.knowm.xchange.bittrex.service.BittrexChartDataPeriodType;
import org.knowm.xchange.bittrex.service.BittrexMarketDataService;
import org.knowm.xchange.currency.Currency;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dto.Order.OrderType;
import org.knowm.xchange.dto.account.AccountInfo;
import org.knowm.xchange.dto.account.Balance;
import org.knowm.xchange.dto.account.Wallet;
import org.knowm.xchange.dto.marketdata.Ticker;
import org.knowm.xchange.dto.trade.LimitOrder;
import org.knowm.xchange.dto.trade.OpenOrders;
import org.knowm.xchange.service.account.AccountService;
import org.knowm.xchange.service.trade.TradeService;
import org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair;
import org.knowm.xchange.service.trade.params.orders.OpenOrdersParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ch.urbanfox.freqtrade.FreqTradeProperties;
import ch.urbanfox.freqtrade.exchange.exception.FreqTradeExchangeInitializationException; | package ch.urbanfox.freqtrade.exchange;
@Component
public class FreqTradeExchangeServiceImpl implements FreqTradeExchangeService {
private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeExchangeServiceImpl.class);
| // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeProperties.java
// @Configuration
// @ConfigurationProperties(prefix = "freqtrade")
// public class FreqTradeProperties {
//
// private State initialState;
//
// private int maxOpenTrades;
//
// private Currency stakeCurrency;
//
// private BigDecimal stakeAmount;
//
// private boolean dryRun = false;
//
// private Map<Long, BigDecimal> minimalRoi = new TreeMap<>();
//
// private BigDecimal stopLoss;
//
// private List<CurrencyPair> pairWhitelist = new ArrayList<>();
//
// private BittrexProperties bittrex;
//
// private TelegramProperties telegram;
//
// public State getInitialState() {
// return initialState;
// }
//
// public void setInitialState(State initialState) {
// this.initialState = initialState;
// }
//
// public int getMaxOpenTrades() {
// return maxOpenTrades;
// }
//
// public void setMaxOpenTrades(int maxOpenTrades) {
// this.maxOpenTrades = maxOpenTrades;
// }
//
// public Currency getStakeCurrency() {
// return stakeCurrency;
// }
//
// public void setStakeCurrency(Currency stakeCurrency) {
// this.stakeCurrency = stakeCurrency;
// }
//
// public BigDecimal getStakeAmount() {
// return stakeAmount;
// }
//
// public void setStakeAmount(BigDecimal stakeAmount) {
// this.stakeAmount = stakeAmount;
// }
//
// public boolean isDryRun() {
// return dryRun;
// }
//
// public void setDryRun(boolean dryRun) {
// this.dryRun = dryRun;
// }
//
// public Map<Long, BigDecimal> getMinimalRoi() {
// return minimalRoi;
// }
//
// public void setMinimalRoi(Map<Long, BigDecimal> minimalRoi) {
// this.minimalRoi = minimalRoi;
// }
//
// public BigDecimal getStopLoss() {
// return stopLoss;
// }
//
// public void setStopLoss(BigDecimal stopLoss) {
// this.stopLoss = stopLoss;
// }
//
// public List<CurrencyPair> getPairWhitelist() {
// return pairWhitelist;
// }
//
// public void setPairWhitelist(List<CurrencyPair> pairWhitelist) {
// this.pairWhitelist = pairWhitelist;
// }
//
// public BittrexProperties getBittrex() {
// return bittrex;
// }
//
// public void setBittrex(BittrexProperties bittrex) {
// this.bittrex = bittrex;
// }
//
// public TelegramProperties getTelegram() {
// return telegram;
// }
//
// public void setTelegram(TelegramProperties telegram) {
// this.telegram = telegram;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/exception/FreqTradeExchangeInitializationException.java
// public class FreqTradeExchangeInitializationException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public FreqTradeExchangeInitializationException(String message) {
// super(message);
// }
//
// }
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeServiceImpl.java
import java.io.IOException;
import java.math.BigDecimal;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import org.knowm.xchange.Exchange;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.knowm.xchange.bittrex.service.BittrexChartDataPeriodType;
import org.knowm.xchange.bittrex.service.BittrexMarketDataService;
import org.knowm.xchange.currency.Currency;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dto.Order.OrderType;
import org.knowm.xchange.dto.account.AccountInfo;
import org.knowm.xchange.dto.account.Balance;
import org.knowm.xchange.dto.account.Wallet;
import org.knowm.xchange.dto.marketdata.Ticker;
import org.knowm.xchange.dto.trade.LimitOrder;
import org.knowm.xchange.dto.trade.OpenOrders;
import org.knowm.xchange.service.account.AccountService;
import org.knowm.xchange.service.trade.TradeService;
import org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair;
import org.knowm.xchange.service.trade.params.orders.OpenOrdersParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ch.urbanfox.freqtrade.FreqTradeProperties;
import ch.urbanfox.freqtrade.exchange.exception.FreqTradeExchangeInitializationException;
package ch.urbanfox.freqtrade.exchange;
@Component
public class FreqTradeExchangeServiceImpl implements FreqTradeExchangeService {
private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeExchangeServiceImpl.class);
| private final FreqTradeProperties properties; |
jeperon/freqtrade-java | src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeServiceImpl.java | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeProperties.java
// @Configuration
// @ConfigurationProperties(prefix = "freqtrade")
// public class FreqTradeProperties {
//
// private State initialState;
//
// private int maxOpenTrades;
//
// private Currency stakeCurrency;
//
// private BigDecimal stakeAmount;
//
// private boolean dryRun = false;
//
// private Map<Long, BigDecimal> minimalRoi = new TreeMap<>();
//
// private BigDecimal stopLoss;
//
// private List<CurrencyPair> pairWhitelist = new ArrayList<>();
//
// private BittrexProperties bittrex;
//
// private TelegramProperties telegram;
//
// public State getInitialState() {
// return initialState;
// }
//
// public void setInitialState(State initialState) {
// this.initialState = initialState;
// }
//
// public int getMaxOpenTrades() {
// return maxOpenTrades;
// }
//
// public void setMaxOpenTrades(int maxOpenTrades) {
// this.maxOpenTrades = maxOpenTrades;
// }
//
// public Currency getStakeCurrency() {
// return stakeCurrency;
// }
//
// public void setStakeCurrency(Currency stakeCurrency) {
// this.stakeCurrency = stakeCurrency;
// }
//
// public BigDecimal getStakeAmount() {
// return stakeAmount;
// }
//
// public void setStakeAmount(BigDecimal stakeAmount) {
// this.stakeAmount = stakeAmount;
// }
//
// public boolean isDryRun() {
// return dryRun;
// }
//
// public void setDryRun(boolean dryRun) {
// this.dryRun = dryRun;
// }
//
// public Map<Long, BigDecimal> getMinimalRoi() {
// return minimalRoi;
// }
//
// public void setMinimalRoi(Map<Long, BigDecimal> minimalRoi) {
// this.minimalRoi = minimalRoi;
// }
//
// public BigDecimal getStopLoss() {
// return stopLoss;
// }
//
// public void setStopLoss(BigDecimal stopLoss) {
// this.stopLoss = stopLoss;
// }
//
// public List<CurrencyPair> getPairWhitelist() {
// return pairWhitelist;
// }
//
// public void setPairWhitelist(List<CurrencyPair> pairWhitelist) {
// this.pairWhitelist = pairWhitelist;
// }
//
// public BittrexProperties getBittrex() {
// return bittrex;
// }
//
// public void setBittrex(BittrexProperties bittrex) {
// this.bittrex = bittrex;
// }
//
// public TelegramProperties getTelegram() {
// return telegram;
// }
//
// public void setTelegram(TelegramProperties telegram) {
// this.telegram = telegram;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/exception/FreqTradeExchangeInitializationException.java
// public class FreqTradeExchangeInitializationException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public FreqTradeExchangeInitializationException(String message) {
// super(message);
// }
//
// }
| import java.io.IOException;
import java.math.BigDecimal;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import org.knowm.xchange.Exchange;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.knowm.xchange.bittrex.service.BittrexChartDataPeriodType;
import org.knowm.xchange.bittrex.service.BittrexMarketDataService;
import org.knowm.xchange.currency.Currency;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dto.Order.OrderType;
import org.knowm.xchange.dto.account.AccountInfo;
import org.knowm.xchange.dto.account.Balance;
import org.knowm.xchange.dto.account.Wallet;
import org.knowm.xchange.dto.marketdata.Ticker;
import org.knowm.xchange.dto.trade.LimitOrder;
import org.knowm.xchange.dto.trade.OpenOrders;
import org.knowm.xchange.service.account.AccountService;
import org.knowm.xchange.service.trade.TradeService;
import org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair;
import org.knowm.xchange.service.trade.params.orders.OpenOrdersParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ch.urbanfox.freqtrade.FreqTradeProperties;
import ch.urbanfox.freqtrade.exchange.exception.FreqTradeExchangeInitializationException; | package ch.urbanfox.freqtrade.exchange;
@Component
public class FreqTradeExchangeServiceImpl implements FreqTradeExchangeService {
private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeExchangeServiceImpl.class);
private final FreqTradeProperties properties;
/**
* Current selected exchange
*/
private final Exchange exchange;
private final BittrexMarketDataService marketDataService;
private final AccountService accountService;
private final TradeService tradeService;
@Autowired
public FreqTradeExchangeServiceImpl(FreqTradeProperties properties, Exchange exchange) {
this.properties = properties;
this.exchange = exchange;
marketDataService = (BittrexMarketDataService) exchange.getMarketDataService();
accountService = exchange.getAccountService();
tradeService = exchange.getTradeService();
if (properties.isDryRun()) {
LOGGER.info("Instance is running with dry_run enabled");
}
// Check if all pairs are available
List<CurrencyPair> markets = getMarkets();
for (CurrencyPair pair : properties.getPairWhitelist()) {
if (!markets.contains(pair)) { | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeProperties.java
// @Configuration
// @ConfigurationProperties(prefix = "freqtrade")
// public class FreqTradeProperties {
//
// private State initialState;
//
// private int maxOpenTrades;
//
// private Currency stakeCurrency;
//
// private BigDecimal stakeAmount;
//
// private boolean dryRun = false;
//
// private Map<Long, BigDecimal> minimalRoi = new TreeMap<>();
//
// private BigDecimal stopLoss;
//
// private List<CurrencyPair> pairWhitelist = new ArrayList<>();
//
// private BittrexProperties bittrex;
//
// private TelegramProperties telegram;
//
// public State getInitialState() {
// return initialState;
// }
//
// public void setInitialState(State initialState) {
// this.initialState = initialState;
// }
//
// public int getMaxOpenTrades() {
// return maxOpenTrades;
// }
//
// public void setMaxOpenTrades(int maxOpenTrades) {
// this.maxOpenTrades = maxOpenTrades;
// }
//
// public Currency getStakeCurrency() {
// return stakeCurrency;
// }
//
// public void setStakeCurrency(Currency stakeCurrency) {
// this.stakeCurrency = stakeCurrency;
// }
//
// public BigDecimal getStakeAmount() {
// return stakeAmount;
// }
//
// public void setStakeAmount(BigDecimal stakeAmount) {
// this.stakeAmount = stakeAmount;
// }
//
// public boolean isDryRun() {
// return dryRun;
// }
//
// public void setDryRun(boolean dryRun) {
// this.dryRun = dryRun;
// }
//
// public Map<Long, BigDecimal> getMinimalRoi() {
// return minimalRoi;
// }
//
// public void setMinimalRoi(Map<Long, BigDecimal> minimalRoi) {
// this.minimalRoi = minimalRoi;
// }
//
// public BigDecimal getStopLoss() {
// return stopLoss;
// }
//
// public void setStopLoss(BigDecimal stopLoss) {
// this.stopLoss = stopLoss;
// }
//
// public List<CurrencyPair> getPairWhitelist() {
// return pairWhitelist;
// }
//
// public void setPairWhitelist(List<CurrencyPair> pairWhitelist) {
// this.pairWhitelist = pairWhitelist;
// }
//
// public BittrexProperties getBittrex() {
// return bittrex;
// }
//
// public void setBittrex(BittrexProperties bittrex) {
// this.bittrex = bittrex;
// }
//
// public TelegramProperties getTelegram() {
// return telegram;
// }
//
// public void setTelegram(TelegramProperties telegram) {
// this.telegram = telegram;
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/exception/FreqTradeExchangeInitializationException.java
// public class FreqTradeExchangeInitializationException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// public FreqTradeExchangeInitializationException(String message) {
// super(message);
// }
//
// }
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeServiceImpl.java
import java.io.IOException;
import java.math.BigDecimal;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import org.knowm.xchange.Exchange;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.knowm.xchange.bittrex.service.BittrexChartDataPeriodType;
import org.knowm.xchange.bittrex.service.BittrexMarketDataService;
import org.knowm.xchange.currency.Currency;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dto.Order.OrderType;
import org.knowm.xchange.dto.account.AccountInfo;
import org.knowm.xchange.dto.account.Balance;
import org.knowm.xchange.dto.account.Wallet;
import org.knowm.xchange.dto.marketdata.Ticker;
import org.knowm.xchange.dto.trade.LimitOrder;
import org.knowm.xchange.dto.trade.OpenOrders;
import org.knowm.xchange.service.account.AccountService;
import org.knowm.xchange.service.trade.TradeService;
import org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair;
import org.knowm.xchange.service.trade.params.orders.OpenOrdersParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ch.urbanfox.freqtrade.FreqTradeProperties;
import ch.urbanfox.freqtrade.exchange.exception.FreqTradeExchangeInitializationException;
package ch.urbanfox.freqtrade.exchange;
@Component
public class FreqTradeExchangeServiceImpl implements FreqTradeExchangeService {
private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeExchangeServiceImpl.class);
private final FreqTradeProperties properties;
/**
* Current selected exchange
*/
private final Exchange exchange;
private final BittrexMarketDataService marketDataService;
private final AccountService accountService;
private final TradeService tradeService;
@Autowired
public FreqTradeExchangeServiceImpl(FreqTradeProperties properties, Exchange exchange) {
this.properties = properties;
this.exchange = exchange;
marketDataService = (BittrexMarketDataService) exchange.getMarketDataService();
accountService = exchange.getAccountService();
tradeService = exchange.getTradeService();
if (properties.isDryRun()) {
LOGGER.info("Instance is running with dry_run enabled");
}
// Check if all pairs are available
List<CurrencyPair> markets = getMarkets();
for (CurrencyPair pair : properties.getPairWhitelist()) {
if (!markets.contains(pair)) { | throw new FreqTradeExchangeInitializationException("Pair: " + pair + " is not available"); |
jeperon/freqtrade-java | src/main/java/ch/urbanfox/freqtrade/telegram/command/AbstractCommandHandler.java | // Path: src/main/java/ch/urbanfox/freqtrade/event/model/CommandEvent.java
// public class CommandEvent {
//
// private final String command;
//
// private final String[] params;
//
// public CommandEvent(String command, String... params) {
// this.command = command;
// this.params = params;
// }
//
// public String getCommand() {
// return command;
// }
//
// public String[] getParams() {
// return params;
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
// }
| import org.springframework.context.event.EventListener;
import ch.urbanfox.freqtrade.event.model.CommandEvent;
import jersey.repackaged.com.google.common.base.Objects; | package ch.urbanfox.freqtrade.telegram.command;
public abstract class AbstractCommandHandler implements CommandHandler {
@EventListener | // Path: src/main/java/ch/urbanfox/freqtrade/event/model/CommandEvent.java
// public class CommandEvent {
//
// private final String command;
//
// private final String[] params;
//
// public CommandEvent(String command, String... params) {
// this.command = command;
// this.params = params;
// }
//
// public String getCommand() {
// return command;
// }
//
// public String[] getParams() {
// return params;
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
// }
// }
// Path: src/main/java/ch/urbanfox/freqtrade/telegram/command/AbstractCommandHandler.java
import org.springframework.context.event.EventListener;
import ch.urbanfox.freqtrade.event.model.CommandEvent;
import jersey.repackaged.com.google.common.base.Objects;
package ch.urbanfox.freqtrade.telegram.command;
public abstract class AbstractCommandHandler implements CommandHandler {
@EventListener | public void eventListener(CommandEvent event) throws Exception { |
jeperon/freqtrade-java | src/test/java/ch/urbanfox/freqtrade/tester/GatherTestDataTester.java | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeApplication.java
// @SpringBootApplication
// public class FreqTradeApplication {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeApplication.class);
//
// public static void main(String[] args) throws InterruptedException, TelegramApiException {
// LOGGER.info("Starting freqtrade...");
//
// ConfigurableApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
//
// LOGGER.info("freqtrade started.");
//
// FreqTradeMainRunner runner = context.getBean(FreqTradeMainRunner.class);
// runner.main();
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeService.java
// public interface FreqTradeExchangeService {
//
// /**
// * Places a limit buy order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to purchase
// * @return orderId of the placed buy order
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// String buy(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get Ticker for given pair.
// *
// * @param pair Pair as str, format: BTC_ETC
// * @return the ticker
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// Ticker getTicker(CurrencyPair pair) throws IOException;
//
// /**
// * Places a limit sell order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to sell
// * @return the order ID
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// String sell(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get all open orders for given pair.
// *
// * @param pair the currency pair
// * @return list of orders
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// List<LimitOrder> getOpenOrders(CurrencyPair pair) throws IOException;
//
// /**
// * Returns the market detail url for the given pair
// *
// * @param pair pair as a String, format: BTC_ANT
// * @return url as a string
// */
// String getPairDetailUrl(String pair);
//
// /**
// * Get account balance.
// *
// * @param currency currency as str, format: BTC
// * @return balance
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// BigDecimal getBalance(Currency currency) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair, ZonedDateTime minimumDate) throws IOException;
//
// }
| import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.knowm.xchange.currency.CurrencyPair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import com.fasterxml.jackson.databind.ObjectMapper;
import ch.urbanfox.freqtrade.FreqTradeApplication;
import ch.urbanfox.freqtrade.exchange.FreqTradeExchangeService; | package ch.urbanfox.freqtrade.tester;
public class GatherTestDataTester {
private static final Logger LOGGER = LoggerFactory.getLogger(GatherTestDataTester.class);
private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS";
public static void main(String[] args) throws IOException {
| // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeApplication.java
// @SpringBootApplication
// public class FreqTradeApplication {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeApplication.class);
//
// public static void main(String[] args) throws InterruptedException, TelegramApiException {
// LOGGER.info("Starting freqtrade...");
//
// ConfigurableApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
//
// LOGGER.info("freqtrade started.");
//
// FreqTradeMainRunner runner = context.getBean(FreqTradeMainRunner.class);
// runner.main();
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeService.java
// public interface FreqTradeExchangeService {
//
// /**
// * Places a limit buy order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to purchase
// * @return orderId of the placed buy order
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// String buy(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get Ticker for given pair.
// *
// * @param pair Pair as str, format: BTC_ETC
// * @return the ticker
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// Ticker getTicker(CurrencyPair pair) throws IOException;
//
// /**
// * Places a limit sell order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to sell
// * @return the order ID
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// String sell(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get all open orders for given pair.
// *
// * @param pair the currency pair
// * @return list of orders
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// List<LimitOrder> getOpenOrders(CurrencyPair pair) throws IOException;
//
// /**
// * Returns the market detail url for the given pair
// *
// * @param pair pair as a String, format: BTC_ANT
// * @return url as a string
// */
// String getPairDetailUrl(String pair);
//
// /**
// * Get account balance.
// *
// * @param currency currency as str, format: BTC
// * @return balance
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// BigDecimal getBalance(Currency currency) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair, ZonedDateTime minimumDate) throws IOException;
//
// }
// Path: src/test/java/ch/urbanfox/freqtrade/tester/GatherTestDataTester.java
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.knowm.xchange.currency.CurrencyPair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import com.fasterxml.jackson.databind.ObjectMapper;
import ch.urbanfox.freqtrade.FreqTradeApplication;
import ch.urbanfox.freqtrade.exchange.FreqTradeExchangeService;
package ch.urbanfox.freqtrade.tester;
public class GatherTestDataTester {
private static final Logger LOGGER = LoggerFactory.getLogger(GatherTestDataTester.class);
private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS";
public static void main(String[] args) throws IOException {
| ApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args); |
jeperon/freqtrade-java | src/test/java/ch/urbanfox/freqtrade/tester/GatherTestDataTester.java | // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeApplication.java
// @SpringBootApplication
// public class FreqTradeApplication {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeApplication.class);
//
// public static void main(String[] args) throws InterruptedException, TelegramApiException {
// LOGGER.info("Starting freqtrade...");
//
// ConfigurableApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
//
// LOGGER.info("freqtrade started.");
//
// FreqTradeMainRunner runner = context.getBean(FreqTradeMainRunner.class);
// runner.main();
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeService.java
// public interface FreqTradeExchangeService {
//
// /**
// * Places a limit buy order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to purchase
// * @return orderId of the placed buy order
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// String buy(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get Ticker for given pair.
// *
// * @param pair Pair as str, format: BTC_ETC
// * @return the ticker
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// Ticker getTicker(CurrencyPair pair) throws IOException;
//
// /**
// * Places a limit sell order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to sell
// * @return the order ID
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// String sell(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get all open orders for given pair.
// *
// * @param pair the currency pair
// * @return list of orders
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// List<LimitOrder> getOpenOrders(CurrencyPair pair) throws IOException;
//
// /**
// * Returns the market detail url for the given pair
// *
// * @param pair pair as a String, format: BTC_ANT
// * @return url as a string
// */
// String getPairDetailUrl(String pair);
//
// /**
// * Get account balance.
// *
// * @param currency currency as str, format: BTC
// * @return balance
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// BigDecimal getBalance(Currency currency) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair, ZonedDateTime minimumDate) throws IOException;
//
// }
| import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.knowm.xchange.currency.CurrencyPair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import com.fasterxml.jackson.databind.ObjectMapper;
import ch.urbanfox.freqtrade.FreqTradeApplication;
import ch.urbanfox.freqtrade.exchange.FreqTradeExchangeService; | package ch.urbanfox.freqtrade.tester;
public class GatherTestDataTester {
private static final Logger LOGGER = LoggerFactory.getLogger(GatherTestDataTester.class);
private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS";
public static void main(String[] args) throws IOException {
ApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
| // Path: src/main/java/ch/urbanfox/freqtrade/FreqTradeApplication.java
// @SpringBootApplication
// public class FreqTradeApplication {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(FreqTradeApplication.class);
//
// public static void main(String[] args) throws InterruptedException, TelegramApiException {
// LOGGER.info("Starting freqtrade...");
//
// ConfigurableApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
//
// LOGGER.info("freqtrade started.");
//
// FreqTradeMainRunner runner = context.getBean(FreqTradeMainRunner.class);
// runner.main();
// }
//
// }
//
// Path: src/main/java/ch/urbanfox/freqtrade/exchange/FreqTradeExchangeService.java
// public interface FreqTradeExchangeService {
//
// /**
// * Places a limit buy order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to purchase
// * @return orderId of the placed buy order
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// String buy(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get Ticker for given pair.
// *
// * @param pair Pair as str, format: BTC_ETC
// * @return the ticker
// *
// * @throws IOException if any error occur while contacting the exchange
// */
// Ticker getTicker(CurrencyPair pair) throws IOException;
//
// /**
// * Places a limit sell order.
// *
// * @param pair currency pair
// * @param rate Rate limit for order
// * @param amount The amount to sell
// * @return the order ID
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// String sell(CurrencyPair pair, BigDecimal rate, BigDecimal amount) throws IOException;
//
// /**
// * Get all open orders for given pair.
// *
// * @param pair the currency pair
// * @return list of orders
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// List<LimitOrder> getOpenOrders(CurrencyPair pair) throws IOException;
//
// /**
// * Returns the market detail url for the given pair
// *
// * @param pair pair as a String, format: BTC_ANT
// * @return url as a string
// */
// String getPairDetailUrl(String pair);
//
// /**
// * Get account balance.
// *
// * @param currency currency as str, format: BTC
// * @return balance
// *
// * @throws IOException if any communication error occur while contacting the
// * exchange
// */
// BigDecimal getBalance(Currency currency) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair) throws IOException;
//
// /**
// * Request ticker data from Bittrex for a given currency pair
// */
// List<BittrexChartData> fetchRawticker(CurrencyPair pair, ZonedDateTime minimumDate) throws IOException;
//
// }
// Path: src/test/java/ch/urbanfox/freqtrade/tester/GatherTestDataTester.java
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.knowm.xchange.bittrex.dto.marketdata.BittrexChartData;
import org.knowm.xchange.currency.CurrencyPair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import com.fasterxml.jackson.databind.ObjectMapper;
import ch.urbanfox.freqtrade.FreqTradeApplication;
import ch.urbanfox.freqtrade.exchange.FreqTradeExchangeService;
package ch.urbanfox.freqtrade.tester;
public class GatherTestDataTester {
private static final Logger LOGGER = LoggerFactory.getLogger(GatherTestDataTester.class);
private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS";
public static void main(String[] args) throws IOException {
ApplicationContext context = SpringApplication.run(FreqTradeApplication.class, args);
| FreqTradeExchangeService exchangeService = context.getBean(FreqTradeExchangeService.class); |
gastaldi/jira-maven-plugin | src/test/java/com/github/gastaldi/jira/GenerateReleaseNotesMojoTest.java | // Path: src/main/java/com/github/gastaldi/jira/GenerateReleaseNotesMojo.java
// public class GenerateReleaseNotesMojo extends AbstractJiraMojo {
//
// /**
// * JQL Template to generate release notes. Parameter 0 = Project Key
// * Parameter 1 = Fix version
// *
// * @parameter expression="${jqlTemplate}"
// * @required
// */
// String jqlTemplate = "project = ''{0}'' AND status in (Resolved, Closed) AND fixVersion = ''{1}''";
//
// /**
// * Template used on each issue found by JQL Template. Parameter 0 = Issue
// * Key Parameter 1 = Issue Summary
// *
// * @parameter expression="${issueTemplate}"
// * @required
// */
// String issueTemplate = "[{0}] {1}";
//
// /**
// * Max number of issues to return
// *
// * @parameter expression="${maxIssues}" default-value="100"
// * @required
// */
// int maxIssues = 100;
//
// /**
// * Released Version
// *
// * @parameter expression="${releaseVersion}"
// * default-value="${project.version}"
// * @required
// */
// String releaseVersion;
//
// /**
// * Target file
// *
// * @parameter expression="${targetFile}"
// * default-value="${outputDirectory}/releaseNotes.txt"
// * @required
// */
// File targetFile;
//
// /**
// * Text to be appended BEFORE all issues details.
// *
// * @parameter expression="${beforeText}"
// */
// String beforeText;
//
// /**
// * Text to be appended AFTER all issues details.
// *
// * @parameter expression="${afterText}"
// */
// String afterText;
//
// @Override
// public void doExecute(JiraSoapService jiraService, String loginToken)
// throws Exception {
// RemoteIssue[] issues = getIssues(jiraService, loginToken);
// output(issues);
// }
//
// /**
// * Recover issues from JIRA based on JQL Filter
// *
// * @param jiraService
// * @param loginToken
// * @return
// * @throws RemoteException
// * @throws com.atlassian.jira.rpc.soap.client.RemoteException
// */
// RemoteIssue[] getIssues(JiraSoapService jiraService, String loginToken)
// throws RemoteException,
// com.atlassian.jira.rpc.soap.client.RemoteException {
// Log log = getLog();
// String jql = format(jqlTemplate, jiraProjectKey, releaseVersion);
// if (log.isInfoEnabled()) {
// log.info("JQL: " + jql);
// }
// RemoteIssue[] issues = jiraService.getIssuesFromJqlSearch(loginToken,
// jql, maxIssues);
// if (log.isInfoEnabled()) {
// log.info("Issues: " + issues.length);
// }
// return issues;
// }
//
// /**
// * Writes issues to output
// *
// * @param issues
// */
// void output(RemoteIssue[] issues) throws IOException {
// Log log = getLog();
// if (targetFile == null) {
// log.warn("No targetFile specified. Ignoring");
// return;
// }
// if (issues == null) {
// log.warn("No issues found. File will not be generated.");
// return;
// }
// OutputStreamWriter writer = new OutputStreamWriter(
// new FileOutputStream(targetFile, true), "Cp1252");
// PrintWriter ps = new PrintWriter(writer);
// try {
// if (beforeText != null) {
// ps.println(beforeText);
// }
// for (RemoteIssue issue : issues) {
// String issueDesc = format(issueTemplate, issue.getKey(),
// issue.getSummary());
// ps.println(issueDesc);
// }
// if (afterText != null) {
// ps.println(afterText);
// }
// } finally {
// ps.flush();
// ps.close();
// }
// }
//
// public void setAfterText(String afterText) {
// this.afterText = afterText;
// }
//
// public void setBeforeText(String beforeText) {
// this.beforeText = beforeText;
// }
//
// public void setReleaseVersion(String releaseVersion) {
// this.releaseVersion = releaseVersion;
// }
//
// public void setIssueTemplate(String issueTemplate) {
// this.issueTemplate = issueTemplate;
// }
//
// public void setJqlTemplate(String jqlTemplate) {
// this.jqlTemplate = jqlTemplate;
// }
// }
| import java.io.File;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import com.github.gastaldi.jira.GenerateReleaseNotesMojo;
| package com.github.gastaldi.jira;
@RunWith(JUnit4.class)
public class GenerateReleaseNotesMojoTest extends AbstractMojoTestCase {
| // Path: src/main/java/com/github/gastaldi/jira/GenerateReleaseNotesMojo.java
// public class GenerateReleaseNotesMojo extends AbstractJiraMojo {
//
// /**
// * JQL Template to generate release notes. Parameter 0 = Project Key
// * Parameter 1 = Fix version
// *
// * @parameter expression="${jqlTemplate}"
// * @required
// */
// String jqlTemplate = "project = ''{0}'' AND status in (Resolved, Closed) AND fixVersion = ''{1}''";
//
// /**
// * Template used on each issue found by JQL Template. Parameter 0 = Issue
// * Key Parameter 1 = Issue Summary
// *
// * @parameter expression="${issueTemplate}"
// * @required
// */
// String issueTemplate = "[{0}] {1}";
//
// /**
// * Max number of issues to return
// *
// * @parameter expression="${maxIssues}" default-value="100"
// * @required
// */
// int maxIssues = 100;
//
// /**
// * Released Version
// *
// * @parameter expression="${releaseVersion}"
// * default-value="${project.version}"
// * @required
// */
// String releaseVersion;
//
// /**
// * Target file
// *
// * @parameter expression="${targetFile}"
// * default-value="${outputDirectory}/releaseNotes.txt"
// * @required
// */
// File targetFile;
//
// /**
// * Text to be appended BEFORE all issues details.
// *
// * @parameter expression="${beforeText}"
// */
// String beforeText;
//
// /**
// * Text to be appended AFTER all issues details.
// *
// * @parameter expression="${afterText}"
// */
// String afterText;
//
// @Override
// public void doExecute(JiraSoapService jiraService, String loginToken)
// throws Exception {
// RemoteIssue[] issues = getIssues(jiraService, loginToken);
// output(issues);
// }
//
// /**
// * Recover issues from JIRA based on JQL Filter
// *
// * @param jiraService
// * @param loginToken
// * @return
// * @throws RemoteException
// * @throws com.atlassian.jira.rpc.soap.client.RemoteException
// */
// RemoteIssue[] getIssues(JiraSoapService jiraService, String loginToken)
// throws RemoteException,
// com.atlassian.jira.rpc.soap.client.RemoteException {
// Log log = getLog();
// String jql = format(jqlTemplate, jiraProjectKey, releaseVersion);
// if (log.isInfoEnabled()) {
// log.info("JQL: " + jql);
// }
// RemoteIssue[] issues = jiraService.getIssuesFromJqlSearch(loginToken,
// jql, maxIssues);
// if (log.isInfoEnabled()) {
// log.info("Issues: " + issues.length);
// }
// return issues;
// }
//
// /**
// * Writes issues to output
// *
// * @param issues
// */
// void output(RemoteIssue[] issues) throws IOException {
// Log log = getLog();
// if (targetFile == null) {
// log.warn("No targetFile specified. Ignoring");
// return;
// }
// if (issues == null) {
// log.warn("No issues found. File will not be generated.");
// return;
// }
// OutputStreamWriter writer = new OutputStreamWriter(
// new FileOutputStream(targetFile, true), "Cp1252");
// PrintWriter ps = new PrintWriter(writer);
// try {
// if (beforeText != null) {
// ps.println(beforeText);
// }
// for (RemoteIssue issue : issues) {
// String issueDesc = format(issueTemplate, issue.getKey(),
// issue.getSummary());
// ps.println(issueDesc);
// }
// if (afterText != null) {
// ps.println(afterText);
// }
// } finally {
// ps.flush();
// ps.close();
// }
// }
//
// public void setAfterText(String afterText) {
// this.afterText = afterText;
// }
//
// public void setBeforeText(String beforeText) {
// this.beforeText = beforeText;
// }
//
// public void setReleaseVersion(String releaseVersion) {
// this.releaseVersion = releaseVersion;
// }
//
// public void setIssueTemplate(String issueTemplate) {
// this.issueTemplate = issueTemplate;
// }
//
// public void setJqlTemplate(String jqlTemplate) {
// this.jqlTemplate = jqlTemplate;
// }
// }
// Path: src/test/java/com/github/gastaldi/jira/GenerateReleaseNotesMojoTest.java
import java.io.File;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import com.github.gastaldi.jira.GenerateReleaseNotesMojo;
package com.github.gastaldi.jira;
@RunWith(JUnit4.class)
public class GenerateReleaseNotesMojoTest extends AbstractMojoTestCase {
| private GenerateReleaseNotesMojo mojo;
|
meruvian/yama | webapi/src/main/java/org/meruvian/yama/webapi/service/commons/FileInfoService.java | // Path: core/src/main/java/org/meruvian/yama/core/commons/FileInfoRepository.java
// @Repository
// public interface FileInfoRepository extends DefaultRepository<FileInfo> {
//
// }
| import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.inject.Inject;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.meruvian.yama.core.commons.FileInfo;
import org.meruvian.yama.core.commons.FileInfoRepository;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service; | /**
* Copyright 2014 Meruvian
*
* 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 org.meruvian.yama.webapi.service.commons;
/**
* @author Dian Aditya
*
*/
@Service
@Transactional
public class FileInfoService implements EnvironmentAware {
@Inject | // Path: core/src/main/java/org/meruvian/yama/core/commons/FileInfoRepository.java
// @Repository
// public interface FileInfoRepository extends DefaultRepository<FileInfo> {
//
// }
// Path: webapi/src/main/java/org/meruvian/yama/webapi/service/commons/FileInfoService.java
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.inject.Inject;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.meruvian.yama.core.commons.FileInfo;
import org.meruvian.yama.core.commons.FileInfoRepository;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
/**
* Copyright 2014 Meruvian
*
* 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 org.meruvian.yama.webapi.service.commons;
/**
* @author Dian Aditya
*
*/
@Service
@Transactional
public class FileInfoService implements EnvironmentAware {
@Inject | private FileInfoRepository fileInfoRepository; |
meruvian/yama | core/src/main/java/org/meruvian/yama/core/user/User.java | // Path: core/src/main/java/org/meruvian/yama/core/DefaultPersistence.java
// @MappedSuperclass
// public class DefaultPersistence {
// protected String id;
// protected LogInformation logInformation = new LogInformation();
//
// @Id()
// @GeneratedValue(generator = "system-uuid")
// @GenericGenerator(name = "system-uuid", strategy = "uuid2")
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// @Embedded
// public LogInformation getLogInformation() {
// return logInformation;
// }
//
// public void setLogInformation(LogInformation logInformation) {
// this.logInformation = logInformation;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/commons/Address.java
// @Embeddable
// public class Address {
// private String street1;
// private String street2;
// private String city;
// private String state;
// private String zip;
//
// @Column(name = "address_street1")
// public String getStreet1() {
// return street1;
// }
//
// public void setStreet1(String street1) {
// this.street1 = street1;
// }
//
// @Column(name = "address_street2")
// public String getStreet2() {
// return street2;
// }
//
// public void setStreet2(String street2) {
// this.street2 = street2;
// }
//
// @Column(name = "address_city")
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// @Column(name = "address_state")
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// @Column(name = "address_zip")
// public String getZip() {
// return zip;
// }
//
// public void setZip(String zip) {
// this.zip = zip;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/commons/Name.java
// @Embeddable
// public class Name {
// private String prefix;
// private String first;
// private String middle;
// private String last;
//
// @Column(name = "name_prefix")
// public String getPrefix() {
// return prefix;
// }
//
// public void setPrefix(String prefix) {
// this.prefix = prefix;
// }
//
// @Column(name = "name_first")
// public String getFirst() {
// return first;
// }
//
// public void setFirst(String first) {
// this.first = first;
// }
//
// @Column(name = "name_middle")
// public String getMiddle() {
// return middle;
// }
//
// public void setMiddle(String middle) {
// this.middle = middle;
// }
//
// @Column(name = "name_last")
// public String getLast() {
// return last;
// }
//
// public void setLast(String last) {
// this.last = last;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/role/UserRole.java
// @Entity
// @Table(name = "yama_user_role", uniqueConstraints = @UniqueConstraint(columnNames = { "role_id", "user_id" }))
// public class UserRole extends DefaultPersistence {
// private Role role = new Role();
// private User user = new User();
//
// public UserRole() {}
//
// public UserRole(Role role, User user) {
// this.role = role;
// this.user = user;
// }
//
// @ManyToOne
// @JoinColumn(name = "role_id", nullable = false)
// public Role getRole() {
// return role;
// }
//
// public void setRole(Role role) {
// this.role = role;
// }
//
// @ManyToOne
// @JoinColumn(name = "user_id", nullable = false)
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.meruvian.yama.core.DefaultPersistence;
import org.meruvian.yama.core.commons.Address;
import org.meruvian.yama.core.commons.FileInfo;
import org.meruvian.yama.core.commons.Name;
import org.meruvian.yama.core.role.UserRole;
import com.fasterxml.jackson.annotation.JsonIgnore; | /**
* Copyright 2014 Meruvian
*
* 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 org.meruvian.yama.core.user;
/**
* @author Dian Aditya
*
*/
@Entity
@Table(name = "yama_backend_user") | // Path: core/src/main/java/org/meruvian/yama/core/DefaultPersistence.java
// @MappedSuperclass
// public class DefaultPersistence {
// protected String id;
// protected LogInformation logInformation = new LogInformation();
//
// @Id()
// @GeneratedValue(generator = "system-uuid")
// @GenericGenerator(name = "system-uuid", strategy = "uuid2")
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// @Embedded
// public LogInformation getLogInformation() {
// return logInformation;
// }
//
// public void setLogInformation(LogInformation logInformation) {
// this.logInformation = logInformation;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/commons/Address.java
// @Embeddable
// public class Address {
// private String street1;
// private String street2;
// private String city;
// private String state;
// private String zip;
//
// @Column(name = "address_street1")
// public String getStreet1() {
// return street1;
// }
//
// public void setStreet1(String street1) {
// this.street1 = street1;
// }
//
// @Column(name = "address_street2")
// public String getStreet2() {
// return street2;
// }
//
// public void setStreet2(String street2) {
// this.street2 = street2;
// }
//
// @Column(name = "address_city")
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// @Column(name = "address_state")
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// @Column(name = "address_zip")
// public String getZip() {
// return zip;
// }
//
// public void setZip(String zip) {
// this.zip = zip;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/commons/Name.java
// @Embeddable
// public class Name {
// private String prefix;
// private String first;
// private String middle;
// private String last;
//
// @Column(name = "name_prefix")
// public String getPrefix() {
// return prefix;
// }
//
// public void setPrefix(String prefix) {
// this.prefix = prefix;
// }
//
// @Column(name = "name_first")
// public String getFirst() {
// return first;
// }
//
// public void setFirst(String first) {
// this.first = first;
// }
//
// @Column(name = "name_middle")
// public String getMiddle() {
// return middle;
// }
//
// public void setMiddle(String middle) {
// this.middle = middle;
// }
//
// @Column(name = "name_last")
// public String getLast() {
// return last;
// }
//
// public void setLast(String last) {
// this.last = last;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/role/UserRole.java
// @Entity
// @Table(name = "yama_user_role", uniqueConstraints = @UniqueConstraint(columnNames = { "role_id", "user_id" }))
// public class UserRole extends DefaultPersistence {
// private Role role = new Role();
// private User user = new User();
//
// public UserRole() {}
//
// public UserRole(Role role, User user) {
// this.role = role;
// this.user = user;
// }
//
// @ManyToOne
// @JoinColumn(name = "role_id", nullable = false)
// public Role getRole() {
// return role;
// }
//
// public void setRole(Role role) {
// this.role = role;
// }
//
// @ManyToOne
// @JoinColumn(name = "user_id", nullable = false)
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
// }
// Path: core/src/main/java/org/meruvian/yama/core/user/User.java
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.meruvian.yama.core.DefaultPersistence;
import org.meruvian.yama.core.commons.Address;
import org.meruvian.yama.core.commons.FileInfo;
import org.meruvian.yama.core.commons.Name;
import org.meruvian.yama.core.role.UserRole;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* Copyright 2014 Meruvian
*
* 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 org.meruvian.yama.core.user;
/**
* @author Dian Aditya
*
*/
@Entity
@Table(name = "yama_backend_user") | public class User extends DefaultPersistence { |
meruvian/yama | core/src/main/java/org/meruvian/yama/core/user/User.java | // Path: core/src/main/java/org/meruvian/yama/core/DefaultPersistence.java
// @MappedSuperclass
// public class DefaultPersistence {
// protected String id;
// protected LogInformation logInformation = new LogInformation();
//
// @Id()
// @GeneratedValue(generator = "system-uuid")
// @GenericGenerator(name = "system-uuid", strategy = "uuid2")
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// @Embedded
// public LogInformation getLogInformation() {
// return logInformation;
// }
//
// public void setLogInformation(LogInformation logInformation) {
// this.logInformation = logInformation;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/commons/Address.java
// @Embeddable
// public class Address {
// private String street1;
// private String street2;
// private String city;
// private String state;
// private String zip;
//
// @Column(name = "address_street1")
// public String getStreet1() {
// return street1;
// }
//
// public void setStreet1(String street1) {
// this.street1 = street1;
// }
//
// @Column(name = "address_street2")
// public String getStreet2() {
// return street2;
// }
//
// public void setStreet2(String street2) {
// this.street2 = street2;
// }
//
// @Column(name = "address_city")
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// @Column(name = "address_state")
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// @Column(name = "address_zip")
// public String getZip() {
// return zip;
// }
//
// public void setZip(String zip) {
// this.zip = zip;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/commons/Name.java
// @Embeddable
// public class Name {
// private String prefix;
// private String first;
// private String middle;
// private String last;
//
// @Column(name = "name_prefix")
// public String getPrefix() {
// return prefix;
// }
//
// public void setPrefix(String prefix) {
// this.prefix = prefix;
// }
//
// @Column(name = "name_first")
// public String getFirst() {
// return first;
// }
//
// public void setFirst(String first) {
// this.first = first;
// }
//
// @Column(name = "name_middle")
// public String getMiddle() {
// return middle;
// }
//
// public void setMiddle(String middle) {
// this.middle = middle;
// }
//
// @Column(name = "name_last")
// public String getLast() {
// return last;
// }
//
// public void setLast(String last) {
// this.last = last;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/role/UserRole.java
// @Entity
// @Table(name = "yama_user_role", uniqueConstraints = @UniqueConstraint(columnNames = { "role_id", "user_id" }))
// public class UserRole extends DefaultPersistence {
// private Role role = new Role();
// private User user = new User();
//
// public UserRole() {}
//
// public UserRole(Role role, User user) {
// this.role = role;
// this.user = user;
// }
//
// @ManyToOne
// @JoinColumn(name = "role_id", nullable = false)
// public Role getRole() {
// return role;
// }
//
// public void setRole(Role role) {
// this.role = role;
// }
//
// @ManyToOne
// @JoinColumn(name = "user_id", nullable = false)
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.meruvian.yama.core.DefaultPersistence;
import org.meruvian.yama.core.commons.Address;
import org.meruvian.yama.core.commons.FileInfo;
import org.meruvian.yama.core.commons.Name;
import org.meruvian.yama.core.role.UserRole;
import com.fasterxml.jackson.annotation.JsonIgnore; | /**
* Copyright 2014 Meruvian
*
* 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 org.meruvian.yama.core.user;
/**
* @author Dian Aditya
*
*/
@Entity
@Table(name = "yama_backend_user")
public class User extends DefaultPersistence {
private String username;
private String password;
private String email; | // Path: core/src/main/java/org/meruvian/yama/core/DefaultPersistence.java
// @MappedSuperclass
// public class DefaultPersistence {
// protected String id;
// protected LogInformation logInformation = new LogInformation();
//
// @Id()
// @GeneratedValue(generator = "system-uuid")
// @GenericGenerator(name = "system-uuid", strategy = "uuid2")
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// @Embedded
// public LogInformation getLogInformation() {
// return logInformation;
// }
//
// public void setLogInformation(LogInformation logInformation) {
// this.logInformation = logInformation;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/commons/Address.java
// @Embeddable
// public class Address {
// private String street1;
// private String street2;
// private String city;
// private String state;
// private String zip;
//
// @Column(name = "address_street1")
// public String getStreet1() {
// return street1;
// }
//
// public void setStreet1(String street1) {
// this.street1 = street1;
// }
//
// @Column(name = "address_street2")
// public String getStreet2() {
// return street2;
// }
//
// public void setStreet2(String street2) {
// this.street2 = street2;
// }
//
// @Column(name = "address_city")
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// @Column(name = "address_state")
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// @Column(name = "address_zip")
// public String getZip() {
// return zip;
// }
//
// public void setZip(String zip) {
// this.zip = zip;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/commons/Name.java
// @Embeddable
// public class Name {
// private String prefix;
// private String first;
// private String middle;
// private String last;
//
// @Column(name = "name_prefix")
// public String getPrefix() {
// return prefix;
// }
//
// public void setPrefix(String prefix) {
// this.prefix = prefix;
// }
//
// @Column(name = "name_first")
// public String getFirst() {
// return first;
// }
//
// public void setFirst(String first) {
// this.first = first;
// }
//
// @Column(name = "name_middle")
// public String getMiddle() {
// return middle;
// }
//
// public void setMiddle(String middle) {
// this.middle = middle;
// }
//
// @Column(name = "name_last")
// public String getLast() {
// return last;
// }
//
// public void setLast(String last) {
// this.last = last;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/role/UserRole.java
// @Entity
// @Table(name = "yama_user_role", uniqueConstraints = @UniqueConstraint(columnNames = { "role_id", "user_id" }))
// public class UserRole extends DefaultPersistence {
// private Role role = new Role();
// private User user = new User();
//
// public UserRole() {}
//
// public UserRole(Role role, User user) {
// this.role = role;
// this.user = user;
// }
//
// @ManyToOne
// @JoinColumn(name = "role_id", nullable = false)
// public Role getRole() {
// return role;
// }
//
// public void setRole(Role role) {
// this.role = role;
// }
//
// @ManyToOne
// @JoinColumn(name = "user_id", nullable = false)
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
// }
// Path: core/src/main/java/org/meruvian/yama/core/user/User.java
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.meruvian.yama.core.DefaultPersistence;
import org.meruvian.yama.core.commons.Address;
import org.meruvian.yama.core.commons.FileInfo;
import org.meruvian.yama.core.commons.Name;
import org.meruvian.yama.core.role.UserRole;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* Copyright 2014 Meruvian
*
* 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 org.meruvian.yama.core.user;
/**
* @author Dian Aditya
*
*/
@Entity
@Table(name = "yama_backend_user")
public class User extends DefaultPersistence {
private String username;
private String password;
private String email; | private Name name = new Name(); |
meruvian/yama | core/src/main/java/org/meruvian/yama/core/user/User.java | // Path: core/src/main/java/org/meruvian/yama/core/DefaultPersistence.java
// @MappedSuperclass
// public class DefaultPersistence {
// protected String id;
// protected LogInformation logInformation = new LogInformation();
//
// @Id()
// @GeneratedValue(generator = "system-uuid")
// @GenericGenerator(name = "system-uuid", strategy = "uuid2")
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// @Embedded
// public LogInformation getLogInformation() {
// return logInformation;
// }
//
// public void setLogInformation(LogInformation logInformation) {
// this.logInformation = logInformation;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/commons/Address.java
// @Embeddable
// public class Address {
// private String street1;
// private String street2;
// private String city;
// private String state;
// private String zip;
//
// @Column(name = "address_street1")
// public String getStreet1() {
// return street1;
// }
//
// public void setStreet1(String street1) {
// this.street1 = street1;
// }
//
// @Column(name = "address_street2")
// public String getStreet2() {
// return street2;
// }
//
// public void setStreet2(String street2) {
// this.street2 = street2;
// }
//
// @Column(name = "address_city")
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// @Column(name = "address_state")
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// @Column(name = "address_zip")
// public String getZip() {
// return zip;
// }
//
// public void setZip(String zip) {
// this.zip = zip;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/commons/Name.java
// @Embeddable
// public class Name {
// private String prefix;
// private String first;
// private String middle;
// private String last;
//
// @Column(name = "name_prefix")
// public String getPrefix() {
// return prefix;
// }
//
// public void setPrefix(String prefix) {
// this.prefix = prefix;
// }
//
// @Column(name = "name_first")
// public String getFirst() {
// return first;
// }
//
// public void setFirst(String first) {
// this.first = first;
// }
//
// @Column(name = "name_middle")
// public String getMiddle() {
// return middle;
// }
//
// public void setMiddle(String middle) {
// this.middle = middle;
// }
//
// @Column(name = "name_last")
// public String getLast() {
// return last;
// }
//
// public void setLast(String last) {
// this.last = last;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/role/UserRole.java
// @Entity
// @Table(name = "yama_user_role", uniqueConstraints = @UniqueConstraint(columnNames = { "role_id", "user_id" }))
// public class UserRole extends DefaultPersistence {
// private Role role = new Role();
// private User user = new User();
//
// public UserRole() {}
//
// public UserRole(Role role, User user) {
// this.role = role;
// this.user = user;
// }
//
// @ManyToOne
// @JoinColumn(name = "role_id", nullable = false)
// public Role getRole() {
// return role;
// }
//
// public void setRole(Role role) {
// this.role = role;
// }
//
// @ManyToOne
// @JoinColumn(name = "user_id", nullable = false)
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.meruvian.yama.core.DefaultPersistence;
import org.meruvian.yama.core.commons.Address;
import org.meruvian.yama.core.commons.FileInfo;
import org.meruvian.yama.core.commons.Name;
import org.meruvian.yama.core.role.UserRole;
import com.fasterxml.jackson.annotation.JsonIgnore; | /**
* Copyright 2014 Meruvian
*
* 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 org.meruvian.yama.core.user;
/**
* @author Dian Aditya
*
*/
@Entity
@Table(name = "yama_backend_user")
public class User extends DefaultPersistence {
private String username;
private String password;
private String email;
private Name name = new Name(); | // Path: core/src/main/java/org/meruvian/yama/core/DefaultPersistence.java
// @MappedSuperclass
// public class DefaultPersistence {
// protected String id;
// protected LogInformation logInformation = new LogInformation();
//
// @Id()
// @GeneratedValue(generator = "system-uuid")
// @GenericGenerator(name = "system-uuid", strategy = "uuid2")
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// @Embedded
// public LogInformation getLogInformation() {
// return logInformation;
// }
//
// public void setLogInformation(LogInformation logInformation) {
// this.logInformation = logInformation;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/commons/Address.java
// @Embeddable
// public class Address {
// private String street1;
// private String street2;
// private String city;
// private String state;
// private String zip;
//
// @Column(name = "address_street1")
// public String getStreet1() {
// return street1;
// }
//
// public void setStreet1(String street1) {
// this.street1 = street1;
// }
//
// @Column(name = "address_street2")
// public String getStreet2() {
// return street2;
// }
//
// public void setStreet2(String street2) {
// this.street2 = street2;
// }
//
// @Column(name = "address_city")
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// @Column(name = "address_state")
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// @Column(name = "address_zip")
// public String getZip() {
// return zip;
// }
//
// public void setZip(String zip) {
// this.zip = zip;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/commons/Name.java
// @Embeddable
// public class Name {
// private String prefix;
// private String first;
// private String middle;
// private String last;
//
// @Column(name = "name_prefix")
// public String getPrefix() {
// return prefix;
// }
//
// public void setPrefix(String prefix) {
// this.prefix = prefix;
// }
//
// @Column(name = "name_first")
// public String getFirst() {
// return first;
// }
//
// public void setFirst(String first) {
// this.first = first;
// }
//
// @Column(name = "name_middle")
// public String getMiddle() {
// return middle;
// }
//
// public void setMiddle(String middle) {
// this.middle = middle;
// }
//
// @Column(name = "name_last")
// public String getLast() {
// return last;
// }
//
// public void setLast(String last) {
// this.last = last;
// }
// }
//
// Path: core/src/main/java/org/meruvian/yama/core/role/UserRole.java
// @Entity
// @Table(name = "yama_user_role", uniqueConstraints = @UniqueConstraint(columnNames = { "role_id", "user_id" }))
// public class UserRole extends DefaultPersistence {
// private Role role = new Role();
// private User user = new User();
//
// public UserRole() {}
//
// public UserRole(Role role, User user) {
// this.role = role;
// this.user = user;
// }
//
// @ManyToOne
// @JoinColumn(name = "role_id", nullable = false)
// public Role getRole() {
// return role;
// }
//
// public void setRole(Role role) {
// this.role = role;
// }
//
// @ManyToOne
// @JoinColumn(name = "user_id", nullable = false)
// public User getUser() {
// return user;
// }
//
// public void setUser(User user) {
// this.user = user;
// }
// }
// Path: core/src/main/java/org/meruvian/yama/core/user/User.java
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.meruvian.yama.core.DefaultPersistence;
import org.meruvian.yama.core.commons.Address;
import org.meruvian.yama.core.commons.FileInfo;
import org.meruvian.yama.core.commons.Name;
import org.meruvian.yama.core.role.UserRole;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* Copyright 2014 Meruvian
*
* 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 org.meruvian.yama.core.user;
/**
* @author Dian Aditya
*
*/
@Entity
@Table(name = "yama_backend_user")
public class User extends DefaultPersistence {
private String username;
private String password;
private String email;
private Name name = new Name(); | private Address address = new Address(); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.