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
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/list/ListRouter.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // } // // Path: sample/src/main/java/com/metova/privvy/sample/MainActivity.java // public class MainActivity extends AppCompatActivity implements PrivvyHost { // // public HostComponent hostComponent; // // private PrivvyHostDelegate hostDelegate; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // hostComponent = SampleApplication.component.newHost() // .hostModule(new HostModule(this)) // .build(); // // hostDelegate = new PrivvyHostDelegate(this); // // setContentView(R.layout.main_activity); // // initialize(NumberComponent.ROUTE_DATA, ButtonComponent.ROUTE_DATA); // } // // @Override // public void initialize(RouteData... routeData) { // hostDelegate.initialize(routeData); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // hostDelegate.replace(oldComponent, newComponent); // } // // @Override // public void goTo(RouteData newComponent) { // hostDelegate.goTo(newComponent); // } // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyRouter.java // public class PrivvyRouter implements PrivvyContract.Router { // // private PrivvyHost host; // // public PrivvyRouter(PrivvyHost host) { // this.host = host; // } // // @Override // public PrivvyHost getHost() { // return host; // } // // }
import com.metova.privvy.PrivvyHost; import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import com.metova.privvy.sample.MainActivity; import com.metova.privvy.PrivvyRouter;
package com.metova.privvy.sample.ui.list; class ListRouter extends PrivvyRouter implements ListContract.Router { ListRouter(PrivvyHost host) { super(host); } @Override public void navigateToMain() {
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // } // // Path: sample/src/main/java/com/metova/privvy/sample/MainActivity.java // public class MainActivity extends AppCompatActivity implements PrivvyHost { // // public HostComponent hostComponent; // // private PrivvyHostDelegate hostDelegate; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // hostComponent = SampleApplication.component.newHost() // .hostModule(new HostModule(this)) // .build(); // // hostDelegate = new PrivvyHostDelegate(this); // // setContentView(R.layout.main_activity); // // initialize(NumberComponent.ROUTE_DATA, ButtonComponent.ROUTE_DATA); // } // // @Override // public void initialize(RouteData... routeData) { // hostDelegate.initialize(routeData); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // hostDelegate.replace(oldComponent, newComponent); // } // // @Override // public void goTo(RouteData newComponent) { // hostDelegate.goTo(newComponent); // } // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyRouter.java // public class PrivvyRouter implements PrivvyContract.Router { // // private PrivvyHost host; // // public PrivvyRouter(PrivvyHost host) { // this.host = host; // } // // @Override // public PrivvyHost getHost() { // return host; // } // // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListRouter.java import com.metova.privvy.PrivvyHost; import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import com.metova.privvy.sample.MainActivity; import com.metova.privvy.PrivvyRouter; package com.metova.privvy.sample.ui.list; class ListRouter extends PrivvyRouter implements ListContract.Router { ListRouter(PrivvyHost host) { super(host); } @Override public void navigateToMain() {
getHost().goTo(RouteData.Builder().viewType(ViewType.ACTIVITY).viewClass(MainActivity.class).build());
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/list/ListInteractor.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyInteractor.java // public abstract class PrivvyInteractor extends CompositeDisposer implements PrivvyContract.Interactor { // // @Override // public void dispose() { // clearDisposables(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/models/DescriptiveNumber.java // public class DescriptiveNumber { // // public int value; // public String description; // // public DescriptiveNumber() { // // } // }
import com.metova.privvy.PrivvyInteractor; import com.metova.privvy.sample.db.FakeDb; import com.metova.privvy.sample.models.DescriptiveNumber; import java.util.List; import io.reactivex.Flowable;
package com.metova.privvy.sample.ui.list; class ListInteractor extends PrivvyInteractor implements ListContract.Interactor { private FakeDb fakeDb; private ListContract.Router router; ListInteractor(FakeDb fakeDb, ListContract.Router router) { this.fakeDb = fakeDb; this.router = router; } @Override
// Path: privvy/src/main/java/com/metova/privvy/PrivvyInteractor.java // public abstract class PrivvyInteractor extends CompositeDisposer implements PrivvyContract.Interactor { // // @Override // public void dispose() { // clearDisposables(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/models/DescriptiveNumber.java // public class DescriptiveNumber { // // public int value; // public String description; // // public DescriptiveNumber() { // // } // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListInteractor.java import com.metova.privvy.PrivvyInteractor; import com.metova.privvy.sample.db.FakeDb; import com.metova.privvy.sample.models.DescriptiveNumber; import java.util.List; import io.reactivex.Flowable; package com.metova.privvy.sample.ui.list; class ListInteractor extends PrivvyInteractor implements ListContract.Interactor { private FakeDb fakeDb; private ListContract.Router router; ListInteractor(FakeDb fakeDb, ListContract.Router router) { this.fakeDb = fakeDb; this.router = router; } @Override
public Flowable<List<DescriptiveNumber>> fetchNumberList() {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/SampleApplication.java
// Path: sample/src/main/java/com/metova/privvy/sample/di/ApplicationComponent.java // @Singleton // @Component(modules = {ApplicationModule.class}) // public interface ApplicationComponent { // // HostComponent.Builder newHost(); // // FakeDb fakeDb(); // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/ApplicationModule.java // @Module // public final class ApplicationModule { // // private final Context context; // // public ApplicationModule(Context context) { // this.context = context; // } // // @Provides // @Named("application") // @Singleton // Context provideApplicationContext() { // return context; // } // }
import com.metova.privvy.sample.di.ApplicationComponent; import com.metova.privvy.sample.di.ApplicationModule; import com.metova.privvy.sample.di.DaggerApplicationComponent; import android.app.Application; import timber.log.Timber;
package com.metova.privvy.sample; public class SampleApplication extends Application { public static ApplicationComponent component; @Override public void onCreate() { super.onCreate(); if (BuildConfig.DEBUG) { Timber.plant(new Timber.DebugTree()); } component = buildComponent(); } protected ApplicationComponent buildComponent() { Timber.d("Building actual component"); return DaggerApplicationComponent.builder()
// Path: sample/src/main/java/com/metova/privvy/sample/di/ApplicationComponent.java // @Singleton // @Component(modules = {ApplicationModule.class}) // public interface ApplicationComponent { // // HostComponent.Builder newHost(); // // FakeDb fakeDb(); // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/ApplicationModule.java // @Module // public final class ApplicationModule { // // private final Context context; // // public ApplicationModule(Context context) { // this.context = context; // } // // @Provides // @Named("application") // @Singleton // Context provideApplicationContext() { // return context; // } // } // Path: sample/src/main/java/com/metova/privvy/sample/SampleApplication.java import com.metova.privvy.sample.di.ApplicationComponent; import com.metova.privvy.sample.di.ApplicationModule; import com.metova.privvy.sample.di.DaggerApplicationComponent; import android.app.Application; import timber.log.Timber; package com.metova.privvy.sample; public class SampleApplication extends Application { public static ApplicationComponent component; @Override public void onCreate() { super.onCreate(); if (BuildConfig.DEBUG) { Timber.plant(new Timber.DebugTree()); } component = buildComponent(); } protected ApplicationComponent buildComponent() { Timber.d("Building actual component"); return DaggerApplicationComponent.builder()
.applicationModule(new ApplicationModule(this)).build();
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/list/ListModule.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // }
import com.metova.privvy.PrivvyHost; import com.metova.privvy.sample.db.FakeDb; import dagger.Module; import dagger.Provides;
package com.metova.privvy.sample.ui.list; @Module public class ListModule { public ListModule() { } @Provides @ListScope ListContract.Presenter providePresenter(ListContract.Interactor interactor) { return new ListPresenter(interactor); } @Provides @ListScope
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListModule.java import com.metova.privvy.PrivvyHost; import com.metova.privvy.sample.db.FakeDb; import dagger.Module; import dagger.Provides; package com.metova.privvy.sample.ui.list; @Module public class ListModule { public ListModule() { } @Provides @ListScope ListContract.Presenter providePresenter(ListContract.Interactor interactor) { return new ListPresenter(interactor); } @Provides @ListScope
ListContract.Interactor provideInteractor(FakeDb fakeDb, ListContract.Router router) {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/list/ListModule.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // }
import com.metova.privvy.PrivvyHost; import com.metova.privvy.sample.db.FakeDb; import dagger.Module; import dagger.Provides;
package com.metova.privvy.sample.ui.list; @Module public class ListModule { public ListModule() { } @Provides @ListScope ListContract.Presenter providePresenter(ListContract.Interactor interactor) { return new ListPresenter(interactor); } @Provides @ListScope ListContract.Interactor provideInteractor(FakeDb fakeDb, ListContract.Router router) { return new ListInteractor(fakeDb, router); } @Provides @ListScope
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListModule.java import com.metova.privvy.PrivvyHost; import com.metova.privvy.sample.db.FakeDb; import dagger.Module; import dagger.Provides; package com.metova.privvy.sample.ui.list; @Module public class ListModule { public ListModule() { } @Provides @ListScope ListContract.Presenter providePresenter(ListContract.Interactor interactor) { return new ListPresenter(interactor); } @Provides @ListScope ListContract.Interactor provideInteractor(FakeDb fakeDb, ListContract.Router router) { return new ListInteractor(fakeDb, router); } @Provides @ListScope
ListContract.Router provideRouter(PrivvyHost host) {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberFragment.java
// Path: sample/src/main/java/com/metova/privvy/sample/MainActivity.java // public class MainActivity extends AppCompatActivity implements PrivvyHost { // // public HostComponent hostComponent; // // private PrivvyHostDelegate hostDelegate; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // hostComponent = SampleApplication.component.newHost() // .hostModule(new HostModule(this)) // .build(); // // hostDelegate = new PrivvyHostDelegate(this); // // setContentView(R.layout.main_activity); // // initialize(NumberComponent.ROUTE_DATA, ButtonComponent.ROUTE_DATA); // } // // @Override // public void initialize(RouteData... routeData) { // hostDelegate.initialize(routeData); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // hostDelegate.replace(oldComponent, newComponent); // } // // @Override // public void goTo(RouteData newComponent) { // hostDelegate.goTo(newComponent); // } // }
import com.metova.privvy.sample.MainActivity; import com.metova.privvy.sample.R; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import javax.inject.Inject; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnLongClick;
package com.metova.privvy.sample.ui.floatingnumber.number; public class NumberFragment extends Fragment implements NumberContract.View { @Inject NumberComponent mNumberComponent; @BindView(R.id.number_text) TextView number; private NumberContract.Presenter presenter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
// Path: sample/src/main/java/com/metova/privvy/sample/MainActivity.java // public class MainActivity extends AppCompatActivity implements PrivvyHost { // // public HostComponent hostComponent; // // private PrivvyHostDelegate hostDelegate; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // hostComponent = SampleApplication.component.newHost() // .hostModule(new HostModule(this)) // .build(); // // hostDelegate = new PrivvyHostDelegate(this); // // setContentView(R.layout.main_activity); // // initialize(NumberComponent.ROUTE_DATA, ButtonComponent.ROUTE_DATA); // } // // @Override // public void initialize(RouteData... routeData) { // hostDelegate.initialize(routeData); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // hostDelegate.replace(oldComponent, newComponent); // } // // @Override // public void goTo(RouteData newComponent) { // hostDelegate.goTo(newComponent); // } // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberFragment.java import com.metova.privvy.sample.MainActivity; import com.metova.privvy.sample.R; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import javax.inject.Inject; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnLongClick; package com.metova.privvy.sample.ui.floatingnumber.number; public class NumberFragment extends Fragment implements NumberContract.View { @Inject NumberComponent mNumberComponent; @BindView(R.id.number_text) TextView number; private NumberContract.Presenter presenter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
((MainActivity) getActivity()).hostComponent.newPrivvyComponent().inject(this);
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberModule.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // }
import com.metova.privvy.PrivvyHost; import com.metova.privvy.sample.db.FakeDb; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import dagger.Module; import dagger.Provides;
package com.metova.privvy.sample.ui.floatingnumber.number; @Module public final class NumberModule { @Provides @NumberScope
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberModule.java import com.metova.privvy.PrivvyHost; import com.metova.privvy.sample.db.FakeDb; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import dagger.Module; import dagger.Provides; package com.metova.privvy.sample.ui.floatingnumber.number; @Module public final class NumberModule { @Provides @NumberScope
NumberContract.Presenter providePresenter(NumberContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberModule.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // }
import com.metova.privvy.PrivvyHost; import com.metova.privvy.sample.db.FakeDb; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import dagger.Module; import dagger.Provides;
package com.metova.privvy.sample.ui.floatingnumber.number; @Module public final class NumberModule { @Provides @NumberScope NumberContract.Presenter providePresenter(NumberContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { return new NumberPresenter(interactor, numberUpdateYoke); } @Provides @NumberScope
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberModule.java import com.metova.privvy.PrivvyHost; import com.metova.privvy.sample.db.FakeDb; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import dagger.Module; import dagger.Provides; package com.metova.privvy.sample.ui.floatingnumber.number; @Module public final class NumberModule { @Provides @NumberScope NumberContract.Presenter providePresenter(NumberContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { return new NumberPresenter(interactor, numberUpdateYoke); } @Provides @NumberScope
NumberContract.Interactor provideInteractor(FakeDb fakeDb, NumberContract.Router router) {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberModule.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // }
import com.metova.privvy.PrivvyHost; import com.metova.privvy.sample.db.FakeDb; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import dagger.Module; import dagger.Provides;
package com.metova.privvy.sample.ui.floatingnumber.number; @Module public final class NumberModule { @Provides @NumberScope NumberContract.Presenter providePresenter(NumberContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { return new NumberPresenter(interactor, numberUpdateYoke); } @Provides @NumberScope NumberContract.Interactor provideInteractor(FakeDb fakeDb, NumberContract.Router router) { return new NumberInteractor(router, fakeDb); } @Provides @NumberScope
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberModule.java import com.metova.privvy.PrivvyHost; import com.metova.privvy.sample.db.FakeDb; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import dagger.Module; import dagger.Provides; package com.metova.privvy.sample.ui.floatingnumber.number; @Module public final class NumberModule { @Provides @NumberScope NumberContract.Presenter providePresenter(NumberContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { return new NumberPresenter(interactor, numberUpdateYoke); } @Provides @NumberScope NumberContract.Interactor provideInteractor(FakeDb fakeDb, NumberContract.Router router) { return new NumberInteractor(router, fakeDb); } @Provides @NumberScope
NumberContract.Router provideRouter(PrivvyHost host) {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberPresenter.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyPresenter.java // public abstract class PrivvyPresenter<V extends PrivvyContract.View, I extends PrivvyContract.Interactor> extends CompositeDisposer implements PrivvyContract.Presenter<V>{ // // private V view; // // private I interactor; // // protected PrivvyPresenter(I interactor) { // this.interactor = interactor; // } // // @Override // public void setView(V view) { // this.view = view; // if (view != null) { // setupSubscriptions(); // } // } // // abstract protected void setupSubscriptions(); // // @CallSuper // @Override // public void onDestroyView() { // clearDisposables(); // setView(null); // interactor.dispose(); // } // // protected V getView() { // return this.view; // } // // protected I getInteractor() { // return this.interactor; // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/models/Number.java // public class Number { // // public int value; // // public Number() { // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // }
import com.metova.privvy.PrivvyPresenter; import com.metova.privvy.sample.models.Number; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import timber.log.Timber;
package com.metova.privvy.sample.ui.floatingnumber.number; class NumberPresenter extends PrivvyPresenter<NumberContract.View, NumberContract.Interactor> implements NumberContract.Presenter { private NumberUpdateYoke numberUpdateYoke; private NumberMapper mapper; NumberPresenter(NumberContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { super(interactor); this.numberUpdateYoke = numberUpdateYoke; this.mapper = new NumberMapper(); } @Override protected void setupSubscriptions() { addDisposables( getInteractor().getNumber().subscribe(this::onNumberUpdated), getInteractor().onNumberUpdated().subscribe(this::onNumberUpdated), numberUpdateYoke.onNumberChanged().subscribe(getView()::updateFontSize) ); } @Override
// Path: privvy/src/main/java/com/metova/privvy/PrivvyPresenter.java // public abstract class PrivvyPresenter<V extends PrivvyContract.View, I extends PrivvyContract.Interactor> extends CompositeDisposer implements PrivvyContract.Presenter<V>{ // // private V view; // // private I interactor; // // protected PrivvyPresenter(I interactor) { // this.interactor = interactor; // } // // @Override // public void setView(V view) { // this.view = view; // if (view != null) { // setupSubscriptions(); // } // } // // abstract protected void setupSubscriptions(); // // @CallSuper // @Override // public void onDestroyView() { // clearDisposables(); // setView(null); // interactor.dispose(); // } // // protected V getView() { // return this.view; // } // // protected I getInteractor() { // return this.interactor; // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/models/Number.java // public class Number { // // public int value; // // public Number() { // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberPresenter.java import com.metova.privvy.PrivvyPresenter; import com.metova.privvy.sample.models.Number; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import timber.log.Timber; package com.metova.privvy.sample.ui.floatingnumber.number; class NumberPresenter extends PrivvyPresenter<NumberContract.View, NumberContract.Interactor> implements NumberContract.Presenter { private NumberUpdateYoke numberUpdateYoke; private NumberMapper mapper; NumberPresenter(NumberContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { super(interactor); this.numberUpdateYoke = numberUpdateYoke; this.mapper = new NumberMapper(); } @Override protected void setupSubscriptions() { addDisposables( getInteractor().getNumber().subscribe(this::onNumberUpdated), getInteractor().onNumberUpdated().subscribe(this::onNumberUpdated), numberUpdateYoke.onNumberChanged().subscribe(getView()::updateFontSize) ); } @Override
public void onNumberUpdated(Number number) {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java
// Path: sample/src/main/java/com/metova/privvy/sample/models/DescriptiveNumber.java // public class DescriptiveNumber { // // public int value; // public String description; // // public DescriptiveNumber() { // // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/models/Number.java // public class Number { // // public int value; // // public Number() { // } // }
import com.jakewharton.rxrelay2.PublishRelay; import com.metova.privvy.sample.models.DescriptiveNumber; import com.metova.privvy.sample.models.Number; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; import io.reactivex.BackpressureStrategy; import io.reactivex.Flowable;
package com.metova.privvy.sample.db; @Singleton public class FakeDb {
// Path: sample/src/main/java/com/metova/privvy/sample/models/DescriptiveNumber.java // public class DescriptiveNumber { // // public int value; // public String description; // // public DescriptiveNumber() { // // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/models/Number.java // public class Number { // // public int value; // // public Number() { // } // } // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java import com.jakewharton.rxrelay2.PublishRelay; import com.metova.privvy.sample.models.DescriptiveNumber; import com.metova.privvy.sample.models.Number; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; import io.reactivex.BackpressureStrategy; import io.reactivex.Flowable; package com.metova.privvy.sample.db; @Singleton public class FakeDb {
private PublishRelay<Number> numberRelay = PublishRelay.create();
metova/privvy
sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java
// Path: sample/src/main/java/com/metova/privvy/sample/models/DescriptiveNumber.java // public class DescriptiveNumber { // // public int value; // public String description; // // public DescriptiveNumber() { // // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/models/Number.java // public class Number { // // public int value; // // public Number() { // } // }
import com.jakewharton.rxrelay2.PublishRelay; import com.metova.privvy.sample.models.DescriptiveNumber; import com.metova.privvy.sample.models.Number; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; import io.reactivex.BackpressureStrategy; import io.reactivex.Flowable;
package com.metova.privvy.sample.db; @Singleton public class FakeDb { private PublishRelay<Number> numberRelay = PublishRelay.create(); private Number number = new Number(); @Inject public FakeDb() { } public Flowable<Number> getNumber() { return Flowable.just(number); } public void updateNumberBy(int value) { number.value += value; numberRelay.accept(this.number); } public Flowable<Number> numberUpdates() { return numberRelay.toFlowable(BackpressureStrategy.BUFFER); }
// Path: sample/src/main/java/com/metova/privvy/sample/models/DescriptiveNumber.java // public class DescriptiveNumber { // // public int value; // public String description; // // public DescriptiveNumber() { // // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/models/Number.java // public class Number { // // public int value; // // public Number() { // } // } // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java import com.jakewharton.rxrelay2.PublishRelay; import com.metova.privvy.sample.models.DescriptiveNumber; import com.metova.privvy.sample.models.Number; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; import io.reactivex.BackpressureStrategy; import io.reactivex.Flowable; package com.metova.privvy.sample.db; @Singleton public class FakeDb { private PublishRelay<Number> numberRelay = PublishRelay.create(); private Number number = new Number(); @Inject public FakeDb() { } public Flowable<Number> getNumber() { return Flowable.just(number); } public void updateNumberBy(int value) { number.value += value; numberRelay.accept(this.number); } public Flowable<Number> numberUpdates() { return numberRelay.toFlowable(BackpressureStrategy.BUFFER); }
public Flowable<List<DescriptiveNumber>> getNumberList() {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/list/ListComponent.java
// Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // }
import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import dagger.Subcomponent;
package com.metova.privvy.sample.ui.list; @ListScope @Subcomponent(modules = {ListModule.class}) public interface ListComponent {
// Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListComponent.java import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import dagger.Subcomponent; package com.metova.privvy.sample.ui.list; @ListScope @Subcomponent(modules = {ListModule.class}) public interface ListComponent {
RouteData ROUTE_DATA = RouteData.Builder()
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/list/ListComponent.java
// Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // }
import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import dagger.Subcomponent;
package com.metova.privvy.sample.ui.list; @ListScope @Subcomponent(modules = {ListModule.class}) public interface ListComponent { RouteData ROUTE_DATA = RouteData.Builder()
// Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListComponent.java import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import dagger.Subcomponent; package com.metova.privvy.sample.ui.list; @ListScope @Subcomponent(modules = {ListModule.class}) public interface ListComponent { RouteData ROUTE_DATA = RouteData.Builder()
.viewType(ViewType.ACTIVITY)
metova/privvy
sample/src/test/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonPresenterTest.java
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // }
import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify;
package com.metova.privvy.sample.ui.floatingnumber.buttons; public class ButtonPresenterTest { @Mock public ButtonContract.Interactor mockInteractor; @Mock
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // } // Path: sample/src/test/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonPresenterTest.java import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; package com.metova.privvy.sample.ui.floatingnumber.buttons; public class ButtonPresenterTest { @Mock public ButtonContract.Interactor mockInteractor; @Mock
public NumberUpdateYoke mockYoke;
metova/privvy
sample/src/main/java/com/metova/privvy/sample/di/YokeModule.java
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYokeImpl.java // public class NumberUpdateYokeImpl implements NumberUpdateYoke { // // private PublishRelay<Integer> numberSubject = PublishRelay.create(); // // public NumberUpdateYokeImpl() { // } // // @Override // public Flowable<Integer> onNumberChanged() { // return numberSubject.toFlowable(BackpressureStrategy.BUFFER); // } // // @Override // public void changeNumber(int newNumber) { // numberSubject.accept(newNumber); // } // // }
import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYokeImpl; import dagger.Module; import dagger.Provides;
package com.metova.privvy.sample.di; @Module public class YokeModule { @Provides @HostScope
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYokeImpl.java // public class NumberUpdateYokeImpl implements NumberUpdateYoke { // // private PublishRelay<Integer> numberSubject = PublishRelay.create(); // // public NumberUpdateYokeImpl() { // } // // @Override // public Flowable<Integer> onNumberChanged() { // return numberSubject.toFlowable(BackpressureStrategy.BUFFER); // } // // @Override // public void changeNumber(int newNumber) { // numberSubject.accept(newNumber); // } // // } // Path: sample/src/main/java/com/metova/privvy/sample/di/YokeModule.java import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYokeImpl; import dagger.Module; import dagger.Provides; package com.metova.privvy.sample.di; @Module public class YokeModule { @Provides @HostScope
NumberUpdateYoke provideNumberUpdateYoke() {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/di/YokeModule.java
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYokeImpl.java // public class NumberUpdateYokeImpl implements NumberUpdateYoke { // // private PublishRelay<Integer> numberSubject = PublishRelay.create(); // // public NumberUpdateYokeImpl() { // } // // @Override // public Flowable<Integer> onNumberChanged() { // return numberSubject.toFlowable(BackpressureStrategy.BUFFER); // } // // @Override // public void changeNumber(int newNumber) { // numberSubject.accept(newNumber); // } // // }
import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYokeImpl; import dagger.Module; import dagger.Provides;
package com.metova.privvy.sample.di; @Module public class YokeModule { @Provides @HostScope NumberUpdateYoke provideNumberUpdateYoke() {
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYokeImpl.java // public class NumberUpdateYokeImpl implements NumberUpdateYoke { // // private PublishRelay<Integer> numberSubject = PublishRelay.create(); // // public NumberUpdateYokeImpl() { // } // // @Override // public Flowable<Integer> onNumberChanged() { // return numberSubject.toFlowable(BackpressureStrategy.BUFFER); // } // // @Override // public void changeNumber(int newNumber) { // numberSubject.accept(newNumber); // } // // } // Path: sample/src/main/java/com/metova/privvy/sample/di/YokeModule.java import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYokeImpl; import dagger.Module; import dagger.Provides; package com.metova.privvy.sample.di; @Module public class YokeModule { @Provides @HostScope NumberUpdateYoke provideNumberUpdateYoke() {
return new NumberUpdateYokeImpl();
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberInteractor.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyInteractor.java // public abstract class PrivvyInteractor extends CompositeDisposer implements PrivvyContract.Interactor { // // @Override // public void dispose() { // clearDisposables(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/models/Number.java // public class Number { // // public int value; // // public Number() { // } // }
import com.metova.privvy.PrivvyInteractor; import com.metova.privvy.sample.db.FakeDb; import com.metova.privvy.sample.models.Number; import io.reactivex.Flowable;
package com.metova.privvy.sample.ui.floatingnumber.number; class NumberInteractor extends PrivvyInteractor implements NumberContract.Interactor { private FakeDb fakeDb; private NumberContract.Router router; NumberInteractor(NumberContract.Router router, FakeDb fakeDb) { this.router = router; this.fakeDb = fakeDb; } @Override
// Path: privvy/src/main/java/com/metova/privvy/PrivvyInteractor.java // public abstract class PrivvyInteractor extends CompositeDisposer implements PrivvyContract.Interactor { // // @Override // public void dispose() { // clearDisposables(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/models/Number.java // public class Number { // // public int value; // // public Number() { // } // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberInteractor.java import com.metova.privvy.PrivvyInteractor; import com.metova.privvy.sample.db.FakeDb; import com.metova.privvy.sample.models.Number; import io.reactivex.Flowable; package com.metova.privvy.sample.ui.floatingnumber.number; class NumberInteractor extends PrivvyInteractor implements NumberContract.Interactor { private FakeDb fakeDb; private NumberContract.Router router; NumberInteractor(NumberContract.Router router, FakeDb fakeDb) { this.router = router; this.fakeDb = fakeDb; } @Override
public Flowable<Number> getNumber() {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/di/PrivvyComponent.java
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonFragment.java // public class ButtonFragment extends Fragment implements ButtonContract.View { // // @Inject // ButtonComponent buttonComponent; // // private ButtonContract.Presenter presenter; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // ((MainActivity) getActivity()).hostComponent.newPrivvyComponent().inject(this); // presenter = buttonComponent.presenter(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.button_view, container, false); // } // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ButterKnife.bind(this, view); // presenter.setView(this); // } // // @Override // public void onDestroyView() { // super.onDestroyView(); // presenter.onDestroyView(); // } // // @Override // @OnClick(R.id.increment_button) // public void onIncrementClick() { // presenter.incrementNumber(); // } // // @Override // @OnClick(R.id.decrement_button) // public void onDecrementClick() { // presenter.decrementNumber(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListActivity.java // public class ListActivity extends AppCompatActivity implements PrivvyHost, ListContract.View, ListAdapter.ListClickCallback { // // @Inject // ListComponent listComponent; // // PrivvyHostDelegate hostDelegate; // // @BindView(R.id.list_recyclerview) // RecyclerView numberList; // // private ListContract.Presenter presenter; // // private ListAdapter listAdapter = new ListAdapter(this); // // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // HostComponent hostComponent = SampleApplication.component.newHost() // .hostModule(new HostModule(this)) // .build(); // // hostComponent.newPrivvyComponent().inject(this); // // hostDelegate = new PrivvyHostDelegate(this); // // setContentView(R.layout.list_activity); // // ButterKnife.bind(this); // // presenter = listComponent.presenter(); // // numberList.setLayoutManager(new LinearLayoutManager(this)); // numberList.setAdapter(listAdapter); // // presenter.setView(this); // } // // @Override // public void updateList(List<ListViewModel> numbers) { // listAdapter.setNumbers(numbers); // } // // @Override // public void updateListItem(ListViewModel number) { // listAdapter.setListItem(number); // } // // @Override // protected void onDestroy() { // super.onDestroy(); // presenter.onDestroyView(); // } // // @OnClick(R.id.list_goback) // public void onBackClicked() { // presenter.goBack(); // } // // @Override // public void onItemClicked(int position) { // presenter.onClickTile(position); // } // // @Override // public void initialize(RouteData... routes) { // hostDelegate.initialize(routes); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // hostDelegate.replace(oldComponent, newComponent); // } // // @Override // public void goTo(RouteData newComponent) { // hostDelegate.goTo(newComponent); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberFragment.java // public class NumberFragment extends Fragment implements NumberContract.View { // // @Inject // NumberComponent mNumberComponent; // // @BindView(R.id.number_text) // TextView number; // // private NumberContract.Presenter presenter; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // ((MainActivity) getActivity()).hostComponent.newPrivvyComponent().inject(this); // presenter = mNumberComponent.presenter(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.number_view, container, false); // } // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ButterKnife.bind(this, view); // presenter.setView(this); // } // // @Override // public void onDestroyView() { // super.onDestroyView(); // presenter.onDestroyView(); // } // // @Override // public void display(NumberViewModel viewModel) { // number.setText(String.valueOf(viewModel.number())); // } // // @Override // @OnLongClick(R.id.number_text) // public boolean onLongClickNumber() { // presenter.incrementNumberBy(); // return true; // } // // @Override // public void updateFontSize(int scale) { // number.setTranslationX(number.getTranslationX() + (10 * scale)); // } // }
import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonFragment; import com.metova.privvy.sample.ui.list.ListActivity; import com.metova.privvy.sample.ui.floatingnumber.number.NumberFragment; import dagger.Subcomponent;
package com.metova.privvy.sample.di; @PrivvyScope @Subcomponent(modules = PrivvyModule.class) public interface PrivvyComponent {
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonFragment.java // public class ButtonFragment extends Fragment implements ButtonContract.View { // // @Inject // ButtonComponent buttonComponent; // // private ButtonContract.Presenter presenter; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // ((MainActivity) getActivity()).hostComponent.newPrivvyComponent().inject(this); // presenter = buttonComponent.presenter(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.button_view, container, false); // } // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ButterKnife.bind(this, view); // presenter.setView(this); // } // // @Override // public void onDestroyView() { // super.onDestroyView(); // presenter.onDestroyView(); // } // // @Override // @OnClick(R.id.increment_button) // public void onIncrementClick() { // presenter.incrementNumber(); // } // // @Override // @OnClick(R.id.decrement_button) // public void onDecrementClick() { // presenter.decrementNumber(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListActivity.java // public class ListActivity extends AppCompatActivity implements PrivvyHost, ListContract.View, ListAdapter.ListClickCallback { // // @Inject // ListComponent listComponent; // // PrivvyHostDelegate hostDelegate; // // @BindView(R.id.list_recyclerview) // RecyclerView numberList; // // private ListContract.Presenter presenter; // // private ListAdapter listAdapter = new ListAdapter(this); // // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // HostComponent hostComponent = SampleApplication.component.newHost() // .hostModule(new HostModule(this)) // .build(); // // hostComponent.newPrivvyComponent().inject(this); // // hostDelegate = new PrivvyHostDelegate(this); // // setContentView(R.layout.list_activity); // // ButterKnife.bind(this); // // presenter = listComponent.presenter(); // // numberList.setLayoutManager(new LinearLayoutManager(this)); // numberList.setAdapter(listAdapter); // // presenter.setView(this); // } // // @Override // public void updateList(List<ListViewModel> numbers) { // listAdapter.setNumbers(numbers); // } // // @Override // public void updateListItem(ListViewModel number) { // listAdapter.setListItem(number); // } // // @Override // protected void onDestroy() { // super.onDestroy(); // presenter.onDestroyView(); // } // // @OnClick(R.id.list_goback) // public void onBackClicked() { // presenter.goBack(); // } // // @Override // public void onItemClicked(int position) { // presenter.onClickTile(position); // } // // @Override // public void initialize(RouteData... routes) { // hostDelegate.initialize(routes); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // hostDelegate.replace(oldComponent, newComponent); // } // // @Override // public void goTo(RouteData newComponent) { // hostDelegate.goTo(newComponent); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberFragment.java // public class NumberFragment extends Fragment implements NumberContract.View { // // @Inject // NumberComponent mNumberComponent; // // @BindView(R.id.number_text) // TextView number; // // private NumberContract.Presenter presenter; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // ((MainActivity) getActivity()).hostComponent.newPrivvyComponent().inject(this); // presenter = mNumberComponent.presenter(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.number_view, container, false); // } // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ButterKnife.bind(this, view); // presenter.setView(this); // } // // @Override // public void onDestroyView() { // super.onDestroyView(); // presenter.onDestroyView(); // } // // @Override // public void display(NumberViewModel viewModel) { // number.setText(String.valueOf(viewModel.number())); // } // // @Override // @OnLongClick(R.id.number_text) // public boolean onLongClickNumber() { // presenter.incrementNumberBy(); // return true; // } // // @Override // public void updateFontSize(int scale) { // number.setTranslationX(number.getTranslationX() + (10 * scale)); // } // } // Path: sample/src/main/java/com/metova/privvy/sample/di/PrivvyComponent.java import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonFragment; import com.metova.privvy.sample.ui.list.ListActivity; import com.metova.privvy.sample.ui.floatingnumber.number.NumberFragment; import dagger.Subcomponent; package com.metova.privvy.sample.di; @PrivvyScope @Subcomponent(modules = PrivvyModule.class) public interface PrivvyComponent {
void inject(ButtonFragment fragment);
metova/privvy
sample/src/main/java/com/metova/privvy/sample/di/PrivvyComponent.java
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonFragment.java // public class ButtonFragment extends Fragment implements ButtonContract.View { // // @Inject // ButtonComponent buttonComponent; // // private ButtonContract.Presenter presenter; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // ((MainActivity) getActivity()).hostComponent.newPrivvyComponent().inject(this); // presenter = buttonComponent.presenter(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.button_view, container, false); // } // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ButterKnife.bind(this, view); // presenter.setView(this); // } // // @Override // public void onDestroyView() { // super.onDestroyView(); // presenter.onDestroyView(); // } // // @Override // @OnClick(R.id.increment_button) // public void onIncrementClick() { // presenter.incrementNumber(); // } // // @Override // @OnClick(R.id.decrement_button) // public void onDecrementClick() { // presenter.decrementNumber(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListActivity.java // public class ListActivity extends AppCompatActivity implements PrivvyHost, ListContract.View, ListAdapter.ListClickCallback { // // @Inject // ListComponent listComponent; // // PrivvyHostDelegate hostDelegate; // // @BindView(R.id.list_recyclerview) // RecyclerView numberList; // // private ListContract.Presenter presenter; // // private ListAdapter listAdapter = new ListAdapter(this); // // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // HostComponent hostComponent = SampleApplication.component.newHost() // .hostModule(new HostModule(this)) // .build(); // // hostComponent.newPrivvyComponent().inject(this); // // hostDelegate = new PrivvyHostDelegate(this); // // setContentView(R.layout.list_activity); // // ButterKnife.bind(this); // // presenter = listComponent.presenter(); // // numberList.setLayoutManager(new LinearLayoutManager(this)); // numberList.setAdapter(listAdapter); // // presenter.setView(this); // } // // @Override // public void updateList(List<ListViewModel> numbers) { // listAdapter.setNumbers(numbers); // } // // @Override // public void updateListItem(ListViewModel number) { // listAdapter.setListItem(number); // } // // @Override // protected void onDestroy() { // super.onDestroy(); // presenter.onDestroyView(); // } // // @OnClick(R.id.list_goback) // public void onBackClicked() { // presenter.goBack(); // } // // @Override // public void onItemClicked(int position) { // presenter.onClickTile(position); // } // // @Override // public void initialize(RouteData... routes) { // hostDelegate.initialize(routes); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // hostDelegate.replace(oldComponent, newComponent); // } // // @Override // public void goTo(RouteData newComponent) { // hostDelegate.goTo(newComponent); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberFragment.java // public class NumberFragment extends Fragment implements NumberContract.View { // // @Inject // NumberComponent mNumberComponent; // // @BindView(R.id.number_text) // TextView number; // // private NumberContract.Presenter presenter; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // ((MainActivity) getActivity()).hostComponent.newPrivvyComponent().inject(this); // presenter = mNumberComponent.presenter(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.number_view, container, false); // } // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ButterKnife.bind(this, view); // presenter.setView(this); // } // // @Override // public void onDestroyView() { // super.onDestroyView(); // presenter.onDestroyView(); // } // // @Override // public void display(NumberViewModel viewModel) { // number.setText(String.valueOf(viewModel.number())); // } // // @Override // @OnLongClick(R.id.number_text) // public boolean onLongClickNumber() { // presenter.incrementNumberBy(); // return true; // } // // @Override // public void updateFontSize(int scale) { // number.setTranslationX(number.getTranslationX() + (10 * scale)); // } // }
import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonFragment; import com.metova.privvy.sample.ui.list.ListActivity; import com.metova.privvy.sample.ui.floatingnumber.number.NumberFragment; import dagger.Subcomponent;
package com.metova.privvy.sample.di; @PrivvyScope @Subcomponent(modules = PrivvyModule.class) public interface PrivvyComponent { void inject(ButtonFragment fragment);
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonFragment.java // public class ButtonFragment extends Fragment implements ButtonContract.View { // // @Inject // ButtonComponent buttonComponent; // // private ButtonContract.Presenter presenter; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // ((MainActivity) getActivity()).hostComponent.newPrivvyComponent().inject(this); // presenter = buttonComponent.presenter(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.button_view, container, false); // } // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ButterKnife.bind(this, view); // presenter.setView(this); // } // // @Override // public void onDestroyView() { // super.onDestroyView(); // presenter.onDestroyView(); // } // // @Override // @OnClick(R.id.increment_button) // public void onIncrementClick() { // presenter.incrementNumber(); // } // // @Override // @OnClick(R.id.decrement_button) // public void onDecrementClick() { // presenter.decrementNumber(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListActivity.java // public class ListActivity extends AppCompatActivity implements PrivvyHost, ListContract.View, ListAdapter.ListClickCallback { // // @Inject // ListComponent listComponent; // // PrivvyHostDelegate hostDelegate; // // @BindView(R.id.list_recyclerview) // RecyclerView numberList; // // private ListContract.Presenter presenter; // // private ListAdapter listAdapter = new ListAdapter(this); // // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // HostComponent hostComponent = SampleApplication.component.newHost() // .hostModule(new HostModule(this)) // .build(); // // hostComponent.newPrivvyComponent().inject(this); // // hostDelegate = new PrivvyHostDelegate(this); // // setContentView(R.layout.list_activity); // // ButterKnife.bind(this); // // presenter = listComponent.presenter(); // // numberList.setLayoutManager(new LinearLayoutManager(this)); // numberList.setAdapter(listAdapter); // // presenter.setView(this); // } // // @Override // public void updateList(List<ListViewModel> numbers) { // listAdapter.setNumbers(numbers); // } // // @Override // public void updateListItem(ListViewModel number) { // listAdapter.setListItem(number); // } // // @Override // protected void onDestroy() { // super.onDestroy(); // presenter.onDestroyView(); // } // // @OnClick(R.id.list_goback) // public void onBackClicked() { // presenter.goBack(); // } // // @Override // public void onItemClicked(int position) { // presenter.onClickTile(position); // } // // @Override // public void initialize(RouteData... routes) { // hostDelegate.initialize(routes); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // hostDelegate.replace(oldComponent, newComponent); // } // // @Override // public void goTo(RouteData newComponent) { // hostDelegate.goTo(newComponent); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberFragment.java // public class NumberFragment extends Fragment implements NumberContract.View { // // @Inject // NumberComponent mNumberComponent; // // @BindView(R.id.number_text) // TextView number; // // private NumberContract.Presenter presenter; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // ((MainActivity) getActivity()).hostComponent.newPrivvyComponent().inject(this); // presenter = mNumberComponent.presenter(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.number_view, container, false); // } // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ButterKnife.bind(this, view); // presenter.setView(this); // } // // @Override // public void onDestroyView() { // super.onDestroyView(); // presenter.onDestroyView(); // } // // @Override // public void display(NumberViewModel viewModel) { // number.setText(String.valueOf(viewModel.number())); // } // // @Override // @OnLongClick(R.id.number_text) // public boolean onLongClickNumber() { // presenter.incrementNumberBy(); // return true; // } // // @Override // public void updateFontSize(int scale) { // number.setTranslationX(number.getTranslationX() + (10 * scale)); // } // } // Path: sample/src/main/java/com/metova/privvy/sample/di/PrivvyComponent.java import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonFragment; import com.metova.privvy.sample.ui.list.ListActivity; import com.metova.privvy.sample.ui.floatingnumber.number.NumberFragment; import dagger.Subcomponent; package com.metova.privvy.sample.di; @PrivvyScope @Subcomponent(modules = PrivvyModule.class) public interface PrivvyComponent { void inject(ButtonFragment fragment);
void inject(NumberFragment fragment);
metova/privvy
sample/src/main/java/com/metova/privvy/sample/di/PrivvyComponent.java
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonFragment.java // public class ButtonFragment extends Fragment implements ButtonContract.View { // // @Inject // ButtonComponent buttonComponent; // // private ButtonContract.Presenter presenter; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // ((MainActivity) getActivity()).hostComponent.newPrivvyComponent().inject(this); // presenter = buttonComponent.presenter(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.button_view, container, false); // } // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ButterKnife.bind(this, view); // presenter.setView(this); // } // // @Override // public void onDestroyView() { // super.onDestroyView(); // presenter.onDestroyView(); // } // // @Override // @OnClick(R.id.increment_button) // public void onIncrementClick() { // presenter.incrementNumber(); // } // // @Override // @OnClick(R.id.decrement_button) // public void onDecrementClick() { // presenter.decrementNumber(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListActivity.java // public class ListActivity extends AppCompatActivity implements PrivvyHost, ListContract.View, ListAdapter.ListClickCallback { // // @Inject // ListComponent listComponent; // // PrivvyHostDelegate hostDelegate; // // @BindView(R.id.list_recyclerview) // RecyclerView numberList; // // private ListContract.Presenter presenter; // // private ListAdapter listAdapter = new ListAdapter(this); // // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // HostComponent hostComponent = SampleApplication.component.newHost() // .hostModule(new HostModule(this)) // .build(); // // hostComponent.newPrivvyComponent().inject(this); // // hostDelegate = new PrivvyHostDelegate(this); // // setContentView(R.layout.list_activity); // // ButterKnife.bind(this); // // presenter = listComponent.presenter(); // // numberList.setLayoutManager(new LinearLayoutManager(this)); // numberList.setAdapter(listAdapter); // // presenter.setView(this); // } // // @Override // public void updateList(List<ListViewModel> numbers) { // listAdapter.setNumbers(numbers); // } // // @Override // public void updateListItem(ListViewModel number) { // listAdapter.setListItem(number); // } // // @Override // protected void onDestroy() { // super.onDestroy(); // presenter.onDestroyView(); // } // // @OnClick(R.id.list_goback) // public void onBackClicked() { // presenter.goBack(); // } // // @Override // public void onItemClicked(int position) { // presenter.onClickTile(position); // } // // @Override // public void initialize(RouteData... routes) { // hostDelegate.initialize(routes); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // hostDelegate.replace(oldComponent, newComponent); // } // // @Override // public void goTo(RouteData newComponent) { // hostDelegate.goTo(newComponent); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberFragment.java // public class NumberFragment extends Fragment implements NumberContract.View { // // @Inject // NumberComponent mNumberComponent; // // @BindView(R.id.number_text) // TextView number; // // private NumberContract.Presenter presenter; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // ((MainActivity) getActivity()).hostComponent.newPrivvyComponent().inject(this); // presenter = mNumberComponent.presenter(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.number_view, container, false); // } // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ButterKnife.bind(this, view); // presenter.setView(this); // } // // @Override // public void onDestroyView() { // super.onDestroyView(); // presenter.onDestroyView(); // } // // @Override // public void display(NumberViewModel viewModel) { // number.setText(String.valueOf(viewModel.number())); // } // // @Override // @OnLongClick(R.id.number_text) // public boolean onLongClickNumber() { // presenter.incrementNumberBy(); // return true; // } // // @Override // public void updateFontSize(int scale) { // number.setTranslationX(number.getTranslationX() + (10 * scale)); // } // }
import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonFragment; import com.metova.privvy.sample.ui.list.ListActivity; import com.metova.privvy.sample.ui.floatingnumber.number.NumberFragment; import dagger.Subcomponent;
package com.metova.privvy.sample.di; @PrivvyScope @Subcomponent(modules = PrivvyModule.class) public interface PrivvyComponent { void inject(ButtonFragment fragment); void inject(NumberFragment fragment);
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonFragment.java // public class ButtonFragment extends Fragment implements ButtonContract.View { // // @Inject // ButtonComponent buttonComponent; // // private ButtonContract.Presenter presenter; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // ((MainActivity) getActivity()).hostComponent.newPrivvyComponent().inject(this); // presenter = buttonComponent.presenter(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.button_view, container, false); // } // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ButterKnife.bind(this, view); // presenter.setView(this); // } // // @Override // public void onDestroyView() { // super.onDestroyView(); // presenter.onDestroyView(); // } // // @Override // @OnClick(R.id.increment_button) // public void onIncrementClick() { // presenter.incrementNumber(); // } // // @Override // @OnClick(R.id.decrement_button) // public void onDecrementClick() { // presenter.decrementNumber(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListActivity.java // public class ListActivity extends AppCompatActivity implements PrivvyHost, ListContract.View, ListAdapter.ListClickCallback { // // @Inject // ListComponent listComponent; // // PrivvyHostDelegate hostDelegate; // // @BindView(R.id.list_recyclerview) // RecyclerView numberList; // // private ListContract.Presenter presenter; // // private ListAdapter listAdapter = new ListAdapter(this); // // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // HostComponent hostComponent = SampleApplication.component.newHost() // .hostModule(new HostModule(this)) // .build(); // // hostComponent.newPrivvyComponent().inject(this); // // hostDelegate = new PrivvyHostDelegate(this); // // setContentView(R.layout.list_activity); // // ButterKnife.bind(this); // // presenter = listComponent.presenter(); // // numberList.setLayoutManager(new LinearLayoutManager(this)); // numberList.setAdapter(listAdapter); // // presenter.setView(this); // } // // @Override // public void updateList(List<ListViewModel> numbers) { // listAdapter.setNumbers(numbers); // } // // @Override // public void updateListItem(ListViewModel number) { // listAdapter.setListItem(number); // } // // @Override // protected void onDestroy() { // super.onDestroy(); // presenter.onDestroyView(); // } // // @OnClick(R.id.list_goback) // public void onBackClicked() { // presenter.goBack(); // } // // @Override // public void onItemClicked(int position) { // presenter.onClickTile(position); // } // // @Override // public void initialize(RouteData... routes) { // hostDelegate.initialize(routes); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // hostDelegate.replace(oldComponent, newComponent); // } // // @Override // public void goTo(RouteData newComponent) { // hostDelegate.goTo(newComponent); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberFragment.java // public class NumberFragment extends Fragment implements NumberContract.View { // // @Inject // NumberComponent mNumberComponent; // // @BindView(R.id.number_text) // TextView number; // // private NumberContract.Presenter presenter; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // ((MainActivity) getActivity()).hostComponent.newPrivvyComponent().inject(this); // presenter = mNumberComponent.presenter(); // } // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.number_view, container, false); // } // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ButterKnife.bind(this, view); // presenter.setView(this); // } // // @Override // public void onDestroyView() { // super.onDestroyView(); // presenter.onDestroyView(); // } // // @Override // public void display(NumberViewModel viewModel) { // number.setText(String.valueOf(viewModel.number())); // } // // @Override // @OnLongClick(R.id.number_text) // public boolean onLongClickNumber() { // presenter.incrementNumberBy(); // return true; // } // // @Override // public void updateFontSize(int scale) { // number.setTranslationX(number.getTranslationX() + (10 * scale)); // } // } // Path: sample/src/main/java/com/metova/privvy/sample/di/PrivvyComponent.java import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonFragment; import com.metova.privvy.sample.ui.list.ListActivity; import com.metova.privvy.sample.ui.floatingnumber.number.NumberFragment; import dagger.Subcomponent; package com.metova.privvy.sample.di; @PrivvyScope @Subcomponent(modules = PrivvyModule.class) public interface PrivvyComponent { void inject(ButtonFragment fragment); void inject(NumberFragment fragment);
void inject(ListActivity activity);
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonFragment.java
// Path: sample/src/main/java/com/metova/privvy/sample/MainActivity.java // public class MainActivity extends AppCompatActivity implements PrivvyHost { // // public HostComponent hostComponent; // // private PrivvyHostDelegate hostDelegate; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // hostComponent = SampleApplication.component.newHost() // .hostModule(new HostModule(this)) // .build(); // // hostDelegate = new PrivvyHostDelegate(this); // // setContentView(R.layout.main_activity); // // initialize(NumberComponent.ROUTE_DATA, ButtonComponent.ROUTE_DATA); // } // // @Override // public void initialize(RouteData... routeData) { // hostDelegate.initialize(routeData); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // hostDelegate.replace(oldComponent, newComponent); // } // // @Override // public void goTo(RouteData newComponent) { // hostDelegate.goTo(newComponent); // } // }
import com.metova.privvy.sample.MainActivity; import com.metova.privvy.sample.R; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import javax.inject.Inject; import butterknife.ButterKnife; import butterknife.OnClick;
package com.metova.privvy.sample.ui.floatingnumber.buttons; public class ButtonFragment extends Fragment implements ButtonContract.View { @Inject ButtonComponent buttonComponent; private ButtonContract.Presenter presenter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
// Path: sample/src/main/java/com/metova/privvy/sample/MainActivity.java // public class MainActivity extends AppCompatActivity implements PrivvyHost { // // public HostComponent hostComponent; // // private PrivvyHostDelegate hostDelegate; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // hostComponent = SampleApplication.component.newHost() // .hostModule(new HostModule(this)) // .build(); // // hostDelegate = new PrivvyHostDelegate(this); // // setContentView(R.layout.main_activity); // // initialize(NumberComponent.ROUTE_DATA, ButtonComponent.ROUTE_DATA); // } // // @Override // public void initialize(RouteData... routeData) { // hostDelegate.initialize(routeData); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // hostDelegate.replace(oldComponent, newComponent); // } // // @Override // public void goTo(RouteData newComponent) { // hostDelegate.goTo(newComponent); // } // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonFragment.java import com.metova.privvy.sample.MainActivity; import com.metova.privvy.sample.R; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import javax.inject.Inject; import butterknife.ButterKnife; import butterknife.OnClick; package com.metova.privvy.sample.ui.floatingnumber.buttons; public class ButtonFragment extends Fragment implements ButtonContract.View { @Inject ButtonComponent buttonComponent; private ButtonContract.Presenter presenter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
((MainActivity) getActivity()).hostComponent.newPrivvyComponent().inject(this);
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/skeleton/SkeletonModule.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // }
import com.metova.privvy.PrivvyHost; import dagger.Module; import dagger.Provides;
package com.metova.privvy.sample.ui.skeleton; @Module public final class SkeletonModule { public SkeletonModule() { } @Provides @SkeletonScope SkeletonContract.Presenter providePresenter(SkeletonContract.Interactor interactor) { return new SkeletonPresenter(interactor); } @Provides @SkeletonScope SkeletonContract.Interactor provideInteractor() { return new SkeletonInteractor(); } @Provides @SkeletonScope
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/skeleton/SkeletonModule.java import com.metova.privvy.PrivvyHost; import dagger.Module; import dagger.Provides; package com.metova.privvy.sample.ui.skeleton; @Module public final class SkeletonModule { public SkeletonModule() { } @Provides @SkeletonScope SkeletonContract.Presenter providePresenter(SkeletonContract.Interactor interactor) { return new SkeletonPresenter(interactor); } @Provides @SkeletonScope SkeletonContract.Interactor provideInteractor() { return new SkeletonInteractor(); } @Provides @SkeletonScope
SkeletonContract.Router provideRouter(PrivvyHost host) {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java
// Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // }
import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import com.metova.privvy.sample.R; import dagger.Subcomponent;
package com.metova.privvy.sample.ui.floatingnumber.number; @NumberScope @Subcomponent(modules = {NumberModule.class}) public interface NumberComponent {
// Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import com.metova.privvy.sample.R; import dagger.Subcomponent; package com.metova.privvy.sample.ui.floatingnumber.number; @NumberScope @Subcomponent(modules = {NumberModule.class}) public interface NumberComponent {
RouteData ROUTE_DATA = RouteData.Builder()
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java
// Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // }
import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import com.metova.privvy.sample.R; import dagger.Subcomponent;
package com.metova.privvy.sample.ui.floatingnumber.number; @NumberScope @Subcomponent(modules = {NumberModule.class}) public interface NumberComponent { RouteData ROUTE_DATA = RouteData.Builder()
// Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import com.metova.privvy.sample.R; import dagger.Subcomponent; package com.metova.privvy.sample.ui.floatingnumber.number; @NumberScope @Subcomponent(modules = {NumberModule.class}) public interface NumberComponent { RouteData ROUTE_DATA = RouteData.Builder()
.viewType(ViewType.FRAGMENT)
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberRouter.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyRouter.java // public class PrivvyRouter implements PrivvyContract.Router { // // private PrivvyHost host; // // public PrivvyRouter(PrivvyHost host) { // this.host = host; // } // // @Override // public PrivvyHost getHost() { // return host; // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListComponent.java // @ListScope // @Subcomponent(modules = {ListModule.class}) // public interface ListComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.ACTIVITY) // .viewClass(ListActivity.class) // .build(); // // ListContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder listModule(ListModule module); // // ListComponent build(); // } // // }
import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyRouter; import com.metova.privvy.sample.ui.list.ListComponent;
package com.metova.privvy.sample.ui.floatingnumber.number; class NumberRouter extends PrivvyRouter implements NumberContract.Router { NumberRouter(PrivvyHost host) { super(host); } @Override public void navigateToList() {
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyRouter.java // public class PrivvyRouter implements PrivvyContract.Router { // // private PrivvyHost host; // // public PrivvyRouter(PrivvyHost host) { // this.host = host; // } // // @Override // public PrivvyHost getHost() { // return host; // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListComponent.java // @ListScope // @Subcomponent(modules = {ListModule.class}) // public interface ListComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.ACTIVITY) // .viewClass(ListActivity.class) // .build(); // // ListContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder listModule(ListModule module); // // ListComponent build(); // } // // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberRouter.java import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyRouter; import com.metova.privvy.sample.ui.list.ListComponent; package com.metova.privvy.sample.ui.floatingnumber.number; class NumberRouter extends PrivvyRouter implements NumberContract.Router { NumberRouter(PrivvyHost host) { super(host); } @Override public void navigateToList() {
getHost().goTo(ListComponent.ROUTE_DATA);
metova/privvy
sample/src/test/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonInteractorTest.java
// Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // }
import com.metova.privvy.sample.db.FakeDb; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import static org.mockito.Mockito.verify;
package com.metova.privvy.sample.ui.floatingnumber.buttons; public class ButtonInteractorTest { @Mock
// Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // Path: sample/src/test/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonInteractorTest.java import com.metova.privvy.sample.db.FakeDb; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import static org.mockito.Mockito.verify; package com.metova.privvy.sample.ui.floatingnumber.buttons; public class ButtonInteractorTest { @Mock
FakeDb fakeDb;
metova/privvy
sample/src/androidTest/java/com/metova/privvy/sample/TestSampleApplication.java
// Path: sample/src/main/java/com/metova/privvy/sample/di/ApplicationComponent.java // @Singleton // @Component(modules = {ApplicationModule.class}) // public interface ApplicationComponent { // // HostComponent.Builder newHost(); // // FakeDb fakeDb(); // }
import com.metova.privvy.sample.di.ApplicationComponent; import timber.log.Timber;
package com.metova.privvy.sample; public class TestSampleApplication extends SampleApplication { @Override
// Path: sample/src/main/java/com/metova/privvy/sample/di/ApplicationComponent.java // @Singleton // @Component(modules = {ApplicationModule.class}) // public interface ApplicationComponent { // // HostComponent.Builder newHost(); // // FakeDb fakeDb(); // } // Path: sample/src/androidTest/java/com/metova/privvy/sample/TestSampleApplication.java import com.metova.privvy.sample.di.ApplicationComponent; import timber.log.Timber; package com.metova.privvy.sample; public class TestSampleApplication extends SampleApplication { @Override
protected ApplicationComponent buildComponent() {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/di/ApplicationComponent.java
// Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // }
import com.metova.privvy.sample.db.FakeDb; import javax.inject.Singleton; import dagger.Component;
package com.metova.privvy.sample.di; @Singleton @Component(modules = {ApplicationModule.class}) public interface ApplicationComponent { HostComponent.Builder newHost();
// Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // Path: sample/src/main/java/com/metova/privvy/sample/di/ApplicationComponent.java import com.metova.privvy.sample.db.FakeDb; import javax.inject.Singleton; import dagger.Component; package com.metova.privvy.sample.di; @Singleton @Component(modules = {ApplicationModule.class}) public interface ApplicationComponent { HostComponent.Builder newHost();
FakeDb fakeDb();
metova/privvy
sample/src/main/java/com/metova/privvy/sample/di/HostModule.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // }
import com.metova.privvy.PrivvyHost; import dagger.Module; import dagger.Provides;
package com.metova.privvy.sample.di; @Module public class HostModule {
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java import com.metova.privvy.PrivvyHost; import dagger.Module; import dagger.Provides; package com.metova.privvy.sample.di; @Module public class HostModule {
private final PrivvyHost host;
metova/privvy
sample/src/androidTest/java/com/metova/privvy/sample/TestApplicationComponent.java
// Path: sample/src/main/java/com/metova/privvy/sample/di/ApplicationComponent.java // @Singleton // @Component(modules = {ApplicationModule.class}) // public interface ApplicationComponent { // // HostComponent.Builder newHost(); // // FakeDb fakeDb(); // }
import com.metova.privvy.sample.di.ApplicationComponent; import javax.inject.Singleton; import dagger.Component;
package com.metova.privvy.sample; @Singleton @Component(modules = {TestApplicationModule.class})
// Path: sample/src/main/java/com/metova/privvy/sample/di/ApplicationComponent.java // @Singleton // @Component(modules = {ApplicationModule.class}) // public interface ApplicationComponent { // // HostComponent.Builder newHost(); // // FakeDb fakeDb(); // } // Path: sample/src/androidTest/java/com/metova/privvy/sample/TestApplicationComponent.java import com.metova.privvy.sample.di.ApplicationComponent; import javax.inject.Singleton; import dagger.Component; package com.metova.privvy.sample; @Singleton @Component(modules = {TestApplicationModule.class})
interface TestApplicationComponent extends ApplicationComponent {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/list/ListActivity.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/SampleApplication.java // public class SampleApplication extends Application { // // public static ApplicationComponent component; // // // @Override // public void onCreate() { // super.onCreate(); // // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // // component = buildComponent(); // } // // protected ApplicationComponent buildComponent() { // Timber.d("Building actual component"); // return DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)).build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // }
import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.R; import com.metova.privvy.sample.SampleApplication; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import java.util.List; import javax.inject.Inject; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick;
package com.metova.privvy.sample.ui.list; public class ListActivity extends AppCompatActivity implements PrivvyHost, ListContract.View, ListAdapter.ListClickCallback { @Inject ListComponent listComponent;
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/SampleApplication.java // public class SampleApplication extends Application { // // public static ApplicationComponent component; // // // @Override // public void onCreate() { // super.onCreate(); // // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // // component = buildComponent(); // } // // protected ApplicationComponent buildComponent() { // Timber.d("Building actual component"); // return DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)).build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListActivity.java import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.R; import com.metova.privvy.sample.SampleApplication; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import java.util.List; import javax.inject.Inject; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; package com.metova.privvy.sample.ui.list; public class ListActivity extends AppCompatActivity implements PrivvyHost, ListContract.View, ListAdapter.ListClickCallback { @Inject ListComponent listComponent;
PrivvyHostDelegate hostDelegate;
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/list/ListActivity.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/SampleApplication.java // public class SampleApplication extends Application { // // public static ApplicationComponent component; // // // @Override // public void onCreate() { // super.onCreate(); // // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // // component = buildComponent(); // } // // protected ApplicationComponent buildComponent() { // Timber.d("Building actual component"); // return DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)).build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // }
import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.R; import com.metova.privvy.sample.SampleApplication; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import java.util.List; import javax.inject.Inject; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick;
package com.metova.privvy.sample.ui.list; public class ListActivity extends AppCompatActivity implements PrivvyHost, ListContract.View, ListAdapter.ListClickCallback { @Inject ListComponent listComponent; PrivvyHostDelegate hostDelegate; @BindView(R.id.list_recyclerview) RecyclerView numberList; private ListContract.Presenter presenter; private ListAdapter listAdapter = new ListAdapter(this); @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState);
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/SampleApplication.java // public class SampleApplication extends Application { // // public static ApplicationComponent component; // // // @Override // public void onCreate() { // super.onCreate(); // // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // // component = buildComponent(); // } // // protected ApplicationComponent buildComponent() { // Timber.d("Building actual component"); // return DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)).build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListActivity.java import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.R; import com.metova.privvy.sample.SampleApplication; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import java.util.List; import javax.inject.Inject; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; package com.metova.privvy.sample.ui.list; public class ListActivity extends AppCompatActivity implements PrivvyHost, ListContract.View, ListAdapter.ListClickCallback { @Inject ListComponent listComponent; PrivvyHostDelegate hostDelegate; @BindView(R.id.list_recyclerview) RecyclerView numberList; private ListContract.Presenter presenter; private ListAdapter listAdapter = new ListAdapter(this); @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState);
HostComponent hostComponent = SampleApplication.component.newHost()
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/list/ListActivity.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/SampleApplication.java // public class SampleApplication extends Application { // // public static ApplicationComponent component; // // // @Override // public void onCreate() { // super.onCreate(); // // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // // component = buildComponent(); // } // // protected ApplicationComponent buildComponent() { // Timber.d("Building actual component"); // return DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)).build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // }
import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.R; import com.metova.privvy.sample.SampleApplication; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import java.util.List; import javax.inject.Inject; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick;
package com.metova.privvy.sample.ui.list; public class ListActivity extends AppCompatActivity implements PrivvyHost, ListContract.View, ListAdapter.ListClickCallback { @Inject ListComponent listComponent; PrivvyHostDelegate hostDelegate; @BindView(R.id.list_recyclerview) RecyclerView numberList; private ListContract.Presenter presenter; private ListAdapter listAdapter = new ListAdapter(this); @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState);
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/SampleApplication.java // public class SampleApplication extends Application { // // public static ApplicationComponent component; // // // @Override // public void onCreate() { // super.onCreate(); // // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // // component = buildComponent(); // } // // protected ApplicationComponent buildComponent() { // Timber.d("Building actual component"); // return DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)).build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListActivity.java import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.R; import com.metova.privvy.sample.SampleApplication; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import java.util.List; import javax.inject.Inject; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; package com.metova.privvy.sample.ui.list; public class ListActivity extends AppCompatActivity implements PrivvyHost, ListContract.View, ListAdapter.ListClickCallback { @Inject ListComponent listComponent; PrivvyHostDelegate hostDelegate; @BindView(R.id.list_recyclerview) RecyclerView numberList; private ListContract.Presenter presenter; private ListAdapter listAdapter = new ListAdapter(this); @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState);
HostComponent hostComponent = SampleApplication.component.newHost()
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/list/ListActivity.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/SampleApplication.java // public class SampleApplication extends Application { // // public static ApplicationComponent component; // // // @Override // public void onCreate() { // super.onCreate(); // // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // // component = buildComponent(); // } // // protected ApplicationComponent buildComponent() { // Timber.d("Building actual component"); // return DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)).build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // }
import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.R; import com.metova.privvy.sample.SampleApplication; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import java.util.List; import javax.inject.Inject; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick;
package com.metova.privvy.sample.ui.list; public class ListActivity extends AppCompatActivity implements PrivvyHost, ListContract.View, ListAdapter.ListClickCallback { @Inject ListComponent listComponent; PrivvyHostDelegate hostDelegate; @BindView(R.id.list_recyclerview) RecyclerView numberList; private ListContract.Presenter presenter; private ListAdapter listAdapter = new ListAdapter(this); @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); HostComponent hostComponent = SampleApplication.component.newHost()
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/SampleApplication.java // public class SampleApplication extends Application { // // public static ApplicationComponent component; // // // @Override // public void onCreate() { // super.onCreate(); // // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // // component = buildComponent(); // } // // protected ApplicationComponent buildComponent() { // Timber.d("Building actual component"); // return DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)).build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListActivity.java import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.R; import com.metova.privvy.sample.SampleApplication; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import java.util.List; import javax.inject.Inject; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; package com.metova.privvy.sample.ui.list; public class ListActivity extends AppCompatActivity implements PrivvyHost, ListContract.View, ListAdapter.ListClickCallback { @Inject ListComponent listComponent; PrivvyHostDelegate hostDelegate; @BindView(R.id.list_recyclerview) RecyclerView numberList; private ListContract.Presenter presenter; private ListAdapter listAdapter = new ListAdapter(this); @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); HostComponent hostComponent = SampleApplication.component.newHost()
.hostModule(new HostModule(this))
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/list/ListActivity.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/SampleApplication.java // public class SampleApplication extends Application { // // public static ApplicationComponent component; // // // @Override // public void onCreate() { // super.onCreate(); // // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // // component = buildComponent(); // } // // protected ApplicationComponent buildComponent() { // Timber.d("Building actual component"); // return DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)).build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // }
import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.R; import com.metova.privvy.sample.SampleApplication; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import java.util.List; import javax.inject.Inject; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick;
presenter.setView(this); } @Override public void updateList(List<ListViewModel> numbers) { listAdapter.setNumbers(numbers); } @Override public void updateListItem(ListViewModel number) { listAdapter.setListItem(number); } @Override protected void onDestroy() { super.onDestroy(); presenter.onDestroyView(); } @OnClick(R.id.list_goback) public void onBackClicked() { presenter.goBack(); } @Override public void onItemClicked(int position) { presenter.onClickTile(position); } @Override
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/SampleApplication.java // public class SampleApplication extends Application { // // public static ApplicationComponent component; // // // @Override // public void onCreate() { // super.onCreate(); // // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // // component = buildComponent(); // } // // protected ApplicationComponent buildComponent() { // Timber.d("Building actual component"); // return DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)).build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListActivity.java import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.R; import com.metova.privvy.sample.SampleApplication; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import java.util.List; import javax.inject.Inject; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; presenter.setView(this); } @Override public void updateList(List<ListViewModel> numbers) { listAdapter.setNumbers(numbers); } @Override public void updateListItem(ListViewModel number) { listAdapter.setListItem(number); } @Override protected void onDestroy() { super.onDestroy(); presenter.onDestroyView(); } @OnClick(R.id.list_goback) public void onBackClicked() { presenter.goBack(); } @Override public void onItemClicked(int position) { presenter.onClickTile(position); } @Override
public void initialize(RouteData... routes) {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/MainActivity.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // }
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent;
package com.metova.privvy.sample; public class MainActivity extends AppCompatActivity implements PrivvyHost { public HostComponent hostComponent;
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // } // Path: sample/src/main/java/com/metova/privvy/sample/MainActivity.java import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent; package com.metova.privvy.sample; public class MainActivity extends AppCompatActivity implements PrivvyHost { public HostComponent hostComponent;
private PrivvyHostDelegate hostDelegate;
metova/privvy
sample/src/main/java/com/metova/privvy/sample/MainActivity.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // }
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent;
package com.metova.privvy.sample; public class MainActivity extends AppCompatActivity implements PrivvyHost { public HostComponent hostComponent; private PrivvyHostDelegate hostDelegate; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); hostComponent = SampleApplication.component.newHost()
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // } // Path: sample/src/main/java/com/metova/privvy/sample/MainActivity.java import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent; package com.metova.privvy.sample; public class MainActivity extends AppCompatActivity implements PrivvyHost { public HostComponent hostComponent; private PrivvyHostDelegate hostDelegate; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); hostComponent = SampleApplication.component.newHost()
.hostModule(new HostModule(this))
metova/privvy
sample/src/main/java/com/metova/privvy/sample/MainActivity.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // }
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent;
package com.metova.privvy.sample; public class MainActivity extends AppCompatActivity implements PrivvyHost { public HostComponent hostComponent; private PrivvyHostDelegate hostDelegate; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); hostComponent = SampleApplication.component.newHost() .hostModule(new HostModule(this)) .build(); hostDelegate = new PrivvyHostDelegate(this); setContentView(R.layout.main_activity);
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // } // Path: sample/src/main/java/com/metova/privvy/sample/MainActivity.java import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent; package com.metova.privvy.sample; public class MainActivity extends AppCompatActivity implements PrivvyHost { public HostComponent hostComponent; private PrivvyHostDelegate hostDelegate; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); hostComponent = SampleApplication.component.newHost() .hostModule(new HostModule(this)) .build(); hostDelegate = new PrivvyHostDelegate(this); setContentView(R.layout.main_activity);
initialize(NumberComponent.ROUTE_DATA, ButtonComponent.ROUTE_DATA);
metova/privvy
sample/src/main/java/com/metova/privvy/sample/MainActivity.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // }
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent;
package com.metova.privvy.sample; public class MainActivity extends AppCompatActivity implements PrivvyHost { public HostComponent hostComponent; private PrivvyHostDelegate hostDelegate; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); hostComponent = SampleApplication.component.newHost() .hostModule(new HostModule(this)) .build(); hostDelegate = new PrivvyHostDelegate(this); setContentView(R.layout.main_activity);
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // } // Path: sample/src/main/java/com/metova/privvy/sample/MainActivity.java import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent; package com.metova.privvy.sample; public class MainActivity extends AppCompatActivity implements PrivvyHost { public HostComponent hostComponent; private PrivvyHostDelegate hostDelegate; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); hostComponent = SampleApplication.component.newHost() .hostModule(new HostModule(this)) .build(); hostDelegate = new PrivvyHostDelegate(this); setContentView(R.layout.main_activity);
initialize(NumberComponent.ROUTE_DATA, ButtonComponent.ROUTE_DATA);
metova/privvy
sample/src/main/java/com/metova/privvy/sample/MainActivity.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // }
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent;
package com.metova.privvy.sample; public class MainActivity extends AppCompatActivity implements PrivvyHost { public HostComponent hostComponent; private PrivvyHostDelegate hostDelegate; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); hostComponent = SampleApplication.component.newHost() .hostModule(new HostModule(this)) .build(); hostDelegate = new PrivvyHostDelegate(this); setContentView(R.layout.main_activity); initialize(NumberComponent.ROUTE_DATA, ButtonComponent.ROUTE_DATA); } @Override
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java // public class PrivvyHostDelegate implements PrivvyHost { // // private AppCompatActivity hostActivity; // // public PrivvyHostDelegate(AppCompatActivity hostActivity) { // this.hostActivity = hostActivity; // } // // @Override // public void initialize(RouteData... routeData) { // for (RouteData data : routeData) { // startComponent(data); // } // } // // private void startComponent(RouteData routeData) { // switch (routeData.viewType()) { // case ACTIVITY: // goTo(routeData); // break; // case FRAGMENT: // startFragment(routeData); // break; // } // } // // @Override // public void goTo(RouteData newComponent) { // hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass())); // } // // private void startFragment(RouteData routeData) { // commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag()); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag()); // } // // @SuppressWarnings("TryWithIdenticalCatches") // private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) { // try { // FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction(); // ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag); // ft.commit(); // } catch (InstantiationException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } // } // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java // @HostScope // @Subcomponent(modules = {HostModule.class, YokeModule.class}) // public interface HostComponent { // // PrivvyComponent newPrivvyComponent(); // // @Subcomponent.Builder // interface Builder { // // HostComponent.Builder hostModule(HostModule module); // // HostComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java // @Module // public class HostModule { // // private final PrivvyHost host; // // public HostModule(PrivvyHost host) { // this.host = host; // } // // @Provides // @HostScope // PrivvyHost provideHost() { // return host; // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // } // Path: sample/src/main/java/com/metova/privvy/sample/MainActivity.java import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.metova.privvy.PrivvyHost; import com.metova.privvy.PrivvyHostDelegate; import com.metova.privvy.RouteData; import com.metova.privvy.sample.di.HostComponent; import com.metova.privvy.sample.di.HostModule; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent; package com.metova.privvy.sample; public class MainActivity extends AppCompatActivity implements PrivvyHost { public HostComponent hostComponent; private PrivvyHostDelegate hostDelegate; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); hostComponent = SampleApplication.component.newHost() .hostModule(new HostModule(this)) .build(); hostDelegate = new PrivvyHostDelegate(this); setContentView(R.layout.main_activity); initialize(NumberComponent.ROUTE_DATA, ButtonComponent.ROUTE_DATA); } @Override
public void initialize(RouteData... routeData) {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java
// Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // }
import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import com.metova.privvy.sample.R; import dagger.Subcomponent;
package com.metova.privvy.sample.ui.floatingnumber.buttons; @ButtonScope @Subcomponent(modules = {ButtonModule.class}) public interface ButtonComponent {
// Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import com.metova.privvy.sample.R; import dagger.Subcomponent; package com.metova.privvy.sample.ui.floatingnumber.buttons; @ButtonScope @Subcomponent(modules = {ButtonModule.class}) public interface ButtonComponent {
RouteData ROUTE_DATA = RouteData.Builder()
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java
// Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // }
import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import com.metova.privvy.sample.R; import dagger.Subcomponent;
package com.metova.privvy.sample.ui.floatingnumber.buttons; @ButtonScope @Subcomponent(modules = {ButtonModule.class}) public interface ButtonComponent { RouteData ROUTE_DATA = RouteData.Builder()
// Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import com.metova.privvy.sample.R; import dagger.Subcomponent; package com.metova.privvy.sample.ui.floatingnumber.buttons; @ButtonScope @Subcomponent(modules = {ButtonModule.class}) public interface ButtonComponent { RouteData ROUTE_DATA = RouteData.Builder()
.viewType(ViewType.FRAGMENT)
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberContract.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyContract.java // public interface PrivvyContract { // // interface View { // // } // // interface Presenter<T extends PrivvyContract.View> { // // void setView(T view); // // void onDestroyView(); // // } // // interface Interactor { // // void dispose(); // } // // interface Router { // // PrivvyHost getHost(); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/models/Number.java // public class Number { // // public int value; // // public Number() { // } // }
import com.metova.privvy.PrivvyContract; import com.metova.privvy.sample.models.Number; import io.reactivex.Flowable;
package com.metova.privvy.sample.ui.floatingnumber.number; public interface NumberContract extends PrivvyContract { interface View extends PrivvyContract.View { boolean onLongClickNumber(); void display(NumberViewModel viewModel); void updateFontSize(int scale); } interface Presenter extends PrivvyContract.Presenter<View> { void incrementNumberBy();
// Path: privvy/src/main/java/com/metova/privvy/PrivvyContract.java // public interface PrivvyContract { // // interface View { // // } // // interface Presenter<T extends PrivvyContract.View> { // // void setView(T view); // // void onDestroyView(); // // } // // interface Interactor { // // void dispose(); // } // // interface Router { // // PrivvyHost getHost(); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/models/Number.java // public class Number { // // public int value; // // public Number() { // } // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberContract.java import com.metova.privvy.PrivvyContract; import com.metova.privvy.sample.models.Number; import io.reactivex.Flowable; package com.metova.privvy.sample.ui.floatingnumber.number; public interface NumberContract extends PrivvyContract { interface View extends PrivvyContract.View { boolean onLongClickNumber(); void display(NumberViewModel viewModel); void updateFontSize(int scale); } interface Presenter extends PrivvyContract.Presenter<View> { void incrementNumberBy();
void onNumberUpdated(Number number);
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/list/ListContract.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyContract.java // public interface PrivvyContract { // // interface View { // // } // // interface Presenter<T extends PrivvyContract.View> { // // void setView(T view); // // void onDestroyView(); // // } // // interface Interactor { // // void dispose(); // } // // interface Router { // // PrivvyHost getHost(); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/models/DescriptiveNumber.java // public class DescriptiveNumber { // // public int value; // public String description; // // public DescriptiveNumber() { // // } // }
import com.metova.privvy.PrivvyContract; import com.metova.privvy.sample.models.DescriptiveNumber; import java.util.List; import io.reactivex.Flowable;
package com.metova.privvy.sample.ui.list; public interface ListContract { interface View extends PrivvyContract.View { void updateList(List<ListViewModel> numbers); void updateListItem(ListViewModel number); } interface Presenter extends PrivvyContract.Presenter<View> { void onClickTile(int position); void goBack(); } interface Interactor extends PrivvyContract.Interactor {
// Path: privvy/src/main/java/com/metova/privvy/PrivvyContract.java // public interface PrivvyContract { // // interface View { // // } // // interface Presenter<T extends PrivvyContract.View> { // // void setView(T view); // // void onDestroyView(); // // } // // interface Interactor { // // void dispose(); // } // // interface Router { // // PrivvyHost getHost(); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/models/DescriptiveNumber.java // public class DescriptiveNumber { // // public int value; // public String description; // // public DescriptiveNumber() { // // } // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListContract.java import com.metova.privvy.PrivvyContract; import com.metova.privvy.sample.models.DescriptiveNumber; import java.util.List; import io.reactivex.Flowable; package com.metova.privvy.sample.ui.list; public interface ListContract { interface View extends PrivvyContract.View { void updateList(List<ListViewModel> numbers); void updateListItem(ListViewModel number); } interface Presenter extends PrivvyContract.Presenter<View> { void onClickTile(int position); void goBack(); } interface Interactor extends PrivvyContract.Interactor {
Flowable<List<DescriptiveNumber>> fetchNumberList();
metova/privvy
sample/src/main/java/com/metova/privvy/sample/di/PrivvyModule.java
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonModule.java // @Module // public final class ButtonModule { // // public ButtonModule() { // } // // @Provides // @ButtonScope // ButtonContract.Presenter providePresenter(ButtonContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new ButtonPresenter(interactor, numberUpdateYoke); // } // // @Provides // @ButtonScope // ButtonContract.Interactor provideInteractor(FakeDb fakeDb) { // return new ButtonInteractor(fakeDb); // } // // @Provides // @ButtonScope // ButtonContract.Router provideButtonRouter(PrivvyHost host) { // return new ButtonRouter(host); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListComponent.java // @ListScope // @Subcomponent(modules = {ListModule.class}) // public interface ListComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.ACTIVITY) // .viewClass(ListActivity.class) // .build(); // // ListContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder listModule(ListModule module); // // ListComponent build(); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListModule.java // @Module // public class ListModule { // // public ListModule() { // // } // // @Provides // @ListScope // ListContract.Presenter providePresenter(ListContract.Interactor interactor) { // return new ListPresenter(interactor); // } // // @Provides // @ListScope // ListContract.Interactor provideInteractor(FakeDb fakeDb, ListContract.Router router) { // return new ListInteractor(fakeDb, router); // } // // @Provides // @ListScope // ListContract.Router provideRouter(PrivvyHost host) { // return new ListRouter(host); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberModule.java // @Module // public final class NumberModule { // // @Provides // @NumberScope // NumberContract.Presenter providePresenter(NumberContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new NumberPresenter(interactor, numberUpdateYoke); // } // // @Provides // @NumberScope // NumberContract.Interactor provideInteractor(FakeDb fakeDb, NumberContract.Router router) { // return new NumberInteractor(router, fakeDb); // } // // @Provides // @NumberScope // NumberContract.Router provideRouter(PrivvyHost host) { // return new NumberRouter(host); // } // // // }
import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonModule; import com.metova.privvy.sample.ui.list.ListComponent; import com.metova.privvy.sample.ui.list.ListModule; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberModule; import dagger.Module; import dagger.Provides;
package com.metova.privvy.sample.di; @Module(subcomponents = { NumberComponent.class,
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonModule.java // @Module // public final class ButtonModule { // // public ButtonModule() { // } // // @Provides // @ButtonScope // ButtonContract.Presenter providePresenter(ButtonContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new ButtonPresenter(interactor, numberUpdateYoke); // } // // @Provides // @ButtonScope // ButtonContract.Interactor provideInteractor(FakeDb fakeDb) { // return new ButtonInteractor(fakeDb); // } // // @Provides // @ButtonScope // ButtonContract.Router provideButtonRouter(PrivvyHost host) { // return new ButtonRouter(host); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListComponent.java // @ListScope // @Subcomponent(modules = {ListModule.class}) // public interface ListComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.ACTIVITY) // .viewClass(ListActivity.class) // .build(); // // ListContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder listModule(ListModule module); // // ListComponent build(); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListModule.java // @Module // public class ListModule { // // public ListModule() { // // } // // @Provides // @ListScope // ListContract.Presenter providePresenter(ListContract.Interactor interactor) { // return new ListPresenter(interactor); // } // // @Provides // @ListScope // ListContract.Interactor provideInteractor(FakeDb fakeDb, ListContract.Router router) { // return new ListInteractor(fakeDb, router); // } // // @Provides // @ListScope // ListContract.Router provideRouter(PrivvyHost host) { // return new ListRouter(host); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberModule.java // @Module // public final class NumberModule { // // @Provides // @NumberScope // NumberContract.Presenter providePresenter(NumberContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new NumberPresenter(interactor, numberUpdateYoke); // } // // @Provides // @NumberScope // NumberContract.Interactor provideInteractor(FakeDb fakeDb, NumberContract.Router router) { // return new NumberInteractor(router, fakeDb); // } // // @Provides // @NumberScope // NumberContract.Router provideRouter(PrivvyHost host) { // return new NumberRouter(host); // } // // // } // Path: sample/src/main/java/com/metova/privvy/sample/di/PrivvyModule.java import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonModule; import com.metova.privvy.sample.ui.list.ListComponent; import com.metova.privvy.sample.ui.list.ListModule; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberModule; import dagger.Module; import dagger.Provides; package com.metova.privvy.sample.di; @Module(subcomponents = { NumberComponent.class,
ButtonComponent.class,
metova/privvy
sample/src/main/java/com/metova/privvy/sample/di/PrivvyModule.java
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonModule.java // @Module // public final class ButtonModule { // // public ButtonModule() { // } // // @Provides // @ButtonScope // ButtonContract.Presenter providePresenter(ButtonContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new ButtonPresenter(interactor, numberUpdateYoke); // } // // @Provides // @ButtonScope // ButtonContract.Interactor provideInteractor(FakeDb fakeDb) { // return new ButtonInteractor(fakeDb); // } // // @Provides // @ButtonScope // ButtonContract.Router provideButtonRouter(PrivvyHost host) { // return new ButtonRouter(host); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListComponent.java // @ListScope // @Subcomponent(modules = {ListModule.class}) // public interface ListComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.ACTIVITY) // .viewClass(ListActivity.class) // .build(); // // ListContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder listModule(ListModule module); // // ListComponent build(); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListModule.java // @Module // public class ListModule { // // public ListModule() { // // } // // @Provides // @ListScope // ListContract.Presenter providePresenter(ListContract.Interactor interactor) { // return new ListPresenter(interactor); // } // // @Provides // @ListScope // ListContract.Interactor provideInteractor(FakeDb fakeDb, ListContract.Router router) { // return new ListInteractor(fakeDb, router); // } // // @Provides // @ListScope // ListContract.Router provideRouter(PrivvyHost host) { // return new ListRouter(host); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberModule.java // @Module // public final class NumberModule { // // @Provides // @NumberScope // NumberContract.Presenter providePresenter(NumberContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new NumberPresenter(interactor, numberUpdateYoke); // } // // @Provides // @NumberScope // NumberContract.Interactor provideInteractor(FakeDb fakeDb, NumberContract.Router router) { // return new NumberInteractor(router, fakeDb); // } // // @Provides // @NumberScope // NumberContract.Router provideRouter(PrivvyHost host) { // return new NumberRouter(host); // } // // // }
import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonModule; import com.metova.privvy.sample.ui.list.ListComponent; import com.metova.privvy.sample.ui.list.ListModule; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberModule; import dagger.Module; import dagger.Provides;
package com.metova.privvy.sample.di; @Module(subcomponents = { NumberComponent.class, ButtonComponent.class,
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonModule.java // @Module // public final class ButtonModule { // // public ButtonModule() { // } // // @Provides // @ButtonScope // ButtonContract.Presenter providePresenter(ButtonContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new ButtonPresenter(interactor, numberUpdateYoke); // } // // @Provides // @ButtonScope // ButtonContract.Interactor provideInteractor(FakeDb fakeDb) { // return new ButtonInteractor(fakeDb); // } // // @Provides // @ButtonScope // ButtonContract.Router provideButtonRouter(PrivvyHost host) { // return new ButtonRouter(host); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListComponent.java // @ListScope // @Subcomponent(modules = {ListModule.class}) // public interface ListComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.ACTIVITY) // .viewClass(ListActivity.class) // .build(); // // ListContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder listModule(ListModule module); // // ListComponent build(); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListModule.java // @Module // public class ListModule { // // public ListModule() { // // } // // @Provides // @ListScope // ListContract.Presenter providePresenter(ListContract.Interactor interactor) { // return new ListPresenter(interactor); // } // // @Provides // @ListScope // ListContract.Interactor provideInteractor(FakeDb fakeDb, ListContract.Router router) { // return new ListInteractor(fakeDb, router); // } // // @Provides // @ListScope // ListContract.Router provideRouter(PrivvyHost host) { // return new ListRouter(host); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberModule.java // @Module // public final class NumberModule { // // @Provides // @NumberScope // NumberContract.Presenter providePresenter(NumberContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new NumberPresenter(interactor, numberUpdateYoke); // } // // @Provides // @NumberScope // NumberContract.Interactor provideInteractor(FakeDb fakeDb, NumberContract.Router router) { // return new NumberInteractor(router, fakeDb); // } // // @Provides // @NumberScope // NumberContract.Router provideRouter(PrivvyHost host) { // return new NumberRouter(host); // } // // // } // Path: sample/src/main/java/com/metova/privvy/sample/di/PrivvyModule.java import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonModule; import com.metova.privvy.sample.ui.list.ListComponent; import com.metova.privvy.sample.ui.list.ListModule; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberModule; import dagger.Module; import dagger.Provides; package com.metova.privvy.sample.di; @Module(subcomponents = { NumberComponent.class, ButtonComponent.class,
ListComponent.class,
metova/privvy
sample/src/main/java/com/metova/privvy/sample/di/PrivvyModule.java
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonModule.java // @Module // public final class ButtonModule { // // public ButtonModule() { // } // // @Provides // @ButtonScope // ButtonContract.Presenter providePresenter(ButtonContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new ButtonPresenter(interactor, numberUpdateYoke); // } // // @Provides // @ButtonScope // ButtonContract.Interactor provideInteractor(FakeDb fakeDb) { // return new ButtonInteractor(fakeDb); // } // // @Provides // @ButtonScope // ButtonContract.Router provideButtonRouter(PrivvyHost host) { // return new ButtonRouter(host); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListComponent.java // @ListScope // @Subcomponent(modules = {ListModule.class}) // public interface ListComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.ACTIVITY) // .viewClass(ListActivity.class) // .build(); // // ListContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder listModule(ListModule module); // // ListComponent build(); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListModule.java // @Module // public class ListModule { // // public ListModule() { // // } // // @Provides // @ListScope // ListContract.Presenter providePresenter(ListContract.Interactor interactor) { // return new ListPresenter(interactor); // } // // @Provides // @ListScope // ListContract.Interactor provideInteractor(FakeDb fakeDb, ListContract.Router router) { // return new ListInteractor(fakeDb, router); // } // // @Provides // @ListScope // ListContract.Router provideRouter(PrivvyHost host) { // return new ListRouter(host); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberModule.java // @Module // public final class NumberModule { // // @Provides // @NumberScope // NumberContract.Presenter providePresenter(NumberContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new NumberPresenter(interactor, numberUpdateYoke); // } // // @Provides // @NumberScope // NumberContract.Interactor provideInteractor(FakeDb fakeDb, NumberContract.Router router) { // return new NumberInteractor(router, fakeDb); // } // // @Provides // @NumberScope // NumberContract.Router provideRouter(PrivvyHost host) { // return new NumberRouter(host); // } // // // }
import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonModule; import com.metova.privvy.sample.ui.list.ListComponent; import com.metova.privvy.sample.ui.list.ListModule; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberModule; import dagger.Module; import dagger.Provides;
package com.metova.privvy.sample.di; @Module(subcomponents = { NumberComponent.class, ButtonComponent.class, ListComponent.class, // SkeletonComponent.class }) public class PrivvyModule { @Provides @PrivvyScope NumberComponent provideNumberComponent(NumberComponent.Builder builder) {
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonModule.java // @Module // public final class ButtonModule { // // public ButtonModule() { // } // // @Provides // @ButtonScope // ButtonContract.Presenter providePresenter(ButtonContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new ButtonPresenter(interactor, numberUpdateYoke); // } // // @Provides // @ButtonScope // ButtonContract.Interactor provideInteractor(FakeDb fakeDb) { // return new ButtonInteractor(fakeDb); // } // // @Provides // @ButtonScope // ButtonContract.Router provideButtonRouter(PrivvyHost host) { // return new ButtonRouter(host); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListComponent.java // @ListScope // @Subcomponent(modules = {ListModule.class}) // public interface ListComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.ACTIVITY) // .viewClass(ListActivity.class) // .build(); // // ListContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder listModule(ListModule module); // // ListComponent build(); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListModule.java // @Module // public class ListModule { // // public ListModule() { // // } // // @Provides // @ListScope // ListContract.Presenter providePresenter(ListContract.Interactor interactor) { // return new ListPresenter(interactor); // } // // @Provides // @ListScope // ListContract.Interactor provideInteractor(FakeDb fakeDb, ListContract.Router router) { // return new ListInteractor(fakeDb, router); // } // // @Provides // @ListScope // ListContract.Router provideRouter(PrivvyHost host) { // return new ListRouter(host); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberModule.java // @Module // public final class NumberModule { // // @Provides // @NumberScope // NumberContract.Presenter providePresenter(NumberContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new NumberPresenter(interactor, numberUpdateYoke); // } // // @Provides // @NumberScope // NumberContract.Interactor provideInteractor(FakeDb fakeDb, NumberContract.Router router) { // return new NumberInteractor(router, fakeDb); // } // // @Provides // @NumberScope // NumberContract.Router provideRouter(PrivvyHost host) { // return new NumberRouter(host); // } // // // } // Path: sample/src/main/java/com/metova/privvy/sample/di/PrivvyModule.java import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonModule; import com.metova.privvy.sample.ui.list.ListComponent; import com.metova.privvy.sample.ui.list.ListModule; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberModule; import dagger.Module; import dagger.Provides; package com.metova.privvy.sample.di; @Module(subcomponents = { NumberComponent.class, ButtonComponent.class, ListComponent.class, // SkeletonComponent.class }) public class PrivvyModule { @Provides @PrivvyScope NumberComponent provideNumberComponent(NumberComponent.Builder builder) {
return builder.numberModule(new NumberModule()).build();
metova/privvy
sample/src/main/java/com/metova/privvy/sample/di/PrivvyModule.java
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonModule.java // @Module // public final class ButtonModule { // // public ButtonModule() { // } // // @Provides // @ButtonScope // ButtonContract.Presenter providePresenter(ButtonContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new ButtonPresenter(interactor, numberUpdateYoke); // } // // @Provides // @ButtonScope // ButtonContract.Interactor provideInteractor(FakeDb fakeDb) { // return new ButtonInteractor(fakeDb); // } // // @Provides // @ButtonScope // ButtonContract.Router provideButtonRouter(PrivvyHost host) { // return new ButtonRouter(host); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListComponent.java // @ListScope // @Subcomponent(modules = {ListModule.class}) // public interface ListComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.ACTIVITY) // .viewClass(ListActivity.class) // .build(); // // ListContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder listModule(ListModule module); // // ListComponent build(); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListModule.java // @Module // public class ListModule { // // public ListModule() { // // } // // @Provides // @ListScope // ListContract.Presenter providePresenter(ListContract.Interactor interactor) { // return new ListPresenter(interactor); // } // // @Provides // @ListScope // ListContract.Interactor provideInteractor(FakeDb fakeDb, ListContract.Router router) { // return new ListInteractor(fakeDb, router); // } // // @Provides // @ListScope // ListContract.Router provideRouter(PrivvyHost host) { // return new ListRouter(host); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberModule.java // @Module // public final class NumberModule { // // @Provides // @NumberScope // NumberContract.Presenter providePresenter(NumberContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new NumberPresenter(interactor, numberUpdateYoke); // } // // @Provides // @NumberScope // NumberContract.Interactor provideInteractor(FakeDb fakeDb, NumberContract.Router router) { // return new NumberInteractor(router, fakeDb); // } // // @Provides // @NumberScope // NumberContract.Router provideRouter(PrivvyHost host) { // return new NumberRouter(host); // } // // // }
import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonModule; import com.metova.privvy.sample.ui.list.ListComponent; import com.metova.privvy.sample.ui.list.ListModule; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberModule; import dagger.Module; import dagger.Provides;
package com.metova.privvy.sample.di; @Module(subcomponents = { NumberComponent.class, ButtonComponent.class, ListComponent.class, // SkeletonComponent.class }) public class PrivvyModule { @Provides @PrivvyScope NumberComponent provideNumberComponent(NumberComponent.Builder builder) { return builder.numberModule(new NumberModule()).build(); } @Provides @PrivvyScope ButtonComponent provideButtonComponent(ButtonComponent.Builder builder) {
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonModule.java // @Module // public final class ButtonModule { // // public ButtonModule() { // } // // @Provides // @ButtonScope // ButtonContract.Presenter providePresenter(ButtonContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new ButtonPresenter(interactor, numberUpdateYoke); // } // // @Provides // @ButtonScope // ButtonContract.Interactor provideInteractor(FakeDb fakeDb) { // return new ButtonInteractor(fakeDb); // } // // @Provides // @ButtonScope // ButtonContract.Router provideButtonRouter(PrivvyHost host) { // return new ButtonRouter(host); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListComponent.java // @ListScope // @Subcomponent(modules = {ListModule.class}) // public interface ListComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.ACTIVITY) // .viewClass(ListActivity.class) // .build(); // // ListContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder listModule(ListModule module); // // ListComponent build(); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListModule.java // @Module // public class ListModule { // // public ListModule() { // // } // // @Provides // @ListScope // ListContract.Presenter providePresenter(ListContract.Interactor interactor) { // return new ListPresenter(interactor); // } // // @Provides // @ListScope // ListContract.Interactor provideInteractor(FakeDb fakeDb, ListContract.Router router) { // return new ListInteractor(fakeDb, router); // } // // @Provides // @ListScope // ListContract.Router provideRouter(PrivvyHost host) { // return new ListRouter(host); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberModule.java // @Module // public final class NumberModule { // // @Provides // @NumberScope // NumberContract.Presenter providePresenter(NumberContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new NumberPresenter(interactor, numberUpdateYoke); // } // // @Provides // @NumberScope // NumberContract.Interactor provideInteractor(FakeDb fakeDb, NumberContract.Router router) { // return new NumberInteractor(router, fakeDb); // } // // @Provides // @NumberScope // NumberContract.Router provideRouter(PrivvyHost host) { // return new NumberRouter(host); // } // // // } // Path: sample/src/main/java/com/metova/privvy/sample/di/PrivvyModule.java import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonModule; import com.metova.privvy.sample.ui.list.ListComponent; import com.metova.privvy.sample.ui.list.ListModule; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberModule; import dagger.Module; import dagger.Provides; package com.metova.privvy.sample.di; @Module(subcomponents = { NumberComponent.class, ButtonComponent.class, ListComponent.class, // SkeletonComponent.class }) public class PrivvyModule { @Provides @PrivvyScope NumberComponent provideNumberComponent(NumberComponent.Builder builder) { return builder.numberModule(new NumberModule()).build(); } @Provides @PrivvyScope ButtonComponent provideButtonComponent(ButtonComponent.Builder builder) {
return builder.buttonModule(new ButtonModule()).build();
metova/privvy
sample/src/main/java/com/metova/privvy/sample/di/PrivvyModule.java
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonModule.java // @Module // public final class ButtonModule { // // public ButtonModule() { // } // // @Provides // @ButtonScope // ButtonContract.Presenter providePresenter(ButtonContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new ButtonPresenter(interactor, numberUpdateYoke); // } // // @Provides // @ButtonScope // ButtonContract.Interactor provideInteractor(FakeDb fakeDb) { // return new ButtonInteractor(fakeDb); // } // // @Provides // @ButtonScope // ButtonContract.Router provideButtonRouter(PrivvyHost host) { // return new ButtonRouter(host); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListComponent.java // @ListScope // @Subcomponent(modules = {ListModule.class}) // public interface ListComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.ACTIVITY) // .viewClass(ListActivity.class) // .build(); // // ListContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder listModule(ListModule module); // // ListComponent build(); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListModule.java // @Module // public class ListModule { // // public ListModule() { // // } // // @Provides // @ListScope // ListContract.Presenter providePresenter(ListContract.Interactor interactor) { // return new ListPresenter(interactor); // } // // @Provides // @ListScope // ListContract.Interactor provideInteractor(FakeDb fakeDb, ListContract.Router router) { // return new ListInteractor(fakeDb, router); // } // // @Provides // @ListScope // ListContract.Router provideRouter(PrivvyHost host) { // return new ListRouter(host); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberModule.java // @Module // public final class NumberModule { // // @Provides // @NumberScope // NumberContract.Presenter providePresenter(NumberContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new NumberPresenter(interactor, numberUpdateYoke); // } // // @Provides // @NumberScope // NumberContract.Interactor provideInteractor(FakeDb fakeDb, NumberContract.Router router) { // return new NumberInteractor(router, fakeDb); // } // // @Provides // @NumberScope // NumberContract.Router provideRouter(PrivvyHost host) { // return new NumberRouter(host); // } // // // }
import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonModule; import com.metova.privvy.sample.ui.list.ListComponent; import com.metova.privvy.sample.ui.list.ListModule; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberModule; import dagger.Module; import dagger.Provides;
package com.metova.privvy.sample.di; @Module(subcomponents = { NumberComponent.class, ButtonComponent.class, ListComponent.class, // SkeletonComponent.class }) public class PrivvyModule { @Provides @PrivvyScope NumberComponent provideNumberComponent(NumberComponent.Builder builder) { return builder.numberModule(new NumberModule()).build(); } @Provides @PrivvyScope ButtonComponent provideButtonComponent(ButtonComponent.Builder builder) { return builder.buttonModule(new ButtonModule()).build(); } @Provides @PrivvyScope ListComponent provideListComponent(ListComponent.Builder builder) {
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java // @ButtonScope // @Subcomponent(modules = {ButtonModule.class}) // public interface ButtonComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(ButtonFragment.class) // .viewId(R.id.button_component) // .build(); // // ButtonContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // // Builder buttonModule(ButtonModule module); // // ButtonComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonModule.java // @Module // public final class ButtonModule { // // public ButtonModule() { // } // // @Provides // @ButtonScope // ButtonContract.Presenter providePresenter(ButtonContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new ButtonPresenter(interactor, numberUpdateYoke); // } // // @Provides // @ButtonScope // ButtonContract.Interactor provideInteractor(FakeDb fakeDb) { // return new ButtonInteractor(fakeDb); // } // // @Provides // @ButtonScope // ButtonContract.Router provideButtonRouter(PrivvyHost host) { // return new ButtonRouter(host); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListComponent.java // @ListScope // @Subcomponent(modules = {ListModule.class}) // public interface ListComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.ACTIVITY) // .viewClass(ListActivity.class) // .build(); // // ListContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder listModule(ListModule module); // // ListComponent build(); // } // // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListModule.java // @Module // public class ListModule { // // public ListModule() { // // } // // @Provides // @ListScope // ListContract.Presenter providePresenter(ListContract.Interactor interactor) { // return new ListPresenter(interactor); // } // // @Provides // @ListScope // ListContract.Interactor provideInteractor(FakeDb fakeDb, ListContract.Router router) { // return new ListInteractor(fakeDb, router); // } // // @Provides // @ListScope // ListContract.Router provideRouter(PrivvyHost host) { // return new ListRouter(host); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java // @NumberScope // @Subcomponent(modules = {NumberModule.class}) // public interface NumberComponent { // // RouteData ROUTE_DATA = RouteData.Builder() // .viewType(ViewType.FRAGMENT) // .viewClass(NumberFragment.class) // .viewId(R.id.number_component) // .build(); // // NumberContract.Presenter presenter(); // // @Subcomponent.Builder // interface Builder { // Builder numberModule(NumberModule module); // // NumberComponent build(); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberModule.java // @Module // public final class NumberModule { // // @Provides // @NumberScope // NumberContract.Presenter providePresenter(NumberContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { // return new NumberPresenter(interactor, numberUpdateYoke); // } // // @Provides // @NumberScope // NumberContract.Interactor provideInteractor(FakeDb fakeDb, NumberContract.Router router) { // return new NumberInteractor(router, fakeDb); // } // // @Provides // @NumberScope // NumberContract.Router provideRouter(PrivvyHost host) { // return new NumberRouter(host); // } // // // } // Path: sample/src/main/java/com/metova/privvy/sample/di/PrivvyModule.java import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent; import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonModule; import com.metova.privvy.sample.ui.list.ListComponent; import com.metova.privvy.sample.ui.list.ListModule; import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent; import com.metova.privvy.sample.ui.floatingnumber.number.NumberModule; import dagger.Module; import dagger.Provides; package com.metova.privvy.sample.di; @Module(subcomponents = { NumberComponent.class, ButtonComponent.class, ListComponent.class, // SkeletonComponent.class }) public class PrivvyModule { @Provides @PrivvyScope NumberComponent provideNumberComponent(NumberComponent.Builder builder) { return builder.numberModule(new NumberModule()).build(); } @Provides @PrivvyScope ButtonComponent provideButtonComponent(ButtonComponent.Builder builder) { return builder.buttonModule(new ButtonModule()).build(); } @Provides @PrivvyScope ListComponent provideListComponent(ListComponent.Builder builder) {
return builder.listModule(new ListModule()).build();
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/Application.java
// Path: src/main/java/org/openstreetmap/osmaxil/flow/__AbstractImportFlow.java // public abstract class __AbstractImportFlow<ELEMENT extends AbstractElement, IMPORT extends AbstractImport> { // // // ========================================================================= // // Instance variables // // ========================================================================= // // protected List<IMPORT> loadedImports = new ArrayList<>(); // // private Geometry includingArea; // // private Geometry excludingArea; // // protected GeometryFactory geometryFactory; // // @Value("${osmaxil.syncMode}") // protected String synchronizationMode; // // @Value("${osmaxil.minMatchingScore}") // protected float minMatchingScore; // // @Value("${osmaxil.refCodeSuffix}") // protected String refCodeSuffix; // // @Value("${osmaxil.useRefCode}") // protected boolean useReferenceCode; // // @Value("${osmaxil.filteringArea.srid}") // protected int filteringAreaSrid; // // @Value("${osmaxil.filteringArea.including}") // protected String includingAreaString; // // @Value("${osmaxil.filteringArea.excluding}") // protected String excludingAreaString; // // @Autowired // protected ApplicationContext appContext; // // @Autowired // protected OsmPostgisDB osmPostgis; // // @Autowired // protected OsmStandardApi osmStandardApi; // // @Autowired // protected OsmXmlFile osmXmlFile; // // // ========================================================================= // // Static variables // // ========================================================================= // // static protected final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // static protected final String LOG_SEPARATOR = "=========================================================="; // // // ========================================================================= // // Abstract methods // // ========================================================================= // // abstract public void load() throws Exception; // // abstract public void process(); // // abstract public void synchronize(); // // abstract public void displayLoadingStatistics(); // // abstract public void displayProcessingStatistics(); // // abstract public void displaySynchronizingStatistics(); // // // ========================================================================= // // Public and protected methods // // ========================================================================= // // protected boolean checkCoordinatesWithFilteringArea(double x, double y) { // Geometry geom = this.geometryFactory.createPoint(new Coordinate(x, y)); // IntersectionMatrix includingMatrix = geom.relate(this.includingArea); // if (!includingMatrix.isWithin()) { // LOGGER.info("Coordinates (" + x + ", " + y + ") are outside the including area " + this.includingAreaString); // return false; // } // IntersectionMatrix excludingMatrix = geom.relate(this.excludingArea); // if (excludingMatrix.isWithin()) { // LOGGER.info("Coordinates (" + x + ", " + y + ") are inside the excluding area " + this.excludingAreaString); // return false; // } // return true; // } // // // ========================================================================= // // Private methods // // ========================================================================= // // @PostConstruct // private void init() throws ParseException { // this.geometryFactory = new GeometryFactory(); // WKTReader wktReader = new WKTReader(); // // Build the including and excluding area // this.includingArea = wktReader.read(this.includingAreaString); // this.excludingArea = wktReader.read(this.excludingAreaString); // } // // }
import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.flow.__AbstractImportFlow; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.stereotype.Component;
package org.openstreetmap.osmaxil; @Component("OsmaxilApp") public class Application { @Value("${osmaxil.flow}") public String flow; public static final String NAME = "Osmaxil"; private static ClassPathXmlApplicationContext applicationContext; static private final Logger LOGGER = Logger.getLogger(Application.class); static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); public static void main(String[] args) { applicationContext = new ClassPathXmlApplicationContext("spring.xml"); Application app = (Application) applicationContext.getBean("OsmaxilApp"); LOGGER.info("=== Starting Osmaxil ==="); long startTime = System.currentTimeMillis(); try { app.run(); } catch (Exception e) { LOGGER.error(e); } LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); LOGGER.info("=== Osmaxil has finished its job ==="); applicationContext.close(); } public void run() throws Exception {
// Path: src/main/java/org/openstreetmap/osmaxil/flow/__AbstractImportFlow.java // public abstract class __AbstractImportFlow<ELEMENT extends AbstractElement, IMPORT extends AbstractImport> { // // // ========================================================================= // // Instance variables // // ========================================================================= // // protected List<IMPORT> loadedImports = new ArrayList<>(); // // private Geometry includingArea; // // private Geometry excludingArea; // // protected GeometryFactory geometryFactory; // // @Value("${osmaxil.syncMode}") // protected String synchronizationMode; // // @Value("${osmaxil.minMatchingScore}") // protected float minMatchingScore; // // @Value("${osmaxil.refCodeSuffix}") // protected String refCodeSuffix; // // @Value("${osmaxil.useRefCode}") // protected boolean useReferenceCode; // // @Value("${osmaxil.filteringArea.srid}") // protected int filteringAreaSrid; // // @Value("${osmaxil.filteringArea.including}") // protected String includingAreaString; // // @Value("${osmaxil.filteringArea.excluding}") // protected String excludingAreaString; // // @Autowired // protected ApplicationContext appContext; // // @Autowired // protected OsmPostgisDB osmPostgis; // // @Autowired // protected OsmStandardApi osmStandardApi; // // @Autowired // protected OsmXmlFile osmXmlFile; // // // ========================================================================= // // Static variables // // ========================================================================= // // static protected final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // static protected final String LOG_SEPARATOR = "=========================================================="; // // // ========================================================================= // // Abstract methods // // ========================================================================= // // abstract public void load() throws Exception; // // abstract public void process(); // // abstract public void synchronize(); // // abstract public void displayLoadingStatistics(); // // abstract public void displayProcessingStatistics(); // // abstract public void displaySynchronizingStatistics(); // // // ========================================================================= // // Public and protected methods // // ========================================================================= // // protected boolean checkCoordinatesWithFilteringArea(double x, double y) { // Geometry geom = this.geometryFactory.createPoint(new Coordinate(x, y)); // IntersectionMatrix includingMatrix = geom.relate(this.includingArea); // if (!includingMatrix.isWithin()) { // LOGGER.info("Coordinates (" + x + ", " + y + ") are outside the including area " + this.includingAreaString); // return false; // } // IntersectionMatrix excludingMatrix = geom.relate(this.excludingArea); // if (excludingMatrix.isWithin()) { // LOGGER.info("Coordinates (" + x + ", " + y + ") are inside the excluding area " + this.excludingAreaString); // return false; // } // return true; // } // // // ========================================================================= // // Private methods // // ========================================================================= // // @PostConstruct // private void init() throws ParseException { // this.geometryFactory = new GeometryFactory(); // WKTReader wktReader = new WKTReader(); // // Build the including and excluding area // this.includingArea = wktReader.read(this.includingAreaString); // this.excludingArea = wktReader.read(this.excludingAreaString); // } // // } // Path: src/main/java/org/openstreetmap/osmaxil/Application.java import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.flow.__AbstractImportFlow; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.stereotype.Component; package org.openstreetmap.osmaxil; @Component("OsmaxilApp") public class Application { @Value("${osmaxil.flow}") public String flow; public static final String NAME = "Osmaxil"; private static ClassPathXmlApplicationContext applicationContext; static private final Logger LOGGER = Logger.getLogger(Application.class); static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); public static void main(String[] args) { applicationContext = new ClassPathXmlApplicationContext("spring.xml"); Application app = (Application) applicationContext.getBean("OsmaxilApp"); LOGGER.info("=== Starting Osmaxil ==="); long startTime = System.currentTimeMillis(); try { app.run(); } catch (Exception e) { LOGGER.error(e); } LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); LOGGER.info("=== Osmaxil has finished its job ==="); applicationContext.close(); } public void run() throws Exception {
__AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow);
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/model/misc/ElementIdWithParentFlags.java
// Path: src/main/java/org/openstreetmap/osmaxil/model/ElementType.java // public enum ElementType { // // Node("node"), // // Way("way"), // // Relation("relation"); // // private String name; // // private ElementType(String name) { // this.name = name; // } // // public String getName() { // return this.name; // } // }
import java.util.ArrayList; import java.util.List; import org.openstreetmap.osmaxil.model.ElementType;
package org.openstreetmap.osmaxil.model.misc; public class ElementIdWithParentFlags { Long osmId;
// Path: src/main/java/org/openstreetmap/osmaxil/model/ElementType.java // public enum ElementType { // // Node("node"), // // Way("way"), // // Relation("relation"); // // private String name; // // private ElementType(String name) { // this.name = name; // } // // public String getName() { // return this.name; // } // } // Path: src/main/java/org/openstreetmap/osmaxil/model/misc/ElementIdWithParentFlags.java import java.util.ArrayList; import java.util.List; import org.openstreetmap.osmaxil.model.ElementType; package org.openstreetmap.osmaxil.model.misc; public class ElementIdWithParentFlags { Long osmId;
ElementType type;
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/dao/OsmXmlFile.java
// Path: src/main/java/org/openstreetmap/osmaxil/Application.java // @Component("OsmaxilApp") // public class Application { // // @Value("${osmaxil.flow}") // public String flow; // // public static final String NAME = "Osmaxil"; // // private static ClassPathXmlApplicationContext applicationContext; // // static private final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // public static void main(String[] args) { // applicationContext = new ClassPathXmlApplicationContext("spring.xml"); // Application app = (Application) applicationContext.getBean("OsmaxilApp"); // LOGGER.info("=== Starting Osmaxil ==="); // long startTime = System.currentTimeMillis(); // try { // app.run(); // } catch (Exception e) { // LOGGER.error(e); // } // LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); // LOGGER.info("=== Osmaxil has finished its job ==="); // applicationContext.close(); // } // // public void run() throws Exception { // __AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow); // flow.load(); // flow.process(); // flow.synchronize(); // flow.displayLoadingStatistics(); // flow.displayProcessingStatistics(); // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlRoot.java // @XmlRootElement(name = "osm") // public class OsmXmlRoot { // // @XmlAttribute // public float version; // // @XmlAttribute // public String generator; // // @XmlElement(name = "node") // public List<OsmXmlNode> nodes = new ArrayList<>();; // // @XmlElement(name = "way") // public List<OsmXmlWay> ways = new ArrayList<>();; // // @XmlElement(name = "relations") // public List<OsmXmlRelation> relations = new ArrayList<>(); // // }
import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import javax.annotation.PreDestroy; import javax.xml.transform.stream.StreamResult; import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.Application; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlRoot; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.oxm.Marshaller; import org.springframework.stereotype.Repository;
package org.openstreetmap.osmaxil.dao; @Repository public class OsmXmlFile { @Autowired @Qualifier(value = "osmMarshaller") private Marshaller marshaller; private int counterForWriteSuccess; private int counterForWriteFailures;
// Path: src/main/java/org/openstreetmap/osmaxil/Application.java // @Component("OsmaxilApp") // public class Application { // // @Value("${osmaxil.flow}") // public String flow; // // public static final String NAME = "Osmaxil"; // // private static ClassPathXmlApplicationContext applicationContext; // // static private final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // public static void main(String[] args) { // applicationContext = new ClassPathXmlApplicationContext("spring.xml"); // Application app = (Application) applicationContext.getBean("OsmaxilApp"); // LOGGER.info("=== Starting Osmaxil ==="); // long startTime = System.currentTimeMillis(); // try { // app.run(); // } catch (Exception e) { // LOGGER.error(e); // } // LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); // LOGGER.info("=== Osmaxil has finished its job ==="); // applicationContext.close(); // } // // public void run() throws Exception { // __AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow); // flow.load(); // flow.process(); // flow.synchronize(); // flow.displayLoadingStatistics(); // flow.displayProcessingStatistics(); // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlRoot.java // @XmlRootElement(name = "osm") // public class OsmXmlRoot { // // @XmlAttribute // public float version; // // @XmlAttribute // public String generator; // // @XmlElement(name = "node") // public List<OsmXmlNode> nodes = new ArrayList<>();; // // @XmlElement(name = "way") // public List<OsmXmlWay> ways = new ArrayList<>();; // // @XmlElement(name = "relations") // public List<OsmXmlRelation> relations = new ArrayList<>(); // // } // Path: src/main/java/org/openstreetmap/osmaxil/dao/OsmXmlFile.java import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import javax.annotation.PreDestroy; import javax.xml.transform.stream.StreamResult; import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.Application; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlRoot; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.oxm.Marshaller; import org.springframework.stereotype.Repository; package org.openstreetmap.osmaxil.dao; @Repository public class OsmXmlFile { @Autowired @Qualifier(value = "osmMarshaller") private Marshaller marshaller; private int counterForWriteSuccess; private int counterForWriteFailures;
static private final Logger LOGGER = Logger.getLogger(Application.class);
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/dao/OsmXmlFile.java
// Path: src/main/java/org/openstreetmap/osmaxil/Application.java // @Component("OsmaxilApp") // public class Application { // // @Value("${osmaxil.flow}") // public String flow; // // public static final String NAME = "Osmaxil"; // // private static ClassPathXmlApplicationContext applicationContext; // // static private final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // public static void main(String[] args) { // applicationContext = new ClassPathXmlApplicationContext("spring.xml"); // Application app = (Application) applicationContext.getBean("OsmaxilApp"); // LOGGER.info("=== Starting Osmaxil ==="); // long startTime = System.currentTimeMillis(); // try { // app.run(); // } catch (Exception e) { // LOGGER.error(e); // } // LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); // LOGGER.info("=== Osmaxil has finished its job ==="); // applicationContext.close(); // } // // public void run() throws Exception { // __AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow); // flow.load(); // flow.process(); // flow.synchronize(); // flow.displayLoadingStatistics(); // flow.displayProcessingStatistics(); // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlRoot.java // @XmlRootElement(name = "osm") // public class OsmXmlRoot { // // @XmlAttribute // public float version; // // @XmlAttribute // public String generator; // // @XmlElement(name = "node") // public List<OsmXmlNode> nodes = new ArrayList<>();; // // @XmlElement(name = "way") // public List<OsmXmlWay> ways = new ArrayList<>();; // // @XmlElement(name = "relations") // public List<OsmXmlRelation> relations = new ArrayList<>(); // // }
import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import javax.annotation.PreDestroy; import javax.xml.transform.stream.StreamResult; import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.Application; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlRoot; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.oxm.Marshaller; import org.springframework.stereotype.Repository;
package org.openstreetmap.osmaxil.dao; @Repository public class OsmXmlFile { @Autowired @Qualifier(value = "osmMarshaller") private Marshaller marshaller; private int counterForWriteSuccess; private int counterForWriteFailures; static private final Logger LOGGER = Logger.getLogger(Application.class); static private final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); static private final String GEN_DIR = "gen"; @PreDestroy public void close() { LOGGER_FOR_STATS.info("=== Closing OSM XML service ==="); LOGGER_FOR_STATS.info("Total of writing successes: " + this.counterForWriteSuccess); LOGGER_FOR_STATS.info("Total of writing failures: " + this.counterForWriteFailures); }
// Path: src/main/java/org/openstreetmap/osmaxil/Application.java // @Component("OsmaxilApp") // public class Application { // // @Value("${osmaxil.flow}") // public String flow; // // public static final String NAME = "Osmaxil"; // // private static ClassPathXmlApplicationContext applicationContext; // // static private final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // public static void main(String[] args) { // applicationContext = new ClassPathXmlApplicationContext("spring.xml"); // Application app = (Application) applicationContext.getBean("OsmaxilApp"); // LOGGER.info("=== Starting Osmaxil ==="); // long startTime = System.currentTimeMillis(); // try { // app.run(); // } catch (Exception e) { // LOGGER.error(e); // } // LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); // LOGGER.info("=== Osmaxil has finished its job ==="); // applicationContext.close(); // } // // public void run() throws Exception { // __AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow); // flow.load(); // flow.process(); // flow.synchronize(); // flow.displayLoadingStatistics(); // flow.displayProcessingStatistics(); // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlRoot.java // @XmlRootElement(name = "osm") // public class OsmXmlRoot { // // @XmlAttribute // public float version; // // @XmlAttribute // public String generator; // // @XmlElement(name = "node") // public List<OsmXmlNode> nodes = new ArrayList<>();; // // @XmlElement(name = "way") // public List<OsmXmlWay> ways = new ArrayList<>();; // // @XmlElement(name = "relations") // public List<OsmXmlRelation> relations = new ArrayList<>(); // // } // Path: src/main/java/org/openstreetmap/osmaxil/dao/OsmXmlFile.java import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import javax.annotation.PreDestroy; import javax.xml.transform.stream.StreamResult; import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.Application; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlRoot; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.oxm.Marshaller; import org.springframework.stereotype.Repository; package org.openstreetmap.osmaxil.dao; @Repository public class OsmXmlFile { @Autowired @Qualifier(value = "osmMarshaller") private Marshaller marshaller; private int counterForWriteSuccess; private int counterForWriteFailures; static private final Logger LOGGER = Logger.getLogger(Application.class); static private final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); static private final String GEN_DIR = "gen"; @PreDestroy public void close() { LOGGER_FOR_STATS.info("=== Closing OSM XML service ==="); LOGGER_FOR_STATS.info("Total of writing successes: " + this.counterForWriteSuccess); LOGGER_FOR_STATS.info("Total of writing failures: " + this.counterForWriteFailures); }
public boolean writeToFile(String name, OsmXmlRoot root) {
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/plugin/parser/AbstractImportParser.java
// Path: src/main/java/org/openstreetmap/osmaxil/Application.java // @Component("OsmaxilApp") // public class Application { // // @Value("${osmaxil.flow}") // public String flow; // // public static final String NAME = "Osmaxil"; // // private static ClassPathXmlApplicationContext applicationContext; // // static private final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // public static void main(String[] args) { // applicationContext = new ClassPathXmlApplicationContext("spring.xml"); // Application app = (Application) applicationContext.getBean("OsmaxilApp"); // LOGGER.info("=== Starting Osmaxil ==="); // long startTime = System.currentTimeMillis(); // try { // app.run(); // } catch (Exception e) { // LOGGER.error(e); // } // LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); // LOGGER.info("=== Osmaxil has finished its job ==="); // applicationContext.close(); // } // // public void run() throws Exception { // __AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow); // flow.load(); // flow.process(); // flow.synchronize(); // flow.displayLoadingStatistics(); // flow.displayProcessingStatistics(); // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/AbstractImport.java // public abstract class AbstractImport extends MatchableObject { // // protected long id; // // protected String name; // // protected Double latitude; // // protected Double longitude; // // protected AbstractElement matchingElement; // // abstract public String getValueByTagName(String tagName); // // @Override // public String toString() { // return "Element with id=[" + this.id + "] and name=[" + this.name + "]"; // } // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getLatitude() { // return latitude; // } // // public void setLatitude(Double latitude) { // this.latitude = latitude; // } // // public Double getLongitude() { // return longitude; // } // // public void setLongitude(Double longitude) { // this.longitude = longitude; // } // // public AbstractElement getMatchingElement() { // return matchingElement; // } // // public void setMatchingElement(AbstractElement matchingElement) { // this.matchingElement = matchingElement; // } // // }
import java.util.Iterator; import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.Application; import org.openstreetmap.osmaxil.model.AbstractImport; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Repository; import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.io.WKTReader;
package org.openstreetmap.osmaxil.plugin.parser; @Repository public abstract class AbstractImportParser<IMPORT extends AbstractImport> implements Iterator<IMPORT> { @Value("${parser.filePath}") protected String filePath; @Value("${parser.srid}") protected int srid; protected GeometryFactory geometryFactory = new GeometryFactory(); protected WKTReader wktReader = new WKTReader();
// Path: src/main/java/org/openstreetmap/osmaxil/Application.java // @Component("OsmaxilApp") // public class Application { // // @Value("${osmaxil.flow}") // public String flow; // // public static final String NAME = "Osmaxil"; // // private static ClassPathXmlApplicationContext applicationContext; // // static private final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // public static void main(String[] args) { // applicationContext = new ClassPathXmlApplicationContext("spring.xml"); // Application app = (Application) applicationContext.getBean("OsmaxilApp"); // LOGGER.info("=== Starting Osmaxil ==="); // long startTime = System.currentTimeMillis(); // try { // app.run(); // } catch (Exception e) { // LOGGER.error(e); // } // LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); // LOGGER.info("=== Osmaxil has finished its job ==="); // applicationContext.close(); // } // // public void run() throws Exception { // __AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow); // flow.load(); // flow.process(); // flow.synchronize(); // flow.displayLoadingStatistics(); // flow.displayProcessingStatistics(); // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/AbstractImport.java // public abstract class AbstractImport extends MatchableObject { // // protected long id; // // protected String name; // // protected Double latitude; // // protected Double longitude; // // protected AbstractElement matchingElement; // // abstract public String getValueByTagName(String tagName); // // @Override // public String toString() { // return "Element with id=[" + this.id + "] and name=[" + this.name + "]"; // } // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getLatitude() { // return latitude; // } // // public void setLatitude(Double latitude) { // this.latitude = latitude; // } // // public Double getLongitude() { // return longitude; // } // // public void setLongitude(Double longitude) { // this.longitude = longitude; // } // // public AbstractElement getMatchingElement() { // return matchingElement; // } // // public void setMatchingElement(AbstractElement matchingElement) { // this.matchingElement = matchingElement; // } // // } // Path: src/main/java/org/openstreetmap/osmaxil/plugin/parser/AbstractImportParser.java import java.util.Iterator; import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.Application; import org.openstreetmap.osmaxil.model.AbstractImport; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Repository; import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.io.WKTReader; package org.openstreetmap.osmaxil.plugin.parser; @Repository public abstract class AbstractImportParser<IMPORT extends AbstractImport> implements Iterator<IMPORT> { @Value("${parser.filePath}") protected String filePath; @Value("${parser.srid}") protected int srid; protected GeometryFactory geometryFactory = new GeometryFactory(); protected WKTReader wktReader = new WKTReader();
static protected final Logger LOGGER = Logger.getLogger(Application.class);
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/dao/ElevationRasterFile.java
// Path: src/main/java/org/openstreetmap/osmaxil/model/ElevationImport.java // public class ElevationImport extends AbstractImport { // // // private Coordinates coordinates; // // public float x, y, z; // // public ElevationImport(float x, float y, float z) { // this.x = x; // this.y = y; // this.z = z; // this.setId(Math.round(z)); // } // // @Override // public String getValueByTagName(String tagName) { // return "Sorry, there is no tag for that type of import"; // } // // @Override // public String toString() { // return "Elevation import with x=" + x + " y=" + y + " z=" + z; // } // // }
import java.util.ArrayList; import java.util.List; import org.gdal.gdal.Band; import org.gdal.gdal.Dataset; import org.gdal.gdal.gdal; import org.gdal.gdalconst.gdalconstConstants; import org.openstreetmap.osmaxil.model.ElevationImport;
public ElevationRasterFile(String source, int srid) { this.init(source, srid); } @Override public void init(String source, int srid) { this.filePath = source; this.srid = srid; gdal.AllRegister(); LOGGER.info("Opening " + this.filePath); this.dataset = gdal.Open(this.filePath, gdalconstConstants.GA_ReadOnly); int numBands = dataset.getRasterCount(); bands = new ArrayList<>(); LOGGER.info("Number of bands is: " + numBands); for (int i = 1; i <= numBands; i++) { this.bands.add(dataset.GetRasterBand(i)); } // Store the coordinates of the lower left point double[] geotransform = dataset.GetGeoTransform(); this.xUpperLeft = geotransform[0]; this.yUpperLeft = geotransform[3]; LOGGER.info("Upper left coordinates are: " + this.xUpperLeft + " " + this.yUpperLeft); // Store the pixel sizes this.xPixelSize = geotransform[1]; this.yPixelSize = Math.abs(geotransform[5]); LOGGER.info("Pixel sizes are: " + this.xPixelSize + " " + this.yPixelSize); } @Override
// Path: src/main/java/org/openstreetmap/osmaxil/model/ElevationImport.java // public class ElevationImport extends AbstractImport { // // // private Coordinates coordinates; // // public float x, y, z; // // public ElevationImport(float x, float y, float z) { // this.x = x; // this.y = y; // this.z = z; // this.setId(Math.round(z)); // } // // @Override // public String getValueByTagName(String tagName) { // return "Sorry, there is no tag for that type of import"; // } // // @Override // public String toString() { // return "Elevation import with x=" + x + " y=" + y + " z=" + z; // } // // } // Path: src/main/java/org/openstreetmap/osmaxil/dao/ElevationRasterFile.java import java.util.ArrayList; import java.util.List; import org.gdal.gdal.Band; import org.gdal.gdal.Dataset; import org.gdal.gdal.gdal; import org.gdal.gdalconst.gdalconstConstants; import org.openstreetmap.osmaxil.model.ElevationImport; public ElevationRasterFile(String source, int srid) { this.init(source, srid); } @Override public void init(String source, int srid) { this.filePath = source; this.srid = srid; gdal.AllRegister(); LOGGER.info("Opening " + this.filePath); this.dataset = gdal.Open(this.filePath, gdalconstConstants.GA_ReadOnly); int numBands = dataset.getRasterCount(); bands = new ArrayList<>(); LOGGER.info("Number of bands is: " + numBands); for (int i = 1; i <= numBands; i++) { this.bands.add(dataset.GetRasterBand(i)); } // Store the coordinates of the lower left point double[] geotransform = dataset.GetGeoTransform(); this.xUpperLeft = geotransform[0]; this.yUpperLeft = geotransform[3]; LOGGER.info("Upper left coordinates are: " + this.xUpperLeft + " " + this.yUpperLeft); // Store the pixel sizes this.xPixelSize = geotransform[1]; this.yPixelSize = Math.abs(geotransform[5]); LOGGER.info("Pixel sizes are: " + this.xPixelSize + " " + this.yPixelSize); } @Override
public ElevationImport findElevationByCoordinates(float x, float y, float valueScale, int srid) {
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/dao/ElevationDataSource.java
// Path: src/main/java/org/openstreetmap/osmaxil/Application.java // @Component("OsmaxilApp") // public class Application { // // @Value("${osmaxil.flow}") // public String flow; // // public static final String NAME = "Osmaxil"; // // private static ClassPathXmlApplicationContext applicationContext; // // static private final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // public static void main(String[] args) { // applicationContext = new ClassPathXmlApplicationContext("spring.xml"); // Application app = (Application) applicationContext.getBean("OsmaxilApp"); // LOGGER.info("=== Starting Osmaxil ==="); // long startTime = System.currentTimeMillis(); // try { // app.run(); // } catch (Exception e) { // LOGGER.error(e); // } // LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); // LOGGER.info("=== Osmaxil has finished its job ==="); // applicationContext.close(); // } // // public void run() throws Exception { // __AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow); // flow.load(); // flow.process(); // flow.synchronize(); // flow.displayLoadingStatistics(); // flow.displayProcessingStatistics(); // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/ElevationImport.java // public class ElevationImport extends AbstractImport { // // // private Coordinates coordinates; // // public float x, y, z; // // public ElevationImport(float x, float y, float z) { // this.x = x; // this.y = y; // this.z = z; // this.setId(Math.round(z)); // } // // @Override // public String getValueByTagName(String tagName) { // return "Sorry, there is no tag for that type of import"; // } // // @Override // public String toString() { // return "Elevation import with x=" + x + " y=" + y + " z=" + z; // } // // }
import java.util.List; import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.Application; import org.openstreetmap.osmaxil.model.ElevationImport;
package org.openstreetmap.osmaxil.dao; public interface ElevationDataSource { public enum Type { DB, FILE }; public enum Use { DTM, DSM };
// Path: src/main/java/org/openstreetmap/osmaxil/Application.java // @Component("OsmaxilApp") // public class Application { // // @Value("${osmaxil.flow}") // public String flow; // // public static final String NAME = "Osmaxil"; // // private static ClassPathXmlApplicationContext applicationContext; // // static private final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // public static void main(String[] args) { // applicationContext = new ClassPathXmlApplicationContext("spring.xml"); // Application app = (Application) applicationContext.getBean("OsmaxilApp"); // LOGGER.info("=== Starting Osmaxil ==="); // long startTime = System.currentTimeMillis(); // try { // app.run(); // } catch (Exception e) { // LOGGER.error(e); // } // LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); // LOGGER.info("=== Osmaxil has finished its job ==="); // applicationContext.close(); // } // // public void run() throws Exception { // __AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow); // flow.load(); // flow.process(); // flow.synchronize(); // flow.displayLoadingStatistics(); // flow.displayProcessingStatistics(); // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/ElevationImport.java // public class ElevationImport extends AbstractImport { // // // private Coordinates coordinates; // // public float x, y, z; // // public ElevationImport(float x, float y, float z) { // this.x = x; // this.y = y; // this.z = z; // this.setId(Math.round(z)); // } // // @Override // public String getValueByTagName(String tagName) { // return "Sorry, there is no tag for that type of import"; // } // // @Override // public String toString() { // return "Elevation import with x=" + x + " y=" + y + " z=" + z; // } // // } // Path: src/main/java/org/openstreetmap/osmaxil/dao/ElevationDataSource.java import java.util.List; import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.Application; import org.openstreetmap.osmaxil.model.ElevationImport; package org.openstreetmap.osmaxil.dao; public interface ElevationDataSource { public enum Type { DB, FILE }; public enum Use { DTM, DSM };
static public final Logger LOGGER = Logger.getLogger(Application.class);
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/dao/ElevationDataSource.java
// Path: src/main/java/org/openstreetmap/osmaxil/Application.java // @Component("OsmaxilApp") // public class Application { // // @Value("${osmaxil.flow}") // public String flow; // // public static final String NAME = "Osmaxil"; // // private static ClassPathXmlApplicationContext applicationContext; // // static private final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // public static void main(String[] args) { // applicationContext = new ClassPathXmlApplicationContext("spring.xml"); // Application app = (Application) applicationContext.getBean("OsmaxilApp"); // LOGGER.info("=== Starting Osmaxil ==="); // long startTime = System.currentTimeMillis(); // try { // app.run(); // } catch (Exception e) { // LOGGER.error(e); // } // LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); // LOGGER.info("=== Osmaxil has finished its job ==="); // applicationContext.close(); // } // // public void run() throws Exception { // __AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow); // flow.load(); // flow.process(); // flow.synchronize(); // flow.displayLoadingStatistics(); // flow.displayProcessingStatistics(); // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/ElevationImport.java // public class ElevationImport extends AbstractImport { // // // private Coordinates coordinates; // // public float x, y, z; // // public ElevationImport(float x, float y, float z) { // this.x = x; // this.y = y; // this.z = z; // this.setId(Math.round(z)); // } // // @Override // public String getValueByTagName(String tagName) { // return "Sorry, there is no tag for that type of import"; // } // // @Override // public String toString() { // return "Elevation import with x=" + x + " y=" + y + " z=" + z; // } // // }
import java.util.List; import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.Application; import org.openstreetmap.osmaxil.model.ElevationImport;
package org.openstreetmap.osmaxil.dao; public interface ElevationDataSource { public enum Type { DB, FILE }; public enum Use { DTM, DSM }; static public final Logger LOGGER = Logger.getLogger(Application.class); abstract void init(String source, int srid); abstract public int getSrid();
// Path: src/main/java/org/openstreetmap/osmaxil/Application.java // @Component("OsmaxilApp") // public class Application { // // @Value("${osmaxil.flow}") // public String flow; // // public static final String NAME = "Osmaxil"; // // private static ClassPathXmlApplicationContext applicationContext; // // static private final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // public static void main(String[] args) { // applicationContext = new ClassPathXmlApplicationContext("spring.xml"); // Application app = (Application) applicationContext.getBean("OsmaxilApp"); // LOGGER.info("=== Starting Osmaxil ==="); // long startTime = System.currentTimeMillis(); // try { // app.run(); // } catch (Exception e) { // LOGGER.error(e); // } // LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); // LOGGER.info("=== Osmaxil has finished its job ==="); // applicationContext.close(); // } // // public void run() throws Exception { // __AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow); // flow.load(); // flow.process(); // flow.synchronize(); // flow.displayLoadingStatistics(); // flow.displayProcessingStatistics(); // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/ElevationImport.java // public class ElevationImport extends AbstractImport { // // // private Coordinates coordinates; // // public float x, y, z; // // public ElevationImport(float x, float y, float z) { // this.x = x; // this.y = y; // this.z = z; // this.setId(Math.round(z)); // } // // @Override // public String getValueByTagName(String tagName) { // return "Sorry, there is no tag for that type of import"; // } // // @Override // public String toString() { // return "Elevation import with x=" + x + " y=" + y + " z=" + z; // } // // } // Path: src/main/java/org/openstreetmap/osmaxil/dao/ElevationDataSource.java import java.util.List; import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.Application; import org.openstreetmap.osmaxil.model.ElevationImport; package org.openstreetmap.osmaxil.dao; public interface ElevationDataSource { public enum Type { DB, FILE }; public enum Use { DTM, DSM }; static public final Logger LOGGER = Logger.getLogger(Application.class); abstract void init(String source, int srid); abstract public int getSrid();
abstract public ElevationImport findElevationByCoordinates(float x, float y, float valueScale, int srid);
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/flow/VegetationElevatorFlow.java
// Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationElement.java // public class VegetationElement extends AbstractElement { // // public VegetationElement(long osmId) { // super(osmId); // } // // @Override // public ElementType getType() { // return ElementType.Node; // } // // @Override // public List<OsmXmlTag> getTags() { // return this.getApiData().nodes.get(0).tags; // } // // @Override // public void setTags(List<OsmXmlTag> tags) { // this.getApiData().nodes.get(0).tags = tags; // } // // @Override // public void updateChangeset(long changesetId) { // this.getApiData().nodes.get(0).changeset = changesetId; // } // // public Double getLatitude() { // return Double.parseDouble(this.getApiData().nodes.get(0).lat); // } // // public Double getLongitude() { // return Double.parseDouble(this.getApiData().nodes.get(0).lon); // } // // public void setLatitude(Double lat) { // this.getApiData().nodes.get(0).lat = lat.toString(); // } // // public void setLongitude(Double lon) { // this.getApiData().nodes.get(0).lon = lon.toString(); // } // // @Override // public String toString() { // return "OSM tree has id=[" + this.getOsmId() + "], coords=[" + this.getLongitude() + " " + this.getLatitude() + "] genus=[" // + this.getTagValue(ElementTag.GENUS) + "], species=[" + this.getTagValue(ElementTag.SPECIES) + "], name=[" + this.getName() + "]"; // } // // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationImport.java // public class VegetationImport extends AbstractImport { // // private String genus; // // private String species; // // private String reference; // // private Integer height; // // private Float circumference; // // private Integer plantingYear; // // @Override // public String getValueByTagName(String tagName) { // if (ElementTag.GENUS.equals(tagName)) { // return this.genus.toString(); // } else if (ElementTag.SPECIES.equals(tagName)) { // return this.species.toString(); // } // return null; // } // // @Override // public String toString() { // return "VegetationImport with id=[" + this.id + "], coords=[" + this.latitude + ", " + this.longitude + "], genus=[" + this.genus + "], species=[" // + this.species + "], height=[" + this.height + "], circumference=[" + this.circumference + "] ref=[" + this.reference + "]"; // } // // public String getReference() { // return reference; // } // // public void setReference(String reference) { // this.reference = reference; // } // // public String getGenus() { // return genus; // } // // public void setGenus(String genus) { // this.genus = genus; // } // // public String getSpecies() { // return species; // } // // public void setSpecies(String subType) { // this.species = subType; // } // // public Integer getHeight() { // return height; // } // // public void setHeight(Integer height) { // this.height = height; // } // // public Float getCircumference() { // return circumference; // } // // public void setCircumference(Float circumference) { // this.circumference = circumference; // } // // public Integer getPlantingYear() { // return plantingYear; // } // // public void setPlantingYear(Integer plantingYear) { // this.plantingYear = plantingYear; // } // }
import java.util.List; import org.openstreetmap.osmaxil.model.VegetationElement; import org.openstreetmap.osmaxil.model.VegetationImport; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component;
package org.openstreetmap.osmaxil.flow; @Component("VegetationElevator") @Lazy
// Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationElement.java // public class VegetationElement extends AbstractElement { // // public VegetationElement(long osmId) { // super(osmId); // } // // @Override // public ElementType getType() { // return ElementType.Node; // } // // @Override // public List<OsmXmlTag> getTags() { // return this.getApiData().nodes.get(0).tags; // } // // @Override // public void setTags(List<OsmXmlTag> tags) { // this.getApiData().nodes.get(0).tags = tags; // } // // @Override // public void updateChangeset(long changesetId) { // this.getApiData().nodes.get(0).changeset = changesetId; // } // // public Double getLatitude() { // return Double.parseDouble(this.getApiData().nodes.get(0).lat); // } // // public Double getLongitude() { // return Double.parseDouble(this.getApiData().nodes.get(0).lon); // } // // public void setLatitude(Double lat) { // this.getApiData().nodes.get(0).lat = lat.toString(); // } // // public void setLongitude(Double lon) { // this.getApiData().nodes.get(0).lon = lon.toString(); // } // // @Override // public String toString() { // return "OSM tree has id=[" + this.getOsmId() + "], coords=[" + this.getLongitude() + " " + this.getLatitude() + "] genus=[" // + this.getTagValue(ElementTag.GENUS) + "], species=[" + this.getTagValue(ElementTag.SPECIES) + "], name=[" + this.getName() + "]"; // } // // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationImport.java // public class VegetationImport extends AbstractImport { // // private String genus; // // private String species; // // private String reference; // // private Integer height; // // private Float circumference; // // private Integer plantingYear; // // @Override // public String getValueByTagName(String tagName) { // if (ElementTag.GENUS.equals(tagName)) { // return this.genus.toString(); // } else if (ElementTag.SPECIES.equals(tagName)) { // return this.species.toString(); // } // return null; // } // // @Override // public String toString() { // return "VegetationImport with id=[" + this.id + "], coords=[" + this.latitude + ", " + this.longitude + "], genus=[" + this.genus + "], species=[" // + this.species + "], height=[" + this.height + "], circumference=[" + this.circumference + "] ref=[" + this.reference + "]"; // } // // public String getReference() { // return reference; // } // // public void setReference(String reference) { // this.reference = reference; // } // // public String getGenus() { // return genus; // } // // public void setGenus(String genus) { // this.genus = genus; // } // // public String getSpecies() { // return species; // } // // public void setSpecies(String subType) { // this.species = subType; // } // // public Integer getHeight() { // return height; // } // // public void setHeight(Integer height) { // this.height = height; // } // // public Float getCircumference() { // return circumference; // } // // public void setCircumference(Float circumference) { // this.circumference = circumference; // } // // public Integer getPlantingYear() { // return plantingYear; // } // // public void setPlantingYear(Integer plantingYear) { // this.plantingYear = plantingYear; // } // } // Path: src/main/java/org/openstreetmap/osmaxil/flow/VegetationElevatorFlow.java import java.util.List; import org.openstreetmap.osmaxil.model.VegetationElement; import org.openstreetmap.osmaxil.model.VegetationImport; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; package org.openstreetmap.osmaxil.flow; @Component("VegetationElevator") @Lazy
public class VegetationElevatorFlow extends AbstractElevatorFlow<VegetationElement, VegetationImport> {
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/flow/VegetationElevatorFlow.java
// Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationElement.java // public class VegetationElement extends AbstractElement { // // public VegetationElement(long osmId) { // super(osmId); // } // // @Override // public ElementType getType() { // return ElementType.Node; // } // // @Override // public List<OsmXmlTag> getTags() { // return this.getApiData().nodes.get(0).tags; // } // // @Override // public void setTags(List<OsmXmlTag> tags) { // this.getApiData().nodes.get(0).tags = tags; // } // // @Override // public void updateChangeset(long changesetId) { // this.getApiData().nodes.get(0).changeset = changesetId; // } // // public Double getLatitude() { // return Double.parseDouble(this.getApiData().nodes.get(0).lat); // } // // public Double getLongitude() { // return Double.parseDouble(this.getApiData().nodes.get(0).lon); // } // // public void setLatitude(Double lat) { // this.getApiData().nodes.get(0).lat = lat.toString(); // } // // public void setLongitude(Double lon) { // this.getApiData().nodes.get(0).lon = lon.toString(); // } // // @Override // public String toString() { // return "OSM tree has id=[" + this.getOsmId() + "], coords=[" + this.getLongitude() + " " + this.getLatitude() + "] genus=[" // + this.getTagValue(ElementTag.GENUS) + "], species=[" + this.getTagValue(ElementTag.SPECIES) + "], name=[" + this.getName() + "]"; // } // // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationImport.java // public class VegetationImport extends AbstractImport { // // private String genus; // // private String species; // // private String reference; // // private Integer height; // // private Float circumference; // // private Integer plantingYear; // // @Override // public String getValueByTagName(String tagName) { // if (ElementTag.GENUS.equals(tagName)) { // return this.genus.toString(); // } else if (ElementTag.SPECIES.equals(tagName)) { // return this.species.toString(); // } // return null; // } // // @Override // public String toString() { // return "VegetationImport with id=[" + this.id + "], coords=[" + this.latitude + ", " + this.longitude + "], genus=[" + this.genus + "], species=[" // + this.species + "], height=[" + this.height + "], circumference=[" + this.circumference + "] ref=[" + this.reference + "]"; // } // // public String getReference() { // return reference; // } // // public void setReference(String reference) { // this.reference = reference; // } // // public String getGenus() { // return genus; // } // // public void setGenus(String genus) { // this.genus = genus; // } // // public String getSpecies() { // return species; // } // // public void setSpecies(String subType) { // this.species = subType; // } // // public Integer getHeight() { // return height; // } // // public void setHeight(Integer height) { // this.height = height; // } // // public Float getCircumference() { // return circumference; // } // // public void setCircumference(Float circumference) { // this.circumference = circumference; // } // // public Integer getPlantingYear() { // return plantingYear; // } // // public void setPlantingYear(Integer plantingYear) { // this.plantingYear = plantingYear; // } // }
import java.util.List; import org.openstreetmap.osmaxil.model.VegetationElement; import org.openstreetmap.osmaxil.model.VegetationImport; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component;
package org.openstreetmap.osmaxil.flow; @Component("VegetationElevator") @Lazy
// Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationElement.java // public class VegetationElement extends AbstractElement { // // public VegetationElement(long osmId) { // super(osmId); // } // // @Override // public ElementType getType() { // return ElementType.Node; // } // // @Override // public List<OsmXmlTag> getTags() { // return this.getApiData().nodes.get(0).tags; // } // // @Override // public void setTags(List<OsmXmlTag> tags) { // this.getApiData().nodes.get(0).tags = tags; // } // // @Override // public void updateChangeset(long changesetId) { // this.getApiData().nodes.get(0).changeset = changesetId; // } // // public Double getLatitude() { // return Double.parseDouble(this.getApiData().nodes.get(0).lat); // } // // public Double getLongitude() { // return Double.parseDouble(this.getApiData().nodes.get(0).lon); // } // // public void setLatitude(Double lat) { // this.getApiData().nodes.get(0).lat = lat.toString(); // } // // public void setLongitude(Double lon) { // this.getApiData().nodes.get(0).lon = lon.toString(); // } // // @Override // public String toString() { // return "OSM tree has id=[" + this.getOsmId() + "], coords=[" + this.getLongitude() + " " + this.getLatitude() + "] genus=[" // + this.getTagValue(ElementTag.GENUS) + "], species=[" + this.getTagValue(ElementTag.SPECIES) + "], name=[" + this.getName() + "]"; // } // // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationImport.java // public class VegetationImport extends AbstractImport { // // private String genus; // // private String species; // // private String reference; // // private Integer height; // // private Float circumference; // // private Integer plantingYear; // // @Override // public String getValueByTagName(String tagName) { // if (ElementTag.GENUS.equals(tagName)) { // return this.genus.toString(); // } else if (ElementTag.SPECIES.equals(tagName)) { // return this.species.toString(); // } // return null; // } // // @Override // public String toString() { // return "VegetationImport with id=[" + this.id + "], coords=[" + this.latitude + ", " + this.longitude + "], genus=[" + this.genus + "], species=[" // + this.species + "], height=[" + this.height + "], circumference=[" + this.circumference + "] ref=[" + this.reference + "]"; // } // // public String getReference() { // return reference; // } // // public void setReference(String reference) { // this.reference = reference; // } // // public String getGenus() { // return genus; // } // // public void setGenus(String genus) { // this.genus = genus; // } // // public String getSpecies() { // return species; // } // // public void setSpecies(String subType) { // this.species = subType; // } // // public Integer getHeight() { // return height; // } // // public void setHeight(Integer height) { // this.height = height; // } // // public Float getCircumference() { // return circumference; // } // // public void setCircumference(Float circumference) { // this.circumference = circumference; // } // // public Integer getPlantingYear() { // return plantingYear; // } // // public void setPlantingYear(Integer plantingYear) { // this.plantingYear = plantingYear; // } // } // Path: src/main/java/org/openstreetmap/osmaxil/flow/VegetationElevatorFlow.java import java.util.List; import org.openstreetmap.osmaxil.model.VegetationElement; import org.openstreetmap.osmaxil.model.VegetationImport; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; package org.openstreetmap.osmaxil.flow; @Component("VegetationElevator") @Lazy
public class VegetationElevatorFlow extends AbstractElevatorFlow<VegetationElement, VegetationImport> {
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/plugin/parser/GrenobleVegetationImportParser.java
// Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationImport.java // public class VegetationImport extends AbstractImport { // // private String genus; // // private String species; // // private String reference; // // private Integer height; // // private Float circumference; // // private Integer plantingYear; // // @Override // public String getValueByTagName(String tagName) { // if (ElementTag.GENUS.equals(tagName)) { // return this.genus.toString(); // } else if (ElementTag.SPECIES.equals(tagName)) { // return this.species.toString(); // } // return null; // } // // @Override // public String toString() { // return "VegetationImport with id=[" + this.id + "], coords=[" + this.latitude + ", " + this.longitude + "], genus=[" + this.genus + "], species=[" // + this.species + "], height=[" + this.height + "], circumference=[" + this.circumference + "] ref=[" + this.reference + "]"; // } // // public String getReference() { // return reference; // } // // public void setReference(String reference) { // this.reference = reference; // } // // public String getGenus() { // return genus; // } // // public void setGenus(String genus) { // this.genus = genus; // } // // public String getSpecies() { // return species; // } // // public void setSpecies(String subType) { // this.species = subType; // } // // public Integer getHeight() { // return height; // } // // public void setHeight(Integer height) { // this.height = height; // } // // public Float getCircumference() { // return circumference; // } // // public void setCircumference(Float circumference) { // this.circumference = circumference; // } // // public Integer getPlantingYear() { // return plantingYear; // } // // public void setPlantingYear(Integer plantingYear) { // this.plantingYear = plantingYear; // } // }
import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Paths; import javax.annotation.PostConstruct; import org.openstreetmap.osmaxil.model.VegetationImport; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; import com.google.gson.Gson;
package org.openstreetmap.osmaxil.plugin.parser; @Component("GrenobleVegetationImportParser") @Lazy
// Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationImport.java // public class VegetationImport extends AbstractImport { // // private String genus; // // private String species; // // private String reference; // // private Integer height; // // private Float circumference; // // private Integer plantingYear; // // @Override // public String getValueByTagName(String tagName) { // if (ElementTag.GENUS.equals(tagName)) { // return this.genus.toString(); // } else if (ElementTag.SPECIES.equals(tagName)) { // return this.species.toString(); // } // return null; // } // // @Override // public String toString() { // return "VegetationImport with id=[" + this.id + "], coords=[" + this.latitude + ", " + this.longitude + "], genus=[" + this.genus + "], species=[" // + this.species + "], height=[" + this.height + "], circumference=[" + this.circumference + "] ref=[" + this.reference + "]"; // } // // public String getReference() { // return reference; // } // // public void setReference(String reference) { // this.reference = reference; // } // // public String getGenus() { // return genus; // } // // public void setGenus(String genus) { // this.genus = genus; // } // // public String getSpecies() { // return species; // } // // public void setSpecies(String subType) { // this.species = subType; // } // // public Integer getHeight() { // return height; // } // // public void setHeight(Integer height) { // this.height = height; // } // // public Float getCircumference() { // return circumference; // } // // public void setCircumference(Float circumference) { // this.circumference = circumference; // } // // public Integer getPlantingYear() { // return plantingYear; // } // // public void setPlantingYear(Integer plantingYear) { // this.plantingYear = plantingYear; // } // } // Path: src/main/java/org/openstreetmap/osmaxil/plugin/parser/GrenobleVegetationImportParser.java import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Paths; import javax.annotation.PostConstruct; import org.openstreetmap.osmaxil.model.VegetationImport; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; import com.google.gson.Gson; package org.openstreetmap.osmaxil.plugin.parser; @Component("GrenobleVegetationImportParser") @Lazy
public class GrenobleVegetationImportParser extends AbstractImportParser<VegetationImport> {
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/plugin/parser/NiceVegetationImportParser2014.java
// Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationImport.java // public class VegetationImport extends AbstractImport { // // private String genus; // // private String species; // // private String reference; // // private Integer height; // // private Float circumference; // // private Integer plantingYear; // // @Override // public String getValueByTagName(String tagName) { // if (ElementTag.GENUS.equals(tagName)) { // return this.genus.toString(); // } else if (ElementTag.SPECIES.equals(tagName)) { // return this.species.toString(); // } // return null; // } // // @Override // public String toString() { // return "VegetationImport with id=[" + this.id + "], coords=[" + this.latitude + ", " + this.longitude + "], genus=[" + this.genus + "], species=[" // + this.species + "], height=[" + this.height + "], circumference=[" + this.circumference + "] ref=[" + this.reference + "]"; // } // // public String getReference() { // return reference; // } // // public void setReference(String reference) { // this.reference = reference; // } // // public String getGenus() { // return genus; // } // // public void setGenus(String genus) { // this.genus = genus; // } // // public String getSpecies() { // return species; // } // // public void setSpecies(String subType) { // this.species = subType; // } // // public Integer getHeight() { // return height; // } // // public void setHeight(Integer height) { // this.height = height; // } // // public Float getCircumference() { // return circumference; // } // // public void setCircumference(Float circumference) { // this.circumference = circumference; // } // // public Integer getPlantingYear() { // return plantingYear; // } // // public void setPlantingYear(Integer plantingYear) { // this.plantingYear = plantingYear; // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/util/StringParsingHelper.java // public class StringParsingHelper { // // static protected final Logger LOGGER = Logger.getLogger(Application.class); // // // Stupid but useful methods for catching and logging exception individually // // static public double parseDouble(String s, String name) { // double result = 0; // try { // result = Double.parseDouble(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // // static public int parseInt(String s, String name) { // int result = 0; // try { // result = Integer.parseInt(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // // static public float parseFloat(String s, String name) { // float result = 0; // try { // result = Float.parseFloat(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // }
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import javax.annotation.PostConstruct; import org.openstreetmap.osmaxil.model.VegetationImport; import org.openstreetmap.osmaxil.util.StringParsingHelper; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Repository; import au.com.bytecode.opencsv.CSVReader;
package org.openstreetmap.osmaxil.plugin.parser; @Repository @Lazy
// Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationImport.java // public class VegetationImport extends AbstractImport { // // private String genus; // // private String species; // // private String reference; // // private Integer height; // // private Float circumference; // // private Integer plantingYear; // // @Override // public String getValueByTagName(String tagName) { // if (ElementTag.GENUS.equals(tagName)) { // return this.genus.toString(); // } else if (ElementTag.SPECIES.equals(tagName)) { // return this.species.toString(); // } // return null; // } // // @Override // public String toString() { // return "VegetationImport with id=[" + this.id + "], coords=[" + this.latitude + ", " + this.longitude + "], genus=[" + this.genus + "], species=[" // + this.species + "], height=[" + this.height + "], circumference=[" + this.circumference + "] ref=[" + this.reference + "]"; // } // // public String getReference() { // return reference; // } // // public void setReference(String reference) { // this.reference = reference; // } // // public String getGenus() { // return genus; // } // // public void setGenus(String genus) { // this.genus = genus; // } // // public String getSpecies() { // return species; // } // // public void setSpecies(String subType) { // this.species = subType; // } // // public Integer getHeight() { // return height; // } // // public void setHeight(Integer height) { // this.height = height; // } // // public Float getCircumference() { // return circumference; // } // // public void setCircumference(Float circumference) { // this.circumference = circumference; // } // // public Integer getPlantingYear() { // return plantingYear; // } // // public void setPlantingYear(Integer plantingYear) { // this.plantingYear = plantingYear; // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/util/StringParsingHelper.java // public class StringParsingHelper { // // static protected final Logger LOGGER = Logger.getLogger(Application.class); // // // Stupid but useful methods for catching and logging exception individually // // static public double parseDouble(String s, String name) { // double result = 0; // try { // result = Double.parseDouble(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // // static public int parseInt(String s, String name) { // int result = 0; // try { // result = Integer.parseInt(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // // static public float parseFloat(String s, String name) { // float result = 0; // try { // result = Float.parseFloat(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // } // Path: src/main/java/org/openstreetmap/osmaxil/plugin/parser/NiceVegetationImportParser2014.java import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import javax.annotation.PostConstruct; import org.openstreetmap.osmaxil.model.VegetationImport; import org.openstreetmap.osmaxil.util.StringParsingHelper; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Repository; import au.com.bytecode.opencsv.CSVReader; package org.openstreetmap.osmaxil.plugin.parser; @Repository @Lazy
public class NiceVegetationImportParser2014 extends AbstractImportParser<VegetationImport> {
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/plugin/parser/NiceVegetationImportParser2014.java
// Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationImport.java // public class VegetationImport extends AbstractImport { // // private String genus; // // private String species; // // private String reference; // // private Integer height; // // private Float circumference; // // private Integer plantingYear; // // @Override // public String getValueByTagName(String tagName) { // if (ElementTag.GENUS.equals(tagName)) { // return this.genus.toString(); // } else if (ElementTag.SPECIES.equals(tagName)) { // return this.species.toString(); // } // return null; // } // // @Override // public String toString() { // return "VegetationImport with id=[" + this.id + "], coords=[" + this.latitude + ", " + this.longitude + "], genus=[" + this.genus + "], species=[" // + this.species + "], height=[" + this.height + "], circumference=[" + this.circumference + "] ref=[" + this.reference + "]"; // } // // public String getReference() { // return reference; // } // // public void setReference(String reference) { // this.reference = reference; // } // // public String getGenus() { // return genus; // } // // public void setGenus(String genus) { // this.genus = genus; // } // // public String getSpecies() { // return species; // } // // public void setSpecies(String subType) { // this.species = subType; // } // // public Integer getHeight() { // return height; // } // // public void setHeight(Integer height) { // this.height = height; // } // // public Float getCircumference() { // return circumference; // } // // public void setCircumference(Float circumference) { // this.circumference = circumference; // } // // public Integer getPlantingYear() { // return plantingYear; // } // // public void setPlantingYear(Integer plantingYear) { // this.plantingYear = plantingYear; // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/util/StringParsingHelper.java // public class StringParsingHelper { // // static protected final Logger LOGGER = Logger.getLogger(Application.class); // // // Stupid but useful methods for catching and logging exception individually // // static public double parseDouble(String s, String name) { // double result = 0; // try { // result = Double.parseDouble(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // // static public int parseInt(String s, String name) { // int result = 0; // try { // result = Integer.parseInt(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // // static public float parseFloat(String s, String name) { // float result = 0; // try { // result = Float.parseFloat(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // }
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import javax.annotation.PostConstruct; import org.openstreetmap.osmaxil.model.VegetationImport; import org.openstreetmap.osmaxil.util.StringParsingHelper; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Repository; import au.com.bytecode.opencsv.CSVReader;
this.hasNext = true; } @Override public boolean hasNext() { // return this.reader.iterator().hasNext() // doesn't work ? return this.hasNext; } @Override public VegetationImport next() { String[] row = null; try { row = this.reader.readNext(); } catch (IOException e) { LOGGER.info("An error has occured while reading CSV: " + e.getMessage()); } if (row == null || row[0] == null) { this.hasNext = false; return null; } this.rowCount++; VegetationImport tree = new VegetationImport(); tree.setId(this.rowCount); // tree.setGenus(row[3]); // tree.setSpecies(row[2]); tree.setReference(row[4]); String geom = row[5].substring(row[5].indexOf(GEOM_TOKEN) + GEOM_TOKEN.length()); geom = geom.substring(0, geom.length() - 2); String[] coords = geom.split(", ");
// Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationImport.java // public class VegetationImport extends AbstractImport { // // private String genus; // // private String species; // // private String reference; // // private Integer height; // // private Float circumference; // // private Integer plantingYear; // // @Override // public String getValueByTagName(String tagName) { // if (ElementTag.GENUS.equals(tagName)) { // return this.genus.toString(); // } else if (ElementTag.SPECIES.equals(tagName)) { // return this.species.toString(); // } // return null; // } // // @Override // public String toString() { // return "VegetationImport with id=[" + this.id + "], coords=[" + this.latitude + ", " + this.longitude + "], genus=[" + this.genus + "], species=[" // + this.species + "], height=[" + this.height + "], circumference=[" + this.circumference + "] ref=[" + this.reference + "]"; // } // // public String getReference() { // return reference; // } // // public void setReference(String reference) { // this.reference = reference; // } // // public String getGenus() { // return genus; // } // // public void setGenus(String genus) { // this.genus = genus; // } // // public String getSpecies() { // return species; // } // // public void setSpecies(String subType) { // this.species = subType; // } // // public Integer getHeight() { // return height; // } // // public void setHeight(Integer height) { // this.height = height; // } // // public Float getCircumference() { // return circumference; // } // // public void setCircumference(Float circumference) { // this.circumference = circumference; // } // // public Integer getPlantingYear() { // return plantingYear; // } // // public void setPlantingYear(Integer plantingYear) { // this.plantingYear = plantingYear; // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/util/StringParsingHelper.java // public class StringParsingHelper { // // static protected final Logger LOGGER = Logger.getLogger(Application.class); // // // Stupid but useful methods for catching and logging exception individually // // static public double parseDouble(String s, String name) { // double result = 0; // try { // result = Double.parseDouble(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // // static public int parseInt(String s, String name) { // int result = 0; // try { // result = Integer.parseInt(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // // static public float parseFloat(String s, String name) { // float result = 0; // try { // result = Float.parseFloat(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // } // Path: src/main/java/org/openstreetmap/osmaxil/plugin/parser/NiceVegetationImportParser2014.java import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import javax.annotation.PostConstruct; import org.openstreetmap.osmaxil.model.VegetationImport; import org.openstreetmap.osmaxil.util.StringParsingHelper; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Repository; import au.com.bytecode.opencsv.CSVReader; this.hasNext = true; } @Override public boolean hasNext() { // return this.reader.iterator().hasNext() // doesn't work ? return this.hasNext; } @Override public VegetationImport next() { String[] row = null; try { row = this.reader.readNext(); } catch (IOException e) { LOGGER.info("An error has occured while reading CSV: " + e.getMessage()); } if (row == null || row[0] == null) { this.hasNext = false; return null; } this.rowCount++; VegetationImport tree = new VegetationImport(); tree.setId(this.rowCount); // tree.setGenus(row[3]); // tree.setSpecies(row[2]); tree.setReference(row[4]); String geom = row[5].substring(row[5].indexOf(GEOM_TOKEN) + GEOM_TOKEN.length()); geom = geom.substring(0, geom.length() - 2); String[] coords = geom.split(", ");
tree.setLongitude(StringParsingHelper.parseDouble(coords[0], "lon"));
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/model/BuildingElement.java
// Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlTag.java // public class OsmXmlTag { // // @XmlAttribute // public String v; // // @XmlAttribute // public String k; // // public OsmXmlTag() { // } // // public OsmXmlTag(String key, String value) { // this.k = key; // this.v = value; // } // }
import java.util.ArrayList; import java.util.List; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlTag;
package org.openstreetmap.osmaxil.model; public class BuildingElement extends AbstractElement { private Integer computedArea; private String innerGeometryString; // could be used by building which has a "hole" (multipolygon) public BuildingElement(long osmId) { super(osmId); } @Override public ElementType getType() { return ElementType.Way; } @Override public void updateChangeset(long changesetId) { this.getApiData().ways.get(0).changeset = changesetId; } @Override
// Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlTag.java // public class OsmXmlTag { // // @XmlAttribute // public String v; // // @XmlAttribute // public String k; // // public OsmXmlTag() { // } // // public OsmXmlTag(String key, String value) { // this.k = key; // this.v = value; // } // } // Path: src/main/java/org/openstreetmap/osmaxil/model/BuildingElement.java import java.util.ArrayList; import java.util.List; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlTag; package org.openstreetmap.osmaxil.model; public class BuildingElement extends AbstractElement { private Integer computedArea; private String innerGeometryString; // could be used by building which has a "hole" (multipolygon) public BuildingElement(long osmId) { super(osmId); } @Override public ElementType getType() { return ElementType.Way; } @Override public void updateChangeset(long changesetId) { this.getApiData().ways.get(0).changeset = changesetId; } @Override
public List<OsmXmlTag> getTags() {
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/model/BuildingImport.java
// Path: src/main/java/org/openstreetmap/osmaxil/model/misc/Coordinates.java // public class Coordinates { // // public String x; // // public String y; // // public String z; // // public Coordinates(String x, String y, String z) { // this.x = x; // this.y = y; // this.z = z; // } // // }
import java.util.ArrayList; import java.util.List; import org.openstreetmap.osmaxil.model.misc.Coordinates; import com.vividsolutions.jts.geom.Point;
package org.openstreetmap.osmaxil.model; public class BuildingImport extends AbstractImport { protected Integer levels; protected Float height; protected String url; protected Integer area; private String geometryAsWKT; protected String geometryRawString; protected List<Point> points = new ArrayList<>();
// Path: src/main/java/org/openstreetmap/osmaxil/model/misc/Coordinates.java // public class Coordinates { // // public String x; // // public String y; // // public String z; // // public Coordinates(String x, String y, String z) { // this.x = x; // this.y = y; // this.z = z; // } // // } // Path: src/main/java/org/openstreetmap/osmaxil/model/BuildingImport.java import java.util.ArrayList; import java.util.List; import org.openstreetmap.osmaxil.model.misc.Coordinates; import com.vividsolutions.jts.geom.Point; package org.openstreetmap.osmaxil.model; public class BuildingImport extends AbstractImport { protected Integer levels; protected Float height; protected String url; protected Integer area; private String geometryAsWKT; protected String geometryRawString; protected List<Point> points = new ArrayList<>();
protected List<Coordinates> coordinates = new ArrayList<>(); // keep coordinates as strings (no more rounding issues)
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/model/VegetationElement.java
// Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlTag.java // public class OsmXmlTag { // // @XmlAttribute // public String v; // // @XmlAttribute // public String k; // // public OsmXmlTag() { // } // // public OsmXmlTag(String key, String value) { // this.k = key; // this.v = value; // } // }
import java.util.List; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlTag;
package org.openstreetmap.osmaxil.model; public class VegetationElement extends AbstractElement { public VegetationElement(long osmId) { super(osmId); } @Override public ElementType getType() { return ElementType.Node; } @Override
// Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlTag.java // public class OsmXmlTag { // // @XmlAttribute // public String v; // // @XmlAttribute // public String k; // // public OsmXmlTag() { // } // // public OsmXmlTag(String key, String value) { // this.k = key; // this.v = value; // } // } // Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationElement.java import java.util.List; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlTag; package org.openstreetmap.osmaxil.model; public class VegetationElement extends AbstractElement { public VegetationElement(long osmId) { super(osmId); } @Override public ElementType getType() { return ElementType.Node; } @Override
public List<OsmXmlTag> getTags() {
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/dao/ElevationDatabase.java
// Path: src/main/java/org/openstreetmap/osmaxil/model/ElevationImport.java // public class ElevationImport extends AbstractImport { // // // private Coordinates coordinates; // // public float x, y, z; // // public ElevationImport(float x, float y, float z) { // this.x = x; // this.y = y; // this.z = z; // this.setId(Math.round(z)); // } // // @Override // public String getValueByTagName(String tagName) { // return "Sorry, there is no tag for that type of import"; // } // // @Override // public String toString() { // return "Elevation import with x=" + x + " y=" + y + " z=" + z; // } // // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/misc/Coordinates.java // public class Coordinates { // // public String x; // // public String y; // // public String z; // // public Coordinates(String x, String y, String z) { // this.x = x; // this.y = y; // this.z = z; // } // // }
import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; import org.openstreetmap.osmaxil.model.ElevationImport; import org.openstreetmap.osmaxil.model.misc.Coordinates; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper;
package org.openstreetmap.osmaxil.dao; //@Service("ElevationDatabase") @Scope("prototype") @Lazy public class ElevationDatabase implements ElevationDataSource { // @Autowired @Qualifier("elevationPostgisJdbcTemplate") private JdbcTemplate jdbcTemplate; public int srid; private String tableName; public ElevationDatabase(String tableName, int srid, JdbcTemplate jdbcTemplate) { this.init(tableName, srid); this.jdbcTemplate = jdbcTemplate; } //////////////////////////////////////////////////////////////////////////////// // Public overrided methods //////////////////////////////////////////////////////////////////////////////// @Override public void init(String tableName, int srid) { this.tableName = tableName; this.srid = srid; } @Override
// Path: src/main/java/org/openstreetmap/osmaxil/model/ElevationImport.java // public class ElevationImport extends AbstractImport { // // // private Coordinates coordinates; // // public float x, y, z; // // public ElevationImport(float x, float y, float z) { // this.x = x; // this.y = y; // this.z = z; // this.setId(Math.round(z)); // } // // @Override // public String getValueByTagName(String tagName) { // return "Sorry, there is no tag for that type of import"; // } // // @Override // public String toString() { // return "Elevation import with x=" + x + " y=" + y + " z=" + z; // } // // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/misc/Coordinates.java // public class Coordinates { // // public String x; // // public String y; // // public String z; // // public Coordinates(String x, String y, String z) { // this.x = x; // this.y = y; // this.z = z; // } // // } // Path: src/main/java/org/openstreetmap/osmaxil/dao/ElevationDatabase.java import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; import org.openstreetmap.osmaxil.model.ElevationImport; import org.openstreetmap.osmaxil.model.misc.Coordinates; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; package org.openstreetmap.osmaxil.dao; //@Service("ElevationDatabase") @Scope("prototype") @Lazy public class ElevationDatabase implements ElevationDataSource { // @Autowired @Qualifier("elevationPostgisJdbcTemplate") private JdbcTemplate jdbcTemplate; public int srid; private String tableName; public ElevationDatabase(String tableName, int srid, JdbcTemplate jdbcTemplate) { this.init(tableName, srid); this.jdbcTemplate = jdbcTemplate; } //////////////////////////////////////////////////////////////////////////////// // Public overrided methods //////////////////////////////////////////////////////////////////////////////// @Override public void init(String tableName, int srid) { this.tableName = tableName; this.srid = srid; } @Override
public ElevationImport findElevationByCoordinates(float x, float y, float valueScale, int srid) {
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/dao/ElevationDatabase.java
// Path: src/main/java/org/openstreetmap/osmaxil/model/ElevationImport.java // public class ElevationImport extends AbstractImport { // // // private Coordinates coordinates; // // public float x, y, z; // // public ElevationImport(float x, float y, float z) { // this.x = x; // this.y = y; // this.z = z; // this.setId(Math.round(z)); // } // // @Override // public String getValueByTagName(String tagName) { // return "Sorry, there is no tag for that type of import"; // } // // @Override // public String toString() { // return "Elevation import with x=" + x + " y=" + y + " z=" + z; // } // // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/misc/Coordinates.java // public class Coordinates { // // public String x; // // public String y; // // public String z; // // public Coordinates(String x, String y, String z) { // this.x = x; // this.y = y; // this.z = z; // } // // }
import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; import org.openstreetmap.osmaxil.model.ElevationImport; import org.openstreetmap.osmaxil.model.misc.Coordinates; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper;
} }); return results; } @Override public int getSrid() { return this.srid; } //////////////////////////////////////////////////////////////////////////////// // Public (not overrided) methods //////////////////////////////////////////////////////////////////////////////// public void executeSQL(String query) { LOGGER.debug("Exec: " + query); this.jdbcTemplate.execute(query); } public boolean testTableExistence(String tableName) { return this.jdbcTemplate.queryForObject("select count(tablename) = 1 from pg_tables where tablename = '" + tableName + "'", Boolean.class); } /** * Find all points which intersect the including geometry and disjoint the excluding geometry (useful for multipolygon buildings with "hole"). * That method use a factor as argument in order to scale the including and excluding geometries. * * TODO: use JTS instead of PostGis functions (ST_Scale and ST_Translate) to perform the scale/skrink process because this implementation is * working but it takes 15 minutes to execute ! */
// Path: src/main/java/org/openstreetmap/osmaxil/model/ElevationImport.java // public class ElevationImport extends AbstractImport { // // // private Coordinates coordinates; // // public float x, y, z; // // public ElevationImport(float x, float y, float z) { // this.x = x; // this.y = y; // this.z = z; // this.setId(Math.round(z)); // } // // @Override // public String getValueByTagName(String tagName) { // return "Sorry, there is no tag for that type of import"; // } // // @Override // public String toString() { // return "Elevation import with x=" + x + " y=" + y + " z=" + z; // } // // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/misc/Coordinates.java // public class Coordinates { // // public String x; // // public String y; // // public String z; // // public Coordinates(String x, String y, String z) { // this.x = x; // this.y = y; // this.z = z; // } // // } // Path: src/main/java/org/openstreetmap/osmaxil/dao/ElevationDatabase.java import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; import org.openstreetmap.osmaxil.model.ElevationImport; import org.openstreetmap.osmaxil.model.misc.Coordinates; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; } }); return results; } @Override public int getSrid() { return this.srid; } //////////////////////////////////////////////////////////////////////////////// // Public (not overrided) methods //////////////////////////////////////////////////////////////////////////////// public void executeSQL(String query) { LOGGER.debug("Exec: " + query); this.jdbcTemplate.execute(query); } public boolean testTableExistence(String tableName) { return this.jdbcTemplate.queryForObject("select count(tablename) = 1 from pg_tables where tablename = '" + tableName + "'", Boolean.class); } /** * Find all points which intersect the including geometry and disjoint the excluding geometry (useful for multipolygon buildings with "hole"). * That method use a factor as argument in order to scale the including and excluding geometries. * * TODO: use JTS instead of PostGis functions (ST_Scale and ST_Translate) to perform the scale/skrink process because this implementation is * working but it takes 15 minutes to execute ! */
public List<Coordinates> findAllPointsByGeometry(String includingGeomAsWKT, String excludingGeomAsWKT, float scaleFactor, int geomSrid) {
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/plugin/parser/NiceVegetationImportParser2015.java
// Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationImport.java // public class VegetationImport extends AbstractImport { // // private String genus; // // private String species; // // private String reference; // // private Integer height; // // private Float circumference; // // private Integer plantingYear; // // @Override // public String getValueByTagName(String tagName) { // if (ElementTag.GENUS.equals(tagName)) { // return this.genus.toString(); // } else if (ElementTag.SPECIES.equals(tagName)) { // return this.species.toString(); // } // return null; // } // // @Override // public String toString() { // return "VegetationImport with id=[" + this.id + "], coords=[" + this.latitude + ", " + this.longitude + "], genus=[" + this.genus + "], species=[" // + this.species + "], height=[" + this.height + "], circumference=[" + this.circumference + "] ref=[" + this.reference + "]"; // } // // public String getReference() { // return reference; // } // // public void setReference(String reference) { // this.reference = reference; // } // // public String getGenus() { // return genus; // } // // public void setGenus(String genus) { // this.genus = genus; // } // // public String getSpecies() { // return species; // } // // public void setSpecies(String subType) { // this.species = subType; // } // // public Integer getHeight() { // return height; // } // // public void setHeight(Integer height) { // this.height = height; // } // // public Float getCircumference() { // return circumference; // } // // public void setCircumference(Float circumference) { // this.circumference = circumference; // } // // public Integer getPlantingYear() { // return plantingYear; // } // // public void setPlantingYear(Integer plantingYear) { // this.plantingYear = plantingYear; // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/util/StringParsingHelper.java // public class StringParsingHelper { // // static protected final Logger LOGGER = Logger.getLogger(Application.class); // // // Stupid but useful methods for catching and logging exception individually // // static public double parseDouble(String s, String name) { // double result = 0; // try { // result = Double.parseDouble(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // // static public int parseInt(String s, String name) { // int result = 0; // try { // result = Integer.parseInt(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // // static public float parseFloat(String s, String name) { // float result = 0; // try { // result = Float.parseFloat(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // }
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import javax.annotation.PostConstruct; import org.openstreetmap.osmaxil.model.VegetationImport; import org.openstreetmap.osmaxil.util.StringParsingHelper; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Repository; import au.com.bytecode.opencsv.CSVReader;
package org.openstreetmap.osmaxil.plugin.parser; @Repository @Lazy
// Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationImport.java // public class VegetationImport extends AbstractImport { // // private String genus; // // private String species; // // private String reference; // // private Integer height; // // private Float circumference; // // private Integer plantingYear; // // @Override // public String getValueByTagName(String tagName) { // if (ElementTag.GENUS.equals(tagName)) { // return this.genus.toString(); // } else if (ElementTag.SPECIES.equals(tagName)) { // return this.species.toString(); // } // return null; // } // // @Override // public String toString() { // return "VegetationImport with id=[" + this.id + "], coords=[" + this.latitude + ", " + this.longitude + "], genus=[" + this.genus + "], species=[" // + this.species + "], height=[" + this.height + "], circumference=[" + this.circumference + "] ref=[" + this.reference + "]"; // } // // public String getReference() { // return reference; // } // // public void setReference(String reference) { // this.reference = reference; // } // // public String getGenus() { // return genus; // } // // public void setGenus(String genus) { // this.genus = genus; // } // // public String getSpecies() { // return species; // } // // public void setSpecies(String subType) { // this.species = subType; // } // // public Integer getHeight() { // return height; // } // // public void setHeight(Integer height) { // this.height = height; // } // // public Float getCircumference() { // return circumference; // } // // public void setCircumference(Float circumference) { // this.circumference = circumference; // } // // public Integer getPlantingYear() { // return plantingYear; // } // // public void setPlantingYear(Integer plantingYear) { // this.plantingYear = plantingYear; // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/util/StringParsingHelper.java // public class StringParsingHelper { // // static protected final Logger LOGGER = Logger.getLogger(Application.class); // // // Stupid but useful methods for catching and logging exception individually // // static public double parseDouble(String s, String name) { // double result = 0; // try { // result = Double.parseDouble(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // // static public int parseInt(String s, String name) { // int result = 0; // try { // result = Integer.parseInt(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // // static public float parseFloat(String s, String name) { // float result = 0; // try { // result = Float.parseFloat(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // } // Path: src/main/java/org/openstreetmap/osmaxil/plugin/parser/NiceVegetationImportParser2015.java import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import javax.annotation.PostConstruct; import org.openstreetmap.osmaxil.model.VegetationImport; import org.openstreetmap.osmaxil.util.StringParsingHelper; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Repository; import au.com.bytecode.opencsv.CSVReader; package org.openstreetmap.osmaxil.plugin.parser; @Repository @Lazy
public class NiceVegetationImportParser2015 extends AbstractImportParser<VegetationImport> {
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/plugin/parser/NiceVegetationImportParser2015.java
// Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationImport.java // public class VegetationImport extends AbstractImport { // // private String genus; // // private String species; // // private String reference; // // private Integer height; // // private Float circumference; // // private Integer plantingYear; // // @Override // public String getValueByTagName(String tagName) { // if (ElementTag.GENUS.equals(tagName)) { // return this.genus.toString(); // } else if (ElementTag.SPECIES.equals(tagName)) { // return this.species.toString(); // } // return null; // } // // @Override // public String toString() { // return "VegetationImport with id=[" + this.id + "], coords=[" + this.latitude + ", " + this.longitude + "], genus=[" + this.genus + "], species=[" // + this.species + "], height=[" + this.height + "], circumference=[" + this.circumference + "] ref=[" + this.reference + "]"; // } // // public String getReference() { // return reference; // } // // public void setReference(String reference) { // this.reference = reference; // } // // public String getGenus() { // return genus; // } // // public void setGenus(String genus) { // this.genus = genus; // } // // public String getSpecies() { // return species; // } // // public void setSpecies(String subType) { // this.species = subType; // } // // public Integer getHeight() { // return height; // } // // public void setHeight(Integer height) { // this.height = height; // } // // public Float getCircumference() { // return circumference; // } // // public void setCircumference(Float circumference) { // this.circumference = circumference; // } // // public Integer getPlantingYear() { // return plantingYear; // } // // public void setPlantingYear(Integer plantingYear) { // this.plantingYear = plantingYear; // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/util/StringParsingHelper.java // public class StringParsingHelper { // // static protected final Logger LOGGER = Logger.getLogger(Application.class); // // // Stupid but useful methods for catching and logging exception individually // // static public double parseDouble(String s, String name) { // double result = 0; // try { // result = Double.parseDouble(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // // static public int parseInt(String s, String name) { // int result = 0; // try { // result = Integer.parseInt(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // // static public float parseFloat(String s, String name) { // float result = 0; // try { // result = Float.parseFloat(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // }
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import javax.annotation.PostConstruct; import org.openstreetmap.osmaxil.model.VegetationImport; import org.openstreetmap.osmaxil.util.StringParsingHelper; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Repository; import au.com.bytecode.opencsv.CSVReader;
this.hasNext = true; } @Override public boolean hasNext() { // return this.reader.iterator().hasNext() // doesn't work ? return this.hasNext; } @Override public VegetationImport next() { String[] row = null; try { row = this.reader.readNext(); } catch (IOException e) { LOGGER.info("An error has occured while reading CSV: " + e.getMessage()); } if (row == null || row[0] == null) { this.hasNext = false; return null; } this.rowCount++; VegetationImport tree = new VegetationImport(); tree.setId(this.rowCount); // tree.setGenus(row[1]); // tree.setSpecies(row[2]); tree.setReference(row[0]); String geom = row[3].substring(row[3].indexOf(GEOM_TOKEN) + GEOM_TOKEN.length()); geom = geom.substring(0, geom.length() - 2); String[] coords = geom.split(", ");
// Path: src/main/java/org/openstreetmap/osmaxil/model/VegetationImport.java // public class VegetationImport extends AbstractImport { // // private String genus; // // private String species; // // private String reference; // // private Integer height; // // private Float circumference; // // private Integer plantingYear; // // @Override // public String getValueByTagName(String tagName) { // if (ElementTag.GENUS.equals(tagName)) { // return this.genus.toString(); // } else if (ElementTag.SPECIES.equals(tagName)) { // return this.species.toString(); // } // return null; // } // // @Override // public String toString() { // return "VegetationImport with id=[" + this.id + "], coords=[" + this.latitude + ", " + this.longitude + "], genus=[" + this.genus + "], species=[" // + this.species + "], height=[" + this.height + "], circumference=[" + this.circumference + "] ref=[" + this.reference + "]"; // } // // public String getReference() { // return reference; // } // // public void setReference(String reference) { // this.reference = reference; // } // // public String getGenus() { // return genus; // } // // public void setGenus(String genus) { // this.genus = genus; // } // // public String getSpecies() { // return species; // } // // public void setSpecies(String subType) { // this.species = subType; // } // // public Integer getHeight() { // return height; // } // // public void setHeight(Integer height) { // this.height = height; // } // // public Float getCircumference() { // return circumference; // } // // public void setCircumference(Float circumference) { // this.circumference = circumference; // } // // public Integer getPlantingYear() { // return plantingYear; // } // // public void setPlantingYear(Integer plantingYear) { // this.plantingYear = plantingYear; // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/util/StringParsingHelper.java // public class StringParsingHelper { // // static protected final Logger LOGGER = Logger.getLogger(Application.class); // // // Stupid but useful methods for catching and logging exception individually // // static public double parseDouble(String s, String name) { // double result = 0; // try { // result = Double.parseDouble(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // // static public int parseInt(String s, String name) { // int result = 0; // try { // result = Integer.parseInt(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // // static public float parseFloat(String s, String name) { // float result = 0; // try { // result = Float.parseFloat(s); // } catch (Exception e) { // LOGGER.warn("Unable to parse " + name + ": " + e.getMessage()); // } // return result; // } // } // Path: src/main/java/org/openstreetmap/osmaxil/plugin/parser/NiceVegetationImportParser2015.java import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import javax.annotation.PostConstruct; import org.openstreetmap.osmaxil.model.VegetationImport; import org.openstreetmap.osmaxil.util.StringParsingHelper; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Repository; import au.com.bytecode.opencsv.CSVReader; this.hasNext = true; } @Override public boolean hasNext() { // return this.reader.iterator().hasNext() // doesn't work ? return this.hasNext; } @Override public VegetationImport next() { String[] row = null; try { row = this.reader.readNext(); } catch (IOException e) { LOGGER.info("An error has occured while reading CSV: " + e.getMessage()); } if (row == null || row[0] == null) { this.hasNext = false; return null; } this.rowCount++; VegetationImport tree = new VegetationImport(); tree.setId(this.rowCount); // tree.setGenus(row[1]); // tree.setSpecies(row[2]); tree.setReference(row[0]); String geom = row[3].substring(row[3].indexOf(GEOM_TOKEN) + GEOM_TOKEN.length()); geom = geom.substring(0, geom.length() - 2); String[] coords = geom.split(", ");
tree.setLongitude(StringParsingHelper.parseDouble(coords[0], "lon"));
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/model/AbstractElement.java
// Path: src/main/java/org/openstreetmap/osmaxil/Application.java // @Component("OsmaxilApp") // public class Application { // // @Value("${osmaxil.flow}") // public String flow; // // public static final String NAME = "Osmaxil"; // // private static ClassPathXmlApplicationContext applicationContext; // // static private final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // public static void main(String[] args) { // applicationContext = new ClassPathXmlApplicationContext("spring.xml"); // Application app = (Application) applicationContext.getBean("OsmaxilApp"); // LOGGER.info("=== Starting Osmaxil ==="); // long startTime = System.currentTimeMillis(); // try { // app.run(); // } catch (Exception e) { // LOGGER.error(e); // } // LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); // LOGGER.info("=== Osmaxil has finished its job ==="); // applicationContext.close(); // } // // public void run() throws Exception { // __AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow); // flow.load(); // flow.process(); // flow.synchronize(); // flow.displayLoadingStatistics(); // flow.displayProcessingStatistics(); // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlRoot.java // @XmlRootElement(name = "osm") // public class OsmXmlRoot { // // @XmlAttribute // public float version; // // @XmlAttribute // public String generator; // // @XmlElement(name = "node") // public List<OsmXmlNode> nodes = new ArrayList<>();; // // @XmlElement(name = "way") // public List<OsmXmlWay> ways = new ArrayList<>();; // // @XmlElement(name = "relations") // public List<OsmXmlRelation> relations = new ArrayList<>(); // // } // // Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlTag.java // public class OsmXmlTag { // // @XmlAttribute // public String v; // // @XmlAttribute // public String k; // // public OsmXmlTag() { // } // // public OsmXmlTag(String key, String value) { // this.k = key; // this.v = value; // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/misc/MatchableObject.java // public class MatchableObject { // // protected float matchingScore; // // public float getMatchingScore() { // return matchingScore; // } // // public void setMatchingScore(float matchingScore) { // this.matchingScore = matchingScore; // } // }
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.Application; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlRoot; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlTag; import org.openstreetmap.osmaxil.model.misc.MatchableObject;
package org.openstreetmap.osmaxil.model; public abstract class AbstractElement extends MatchableObject { protected Long osmId;
// Path: src/main/java/org/openstreetmap/osmaxil/Application.java // @Component("OsmaxilApp") // public class Application { // // @Value("${osmaxil.flow}") // public String flow; // // public static final String NAME = "Osmaxil"; // // private static ClassPathXmlApplicationContext applicationContext; // // static private final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // public static void main(String[] args) { // applicationContext = new ClassPathXmlApplicationContext("spring.xml"); // Application app = (Application) applicationContext.getBean("OsmaxilApp"); // LOGGER.info("=== Starting Osmaxil ==="); // long startTime = System.currentTimeMillis(); // try { // app.run(); // } catch (Exception e) { // LOGGER.error(e); // } // LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); // LOGGER.info("=== Osmaxil has finished its job ==="); // applicationContext.close(); // } // // public void run() throws Exception { // __AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow); // flow.load(); // flow.process(); // flow.synchronize(); // flow.displayLoadingStatistics(); // flow.displayProcessingStatistics(); // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlRoot.java // @XmlRootElement(name = "osm") // public class OsmXmlRoot { // // @XmlAttribute // public float version; // // @XmlAttribute // public String generator; // // @XmlElement(name = "node") // public List<OsmXmlNode> nodes = new ArrayList<>();; // // @XmlElement(name = "way") // public List<OsmXmlWay> ways = new ArrayList<>();; // // @XmlElement(name = "relations") // public List<OsmXmlRelation> relations = new ArrayList<>(); // // } // // Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlTag.java // public class OsmXmlTag { // // @XmlAttribute // public String v; // // @XmlAttribute // public String k; // // public OsmXmlTag() { // } // // public OsmXmlTag(String key, String value) { // this.k = key; // this.v = value; // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/misc/MatchableObject.java // public class MatchableObject { // // protected float matchingScore; // // public float getMatchingScore() { // return matchingScore; // } // // public void setMatchingScore(float matchingScore) { // this.matchingScore = matchingScore; // } // } // Path: src/main/java/org/openstreetmap/osmaxil/model/AbstractElement.java import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.Application; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlRoot; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlTag; import org.openstreetmap.osmaxil.model.misc.MatchableObject; package org.openstreetmap.osmaxil.model; public abstract class AbstractElement extends MatchableObject { protected Long osmId;
protected OsmXmlRoot apiData;
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/model/AbstractElement.java
// Path: src/main/java/org/openstreetmap/osmaxil/Application.java // @Component("OsmaxilApp") // public class Application { // // @Value("${osmaxil.flow}") // public String flow; // // public static final String NAME = "Osmaxil"; // // private static ClassPathXmlApplicationContext applicationContext; // // static private final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // public static void main(String[] args) { // applicationContext = new ClassPathXmlApplicationContext("spring.xml"); // Application app = (Application) applicationContext.getBean("OsmaxilApp"); // LOGGER.info("=== Starting Osmaxil ==="); // long startTime = System.currentTimeMillis(); // try { // app.run(); // } catch (Exception e) { // LOGGER.error(e); // } // LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); // LOGGER.info("=== Osmaxil has finished its job ==="); // applicationContext.close(); // } // // public void run() throws Exception { // __AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow); // flow.load(); // flow.process(); // flow.synchronize(); // flow.displayLoadingStatistics(); // flow.displayProcessingStatistics(); // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlRoot.java // @XmlRootElement(name = "osm") // public class OsmXmlRoot { // // @XmlAttribute // public float version; // // @XmlAttribute // public String generator; // // @XmlElement(name = "node") // public List<OsmXmlNode> nodes = new ArrayList<>();; // // @XmlElement(name = "way") // public List<OsmXmlWay> ways = new ArrayList<>();; // // @XmlElement(name = "relations") // public List<OsmXmlRelation> relations = new ArrayList<>(); // // } // // Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlTag.java // public class OsmXmlTag { // // @XmlAttribute // public String v; // // @XmlAttribute // public String k; // // public OsmXmlTag() { // } // // public OsmXmlTag(String key, String value) { // this.k = key; // this.v = value; // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/misc/MatchableObject.java // public class MatchableObject { // // protected float matchingScore; // // public float getMatchingScore() { // return matchingScore; // } // // public void setMatchingScore(float matchingScore) { // this.matchingScore = matchingScore; // } // }
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.Application; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlRoot; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlTag; import org.openstreetmap.osmaxil.model.misc.MatchableObject;
package org.openstreetmap.osmaxil.model; public abstract class AbstractElement extends MatchableObject { protected Long osmId; protected OsmXmlRoot apiData; private Long relationId; private boolean altered; private String geometryString; private List<AbstractImport> matchingImports; private Map<String, String> originalValuesByTagNames; private Integer computedHeight;
// Path: src/main/java/org/openstreetmap/osmaxil/Application.java // @Component("OsmaxilApp") // public class Application { // // @Value("${osmaxil.flow}") // public String flow; // // public static final String NAME = "Osmaxil"; // // private static ClassPathXmlApplicationContext applicationContext; // // static private final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // public static void main(String[] args) { // applicationContext = new ClassPathXmlApplicationContext("spring.xml"); // Application app = (Application) applicationContext.getBean("OsmaxilApp"); // LOGGER.info("=== Starting Osmaxil ==="); // long startTime = System.currentTimeMillis(); // try { // app.run(); // } catch (Exception e) { // LOGGER.error(e); // } // LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); // LOGGER.info("=== Osmaxil has finished its job ==="); // applicationContext.close(); // } // // public void run() throws Exception { // __AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow); // flow.load(); // flow.process(); // flow.synchronize(); // flow.displayLoadingStatistics(); // flow.displayProcessingStatistics(); // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlRoot.java // @XmlRootElement(name = "osm") // public class OsmXmlRoot { // // @XmlAttribute // public float version; // // @XmlAttribute // public String generator; // // @XmlElement(name = "node") // public List<OsmXmlNode> nodes = new ArrayList<>();; // // @XmlElement(name = "way") // public List<OsmXmlWay> ways = new ArrayList<>();; // // @XmlElement(name = "relations") // public List<OsmXmlRelation> relations = new ArrayList<>(); // // } // // Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlTag.java // public class OsmXmlTag { // // @XmlAttribute // public String v; // // @XmlAttribute // public String k; // // public OsmXmlTag() { // } // // public OsmXmlTag(String key, String value) { // this.k = key; // this.v = value; // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/misc/MatchableObject.java // public class MatchableObject { // // protected float matchingScore; // // public float getMatchingScore() { // return matchingScore; // } // // public void setMatchingScore(float matchingScore) { // this.matchingScore = matchingScore; // } // } // Path: src/main/java/org/openstreetmap/osmaxil/model/AbstractElement.java import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.Application; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlRoot; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlTag; import org.openstreetmap.osmaxil.model.misc.MatchableObject; package org.openstreetmap.osmaxil.model; public abstract class AbstractElement extends MatchableObject { protected Long osmId; protected OsmXmlRoot apiData; private Long relationId; private boolean altered; private String geometryString; private List<AbstractImport> matchingImports; private Map<String, String> originalValuesByTagNames; private Integer computedHeight;
static protected final Logger LOGGER = Logger.getLogger(Application.class);
vince-from-nice/osmaxil
src/main/java/org/openstreetmap/osmaxil/model/AbstractElement.java
// Path: src/main/java/org/openstreetmap/osmaxil/Application.java // @Component("OsmaxilApp") // public class Application { // // @Value("${osmaxil.flow}") // public String flow; // // public static final String NAME = "Osmaxil"; // // private static ClassPathXmlApplicationContext applicationContext; // // static private final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // public static void main(String[] args) { // applicationContext = new ClassPathXmlApplicationContext("spring.xml"); // Application app = (Application) applicationContext.getBean("OsmaxilApp"); // LOGGER.info("=== Starting Osmaxil ==="); // long startTime = System.currentTimeMillis(); // try { // app.run(); // } catch (Exception e) { // LOGGER.error(e); // } // LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); // LOGGER.info("=== Osmaxil has finished its job ==="); // applicationContext.close(); // } // // public void run() throws Exception { // __AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow); // flow.load(); // flow.process(); // flow.synchronize(); // flow.displayLoadingStatistics(); // flow.displayProcessingStatistics(); // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlRoot.java // @XmlRootElement(name = "osm") // public class OsmXmlRoot { // // @XmlAttribute // public float version; // // @XmlAttribute // public String generator; // // @XmlElement(name = "node") // public List<OsmXmlNode> nodes = new ArrayList<>();; // // @XmlElement(name = "way") // public List<OsmXmlWay> ways = new ArrayList<>();; // // @XmlElement(name = "relations") // public List<OsmXmlRelation> relations = new ArrayList<>(); // // } // // Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlTag.java // public class OsmXmlTag { // // @XmlAttribute // public String v; // // @XmlAttribute // public String k; // // public OsmXmlTag() { // } // // public OsmXmlTag(String key, String value) { // this.k = key; // this.v = value; // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/misc/MatchableObject.java // public class MatchableObject { // // protected float matchingScore; // // public float getMatchingScore() { // return matchingScore; // } // // public void setMatchingScore(float matchingScore) { // this.matchingScore = matchingScore; // } // }
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.Application; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlRoot; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlTag; import org.openstreetmap.osmaxil.model.misc.MatchableObject;
package org.openstreetmap.osmaxil.model; public abstract class AbstractElement extends MatchableObject { protected Long osmId; protected OsmXmlRoot apiData; private Long relationId; private boolean altered; private String geometryString; private List<AbstractImport> matchingImports; private Map<String, String> originalValuesByTagNames; private Integer computedHeight; static protected final Logger LOGGER = Logger.getLogger(Application.class); // ========================================================================= // Abstract methods // ========================================================================= abstract public ElementType getType(); abstract public void updateChangeset(long changesetId);
// Path: src/main/java/org/openstreetmap/osmaxil/Application.java // @Component("OsmaxilApp") // public class Application { // // @Value("${osmaxil.flow}") // public String flow; // // public static final String NAME = "Osmaxil"; // // private static ClassPathXmlApplicationContext applicationContext; // // static private final Logger LOGGER = Logger.getLogger(Application.class); // // static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats"); // // public static void main(String[] args) { // applicationContext = new ClassPathXmlApplicationContext("spring.xml"); // Application app = (Application) applicationContext.getBean("OsmaxilApp"); // LOGGER.info("=== Starting Osmaxil ==="); // long startTime = System.currentTimeMillis(); // try { // app.run(); // } catch (Exception e) { // LOGGER.error(e); // } // LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds"); // LOGGER.info("=== Osmaxil has finished its job ==="); // applicationContext.close(); // } // // public void run() throws Exception { // __AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow); // flow.load(); // flow.process(); // flow.synchronize(); // flow.displayLoadingStatistics(); // flow.displayProcessingStatistics(); // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlRoot.java // @XmlRootElement(name = "osm") // public class OsmXmlRoot { // // @XmlAttribute // public float version; // // @XmlAttribute // public String generator; // // @XmlElement(name = "node") // public List<OsmXmlNode> nodes = new ArrayList<>();; // // @XmlElement(name = "way") // public List<OsmXmlWay> ways = new ArrayList<>();; // // @XmlElement(name = "relations") // public List<OsmXmlRelation> relations = new ArrayList<>(); // // } // // Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlTag.java // public class OsmXmlTag { // // @XmlAttribute // public String v; // // @XmlAttribute // public String k; // // public OsmXmlTag() { // } // // public OsmXmlTag(String key, String value) { // this.k = key; // this.v = value; // } // } // // Path: src/main/java/org/openstreetmap/osmaxil/model/misc/MatchableObject.java // public class MatchableObject { // // protected float matchingScore; // // public float getMatchingScore() { // return matchingScore; // } // // public void setMatchingScore(float matchingScore) { // this.matchingScore = matchingScore; // } // } // Path: src/main/java/org/openstreetmap/osmaxil/model/AbstractElement.java import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.log4j.Logger; import org.openstreetmap.osmaxil.Application; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlRoot; import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlTag; import org.openstreetmap.osmaxil.model.misc.MatchableObject; package org.openstreetmap.osmaxil.model; public abstract class AbstractElement extends MatchableObject { protected Long osmId; protected OsmXmlRoot apiData; private Long relationId; private boolean altered; private String geometryString; private List<AbstractImport> matchingImports; private Map<String, String> originalValuesByTagNames; private Integer computedHeight; static protected final Logger LOGGER = Logger.getLogger(Application.class); // ========================================================================= // Abstract methods // ========================================================================= abstract public ElementType getType(); abstract public void updateChangeset(long changesetId);
abstract public List<OsmXmlTag> getTags();
davemckain/jacomax
jacomax/src/main/java/uk/ac/ed/ph/jacomax/utilities/MaximaOutputUtilities.java
// Path: jacomax/src/main/java/uk/ac/ed/ph/jacomax/internal/Assert.java // public final class Assert { // // /** // * Checks that the given object is non-null, throwing an // * IllegalArgumentException if the check fails. If the check succeeds then // * nothing happens. // * // * @param value object to test // * @param objectName name to give to supplied Object when constructing Exception message. // * // * @throws IllegalArgumentException if <code>value</code> is null. // */ // public static void notNull(final Object value, final String objectName) { // if (value==null) { // throw new IllegalArgumentException(objectName + " must not be null"); // } // } // }
import java.util.regex.Matcher; import java.util.regex.Pattern; import uk.ac.ed.ph.jacomax.internal.Assert;
/* Copyright (c) 2010 - 2012, The University of Edinburgh. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * * Neither the name of the University of Edinburgh nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package uk.ac.ed.ph.jacomax.utilities; /** * Provides some basic utility methods for handling Maxima outputs. * <p> * This might become more fully-featured in the future... * * @author David McKain */ public final class MaximaOutputUtilities { public static final String DEFAULT_INCHAR = "%i"; public static final String DEFAULT_OUTCHAR = "%o"; public static String stripIntermediateInputPrompts(final String rawOutput) {
// Path: jacomax/src/main/java/uk/ac/ed/ph/jacomax/internal/Assert.java // public final class Assert { // // /** // * Checks that the given object is non-null, throwing an // * IllegalArgumentException if the check fails. If the check succeeds then // * nothing happens. // * // * @param value object to test // * @param objectName name to give to supplied Object when constructing Exception message. // * // * @throws IllegalArgumentException if <code>value</code> is null. // */ // public static void notNull(final Object value, final String objectName) { // if (value==null) { // throw new IllegalArgumentException(objectName + " must not be null"); // } // } // } // Path: jacomax/src/main/java/uk/ac/ed/ph/jacomax/utilities/MaximaOutputUtilities.java import java.util.regex.Matcher; import java.util.regex.Pattern; import uk.ac.ed.ph.jacomax.internal.Assert; /* Copyright (c) 2010 - 2012, The University of Edinburgh. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * * Neither the name of the University of Edinburgh nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package uk.ac.ed.ph.jacomax.utilities; /** * Provides some basic utility methods for handling Maxima outputs. * <p> * This might become more fully-featured in the future... * * @author David McKain */ public final class MaximaOutputUtilities { public static final String DEFAULT_INCHAR = "%i"; public static final String DEFAULT_OUTCHAR = "%o"; public static String stripIntermediateInputPrompts(final String rawOutput) {
Assert.notNull(rawOutput, "rawOutput");
davemckain/jacomax
jacomax/src/main/java/uk/ac/ed/ph/jacomax/internal/MaximaBatchProcessImpl.java
// Path: jacomax/src/main/java/uk/ac/ed/ph/jacomax/JacomaxRuntimeException.java // public class JacomaxRuntimeException extends RuntimeException { // // private static final long serialVersionUID = 7100573731627419599L; // // public JacomaxRuntimeException(final String message) { // super(message); // } // // public JacomaxRuntimeException(final Throwable cause) { // super(cause); // } // // public JacomaxRuntimeException(final String message, final Throwable cause) { // super(message, cause); // } // } // // Path: jacomax/src/main/java/uk/ac/ed/ph/jacomax/MaximaTimeoutException.java // public final class MaximaTimeoutException extends Exception { // // private static final long serialVersionUID = 6077105489157609103L; // // private final int timeoutSeconds; // // public MaximaTimeoutException(final int timeoutSeconds) { // super("Timeout of " + timeoutSeconds + "s exceeded waiting for response from Maxima"); // this.timeoutSeconds = timeoutSeconds; // } // // public int getTimeoutSeconds() { // return timeoutSeconds; // } // }
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import uk.ac.ed.ph.jacomax.JacomaxRuntimeException; import uk.ac.ed.ph.jacomax.MaximaTimeoutException;
/* Copyright (c) 2010 - 2012, The University of Edinburgh. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * * Neither the name of the University of Edinburgh nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package uk.ac.ed.ph.jacomax.internal; /** * Internal implementation of batch process functionality. * * @author David McKain */ public final class MaximaBatchProcessImpl { private static final Logger logger = LoggerFactory.getLogger(MaximaBatchProcessImpl.class); private final MaximaProcessController maximaProcessController; private final InputStream batchInputStream; private final OutputStream batchOutputStream; public MaximaBatchProcessImpl(final MaximaProcessController maximaProcessController, final InputStream batchInputStream, final OutputStream batchOutputStream) { this.maximaProcessController = maximaProcessController; this.batchInputStream = batchInputStream; this.batchOutputStream = batchOutputStream; }
// Path: jacomax/src/main/java/uk/ac/ed/ph/jacomax/JacomaxRuntimeException.java // public class JacomaxRuntimeException extends RuntimeException { // // private static final long serialVersionUID = 7100573731627419599L; // // public JacomaxRuntimeException(final String message) { // super(message); // } // // public JacomaxRuntimeException(final Throwable cause) { // super(cause); // } // // public JacomaxRuntimeException(final String message, final Throwable cause) { // super(message, cause); // } // } // // Path: jacomax/src/main/java/uk/ac/ed/ph/jacomax/MaximaTimeoutException.java // public final class MaximaTimeoutException extends Exception { // // private static final long serialVersionUID = 6077105489157609103L; // // private final int timeoutSeconds; // // public MaximaTimeoutException(final int timeoutSeconds) { // super("Timeout of " + timeoutSeconds + "s exceeded waiting for response from Maxima"); // this.timeoutSeconds = timeoutSeconds; // } // // public int getTimeoutSeconds() { // return timeoutSeconds; // } // } // Path: jacomax/src/main/java/uk/ac/ed/ph/jacomax/internal/MaximaBatchProcessImpl.java import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import uk.ac.ed.ph.jacomax.JacomaxRuntimeException; import uk.ac.ed.ph.jacomax.MaximaTimeoutException; /* Copyright (c) 2010 - 2012, The University of Edinburgh. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * * Neither the name of the University of Edinburgh nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package uk.ac.ed.ph.jacomax.internal; /** * Internal implementation of batch process functionality. * * @author David McKain */ public final class MaximaBatchProcessImpl { private static final Logger logger = LoggerFactory.getLogger(MaximaBatchProcessImpl.class); private final MaximaProcessController maximaProcessController; private final InputStream batchInputStream; private final OutputStream batchOutputStream; public MaximaBatchProcessImpl(final MaximaProcessController maximaProcessController, final InputStream batchInputStream, final OutputStream batchOutputStream) { this.maximaProcessController = maximaProcessController; this.batchInputStream = batchInputStream; this.batchOutputStream = batchOutputStream; }
public int run(final int timeout) throws MaximaTimeoutException {
davemckain/jacomax
jacomax/src/main/java/uk/ac/ed/ph/jacomax/internal/MaximaBatchProcessImpl.java
// Path: jacomax/src/main/java/uk/ac/ed/ph/jacomax/JacomaxRuntimeException.java // public class JacomaxRuntimeException extends RuntimeException { // // private static final long serialVersionUID = 7100573731627419599L; // // public JacomaxRuntimeException(final String message) { // super(message); // } // // public JacomaxRuntimeException(final Throwable cause) { // super(cause); // } // // public JacomaxRuntimeException(final String message, final Throwable cause) { // super(message, cause); // } // } // // Path: jacomax/src/main/java/uk/ac/ed/ph/jacomax/MaximaTimeoutException.java // public final class MaximaTimeoutException extends Exception { // // private static final long serialVersionUID = 6077105489157609103L; // // private final int timeoutSeconds; // // public MaximaTimeoutException(final int timeoutSeconds) { // super("Timeout of " + timeoutSeconds + "s exceeded waiting for response from Maxima"); // this.timeoutSeconds = timeoutSeconds; // } // // public int getTimeoutSeconds() { // return timeoutSeconds; // } // }
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import uk.ac.ed.ph.jacomax.JacomaxRuntimeException; import uk.ac.ed.ph.jacomax.MaximaTimeoutException;
/* Copyright (c) 2010 - 2012, The University of Edinburgh. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * * Neither the name of the University of Edinburgh nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package uk.ac.ed.ph.jacomax.internal; /** * Internal implementation of batch process functionality. * * @author David McKain */ public final class MaximaBatchProcessImpl { private static final Logger logger = LoggerFactory.getLogger(MaximaBatchProcessImpl.class); private final MaximaProcessController maximaProcessController; private final InputStream batchInputStream; private final OutputStream batchOutputStream; public MaximaBatchProcessImpl(final MaximaProcessController maximaProcessController, final InputStream batchInputStream, final OutputStream batchOutputStream) { this.maximaProcessController = maximaProcessController; this.batchInputStream = batchInputStream; this.batchOutputStream = batchOutputStream; } public int run(final int timeout) throws MaximaTimeoutException { logger.debug("Running Maxima process in batch mode"); final BatchOutputHandler writerOutputHandler = new BatchOutputHandler(batchOutputStream); int returnCode; try { maximaProcessController.doMaximaCall(batchInputStream, true, writerOutputHandler, timeout); } finally { try { returnCode = maximaProcessController.terminate(); } finally { try { batchOutputStream.flush(); } catch (final IOException e) {
// Path: jacomax/src/main/java/uk/ac/ed/ph/jacomax/JacomaxRuntimeException.java // public class JacomaxRuntimeException extends RuntimeException { // // private static final long serialVersionUID = 7100573731627419599L; // // public JacomaxRuntimeException(final String message) { // super(message); // } // // public JacomaxRuntimeException(final Throwable cause) { // super(cause); // } // // public JacomaxRuntimeException(final String message, final Throwable cause) { // super(message, cause); // } // } // // Path: jacomax/src/main/java/uk/ac/ed/ph/jacomax/MaximaTimeoutException.java // public final class MaximaTimeoutException extends Exception { // // private static final long serialVersionUID = 6077105489157609103L; // // private final int timeoutSeconds; // // public MaximaTimeoutException(final int timeoutSeconds) { // super("Timeout of " + timeoutSeconds + "s exceeded waiting for response from Maxima"); // this.timeoutSeconds = timeoutSeconds; // } // // public int getTimeoutSeconds() { // return timeoutSeconds; // } // } // Path: jacomax/src/main/java/uk/ac/ed/ph/jacomax/internal/MaximaBatchProcessImpl.java import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import uk.ac.ed.ph.jacomax.JacomaxRuntimeException; import uk.ac.ed.ph.jacomax.MaximaTimeoutException; /* Copyright (c) 2010 - 2012, The University of Edinburgh. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * * Neither the name of the University of Edinburgh nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package uk.ac.ed.ph.jacomax.internal; /** * Internal implementation of batch process functionality. * * @author David McKain */ public final class MaximaBatchProcessImpl { private static final Logger logger = LoggerFactory.getLogger(MaximaBatchProcessImpl.class); private final MaximaProcessController maximaProcessController; private final InputStream batchInputStream; private final OutputStream batchOutputStream; public MaximaBatchProcessImpl(final MaximaProcessController maximaProcessController, final InputStream batchInputStream, final OutputStream batchOutputStream) { this.maximaProcessController = maximaProcessController; this.batchInputStream = batchInputStream; this.batchOutputStream = batchOutputStream; } public int run(final int timeout) throws MaximaTimeoutException { logger.debug("Running Maxima process in batch mode"); final BatchOutputHandler writerOutputHandler = new BatchOutputHandler(batchOutputStream); int returnCode; try { maximaProcessController.doMaximaCall(batchInputStream, true, writerOutputHandler, timeout); } finally { try { returnCode = maximaProcessController.terminate(); } finally { try { batchOutputStream.flush(); } catch (final IOException e) {
throw new JacomaxRuntimeException("Could not flush batchOutputStream", e);
maeln/LambdaHindleyMilner
src/main/java/inference/interfaces/Substitutable.java
// Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // } // // Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // }
import inference.Substitution; import types.TVariable; import types.Type; import java.util.Collection; import java.util.HashSet;
package inference.interfaces; /** * Created by valentin on 18/10/2016. */ public abstract class Substitutable<T extends Substitutable<T>> { public T apply(Substitution s) { T result = identity();
// Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // } // // Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // } // Path: src/main/java/inference/interfaces/Substitutable.java import inference.Substitution; import types.TVariable; import types.Type; import java.util.Collection; import java.util.HashSet; package inference.interfaces; /** * Created by valentin on 18/10/2016. */ public abstract class Substitutable<T extends Substitutable<T>> { public T apply(Substitution s) { T result = identity();
for (TVariable var : s.variables()) {
maeln/LambdaHindleyMilner
src/main/java/inference/interfaces/Substitutable.java
// Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // } // // Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // }
import inference.Substitution; import types.TVariable; import types.Type; import java.util.Collection; import java.util.HashSet;
package inference.interfaces; /** * Created by valentin on 18/10/2016. */ public abstract class Substitutable<T extends Substitutable<T>> { public T apply(Substitution s) { T result = identity(); for (TVariable var : s.variables()) { result = result.substitute(var, s.substituteOf(var)); } return result; } abstract public HashSet<TVariable> ftv();
// Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // } // // Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // } // Path: src/main/java/inference/interfaces/Substitutable.java import inference.Substitution; import types.TVariable; import types.Type; import java.util.Collection; import java.util.HashSet; package inference.interfaces; /** * Created by valentin on 18/10/2016. */ public abstract class Substitutable<T extends Substitutable<T>> { public T apply(Substitution s) { T result = identity(); for (TVariable var : s.variables()) { result = result.substitute(var, s.substituteOf(var)); } return result; } abstract public HashSet<TVariable> ftv();
abstract public T substitute(TVariable var, Type t);
maeln/LambdaHindleyMilner
src/main/java/ast/Variable.java
// Path: src/main/java/inference/environements/TypeInferenceEnv.java // public class TypeInferenceEnv { // private TypeGenerator typeGenerator; // private TypeEnv typeEnv; // private List<Constraint> constraints; // // public TypeInferenceEnv() { // typeGenerator = new TypeGenerator(); // typeEnv = new TypeEnv(); // constraints = new LinkedList<>(); // } // // private TypeInferenceEnv(TypeInferenceEnv globalEnv) { // typeGenerator = globalEnv.typeGenerator; // typeEnv = new TypeEnv().mergeWith(globalEnv.typeEnv); // constraints = globalEnv.constraints(); // } // // public TypeInferenceEnv inEnv(Variable var, Scheme scheme) { // TypeInferenceEnv localEnv = new TypeInferenceEnv(this); // localEnv.bind(var, scheme); // return localEnv; // } // // public void bind(Variable var, Scheme scheme) { // typeEnv.extend(var, scheme); // } // // public void unify(Type t1, Type t2) { // constraints.add(new Constraint(t1, t2)); // } // // // public Type instantiate(Scheme scheme) { // // List<Type> freshVars = new LinkedList<>(); // // scheme.variables().forEach(var -> freshVars.add(freshName())); // // // // Type instatiation = scheme.type().duplicate(); // // instatiation.apply(new Substitution(scheme.variables(), freshVars)); // // // // return instatiation; // // } // // public Scheme generalize(Type t) { // HashSet<TVariable> freeVars = t.ftv(); // freeVars.removeAll(typeEnv.ftv()); // return forall(new ArrayList<>(freeVars), t); // } // // public Scheme lookup(Variable variable) { // return typeEnv.lookup(variable); // } // // public TVariable freshName() { // return typeGenerator.freshName(); // } // // public List<Constraint> constraints() { // return constraints; // } // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // }
import inference.environements.TypeInferenceEnv; import types.Type;
package ast; public class Variable extends Expression { private String name; public Variable(String name) { this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override
// Path: src/main/java/inference/environements/TypeInferenceEnv.java // public class TypeInferenceEnv { // private TypeGenerator typeGenerator; // private TypeEnv typeEnv; // private List<Constraint> constraints; // // public TypeInferenceEnv() { // typeGenerator = new TypeGenerator(); // typeEnv = new TypeEnv(); // constraints = new LinkedList<>(); // } // // private TypeInferenceEnv(TypeInferenceEnv globalEnv) { // typeGenerator = globalEnv.typeGenerator; // typeEnv = new TypeEnv().mergeWith(globalEnv.typeEnv); // constraints = globalEnv.constraints(); // } // // public TypeInferenceEnv inEnv(Variable var, Scheme scheme) { // TypeInferenceEnv localEnv = new TypeInferenceEnv(this); // localEnv.bind(var, scheme); // return localEnv; // } // // public void bind(Variable var, Scheme scheme) { // typeEnv.extend(var, scheme); // } // // public void unify(Type t1, Type t2) { // constraints.add(new Constraint(t1, t2)); // } // // // public Type instantiate(Scheme scheme) { // // List<Type> freshVars = new LinkedList<>(); // // scheme.variables().forEach(var -> freshVars.add(freshName())); // // // // Type instatiation = scheme.type().duplicate(); // // instatiation.apply(new Substitution(scheme.variables(), freshVars)); // // // // return instatiation; // // } // // public Scheme generalize(Type t) { // HashSet<TVariable> freeVars = t.ftv(); // freeVars.removeAll(typeEnv.ftv()); // return forall(new ArrayList<>(freeVars), t); // } // // public Scheme lookup(Variable variable) { // return typeEnv.lookup(variable); // } // // public TVariable freshName() { // return typeGenerator.freshName(); // } // // public List<Constraint> constraints() { // return constraints; // } // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // } // Path: src/main/java/ast/Variable.java import inference.environements.TypeInferenceEnv; import types.Type; package ast; public class Variable extends Expression { private String name; public Variable(String name) { this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override
public Type infer(TypeInferenceEnv env) {
maeln/LambdaHindleyMilner
src/main/java/ast/Variable.java
// Path: src/main/java/inference/environements/TypeInferenceEnv.java // public class TypeInferenceEnv { // private TypeGenerator typeGenerator; // private TypeEnv typeEnv; // private List<Constraint> constraints; // // public TypeInferenceEnv() { // typeGenerator = new TypeGenerator(); // typeEnv = new TypeEnv(); // constraints = new LinkedList<>(); // } // // private TypeInferenceEnv(TypeInferenceEnv globalEnv) { // typeGenerator = globalEnv.typeGenerator; // typeEnv = new TypeEnv().mergeWith(globalEnv.typeEnv); // constraints = globalEnv.constraints(); // } // // public TypeInferenceEnv inEnv(Variable var, Scheme scheme) { // TypeInferenceEnv localEnv = new TypeInferenceEnv(this); // localEnv.bind(var, scheme); // return localEnv; // } // // public void bind(Variable var, Scheme scheme) { // typeEnv.extend(var, scheme); // } // // public void unify(Type t1, Type t2) { // constraints.add(new Constraint(t1, t2)); // } // // // public Type instantiate(Scheme scheme) { // // List<Type> freshVars = new LinkedList<>(); // // scheme.variables().forEach(var -> freshVars.add(freshName())); // // // // Type instatiation = scheme.type().duplicate(); // // instatiation.apply(new Substitution(scheme.variables(), freshVars)); // // // // return instatiation; // // } // // public Scheme generalize(Type t) { // HashSet<TVariable> freeVars = t.ftv(); // freeVars.removeAll(typeEnv.ftv()); // return forall(new ArrayList<>(freeVars), t); // } // // public Scheme lookup(Variable variable) { // return typeEnv.lookup(variable); // } // // public TVariable freshName() { // return typeGenerator.freshName(); // } // // public List<Constraint> constraints() { // return constraints; // } // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // }
import inference.environements.TypeInferenceEnv; import types.Type;
package ast; public class Variable extends Expression { private String name; public Variable(String name) { this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override
// Path: src/main/java/inference/environements/TypeInferenceEnv.java // public class TypeInferenceEnv { // private TypeGenerator typeGenerator; // private TypeEnv typeEnv; // private List<Constraint> constraints; // // public TypeInferenceEnv() { // typeGenerator = new TypeGenerator(); // typeEnv = new TypeEnv(); // constraints = new LinkedList<>(); // } // // private TypeInferenceEnv(TypeInferenceEnv globalEnv) { // typeGenerator = globalEnv.typeGenerator; // typeEnv = new TypeEnv().mergeWith(globalEnv.typeEnv); // constraints = globalEnv.constraints(); // } // // public TypeInferenceEnv inEnv(Variable var, Scheme scheme) { // TypeInferenceEnv localEnv = new TypeInferenceEnv(this); // localEnv.bind(var, scheme); // return localEnv; // } // // public void bind(Variable var, Scheme scheme) { // typeEnv.extend(var, scheme); // } // // public void unify(Type t1, Type t2) { // constraints.add(new Constraint(t1, t2)); // } // // // public Type instantiate(Scheme scheme) { // // List<Type> freshVars = new LinkedList<>(); // // scheme.variables().forEach(var -> freshVars.add(freshName())); // // // // Type instatiation = scheme.type().duplicate(); // // instatiation.apply(new Substitution(scheme.variables(), freshVars)); // // // // return instatiation; // // } // // public Scheme generalize(Type t) { // HashSet<TVariable> freeVars = t.ftv(); // freeVars.removeAll(typeEnv.ftv()); // return forall(new ArrayList<>(freeVars), t); // } // // public Scheme lookup(Variable variable) { // return typeEnv.lookup(variable); // } // // public TVariable freshName() { // return typeGenerator.freshName(); // } // // public List<Constraint> constraints() { // return constraints; // } // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // } // Path: src/main/java/ast/Variable.java import inference.environements.TypeInferenceEnv; import types.Type; package ast; public class Variable extends Expression { private String name; public Variable(String name) { this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override
public Type infer(TypeInferenceEnv env) {
maeln/LambdaHindleyMilner
src/test/java/inference/TypeGeneratorTest.java
// Path: src/main/java/inference/environements/TypeGenerator.java // public class TypeGenerator { // private int counter = 0; // // public TVariable freshName() { // char letter = (char) (97 + counter % 26); // String name = letter + Integer.toString(counter / 26); // counter++; // return variable(name); // } // } // // Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // }
import inference.environements.TypeGenerator; import org.junit.Test; import types.TVariable; import java.util.HashSet; import static org.junit.Assert.*;
package inference; /** * Created by valentin on 24/10/2016. */ public class TypeGeneratorTest { private int n = 100; @Test public void freshName() throws Exception {
// Path: src/main/java/inference/environements/TypeGenerator.java // public class TypeGenerator { // private int counter = 0; // // public TVariable freshName() { // char letter = (char) (97 + counter % 26); // String name = letter + Integer.toString(counter / 26); // counter++; // return variable(name); // } // } // // Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // } // Path: src/test/java/inference/TypeGeneratorTest.java import inference.environements.TypeGenerator; import org.junit.Test; import types.TVariable; import java.util.HashSet; import static org.junit.Assert.*; package inference; /** * Created by valentin on 24/10/2016. */ public class TypeGeneratorTest { private int n = 100; @Test public void freshName() throws Exception {
TypeGenerator gen = new TypeGenerator();
maeln/LambdaHindleyMilner
src/test/java/inference/TypeGeneratorTest.java
// Path: src/main/java/inference/environements/TypeGenerator.java // public class TypeGenerator { // private int counter = 0; // // public TVariable freshName() { // char letter = (char) (97 + counter % 26); // String name = letter + Integer.toString(counter / 26); // counter++; // return variable(name); // } // } // // Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // }
import inference.environements.TypeGenerator; import org.junit.Test; import types.TVariable; import java.util.HashSet; import static org.junit.Assert.*;
package inference; /** * Created by valentin on 24/10/2016. */ public class TypeGeneratorTest { private int n = 100; @Test public void freshName() throws Exception { TypeGenerator gen = new TypeGenerator();
// Path: src/main/java/inference/environements/TypeGenerator.java // public class TypeGenerator { // private int counter = 0; // // public TVariable freshName() { // char letter = (char) (97 + counter % 26); // String name = letter + Integer.toString(counter / 26); // counter++; // return variable(name); // } // } // // Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // } // Path: src/test/java/inference/TypeGeneratorTest.java import inference.environements.TypeGenerator; import org.junit.Test; import types.TVariable; import java.util.HashSet; import static org.junit.Assert.*; package inference; /** * Created by valentin on 24/10/2016. */ public class TypeGeneratorTest { private int n = 100; @Test public void freshName() throws Exception { TypeGenerator gen = new TypeGenerator();
HashSet<TVariable> vars = new HashSet<>();
maeln/LambdaHindleyMilner
src/main/java/inference/Constraint.java
// Path: src/main/java/inference/interfaces/Substitutable.java // public abstract class Substitutable<T extends Substitutable<T>> { // public T apply(Substitution s) { // T result = identity(); // for (TVariable var : s.variables()) { // result = result.substitute(var, s.substituteOf(var)); // } // return result; // } // abstract public HashSet<TVariable> ftv(); // // abstract public T substitute(TVariable var, Type t); // // abstract public T identity(); // } // // Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // }
import inference.interfaces.Substitutable; import types.TVariable; import types.Type; import java.util.HashSet;
package inference; /** * Created by valentin on 24/10/2016. */ public class Constraint extends Substitutable<Constraint> { private final Type left, right; public Constraint(Type left, Type right) { this.left = left; this.right = right; } public Type left() { return left; } public Type right() { return right; } @Override
// Path: src/main/java/inference/interfaces/Substitutable.java // public abstract class Substitutable<T extends Substitutable<T>> { // public T apply(Substitution s) { // T result = identity(); // for (TVariable var : s.variables()) { // result = result.substitute(var, s.substituteOf(var)); // } // return result; // } // abstract public HashSet<TVariable> ftv(); // // abstract public T substitute(TVariable var, Type t); // // abstract public T identity(); // } // // Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // } // Path: src/main/java/inference/Constraint.java import inference.interfaces.Substitutable; import types.TVariable; import types.Type; import java.util.HashSet; package inference; /** * Created by valentin on 24/10/2016. */ public class Constraint extends Substitutable<Constraint> { private final Type left, right; public Constraint(Type left, Type right) { this.left = left; this.right = right; } public Type left() { return left; } public Type right() { return right; } @Override
public HashSet<TVariable> ftv() {
maeln/LambdaHindleyMilner
src/main/java/types/TVariable.java
// Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // }
import inference.Substitution; import java.util.*;
package types; /** * Created by valentin on 18/10/2016. * */ public class TVariable extends Type { private final String name; private final static HashSet<TVariable> instantiated = new HashSet<>(); private TVariable(String name) { this.name = name; } public String name() { return name; } public static TVariable variable(String name) { TVariable var = new TVariable(name); if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); return var; } public static List<TVariable> variables(String... names) { List<TVariable> variables = new LinkedList<>(); for (String name : names) variables.add(new TVariable(name)); return variables; } @Override public Type substitute(TVariable var, Type type) { return this.equals(var) ? type : this; } @Override public HashSet<TVariable> ftv() { return new HashSet<>(Collections.singleton(this)); } @Override
// Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // } // Path: src/main/java/types/TVariable.java import inference.Substitution; import java.util.*; package types; /** * Created by valentin on 18/10/2016. * */ public class TVariable extends Type { private final String name; private final static HashSet<TVariable> instantiated = new HashSet<>(); private TVariable(String name) { this.name = name; } public String name() { return name; } public static TVariable variable(String name) { TVariable var = new TVariable(name); if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); return var; } public static List<TVariable> variables(String... names) { List<TVariable> variables = new LinkedList<>(); for (String name : names) variables.add(new TVariable(name)); return variables; } @Override public Type substitute(TVariable var, Type type) { return this.equals(var) ? type : this; } @Override public HashSet<TVariable> ftv() { return new HashSet<>(Collections.singleton(this)); } @Override
protected Substitution unifyWith(TFunction fun) {
maeln/LambdaHindleyMilner
src/main/java/types/Type.java
// Path: src/main/java/exceptions/UnificationFailException.java // public class UnificationFailException extends RuntimeException { // public UnificationFailException(Unifyable first, Unifyable second) { // super("The unification of inferred type for this expression has failed : " + first + " <=/=> " + second); // } // } // // Path: src/main/java/inference/interfaces/Substitutable.java // public abstract class Substitutable<T extends Substitutable<T>> { // public T apply(Substitution s) { // T result = identity(); // for (TVariable var : s.variables()) { // result = result.substitute(var, s.substituteOf(var)); // } // return result; // } // abstract public HashSet<TVariable> ftv(); // // abstract public T substitute(TVariable var, Type t); // // abstract public T identity(); // } // // Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // } // // Path: src/main/java/inference/interfaces/Unifyable.java // public interface Unifyable { // Substitution unifyWith(Type type); // // default Substitution bind(TVariable var, Type type) { // if(var.equals(type)) return new Substitution(); // if(type.ftv().contains(var)) throw new InfiniteTypeException(this, type); // return new Substitution(var, type); // } // }
import exceptions.UnificationFailException; import inference.interfaces.Substitutable; import inference.Substitution; import inference.interfaces.Unifyable;
package types; /** * Created by valentin on 18/10/2016. * * Interface générale de type. */ public abstract class Type extends Substitutable<Type> implements Unifyable{ @Override public Type identity() { return this; } @Override
// Path: src/main/java/exceptions/UnificationFailException.java // public class UnificationFailException extends RuntimeException { // public UnificationFailException(Unifyable first, Unifyable second) { // super("The unification of inferred type for this expression has failed : " + first + " <=/=> " + second); // } // } // // Path: src/main/java/inference/interfaces/Substitutable.java // public abstract class Substitutable<T extends Substitutable<T>> { // public T apply(Substitution s) { // T result = identity(); // for (TVariable var : s.variables()) { // result = result.substitute(var, s.substituteOf(var)); // } // return result; // } // abstract public HashSet<TVariable> ftv(); // // abstract public T substitute(TVariable var, Type t); // // abstract public T identity(); // } // // Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // } // // Path: src/main/java/inference/interfaces/Unifyable.java // public interface Unifyable { // Substitution unifyWith(Type type); // // default Substitution bind(TVariable var, Type type) { // if(var.equals(type)) return new Substitution(); // if(type.ftv().contains(var)) throw new InfiniteTypeException(this, type); // return new Substitution(var, type); // } // } // Path: src/main/java/types/Type.java import exceptions.UnificationFailException; import inference.interfaces.Substitutable; import inference.Substitution; import inference.interfaces.Unifyable; package types; /** * Created by valentin on 18/10/2016. * * Interface générale de type. */ public abstract class Type extends Substitutable<Type> implements Unifyable{ @Override public Type identity() { return this; } @Override
public final Substitution unifyWith(Type type) {
maeln/LambdaHindleyMilner
src/main/java/types/Type.java
// Path: src/main/java/exceptions/UnificationFailException.java // public class UnificationFailException extends RuntimeException { // public UnificationFailException(Unifyable first, Unifyable second) { // super("The unification of inferred type for this expression has failed : " + first + " <=/=> " + second); // } // } // // Path: src/main/java/inference/interfaces/Substitutable.java // public abstract class Substitutable<T extends Substitutable<T>> { // public T apply(Substitution s) { // T result = identity(); // for (TVariable var : s.variables()) { // result = result.substitute(var, s.substituteOf(var)); // } // return result; // } // abstract public HashSet<TVariable> ftv(); // // abstract public T substitute(TVariable var, Type t); // // abstract public T identity(); // } // // Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // } // // Path: src/main/java/inference/interfaces/Unifyable.java // public interface Unifyable { // Substitution unifyWith(Type type); // // default Substitution bind(TVariable var, Type type) { // if(var.equals(type)) return new Substitution(); // if(type.ftv().contains(var)) throw new InfiniteTypeException(this, type); // return new Substitution(var, type); // } // }
import exceptions.UnificationFailException; import inference.interfaces.Substitutable; import inference.Substitution; import inference.interfaces.Unifyable;
package types; /** * Created by valentin on 18/10/2016. * * Interface générale de type. */ public abstract class Type extends Substitutable<Type> implements Unifyable{ @Override public Type identity() { return this; } @Override public final Substitution unifyWith(Type type) { if(this.equals(type)) return new Substitution(); if(type instanceof TVariable) return unifyWith((TVariable) type); if(type instanceof TFunction) return unifyWith((TFunction) type); if(type instanceof TConstructor) return unifyWith((TConstructor) type);
// Path: src/main/java/exceptions/UnificationFailException.java // public class UnificationFailException extends RuntimeException { // public UnificationFailException(Unifyable first, Unifyable second) { // super("The unification of inferred type for this expression has failed : " + first + " <=/=> " + second); // } // } // // Path: src/main/java/inference/interfaces/Substitutable.java // public abstract class Substitutable<T extends Substitutable<T>> { // public T apply(Substitution s) { // T result = identity(); // for (TVariable var : s.variables()) { // result = result.substitute(var, s.substituteOf(var)); // } // return result; // } // abstract public HashSet<TVariable> ftv(); // // abstract public T substitute(TVariable var, Type t); // // abstract public T identity(); // } // // Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // } // // Path: src/main/java/inference/interfaces/Unifyable.java // public interface Unifyable { // Substitution unifyWith(Type type); // // default Substitution bind(TVariable var, Type type) { // if(var.equals(type)) return new Substitution(); // if(type.ftv().contains(var)) throw new InfiniteTypeException(this, type); // return new Substitution(var, type); // } // } // Path: src/main/java/types/Type.java import exceptions.UnificationFailException; import inference.interfaces.Substitutable; import inference.Substitution; import inference.interfaces.Unifyable; package types; /** * Created by valentin on 18/10/2016. * * Interface générale de type. */ public abstract class Type extends Substitutable<Type> implements Unifyable{ @Override public Type identity() { return this; } @Override public final Substitution unifyWith(Type type) { if(this.equals(type)) return new Substitution(); if(type instanceof TVariable) return unifyWith((TVariable) type); if(type instanceof TFunction) return unifyWith((TFunction) type); if(type instanceof TConstructor) return unifyWith((TConstructor) type);
throw new UnificationFailException(this, type);
maeln/LambdaHindleyMilner
src/main/java/types/TConstructor.java
// Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // }
import inference.Substitution; import java.util.HashMap; import java.util.HashSet; import java.util.Map;
package types; /** * Created by valentin on 18/10/2016. * * Constructeur de type. Ceci n'est pas utilisé pour le moment. */ public class TConstructor extends Type { private final static Map<String, TConstructor> instantiated = new HashMap<>(); private final String name; private TConstructor(String name) { System.out.println("Creation of TConstructor(" + name + ")"); this.name = name; } public static TConstructor constructor(String name) { TConstructor cons = instantiated.get(name); if(cons == null) { cons = new TConstructor(name); instantiated.put(name, cons); } return cons; } public String name() { return name; } @Override
// Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // } // Path: src/main/java/types/TConstructor.java import inference.Substitution; import java.util.HashMap; import java.util.HashSet; import java.util.Map; package types; /** * Created by valentin on 18/10/2016. * * Constructeur de type. Ceci n'est pas utilisé pour le moment. */ public class TConstructor extends Type { private final static Map<String, TConstructor> instantiated = new HashMap<>(); private final String name; private TConstructor(String name) { System.out.println("Creation of TConstructor(" + name + ")"); this.name = name; } public static TConstructor constructor(String name) { TConstructor cons = instantiated.get(name); if(cons == null) { cons = new TConstructor(name); instantiated.put(name, cons); } return cons; } public String name() { return name; } @Override
public Type apply(Substitution substitution) {
maeln/LambdaHindleyMilner
src/main/java/ast/Literal.java
// Path: src/main/java/inference/environements/TypeInferenceEnv.java // public class TypeInferenceEnv { // private TypeGenerator typeGenerator; // private TypeEnv typeEnv; // private List<Constraint> constraints; // // public TypeInferenceEnv() { // typeGenerator = new TypeGenerator(); // typeEnv = new TypeEnv(); // constraints = new LinkedList<>(); // } // // private TypeInferenceEnv(TypeInferenceEnv globalEnv) { // typeGenerator = globalEnv.typeGenerator; // typeEnv = new TypeEnv().mergeWith(globalEnv.typeEnv); // constraints = globalEnv.constraints(); // } // // public TypeInferenceEnv inEnv(Variable var, Scheme scheme) { // TypeInferenceEnv localEnv = new TypeInferenceEnv(this); // localEnv.bind(var, scheme); // return localEnv; // } // // public void bind(Variable var, Scheme scheme) { // typeEnv.extend(var, scheme); // } // // public void unify(Type t1, Type t2) { // constraints.add(new Constraint(t1, t2)); // } // // // public Type instantiate(Scheme scheme) { // // List<Type> freshVars = new LinkedList<>(); // // scheme.variables().forEach(var -> freshVars.add(freshName())); // // // // Type instatiation = scheme.type().duplicate(); // // instatiation.apply(new Substitution(scheme.variables(), freshVars)); // // // // return instatiation; // // } // // public Scheme generalize(Type t) { // HashSet<TVariable> freeVars = t.ftv(); // freeVars.removeAll(typeEnv.ftv()); // return forall(new ArrayList<>(freeVars), t); // } // // public Scheme lookup(Variable variable) { // return typeEnv.lookup(variable); // } // // public TVariable freshName() { // return typeGenerator.freshName(); // } // // public List<Constraint> constraints() { // return constraints; // } // } // // Path: src/main/java/types/TConstructor.java // public class TConstructor extends Type { // private final static Map<String, TConstructor> instantiated = new HashMap<>(); // private final String name; // // private TConstructor(String name) { // System.out.println("Creation of TConstructor(" + name + ")"); // this.name = name; // } // // public static TConstructor constructor(String name) { // TConstructor cons = instantiated.get(name); // if(cons == null) { // cons = new TConstructor(name); // instantiated.put(name, cons); // } // return cons; // } // // public String name() { // return name; // } // // @Override // public Type apply(Substitution substitution) { // return this; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(); // } // // // Object override - Begin // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TConstructor that = (TConstructor) o; // // return name.equals(that.name); // } // // @Override // public int hashCode() { // return name.hashCode(); // } // // @Override // public String toString() { // return name; // } // // @Override // public Type instantiate(Substitution sub) { // return this; // } // // Object override - End // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // }
import inference.environements.TypeInferenceEnv; import types.TConstructor; import types.Type;
package ast; /** * Created by valentin on 25/10/2016. */ public abstract class Literal<T> extends Expression { private T value;
// Path: src/main/java/inference/environements/TypeInferenceEnv.java // public class TypeInferenceEnv { // private TypeGenerator typeGenerator; // private TypeEnv typeEnv; // private List<Constraint> constraints; // // public TypeInferenceEnv() { // typeGenerator = new TypeGenerator(); // typeEnv = new TypeEnv(); // constraints = new LinkedList<>(); // } // // private TypeInferenceEnv(TypeInferenceEnv globalEnv) { // typeGenerator = globalEnv.typeGenerator; // typeEnv = new TypeEnv().mergeWith(globalEnv.typeEnv); // constraints = globalEnv.constraints(); // } // // public TypeInferenceEnv inEnv(Variable var, Scheme scheme) { // TypeInferenceEnv localEnv = new TypeInferenceEnv(this); // localEnv.bind(var, scheme); // return localEnv; // } // // public void bind(Variable var, Scheme scheme) { // typeEnv.extend(var, scheme); // } // // public void unify(Type t1, Type t2) { // constraints.add(new Constraint(t1, t2)); // } // // // public Type instantiate(Scheme scheme) { // // List<Type> freshVars = new LinkedList<>(); // // scheme.variables().forEach(var -> freshVars.add(freshName())); // // // // Type instatiation = scheme.type().duplicate(); // // instatiation.apply(new Substitution(scheme.variables(), freshVars)); // // // // return instatiation; // // } // // public Scheme generalize(Type t) { // HashSet<TVariable> freeVars = t.ftv(); // freeVars.removeAll(typeEnv.ftv()); // return forall(new ArrayList<>(freeVars), t); // } // // public Scheme lookup(Variable variable) { // return typeEnv.lookup(variable); // } // // public TVariable freshName() { // return typeGenerator.freshName(); // } // // public List<Constraint> constraints() { // return constraints; // } // } // // Path: src/main/java/types/TConstructor.java // public class TConstructor extends Type { // private final static Map<String, TConstructor> instantiated = new HashMap<>(); // private final String name; // // private TConstructor(String name) { // System.out.println("Creation of TConstructor(" + name + ")"); // this.name = name; // } // // public static TConstructor constructor(String name) { // TConstructor cons = instantiated.get(name); // if(cons == null) { // cons = new TConstructor(name); // instantiated.put(name, cons); // } // return cons; // } // // public String name() { // return name; // } // // @Override // public Type apply(Substitution substitution) { // return this; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(); // } // // // Object override - Begin // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TConstructor that = (TConstructor) o; // // return name.equals(that.name); // } // // @Override // public int hashCode() { // return name.hashCode(); // } // // @Override // public String toString() { // return name; // } // // @Override // public Type instantiate(Substitution sub) { // return this; // } // // Object override - End // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // } // Path: src/main/java/ast/Literal.java import inference.environements.TypeInferenceEnv; import types.TConstructor; import types.Type; package ast; /** * Created by valentin on 25/10/2016. */ public abstract class Literal<T> extends Expression { private T value;
private Type type;
maeln/LambdaHindleyMilner
src/main/java/ast/Literal.java
// Path: src/main/java/inference/environements/TypeInferenceEnv.java // public class TypeInferenceEnv { // private TypeGenerator typeGenerator; // private TypeEnv typeEnv; // private List<Constraint> constraints; // // public TypeInferenceEnv() { // typeGenerator = new TypeGenerator(); // typeEnv = new TypeEnv(); // constraints = new LinkedList<>(); // } // // private TypeInferenceEnv(TypeInferenceEnv globalEnv) { // typeGenerator = globalEnv.typeGenerator; // typeEnv = new TypeEnv().mergeWith(globalEnv.typeEnv); // constraints = globalEnv.constraints(); // } // // public TypeInferenceEnv inEnv(Variable var, Scheme scheme) { // TypeInferenceEnv localEnv = new TypeInferenceEnv(this); // localEnv.bind(var, scheme); // return localEnv; // } // // public void bind(Variable var, Scheme scheme) { // typeEnv.extend(var, scheme); // } // // public void unify(Type t1, Type t2) { // constraints.add(new Constraint(t1, t2)); // } // // // public Type instantiate(Scheme scheme) { // // List<Type> freshVars = new LinkedList<>(); // // scheme.variables().forEach(var -> freshVars.add(freshName())); // // // // Type instatiation = scheme.type().duplicate(); // // instatiation.apply(new Substitution(scheme.variables(), freshVars)); // // // // return instatiation; // // } // // public Scheme generalize(Type t) { // HashSet<TVariable> freeVars = t.ftv(); // freeVars.removeAll(typeEnv.ftv()); // return forall(new ArrayList<>(freeVars), t); // } // // public Scheme lookup(Variable variable) { // return typeEnv.lookup(variable); // } // // public TVariable freshName() { // return typeGenerator.freshName(); // } // // public List<Constraint> constraints() { // return constraints; // } // } // // Path: src/main/java/types/TConstructor.java // public class TConstructor extends Type { // private final static Map<String, TConstructor> instantiated = new HashMap<>(); // private final String name; // // private TConstructor(String name) { // System.out.println("Creation of TConstructor(" + name + ")"); // this.name = name; // } // // public static TConstructor constructor(String name) { // TConstructor cons = instantiated.get(name); // if(cons == null) { // cons = new TConstructor(name); // instantiated.put(name, cons); // } // return cons; // } // // public String name() { // return name; // } // // @Override // public Type apply(Substitution substitution) { // return this; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(); // } // // // Object override - Begin // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TConstructor that = (TConstructor) o; // // return name.equals(that.name); // } // // @Override // public int hashCode() { // return name.hashCode(); // } // // @Override // public String toString() { // return name; // } // // @Override // public Type instantiate(Substitution sub) { // return this; // } // // Object override - End // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // }
import inference.environements.TypeInferenceEnv; import types.TConstructor; import types.Type;
package ast; /** * Created by valentin on 25/10/2016. */ public abstract class Literal<T> extends Expression { private T value; private Type type;
// Path: src/main/java/inference/environements/TypeInferenceEnv.java // public class TypeInferenceEnv { // private TypeGenerator typeGenerator; // private TypeEnv typeEnv; // private List<Constraint> constraints; // // public TypeInferenceEnv() { // typeGenerator = new TypeGenerator(); // typeEnv = new TypeEnv(); // constraints = new LinkedList<>(); // } // // private TypeInferenceEnv(TypeInferenceEnv globalEnv) { // typeGenerator = globalEnv.typeGenerator; // typeEnv = new TypeEnv().mergeWith(globalEnv.typeEnv); // constraints = globalEnv.constraints(); // } // // public TypeInferenceEnv inEnv(Variable var, Scheme scheme) { // TypeInferenceEnv localEnv = new TypeInferenceEnv(this); // localEnv.bind(var, scheme); // return localEnv; // } // // public void bind(Variable var, Scheme scheme) { // typeEnv.extend(var, scheme); // } // // public void unify(Type t1, Type t2) { // constraints.add(new Constraint(t1, t2)); // } // // // public Type instantiate(Scheme scheme) { // // List<Type> freshVars = new LinkedList<>(); // // scheme.variables().forEach(var -> freshVars.add(freshName())); // // // // Type instatiation = scheme.type().duplicate(); // // instatiation.apply(new Substitution(scheme.variables(), freshVars)); // // // // return instatiation; // // } // // public Scheme generalize(Type t) { // HashSet<TVariable> freeVars = t.ftv(); // freeVars.removeAll(typeEnv.ftv()); // return forall(new ArrayList<>(freeVars), t); // } // // public Scheme lookup(Variable variable) { // return typeEnv.lookup(variable); // } // // public TVariable freshName() { // return typeGenerator.freshName(); // } // // public List<Constraint> constraints() { // return constraints; // } // } // // Path: src/main/java/types/TConstructor.java // public class TConstructor extends Type { // private final static Map<String, TConstructor> instantiated = new HashMap<>(); // private final String name; // // private TConstructor(String name) { // System.out.println("Creation of TConstructor(" + name + ")"); // this.name = name; // } // // public static TConstructor constructor(String name) { // TConstructor cons = instantiated.get(name); // if(cons == null) { // cons = new TConstructor(name); // instantiated.put(name, cons); // } // return cons; // } // // public String name() { // return name; // } // // @Override // public Type apply(Substitution substitution) { // return this; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(); // } // // // Object override - Begin // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TConstructor that = (TConstructor) o; // // return name.equals(that.name); // } // // @Override // public int hashCode() { // return name.hashCode(); // } // // @Override // public String toString() { // return name; // } // // @Override // public Type instantiate(Substitution sub) { // return this; // } // // Object override - End // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // } // Path: src/main/java/ast/Literal.java import inference.environements.TypeInferenceEnv; import types.TConstructor; import types.Type; package ast; /** * Created by valentin on 25/10/2016. */ public abstract class Literal<T> extends Expression { private T value; private Type type;
public Literal(T value, TConstructor type){
maeln/LambdaHindleyMilner
src/main/java/ast/Literal.java
// Path: src/main/java/inference/environements/TypeInferenceEnv.java // public class TypeInferenceEnv { // private TypeGenerator typeGenerator; // private TypeEnv typeEnv; // private List<Constraint> constraints; // // public TypeInferenceEnv() { // typeGenerator = new TypeGenerator(); // typeEnv = new TypeEnv(); // constraints = new LinkedList<>(); // } // // private TypeInferenceEnv(TypeInferenceEnv globalEnv) { // typeGenerator = globalEnv.typeGenerator; // typeEnv = new TypeEnv().mergeWith(globalEnv.typeEnv); // constraints = globalEnv.constraints(); // } // // public TypeInferenceEnv inEnv(Variable var, Scheme scheme) { // TypeInferenceEnv localEnv = new TypeInferenceEnv(this); // localEnv.bind(var, scheme); // return localEnv; // } // // public void bind(Variable var, Scheme scheme) { // typeEnv.extend(var, scheme); // } // // public void unify(Type t1, Type t2) { // constraints.add(new Constraint(t1, t2)); // } // // // public Type instantiate(Scheme scheme) { // // List<Type> freshVars = new LinkedList<>(); // // scheme.variables().forEach(var -> freshVars.add(freshName())); // // // // Type instatiation = scheme.type().duplicate(); // // instatiation.apply(new Substitution(scheme.variables(), freshVars)); // // // // return instatiation; // // } // // public Scheme generalize(Type t) { // HashSet<TVariable> freeVars = t.ftv(); // freeVars.removeAll(typeEnv.ftv()); // return forall(new ArrayList<>(freeVars), t); // } // // public Scheme lookup(Variable variable) { // return typeEnv.lookup(variable); // } // // public TVariable freshName() { // return typeGenerator.freshName(); // } // // public List<Constraint> constraints() { // return constraints; // } // } // // Path: src/main/java/types/TConstructor.java // public class TConstructor extends Type { // private final static Map<String, TConstructor> instantiated = new HashMap<>(); // private final String name; // // private TConstructor(String name) { // System.out.println("Creation of TConstructor(" + name + ")"); // this.name = name; // } // // public static TConstructor constructor(String name) { // TConstructor cons = instantiated.get(name); // if(cons == null) { // cons = new TConstructor(name); // instantiated.put(name, cons); // } // return cons; // } // // public String name() { // return name; // } // // @Override // public Type apply(Substitution substitution) { // return this; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(); // } // // // Object override - Begin // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TConstructor that = (TConstructor) o; // // return name.equals(that.name); // } // // @Override // public int hashCode() { // return name.hashCode(); // } // // @Override // public String toString() { // return name; // } // // @Override // public Type instantiate(Substitution sub) { // return this; // } // // Object override - End // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // }
import inference.environements.TypeInferenceEnv; import types.TConstructor; import types.Type;
package ast; /** * Created by valentin on 25/10/2016. */ public abstract class Literal<T> extends Expression { private T value; private Type type; public Literal(T value, TConstructor type){ this.value = value; this.type = type; } public T value() { return value; } @Override
// Path: src/main/java/inference/environements/TypeInferenceEnv.java // public class TypeInferenceEnv { // private TypeGenerator typeGenerator; // private TypeEnv typeEnv; // private List<Constraint> constraints; // // public TypeInferenceEnv() { // typeGenerator = new TypeGenerator(); // typeEnv = new TypeEnv(); // constraints = new LinkedList<>(); // } // // private TypeInferenceEnv(TypeInferenceEnv globalEnv) { // typeGenerator = globalEnv.typeGenerator; // typeEnv = new TypeEnv().mergeWith(globalEnv.typeEnv); // constraints = globalEnv.constraints(); // } // // public TypeInferenceEnv inEnv(Variable var, Scheme scheme) { // TypeInferenceEnv localEnv = new TypeInferenceEnv(this); // localEnv.bind(var, scheme); // return localEnv; // } // // public void bind(Variable var, Scheme scheme) { // typeEnv.extend(var, scheme); // } // // public void unify(Type t1, Type t2) { // constraints.add(new Constraint(t1, t2)); // } // // // public Type instantiate(Scheme scheme) { // // List<Type> freshVars = new LinkedList<>(); // // scheme.variables().forEach(var -> freshVars.add(freshName())); // // // // Type instatiation = scheme.type().duplicate(); // // instatiation.apply(new Substitution(scheme.variables(), freshVars)); // // // // return instatiation; // // } // // public Scheme generalize(Type t) { // HashSet<TVariable> freeVars = t.ftv(); // freeVars.removeAll(typeEnv.ftv()); // return forall(new ArrayList<>(freeVars), t); // } // // public Scheme lookup(Variable variable) { // return typeEnv.lookup(variable); // } // // public TVariable freshName() { // return typeGenerator.freshName(); // } // // public List<Constraint> constraints() { // return constraints; // } // } // // Path: src/main/java/types/TConstructor.java // public class TConstructor extends Type { // private final static Map<String, TConstructor> instantiated = new HashMap<>(); // private final String name; // // private TConstructor(String name) { // System.out.println("Creation of TConstructor(" + name + ")"); // this.name = name; // } // // public static TConstructor constructor(String name) { // TConstructor cons = instantiated.get(name); // if(cons == null) { // cons = new TConstructor(name); // instantiated.put(name, cons); // } // return cons; // } // // public String name() { // return name; // } // // @Override // public Type apply(Substitution substitution) { // return this; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(); // } // // // Object override - Begin // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TConstructor that = (TConstructor) o; // // return name.equals(that.name); // } // // @Override // public int hashCode() { // return name.hashCode(); // } // // @Override // public String toString() { // return name; // } // // @Override // public Type instantiate(Substitution sub) { // return this; // } // // Object override - End // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // } // Path: src/main/java/ast/Literal.java import inference.environements.TypeInferenceEnv; import types.TConstructor; import types.Type; package ast; /** * Created by valentin on 25/10/2016. */ public abstract class Literal<T> extends Expression { private T value; private Type type; public Literal(T value, TConstructor type){ this.value = value; this.type = type; } public T value() { return value; } @Override
public Type infer(TypeInferenceEnv typeInferenceEnv) {
maeln/LambdaHindleyMilner
src/main/java/inference/environements/TypeGenerator.java
// Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // } // // Path: src/main/java/types/TVariable.java // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // }
import types.TVariable; import static types.TVariable.variable;
package inference.environements; /** * Created by valentin on 24/10/2016. */ public class TypeGenerator { private int counter = 0;
// Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // } // // Path: src/main/java/types/TVariable.java // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // Path: src/main/java/inference/environements/TypeGenerator.java import types.TVariable; import static types.TVariable.variable; package inference.environements; /** * Created by valentin on 24/10/2016. */ public class TypeGenerator { private int counter = 0;
public TVariable freshName() {
maeln/LambdaHindleyMilner
src/main/java/inference/environements/TypeGenerator.java
// Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // } // // Path: src/main/java/types/TVariable.java // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // }
import types.TVariable; import static types.TVariable.variable;
package inference.environements; /** * Created by valentin on 24/10/2016. */ public class TypeGenerator { private int counter = 0; public TVariable freshName() { char letter = (char) (97 + counter % 26); String name = letter + Integer.toString(counter / 26); counter++;
// Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // } // // Path: src/main/java/types/TVariable.java // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // Path: src/main/java/inference/environements/TypeGenerator.java import types.TVariable; import static types.TVariable.variable; package inference.environements; /** * Created by valentin on 24/10/2016. */ public class TypeGenerator { private int counter = 0; public TVariable freshName() { char letter = (char) (97 + counter % 26); String name = letter + Integer.toString(counter / 26); counter++;
return variable(name);
maeln/LambdaHindleyMilner
src/test/java/ast/ApplicationTest.java
// Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // }
import org.junit.Test; import types.TVariable; import types.Type; import static org.junit.Assert.*;
package ast; /** * Created by maeln on 20/10/16. */ public class ApplicationTest { @Test public void infer() throws Exception { Variable x = new Variable("x"); Expression exp = new Application(new Lambda(x,x), new Lambda(x,x));
// Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // } // Path: src/test/java/ast/ApplicationTest.java import org.junit.Test; import types.TVariable; import types.Type; import static org.junit.Assert.*; package ast; /** * Created by maeln on 20/10/16. */ public class ApplicationTest { @Test public void infer() throws Exception { Variable x = new Variable("x"); Expression exp = new Application(new Lambda(x,x), new Lambda(x,x));
Type t = exp.infer();
maeln/LambdaHindleyMilner
src/test/java/ast/ApplicationTest.java
// Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // }
import org.junit.Test; import types.TVariable; import types.Type; import static org.junit.Assert.*;
package ast; /** * Created by maeln on 20/10/16. */ public class ApplicationTest { @Test public void infer() throws Exception { Variable x = new Variable("x"); Expression exp = new Application(new Lambda(x,x), new Lambda(x,x)); Type t = exp.infer();
// Path: src/main/java/types/TVariable.java // public class TVariable extends Type { // private final String name; // private final static HashSet<TVariable> instantiated = new HashSet<>(); // // private TVariable(String name) { // this.name = name; // } // // public String name() { // return name; // } // // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // // @Override // public Type substitute(TVariable var, Type type) { // return this.equals(var) ? type : this; // } // // @Override // public HashSet<TVariable> ftv() { // return new HashSet<>(Collections.singleton(this)); // } // // @Override // protected Substitution unifyWith(TFunction fun) { // return bind(this, fun); // } // // @Override // protected Substitution unifyWith(TConstructor cons) { // return bind(this, cons); // } // // @Override // public Type instantiate(Substitution sub) { // return sub.variables().contains(this) ? sub.substituteOf(this) : this; // } // // @Override // protected Substitution unifyWith(TVariable var) { // return bind(this, var); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // TVariable tVariable = (TVariable) o; // // return name.equals(tVariable.name); // // } // // @Override // public int hashCode() { // return ("TVariable_" + name).hashCode(); // } // // @Override // public String toString() { // return name(); // } // } // // Path: src/main/java/types/Type.java // public abstract class Type extends Substitutable<Type> implements Unifyable{ // // @Override // public Type identity() { // return this; // } // // @Override // public final Substitution unifyWith(Type type) { // if(this.equals(type)) return new Substitution(); // if(type instanceof TVariable) return unifyWith((TVariable) type); // if(type instanceof TFunction) return unifyWith((TFunction) type); // if(type instanceof TConstructor) return unifyWith((TConstructor) type); // throw new UnificationFailException(this, type); // } // // protected Substitution unifyWith(TVariable var) { // return bind(var, this); // } // // protected Substitution unifyWith(TFunction fun) { // throw new UnificationFailException(this, fun); // } // // protected Substitution unifyWith(TConstructor cons) { // throw new UnificationFailException(this, cons); // } // // public abstract Type instantiate(Substitution sub); // } // Path: src/test/java/ast/ApplicationTest.java import org.junit.Test; import types.TVariable; import types.Type; import static org.junit.Assert.*; package ast; /** * Created by maeln on 20/10/16. */ public class ApplicationTest { @Test public void infer() throws Exception { Variable x = new Variable("x"); Expression exp = new Application(new Lambda(x,x), new Lambda(x,x)); Type t = exp.infer();
assertTrue("Should return a TVariable", t instanceof TVariable);
maeln/LambdaHindleyMilner
src/main/java/types/TFunction.java
// Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // }
import inference.Substitution; import java.util.HashMap; import java.util.HashSet;
return result; } // Substitutable - Begin @Override public Type substitute(TVariable var, Type type) { TFunction result; String before = this.toString(); //* left = left.substitute(var, type); right = right.substitute(var, type); result = this; /*/ result = function(left.substitute(var, type), right.substitute(var, type)); //*/ System.out.println(var + " => " + type + " \n\t" + before + " => " + result + "\n"); return result; } @Override public HashSet<TVariable> ftv() { HashSet<TVariable> set = new HashSet<>(left.ftv()); set.addAll(right.ftv()); return set; } //Substitutable - End @Override
// Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // } // Path: src/main/java/types/TFunction.java import inference.Substitution; import java.util.HashMap; import java.util.HashSet; return result; } // Substitutable - Begin @Override public Type substitute(TVariable var, Type type) { TFunction result; String before = this.toString(); //* left = left.substitute(var, type); right = right.substitute(var, type); result = this; /*/ result = function(left.substitute(var, type), right.substitute(var, type)); //*/ System.out.println(var + " => " + type + " \n\t" + before + " => " + result + "\n"); return result; } @Override public HashSet<TVariable> ftv() { HashSet<TVariable> set = new HashSet<>(left.ftv()); set.addAll(right.ftv()); return set; } //Substitutable - End @Override
protected Substitution unifyWith(TFunction fun) {
maeln/LambdaHindleyMilner
src/main/java/app/Main.java
// Path: src/main/java/ast/lit/Bool.java // public class Bool extends Literal<Boolean> { // // public Bool(Boolean value) { // super(value, constructor("Bool")); // } // } // // Path: src/main/java/ast/lit/Int.java // public class Int extends Literal<Integer> { // // public Int(Integer value) { // super(value, constructor("Int")); // } // } // // Path: src/main/java/app/InferenceApp.java // static void infer(Expression exp) { // try { // Type t = exp.infer(); // System.out.println(exp + " :: " + t); // } // catch (InfiniteTypeException | UnboundVariableException | UnificationFailException e) { // System.out.println("Type error in " + exp + " : " + e.getMessage()); // } // }
import ast.*; import ast.lit.Bool; import ast.lit.Int; import org.fusesource.jansi.AnsiConsole; import static app.InferenceApp.infer;
package app; public class Main { public static void main(String[] args) { AnsiConsole.systemInstall(); // Display a lambda expression. //* Expression root = new Let("x", new Lambda(new Variable("x"), new Variable("x")), new Application( new Variable("x"), new Lambda("y", new Lambda("z", new Lambda("w", new Application( new Variable("y"), new Application( new Lambda("a", new Application(new Variable("w"), new Variable("a"))), new Application(new Variable("z"), new Variable("w")) ) )))) ) ); /*/ Expression root = new Application( new Lambda("x", new Application( new Variable("x"), new Lambda("y", new Lambda("z", new Lambda("w", new Application( new Variable("y"), new Application( new Lambda("a", new Application(new Variable("w"), new Variable("a"))), new Application(new Variable("z"), new Variable("w")) ) )))) )), new Lambda("x", new Variable("x")) ); //*/ // (let f = \x -> x in ((\x -> \y -> y (f (3::Int))) (f True)))
// Path: src/main/java/ast/lit/Bool.java // public class Bool extends Literal<Boolean> { // // public Bool(Boolean value) { // super(value, constructor("Bool")); // } // } // // Path: src/main/java/ast/lit/Int.java // public class Int extends Literal<Integer> { // // public Int(Integer value) { // super(value, constructor("Int")); // } // } // // Path: src/main/java/app/InferenceApp.java // static void infer(Expression exp) { // try { // Type t = exp.infer(); // System.out.println(exp + " :: " + t); // } // catch (InfiniteTypeException | UnboundVariableException | UnificationFailException e) { // System.out.println("Type error in " + exp + " : " + e.getMessage()); // } // } // Path: src/main/java/app/Main.java import ast.*; import ast.lit.Bool; import ast.lit.Int; import org.fusesource.jansi.AnsiConsole; import static app.InferenceApp.infer; package app; public class Main { public static void main(String[] args) { AnsiConsole.systemInstall(); // Display a lambda expression. //* Expression root = new Let("x", new Lambda(new Variable("x"), new Variable("x")), new Application( new Variable("x"), new Lambda("y", new Lambda("z", new Lambda("w", new Application( new Variable("y"), new Application( new Lambda("a", new Application(new Variable("w"), new Variable("a"))), new Application(new Variable("z"), new Variable("w")) ) )))) ) ); /*/ Expression root = new Application( new Lambda("x", new Application( new Variable("x"), new Lambda("y", new Lambda("z", new Lambda("w", new Application( new Variable("y"), new Application( new Lambda("a", new Application(new Variable("w"), new Variable("a"))), new Application(new Variable("z"), new Variable("w")) ) )))) )), new Lambda("x", new Variable("x")) ); //*/ // (let f = \x -> x in ((\x -> \y -> y (f (3::Int))) (f True)))
Expression remi1 = new Bool(true);
maeln/LambdaHindleyMilner
src/main/java/app/Main.java
// Path: src/main/java/ast/lit/Bool.java // public class Bool extends Literal<Boolean> { // // public Bool(Boolean value) { // super(value, constructor("Bool")); // } // } // // Path: src/main/java/ast/lit/Int.java // public class Int extends Literal<Integer> { // // public Int(Integer value) { // super(value, constructor("Int")); // } // } // // Path: src/main/java/app/InferenceApp.java // static void infer(Expression exp) { // try { // Type t = exp.infer(); // System.out.println(exp + " :: " + t); // } // catch (InfiniteTypeException | UnboundVariableException | UnificationFailException e) { // System.out.println("Type error in " + exp + " : " + e.getMessage()); // } // }
import ast.*; import ast.lit.Bool; import ast.lit.Int; import org.fusesource.jansi.AnsiConsole; import static app.InferenceApp.infer;
package app; public class Main { public static void main(String[] args) { AnsiConsole.systemInstall(); // Display a lambda expression. //* Expression root = new Let("x", new Lambda(new Variable("x"), new Variable("x")), new Application( new Variable("x"), new Lambda("y", new Lambda("z", new Lambda("w", new Application( new Variable("y"), new Application( new Lambda("a", new Application(new Variable("w"), new Variable("a"))), new Application(new Variable("z"), new Variable("w")) ) )))) ) ); /*/ Expression root = new Application( new Lambda("x", new Application( new Variable("x"), new Lambda("y", new Lambda("z", new Lambda("w", new Application( new Variable("y"), new Application( new Lambda("a", new Application(new Variable("w"), new Variable("a"))), new Application(new Variable("z"), new Variable("w")) ) )))) )), new Lambda("x", new Variable("x")) ); //*/ // (let f = \x -> x in ((\x -> \y -> y (f (3::Int))) (f True))) Expression remi1 = new Bool(true); Expression remi2 = new Let("f",new Lambda("x", new Variable("x")),new Application(new Variable("f"),remi1));
// Path: src/main/java/ast/lit/Bool.java // public class Bool extends Literal<Boolean> { // // public Bool(Boolean value) { // super(value, constructor("Bool")); // } // } // // Path: src/main/java/ast/lit/Int.java // public class Int extends Literal<Integer> { // // public Int(Integer value) { // super(value, constructor("Int")); // } // } // // Path: src/main/java/app/InferenceApp.java // static void infer(Expression exp) { // try { // Type t = exp.infer(); // System.out.println(exp + " :: " + t); // } // catch (InfiniteTypeException | UnboundVariableException | UnificationFailException e) { // System.out.println("Type error in " + exp + " : " + e.getMessage()); // } // } // Path: src/main/java/app/Main.java import ast.*; import ast.lit.Bool; import ast.lit.Int; import org.fusesource.jansi.AnsiConsole; import static app.InferenceApp.infer; package app; public class Main { public static void main(String[] args) { AnsiConsole.systemInstall(); // Display a lambda expression. //* Expression root = new Let("x", new Lambda(new Variable("x"), new Variable("x")), new Application( new Variable("x"), new Lambda("y", new Lambda("z", new Lambda("w", new Application( new Variable("y"), new Application( new Lambda("a", new Application(new Variable("w"), new Variable("a"))), new Application(new Variable("z"), new Variable("w")) ) )))) ) ); /*/ Expression root = new Application( new Lambda("x", new Application( new Variable("x"), new Lambda("y", new Lambda("z", new Lambda("w", new Application( new Variable("y"), new Application( new Lambda("a", new Application(new Variable("w"), new Variable("a"))), new Application(new Variable("z"), new Variable("w")) ) )))) )), new Lambda("x", new Variable("x")) ); //*/ // (let f = \x -> x in ((\x -> \y -> y (f (3::Int))) (f True))) Expression remi1 = new Bool(true); Expression remi2 = new Let("f",new Lambda("x", new Variable("x")),new Application(new Variable("f"),remi1));
Expression remi3 = new Let("f",new Lambda("x", new Variable("x")),new Application(new Lambda("x", new Lambda("y",new Application(new Variable("y"),new Application(new Variable("f"),new Int(3)))))
maeln/LambdaHindleyMilner
src/main/java/app/Main.java
// Path: src/main/java/ast/lit/Bool.java // public class Bool extends Literal<Boolean> { // // public Bool(Boolean value) { // super(value, constructor("Bool")); // } // } // // Path: src/main/java/ast/lit/Int.java // public class Int extends Literal<Integer> { // // public Int(Integer value) { // super(value, constructor("Int")); // } // } // // Path: src/main/java/app/InferenceApp.java // static void infer(Expression exp) { // try { // Type t = exp.infer(); // System.out.println(exp + " :: " + t); // } // catch (InfiniteTypeException | UnboundVariableException | UnificationFailException e) { // System.out.println("Type error in " + exp + " : " + e.getMessage()); // } // }
import ast.*; import ast.lit.Bool; import ast.lit.Int; import org.fusesource.jansi.AnsiConsole; import static app.InferenceApp.infer;
package app; public class Main { public static void main(String[] args) { AnsiConsole.systemInstall(); // Display a lambda expression. //* Expression root = new Let("x", new Lambda(new Variable("x"), new Variable("x")), new Application( new Variable("x"), new Lambda("y", new Lambda("z", new Lambda("w", new Application( new Variable("y"), new Application( new Lambda("a", new Application(new Variable("w"), new Variable("a"))), new Application(new Variable("z"), new Variable("w")) ) )))) ) ); /*/ Expression root = new Application( new Lambda("x", new Application( new Variable("x"), new Lambda("y", new Lambda("z", new Lambda("w", new Application( new Variable("y"), new Application( new Lambda("a", new Application(new Variable("w"), new Variable("a"))), new Application(new Variable("z"), new Variable("w")) ) )))) )), new Lambda("x", new Variable("x")) ); //*/ // (let f = \x -> x in ((\x -> \y -> y (f (3::Int))) (f True))) Expression remi1 = new Bool(true); Expression remi2 = new Let("f",new Lambda("x", new Variable("x")),new Application(new Variable("f"),remi1)); Expression remi3 = new Let("f",new Lambda("x", new Variable("x")),new Application(new Lambda("x", new Lambda("y",new Application(new Variable("y"),new Application(new Variable("f"),new Int(3))))) ,new Application(new Variable("f"),new Bool(true)))); // (\f -> \x -> x in ((\x -> \y -> y (f (3::Int))) (f True))) (\z->z) Expression remi4 = new Application(new Lambda("f",new Application(new Lambda("x", new Lambda("y",new Application(new Variable("y"),new Application(new Variable("f"),new Int(3))))) ,new Application(new Variable("f"),new Bool(true)))),new Lambda("x", new Variable("x")));
// Path: src/main/java/ast/lit/Bool.java // public class Bool extends Literal<Boolean> { // // public Bool(Boolean value) { // super(value, constructor("Bool")); // } // } // // Path: src/main/java/ast/lit/Int.java // public class Int extends Literal<Integer> { // // public Int(Integer value) { // super(value, constructor("Int")); // } // } // // Path: src/main/java/app/InferenceApp.java // static void infer(Expression exp) { // try { // Type t = exp.infer(); // System.out.println(exp + " :: " + t); // } // catch (InfiniteTypeException | UnboundVariableException | UnificationFailException e) { // System.out.println("Type error in " + exp + " : " + e.getMessage()); // } // } // Path: src/main/java/app/Main.java import ast.*; import ast.lit.Bool; import ast.lit.Int; import org.fusesource.jansi.AnsiConsole; import static app.InferenceApp.infer; package app; public class Main { public static void main(String[] args) { AnsiConsole.systemInstall(); // Display a lambda expression. //* Expression root = new Let("x", new Lambda(new Variable("x"), new Variable("x")), new Application( new Variable("x"), new Lambda("y", new Lambda("z", new Lambda("w", new Application( new Variable("y"), new Application( new Lambda("a", new Application(new Variable("w"), new Variable("a"))), new Application(new Variable("z"), new Variable("w")) ) )))) ) ); /*/ Expression root = new Application( new Lambda("x", new Application( new Variable("x"), new Lambda("y", new Lambda("z", new Lambda("w", new Application( new Variable("y"), new Application( new Lambda("a", new Application(new Variable("w"), new Variable("a"))), new Application(new Variable("z"), new Variable("w")) ) )))) )), new Lambda("x", new Variable("x")) ); //*/ // (let f = \x -> x in ((\x -> \y -> y (f (3::Int))) (f True))) Expression remi1 = new Bool(true); Expression remi2 = new Let("f",new Lambda("x", new Variable("x")),new Application(new Variable("f"),remi1)); Expression remi3 = new Let("f",new Lambda("x", new Variable("x")),new Application(new Lambda("x", new Lambda("y",new Application(new Variable("y"),new Application(new Variable("f"),new Int(3))))) ,new Application(new Variable("f"),new Bool(true)))); // (\f -> \x -> x in ((\x -> \y -> y (f (3::Int))) (f True))) (\z->z) Expression remi4 = new Application(new Lambda("f",new Application(new Lambda("x", new Lambda("y",new Application(new Variable("y"),new Application(new Variable("f"),new Int(3))))) ,new Application(new Variable("f"),new Bool(true)))),new Lambda("x", new Variable("x")));
infer(remi3);
maeln/LambdaHindleyMilner
src/test/java/types/TFunctionTest.java
// Path: src/main/java/ast/Variable.java // public class Variable extends Expression { // private String name; // // public Variable(String name) { // this.name = name; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // // @Override // public Type infer(TypeInferenceEnv env) { // return env.lookup(this).instantiate(env); // } // // // //Object override // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Variable variable = (Variable) o; // // return name != null ? name.equals(variable.name) : variable.name == null; // // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // // @Override // public String toString() { // return name; // } // } // // Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // } // // Path: src/main/java/types/TFunction.java // public static TFunction function(Type left, Type right) { // int hash = hash(left, right); // TFunction f = instantiated.get(hash); // if(f == null) { // f = new TFunction(left, right); // instantiated.put(hash, f); // } // return f; // } // // Path: src/main/java/types/TVariable.java // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // Path: src/main/java/types/TVariable.java // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // }
import ast.Variable; import inference.Substitution; import org.junit.Before; import org.junit.Test; import java.util.*; import static org.junit.Assert.*; import static types.TFunction.function; import static types.TVariable.variable; import static types.TVariable.variables;
package types; /** * Created by valentin on 20/10/2016. */ public class TFunctionTest { private static final String name = "TEST"; @Test public void createFunction() throws Exception {
// Path: src/main/java/ast/Variable.java // public class Variable extends Expression { // private String name; // // public Variable(String name) { // this.name = name; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // // @Override // public Type infer(TypeInferenceEnv env) { // return env.lookup(this).instantiate(env); // } // // // //Object override // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Variable variable = (Variable) o; // // return name != null ? name.equals(variable.name) : variable.name == null; // // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // // @Override // public String toString() { // return name; // } // } // // Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // } // // Path: src/main/java/types/TFunction.java // public static TFunction function(Type left, Type right) { // int hash = hash(left, right); // TFunction f = instantiated.get(hash); // if(f == null) { // f = new TFunction(left, right); // instantiated.put(hash, f); // } // return f; // } // // Path: src/main/java/types/TVariable.java // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // Path: src/main/java/types/TVariable.java // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // Path: src/test/java/types/TFunctionTest.java import ast.Variable; import inference.Substitution; import org.junit.Before; import org.junit.Test; import java.util.*; import static org.junit.Assert.*; import static types.TFunction.function; import static types.TVariable.variable; import static types.TVariable.variables; package types; /** * Created by valentin on 20/10/2016. */ public class TFunctionTest { private static final String name = "TEST"; @Test public void createFunction() throws Exception {
Type left = variable(name);
maeln/LambdaHindleyMilner
src/test/java/types/TFunctionTest.java
// Path: src/main/java/ast/Variable.java // public class Variable extends Expression { // private String name; // // public Variable(String name) { // this.name = name; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // // @Override // public Type infer(TypeInferenceEnv env) { // return env.lookup(this).instantiate(env); // } // // // //Object override // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Variable variable = (Variable) o; // // return name != null ? name.equals(variable.name) : variable.name == null; // // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // // @Override // public String toString() { // return name; // } // } // // Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // } // // Path: src/main/java/types/TFunction.java // public static TFunction function(Type left, Type right) { // int hash = hash(left, right); // TFunction f = instantiated.get(hash); // if(f == null) { // f = new TFunction(left, right); // instantiated.put(hash, f); // } // return f; // } // // Path: src/main/java/types/TVariable.java // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // Path: src/main/java/types/TVariable.java // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // }
import ast.Variable; import inference.Substitution; import org.junit.Before; import org.junit.Test; import java.util.*; import static org.junit.Assert.*; import static types.TFunction.function; import static types.TVariable.variable; import static types.TVariable.variables;
package types; /** * Created by valentin on 20/10/2016. */ public class TFunctionTest { private static final String name = "TEST"; @Test public void createFunction() throws Exception { Type left = variable(name); Type right = variable(name);
// Path: src/main/java/ast/Variable.java // public class Variable extends Expression { // private String name; // // public Variable(String name) { // this.name = name; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // // @Override // public Type infer(TypeInferenceEnv env) { // return env.lookup(this).instantiate(env); // } // // // //Object override // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Variable variable = (Variable) o; // // return name != null ? name.equals(variable.name) : variable.name == null; // // } // // @Override // public int hashCode() { // return name != null ? name.hashCode() : 0; // } // // @Override // public String toString() { // return name; // } // } // // Path: src/main/java/inference/Substitution.java // public class Substitution extends Substitutable<Substitution> { // private HashMap<TVariable, Type> subs = new HashMap<>(); // // public Substitution() {} // // public Substitution(TVariable variable, Type type) { // subs.put(variable, type); // } // // private Substitution(Substitution previous) { // subs.putAll(previous.subs); // } // // public Substitution(List<TVariable> vars, List<Type> substitute) { // if(vars.size() != substitute.size()) // throw new IllegalArgumentException("Number of variables have to match number of types"); // // for (int i = 0; i < vars.size(); i++) subs.put(vars.get(i), substitute.get(i)); // } // // public List<TVariable> variables() { // return new LinkedList<>(subs.keySet()); // } // // public Type substituteOf(TVariable var) { // return subs.get(var); // } // // public Substitution composeWith(Substitution sub) { // Substitution substituted = new Substitution(sub); // substituted.apply(this); // subs.putAll(substituted.subs); // return this; // } // // @Override // public HashSet<TVariable> ftv() { // HashSet<TVariable> freeVars = new HashSet<>(); // for (TVariable var : variables()) freeVars.addAll(substituteOf(var).ftv()); // return freeVars; // } // // @Override // public Substitution substitute(TVariable var, Type t) { // for (TVariable variable : variables()) // subs.replace(variable, substituteOf(variable).substitute(var, t)); // return this; // } // // @Override // public String toString() { // return subs.toString(); // } // // @Override // public Substitution identity() { // return this; // } // } // // Path: src/main/java/types/TFunction.java // public static TFunction function(Type left, Type right) { // int hash = hash(left, right); // TFunction f = instantiated.get(hash); // if(f == null) { // f = new TFunction(left, right); // instantiated.put(hash, f); // } // return f; // } // // Path: src/main/java/types/TVariable.java // public static TVariable variable(String name) { // TVariable var = new TVariable(name); // if(!instantiated.add(var)) System.out.println("Creation avoidable : TVariable(" + name + ")"); // return var; // } // // Path: src/main/java/types/TVariable.java // public static List<TVariable> variables(String... names) { // List<TVariable> variables = new LinkedList<>(); // for (String name : names) variables.add(new TVariable(name)); // return variables; // } // Path: src/test/java/types/TFunctionTest.java import ast.Variable; import inference.Substitution; import org.junit.Before; import org.junit.Test; import java.util.*; import static org.junit.Assert.*; import static types.TFunction.function; import static types.TVariable.variable; import static types.TVariable.variables; package types; /** * Created by valentin on 20/10/2016. */ public class TFunctionTest { private static final String name = "TEST"; @Test public void createFunction() throws Exception { Type left = variable(name); Type right = variable(name);
TFunction fun = function(left, right);