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 |
|---|---|---|---|---|---|---|
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/fragment/MoviesFragment.java
// public class MoviesFragment extends Fragment implements MoviesPresenter.MoviesView {
//
// @Inject
// MoviesPresenter moviesPresenter;
//
// private MoviesAdapter adapter;
// private RecyclerView recyclerView;
// private View rootView;
// private TextView moviesCountTextView;
// private ImageButton refreshButton;
//
// private ProgressBar progressBarLoading;
//
// @Override
// public void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// ((MoviesApplication) getActivity().getApplication()).getAppComponent().activityComponent
// ().activityModule(
// new ActivityModule(getActivity())).build().inject(this);
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Bundle savedInstanceState) {
// rootView = inflater.inflate(R.layout.fragment_movies, container, false);
//
// progressBarLoading = (ProgressBar) getActivity().findViewById(R.id.pb_loading);
//
// initializeTitle();
// initializeRefreshButton();
// initializeAdapter();
// initializeRecyclerView();
//
// initializePresenter();
//
// return rootView;
// }
//
// private void initializePresenter() {
// moviesPresenter.attachView(this);
// }
//
// private void initializeTitle() {
// moviesCountTextView = (TextView) rootView.findViewById(
// R.id.movies_title_text_view);
// }
//
// private void initializeRefreshButton() {
// refreshButton = (ImageButton) rootView.findViewById(
// R.id.refresh_button);
//
// refreshButton.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// moviesPresenter.onRefreshAction();
// }
// });
// }
//
// private void initializeAdapter() {
// adapter = new MoviesAdapter();
//
// adapter.setOnMovieClickListener(new MoviesAdapter.OnMovieClickListener() {
// @Override
// public void onItemClick(View view, Movie movie) {
// moviesPresenter.onMovieClicked(movie);
// }
// });
// }
//
// private void initializeRecyclerView() {
// recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview_movies);
// recyclerView.setAdapter(adapter);
// }
//
// private void refreshTitleWithMoviesCount(int count) {
// String countText = getString(R.string.movies_count_text);
//
// moviesCountTextView.setText(String.format(countText, count));
// }
//
// @Override
// public void showMovies(List<Movie> movies) {
// adapter.setMovies(movies);
// }
//
// @Override
// public void hideLoading() {
// progressBarLoading.setVisibility(View.GONE);
// }
//
// @Override
// public void showLoading() {
// adapter.clearMovies();
// progressBarLoading.setVisibility(View.VISIBLE);
// moviesCountTextView.setText(R.string.loading_movies_text);
// }
//
// @Override
// public void showTotalMovies(int count) {
// refreshTitleWithMoviesCount(count);
// }
//
// @Override
// public void showConnectionError() {
// Toast.makeText(getActivity(), R.string.connection_error_text, Toast.LENGTH_SHORT).show();
// }
//
// @Override
// public boolean isReady() {
// return isAdded();
// }
// }
| import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.presentation.view.fragment.MoviesFragment; | package com.xurxodev.moviesandroidkata.presentation.view.activity;
public class MoviesActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_movies);
initializeToolBar();
if (savedInstanceState == null) {
showDetailFragment();
}
}
private void showDetailFragment() { | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/fragment/MoviesFragment.java
// public class MoviesFragment extends Fragment implements MoviesPresenter.MoviesView {
//
// @Inject
// MoviesPresenter moviesPresenter;
//
// private MoviesAdapter adapter;
// private RecyclerView recyclerView;
// private View rootView;
// private TextView moviesCountTextView;
// private ImageButton refreshButton;
//
// private ProgressBar progressBarLoading;
//
// @Override
// public void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// ((MoviesApplication) getActivity().getApplication()).getAppComponent().activityComponent
// ().activityModule(
// new ActivityModule(getActivity())).build().inject(this);
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Bundle savedInstanceState) {
// rootView = inflater.inflate(R.layout.fragment_movies, container, false);
//
// progressBarLoading = (ProgressBar) getActivity().findViewById(R.id.pb_loading);
//
// initializeTitle();
// initializeRefreshButton();
// initializeAdapter();
// initializeRecyclerView();
//
// initializePresenter();
//
// return rootView;
// }
//
// private void initializePresenter() {
// moviesPresenter.attachView(this);
// }
//
// private void initializeTitle() {
// moviesCountTextView = (TextView) rootView.findViewById(
// R.id.movies_title_text_view);
// }
//
// private void initializeRefreshButton() {
// refreshButton = (ImageButton) rootView.findViewById(
// R.id.refresh_button);
//
// refreshButton.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// moviesPresenter.onRefreshAction();
// }
// });
// }
//
// private void initializeAdapter() {
// adapter = new MoviesAdapter();
//
// adapter.setOnMovieClickListener(new MoviesAdapter.OnMovieClickListener() {
// @Override
// public void onItemClick(View view, Movie movie) {
// moviesPresenter.onMovieClicked(movie);
// }
// });
// }
//
// private void initializeRecyclerView() {
// recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview_movies);
// recyclerView.setAdapter(adapter);
// }
//
// private void refreshTitleWithMoviesCount(int count) {
// String countText = getString(R.string.movies_count_text);
//
// moviesCountTextView.setText(String.format(countText, count));
// }
//
// @Override
// public void showMovies(List<Movie> movies) {
// adapter.setMovies(movies);
// }
//
// @Override
// public void hideLoading() {
// progressBarLoading.setVisibility(View.GONE);
// }
//
// @Override
// public void showLoading() {
// adapter.clearMovies();
// progressBarLoading.setVisibility(View.VISIBLE);
// moviesCountTextView.setText(R.string.loading_movies_text);
// }
//
// @Override
// public void showTotalMovies(int count) {
// refreshTitleWithMoviesCount(count);
// }
//
// @Override
// public void showConnectionError() {
// Toast.makeText(getActivity(), R.string.connection_error_text, Toast.LENGTH_SHORT).show();
// }
//
// @Override
// public boolean isReady() {
// return isAdded();
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.presentation.view.fragment.MoviesFragment;
package com.xurxodev.moviesandroidkata.presentation.view.activity;
public class MoviesActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_movies);
initializeToolBar();
if (savedInstanceState == null) {
showDetailFragment();
}
}
private void showDetailFragment() { | MoviesFragment fragment = new MoviesFragment(); |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMovieDetailUseCase.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
| import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import com.xurxodev.moviesandroidkata.domain.entity.Movie; | package com.xurxodev.moviesandroidkata.domain.usecase;
public class GetMovieDetailUseCase implements UseCase {
public interface Callback { | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMovieDetailUseCase.java
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
package com.xurxodev.moviesandroidkata.domain.usecase;
public class GetMovieDetailUseCase implements UseCase {
public interface Callback { | void onCompetitorDetailLoaded(final Movie competitor); |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMovieDetailUseCase.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
| import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import com.xurxodev.moviesandroidkata.domain.entity.Movie; | package com.xurxodev.moviesandroidkata.domain.usecase;
public class GetMovieDetailUseCase implements UseCase {
public interface Callback {
void onCompetitorDetailLoaded(final Movie competitor);
void onCompetitorDetailNotFound();
void onConnectionError();
}
| // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMovieDetailUseCase.java
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
package com.xurxodev.moviesandroidkata.domain.usecase;
public class GetMovieDetailUseCase implements UseCase {
public interface Callback {
void onCompetitorDetailLoaded(final Movie competitor);
void onCompetitorDetailNotFound();
void onConnectionError();
}
| private MovieRepository competitorRepository; |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMovieDetailUseCase.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
| import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import com.xurxodev.moviesandroidkata.domain.entity.Movie; | package com.xurxodev.moviesandroidkata.domain.usecase;
public class GetMovieDetailUseCase implements UseCase {
public interface Callback {
void onCompetitorDetailLoaded(final Movie competitor);
void onCompetitorDetailNotFound();
void onConnectionError();
}
private MovieRepository competitorRepository; | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMovieDetailUseCase.java
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
package com.xurxodev.moviesandroidkata.domain.usecase;
public class GetMovieDetailUseCase implements UseCase {
public interface Callback {
void onCompetitorDetailLoaded(final Movie competitor);
void onCompetitorDetailNotFound();
void onConnectionError();
}
private MovieRepository competitorRepository; | private AsyncExecutor asyncExecutor; |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMovieDetailUseCase.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
| import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import com.xurxodev.moviesandroidkata.domain.entity.Movie; | package com.xurxodev.moviesandroidkata.domain.usecase;
public class GetMovieDetailUseCase implements UseCase {
public interface Callback {
void onCompetitorDetailLoaded(final Movie competitor);
void onCompetitorDetailNotFound();
void onConnectionError();
}
private MovieRepository competitorRepository;
private AsyncExecutor asyncExecutor; | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMovieDetailUseCase.java
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
package com.xurxodev.moviesandroidkata.domain.usecase;
public class GetMovieDetailUseCase implements UseCase {
public interface Callback {
void onCompetitorDetailLoaded(final Movie competitor);
void onCompetitorDetailNotFound();
void onConnectionError();
}
private MovieRepository competitorRepository;
private AsyncExecutor asyncExecutor; | private MainExecutor mainExecutor; |
xurxodev/Movies-Android-Kata | app/src/androidTest/java/com/xurxodev/moviesandroidkata/test/MovieDetailTitleFeature.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
// public class MoviesRobot {
// private MoviesActivity activity;
// RecyclerView recyclerView;
// ProgressbarIdlingResource progressbarIdlingResource;
//
// public MoviesRobot(MoviesActivity activity) {
// this.activity = activity;
// this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
// this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
//
// removeAnimateDrawableFromProgressForTest();
// }
//
// public int getNumMoviesRows() {
// return recyclerView.getAdapter().getItemCount();
// }
//
// public MoviesRobot waitForMovies() {
// Espresso.registerIdlingResources(progressbarIdlingResource);
//
// onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
//
// Espresso.unregisterIdlingResources(progressbarIdlingResource);
//
// return this;
// }
//
// public String getMovieTitle(int i) {
// return ((MoviesAdapter) recyclerView.getAdapter()).movies.get(i).getTitle();
// }
//
// public MovieDetailRobot navigateToMovie(int position) {
// onView(withId(R.id.recyclerview_movies))
// .perform(RecyclerViewActions.actionOnItemAtPosition(position, click()));
//
// return new MovieDetailRobot(this);
// }
//
// public MoviesRobot verifyTextWithMoviesCount(int numMovies) {
// String formatCountText = activity.getString(R.string.movies_count_text);
// String expectedText = String.format(formatCountText, numMovies);
//
// onView(withId(R.id.movies_title_text_view)).check(matches(withText(expectedText)));
//
// return this;
// }
//
// public MoviesRobot refreshMovies() {
// onView(withId(R.id.refresh_button)).perform(click());
// return this;
// }
//
// public MoviesRobot verifyLoadingText() {
// String text = activity.getString(R.string.loading_movies_text);
//
// onView(withId(R.id.movies_title_text_view)).check(
// matches(withText(text)));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsVisible() {
// onView(withId(R.id.pb_loading)).check(
// matches(isDisplayed()));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsHide() {
// onView(withId(R.id.pb_loading)).check(
// matches(not(isDisplayed())));
//
// return this;
// }
//
// private void removeAnimateDrawableFromProgressForTest() {
// Drawable notAnimatedDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_refresh);
// ((ProgressBar) activity.findViewById(R.id.pb_loading)).setIndeterminateDrawable(
// notAnimatedDrawable);
//
// }
// }
| import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.robot.MoviesRobot;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith; | package com.xurxodev.moviesandroidkata.test;
@RunWith(AndroidJUnit4.class)
public class MovieDetailTitleFeature {
@Rule | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
// public class MoviesRobot {
// private MoviesActivity activity;
// RecyclerView recyclerView;
// ProgressbarIdlingResource progressbarIdlingResource;
//
// public MoviesRobot(MoviesActivity activity) {
// this.activity = activity;
// this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
// this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
//
// removeAnimateDrawableFromProgressForTest();
// }
//
// public int getNumMoviesRows() {
// return recyclerView.getAdapter().getItemCount();
// }
//
// public MoviesRobot waitForMovies() {
// Espresso.registerIdlingResources(progressbarIdlingResource);
//
// onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
//
// Espresso.unregisterIdlingResources(progressbarIdlingResource);
//
// return this;
// }
//
// public String getMovieTitle(int i) {
// return ((MoviesAdapter) recyclerView.getAdapter()).movies.get(i).getTitle();
// }
//
// public MovieDetailRobot navigateToMovie(int position) {
// onView(withId(R.id.recyclerview_movies))
// .perform(RecyclerViewActions.actionOnItemAtPosition(position, click()));
//
// return new MovieDetailRobot(this);
// }
//
// public MoviesRobot verifyTextWithMoviesCount(int numMovies) {
// String formatCountText = activity.getString(R.string.movies_count_text);
// String expectedText = String.format(formatCountText, numMovies);
//
// onView(withId(R.id.movies_title_text_view)).check(matches(withText(expectedText)));
//
// return this;
// }
//
// public MoviesRobot refreshMovies() {
// onView(withId(R.id.refresh_button)).perform(click());
// return this;
// }
//
// public MoviesRobot verifyLoadingText() {
// String text = activity.getString(R.string.loading_movies_text);
//
// onView(withId(R.id.movies_title_text_view)).check(
// matches(withText(text)));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsVisible() {
// onView(withId(R.id.pb_loading)).check(
// matches(isDisplayed()));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsHide() {
// onView(withId(R.id.pb_loading)).check(
// matches(not(isDisplayed())));
//
// return this;
// }
//
// private void removeAnimateDrawableFromProgressForTest() {
// Drawable notAnimatedDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_refresh);
// ((ProgressBar) activity.findViewById(R.id.pb_loading)).setIndeterminateDrawable(
// notAnimatedDrawable);
//
// }
// }
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/test/MovieDetailTitleFeature.java
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.robot.MoviesRobot;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
package com.xurxodev.moviesandroidkata.test;
@RunWith(AndroidJUnit4.class)
public class MovieDetailTitleFeature {
@Rule | public ActivityTestRule<MoviesActivity> activityTestRule = |
xurxodev/Movies-Android-Kata | app/src/androidTest/java/com/xurxodev/moviesandroidkata/test/MovieDetailTitleFeature.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
// public class MoviesRobot {
// private MoviesActivity activity;
// RecyclerView recyclerView;
// ProgressbarIdlingResource progressbarIdlingResource;
//
// public MoviesRobot(MoviesActivity activity) {
// this.activity = activity;
// this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
// this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
//
// removeAnimateDrawableFromProgressForTest();
// }
//
// public int getNumMoviesRows() {
// return recyclerView.getAdapter().getItemCount();
// }
//
// public MoviesRobot waitForMovies() {
// Espresso.registerIdlingResources(progressbarIdlingResource);
//
// onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
//
// Espresso.unregisterIdlingResources(progressbarIdlingResource);
//
// return this;
// }
//
// public String getMovieTitle(int i) {
// return ((MoviesAdapter) recyclerView.getAdapter()).movies.get(i).getTitle();
// }
//
// public MovieDetailRobot navigateToMovie(int position) {
// onView(withId(R.id.recyclerview_movies))
// .perform(RecyclerViewActions.actionOnItemAtPosition(position, click()));
//
// return new MovieDetailRobot(this);
// }
//
// public MoviesRobot verifyTextWithMoviesCount(int numMovies) {
// String formatCountText = activity.getString(R.string.movies_count_text);
// String expectedText = String.format(formatCountText, numMovies);
//
// onView(withId(R.id.movies_title_text_view)).check(matches(withText(expectedText)));
//
// return this;
// }
//
// public MoviesRobot refreshMovies() {
// onView(withId(R.id.refresh_button)).perform(click());
// return this;
// }
//
// public MoviesRobot verifyLoadingText() {
// String text = activity.getString(R.string.loading_movies_text);
//
// onView(withId(R.id.movies_title_text_view)).check(
// matches(withText(text)));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsVisible() {
// onView(withId(R.id.pb_loading)).check(
// matches(isDisplayed()));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsHide() {
// onView(withId(R.id.pb_loading)).check(
// matches(not(isDisplayed())));
//
// return this;
// }
//
// private void removeAnimateDrawableFromProgressForTest() {
// Drawable notAnimatedDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_refresh);
// ((ProgressBar) activity.findViewById(R.id.pb_loading)).setIndeterminateDrawable(
// notAnimatedDrawable);
//
// }
// }
| import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.robot.MoviesRobot;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith; | package com.xurxodev.moviesandroidkata.test;
@RunWith(AndroidJUnit4.class)
public class MovieDetailTitleFeature {
@Rule
public ActivityTestRule<MoviesActivity> activityTestRule =
new ActivityTestRule<>(MoviesActivity.class);
@Test
public void show_movie_title_as_screen_title() { | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
// public class MoviesRobot {
// private MoviesActivity activity;
// RecyclerView recyclerView;
// ProgressbarIdlingResource progressbarIdlingResource;
//
// public MoviesRobot(MoviesActivity activity) {
// this.activity = activity;
// this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
// this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
//
// removeAnimateDrawableFromProgressForTest();
// }
//
// public int getNumMoviesRows() {
// return recyclerView.getAdapter().getItemCount();
// }
//
// public MoviesRobot waitForMovies() {
// Espresso.registerIdlingResources(progressbarIdlingResource);
//
// onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
//
// Espresso.unregisterIdlingResources(progressbarIdlingResource);
//
// return this;
// }
//
// public String getMovieTitle(int i) {
// return ((MoviesAdapter) recyclerView.getAdapter()).movies.get(i).getTitle();
// }
//
// public MovieDetailRobot navigateToMovie(int position) {
// onView(withId(R.id.recyclerview_movies))
// .perform(RecyclerViewActions.actionOnItemAtPosition(position, click()));
//
// return new MovieDetailRobot(this);
// }
//
// public MoviesRobot verifyTextWithMoviesCount(int numMovies) {
// String formatCountText = activity.getString(R.string.movies_count_text);
// String expectedText = String.format(formatCountText, numMovies);
//
// onView(withId(R.id.movies_title_text_view)).check(matches(withText(expectedText)));
//
// return this;
// }
//
// public MoviesRobot refreshMovies() {
// onView(withId(R.id.refresh_button)).perform(click());
// return this;
// }
//
// public MoviesRobot verifyLoadingText() {
// String text = activity.getString(R.string.loading_movies_text);
//
// onView(withId(R.id.movies_title_text_view)).check(
// matches(withText(text)));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsVisible() {
// onView(withId(R.id.pb_loading)).check(
// matches(isDisplayed()));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsHide() {
// onView(withId(R.id.pb_loading)).check(
// matches(not(isDisplayed())));
//
// return this;
// }
//
// private void removeAnimateDrawableFromProgressForTest() {
// Drawable notAnimatedDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_refresh);
// ((ProgressBar) activity.findViewById(R.id.pb_loading)).setIndeterminateDrawable(
// notAnimatedDrawable);
//
// }
// }
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/test/MovieDetailTitleFeature.java
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.robot.MoviesRobot;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
package com.xurxodev.moviesandroidkata.test;
@RunWith(AndroidJUnit4.class)
public class MovieDetailTitleFeature {
@Rule
public ActivityTestRule<MoviesActivity> activityTestRule =
new ActivityTestRule<>(MoviesActivity.class);
@Test
public void show_movie_title_as_screen_title() { | MoviesRobot moviesRobot = new MoviesRobot(activityTestRule.getActivity()); |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/di/module/AppModule.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/ThreadExecutor.java
// public class ThreadExecutor implements AsyncExecutor {
//
// private static final int CORE_POOL_SIZE = 3;
// private static final int MAX_POOL_SIZE = 5;
// private static final int KEEP_ALIVE_TIME = 120;
// private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS;
// private static final BlockingQueue<Runnable> WORK_QUEUE = new LinkedBlockingQueue<Runnable>();
//
// private ThreadPoolExecutor threadPoolExecutor;
//
// public ThreadExecutor() {
// int corePoolSize = CORE_POOL_SIZE;
// int maxPoolSize = MAX_POOL_SIZE;
// int keepAliveTime = KEEP_ALIVE_TIME;
// TimeUnit timeUnit = TIME_UNIT;
// BlockingQueue<Runnable> workQueue = WORK_QUEUE;
// threadPoolExecutor =
// new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, timeUnit, workQueue);
// }
//
// @Override
// public void run(final UseCase interactor) {
// if (interactor == null) {
// throw new IllegalArgumentException("Interactor to execute can't be null");
// }
//
// threadPoolExecutor.submit(new Runnable() {
// @Override public void run() {
// interactor.run();
// }
// });
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/UIThreadExecutor.java
// public class UIThreadExecutor implements MainExecutor {
//
// private Handler handler;
//
// @Inject
// public UIThreadExecutor() {
// this.handler = new Handler(Looper.getMainLooper());
// }
//
// public void run(Runnable runnable) {
// handler.post(runnable);
// }
// }
| import android.app.Application;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.presentation.executor.ThreadExecutor;
import com.xurxodev.moviesandroidkata.presentation.executor.UIThreadExecutor;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides; | package com.xurxodev.moviesandroidkata.di.module;
@Module
public class AppModule {
Application mApplication;
public AppModule(Application application) {
mApplication = application;
}
@Provides
@Singleton
Application providesApplication() {
return mApplication;
}
@Provides
@Singleton | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/ThreadExecutor.java
// public class ThreadExecutor implements AsyncExecutor {
//
// private static final int CORE_POOL_SIZE = 3;
// private static final int MAX_POOL_SIZE = 5;
// private static final int KEEP_ALIVE_TIME = 120;
// private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS;
// private static final BlockingQueue<Runnable> WORK_QUEUE = new LinkedBlockingQueue<Runnable>();
//
// private ThreadPoolExecutor threadPoolExecutor;
//
// public ThreadExecutor() {
// int corePoolSize = CORE_POOL_SIZE;
// int maxPoolSize = MAX_POOL_SIZE;
// int keepAliveTime = KEEP_ALIVE_TIME;
// TimeUnit timeUnit = TIME_UNIT;
// BlockingQueue<Runnable> workQueue = WORK_QUEUE;
// threadPoolExecutor =
// new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, timeUnit, workQueue);
// }
//
// @Override
// public void run(final UseCase interactor) {
// if (interactor == null) {
// throw new IllegalArgumentException("Interactor to execute can't be null");
// }
//
// threadPoolExecutor.submit(new Runnable() {
// @Override public void run() {
// interactor.run();
// }
// });
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/UIThreadExecutor.java
// public class UIThreadExecutor implements MainExecutor {
//
// private Handler handler;
//
// @Inject
// public UIThreadExecutor() {
// this.handler = new Handler(Looper.getMainLooper());
// }
//
// public void run(Runnable runnable) {
// handler.post(runnable);
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/module/AppModule.java
import android.app.Application;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.presentation.executor.ThreadExecutor;
import com.xurxodev.moviesandroidkata.presentation.executor.UIThreadExecutor;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
package com.xurxodev.moviesandroidkata.di.module;
@Module
public class AppModule {
Application mApplication;
public AppModule(Application application) {
mApplication = application;
}
@Provides
@Singleton
Application providesApplication() {
return mApplication;
}
@Provides
@Singleton | public AsyncExecutor provideAsyncExecutor() { |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/di/module/AppModule.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/ThreadExecutor.java
// public class ThreadExecutor implements AsyncExecutor {
//
// private static final int CORE_POOL_SIZE = 3;
// private static final int MAX_POOL_SIZE = 5;
// private static final int KEEP_ALIVE_TIME = 120;
// private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS;
// private static final BlockingQueue<Runnable> WORK_QUEUE = new LinkedBlockingQueue<Runnable>();
//
// private ThreadPoolExecutor threadPoolExecutor;
//
// public ThreadExecutor() {
// int corePoolSize = CORE_POOL_SIZE;
// int maxPoolSize = MAX_POOL_SIZE;
// int keepAliveTime = KEEP_ALIVE_TIME;
// TimeUnit timeUnit = TIME_UNIT;
// BlockingQueue<Runnable> workQueue = WORK_QUEUE;
// threadPoolExecutor =
// new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, timeUnit, workQueue);
// }
//
// @Override
// public void run(final UseCase interactor) {
// if (interactor == null) {
// throw new IllegalArgumentException("Interactor to execute can't be null");
// }
//
// threadPoolExecutor.submit(new Runnable() {
// @Override public void run() {
// interactor.run();
// }
// });
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/UIThreadExecutor.java
// public class UIThreadExecutor implements MainExecutor {
//
// private Handler handler;
//
// @Inject
// public UIThreadExecutor() {
// this.handler = new Handler(Looper.getMainLooper());
// }
//
// public void run(Runnable runnable) {
// handler.post(runnable);
// }
// }
| import android.app.Application;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.presentation.executor.ThreadExecutor;
import com.xurxodev.moviesandroidkata.presentation.executor.UIThreadExecutor;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides; | package com.xurxodev.moviesandroidkata.di.module;
@Module
public class AppModule {
Application mApplication;
public AppModule(Application application) {
mApplication = application;
}
@Provides
@Singleton
Application providesApplication() {
return mApplication;
}
@Provides
@Singleton
public AsyncExecutor provideAsyncExecutor() { | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/ThreadExecutor.java
// public class ThreadExecutor implements AsyncExecutor {
//
// private static final int CORE_POOL_SIZE = 3;
// private static final int MAX_POOL_SIZE = 5;
// private static final int KEEP_ALIVE_TIME = 120;
// private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS;
// private static final BlockingQueue<Runnable> WORK_QUEUE = new LinkedBlockingQueue<Runnable>();
//
// private ThreadPoolExecutor threadPoolExecutor;
//
// public ThreadExecutor() {
// int corePoolSize = CORE_POOL_SIZE;
// int maxPoolSize = MAX_POOL_SIZE;
// int keepAliveTime = KEEP_ALIVE_TIME;
// TimeUnit timeUnit = TIME_UNIT;
// BlockingQueue<Runnable> workQueue = WORK_QUEUE;
// threadPoolExecutor =
// new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, timeUnit, workQueue);
// }
//
// @Override
// public void run(final UseCase interactor) {
// if (interactor == null) {
// throw new IllegalArgumentException("Interactor to execute can't be null");
// }
//
// threadPoolExecutor.submit(new Runnable() {
// @Override public void run() {
// interactor.run();
// }
// });
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/UIThreadExecutor.java
// public class UIThreadExecutor implements MainExecutor {
//
// private Handler handler;
//
// @Inject
// public UIThreadExecutor() {
// this.handler = new Handler(Looper.getMainLooper());
// }
//
// public void run(Runnable runnable) {
// handler.post(runnable);
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/module/AppModule.java
import android.app.Application;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.presentation.executor.ThreadExecutor;
import com.xurxodev.moviesandroidkata.presentation.executor.UIThreadExecutor;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
package com.xurxodev.moviesandroidkata.di.module;
@Module
public class AppModule {
Application mApplication;
public AppModule(Application application) {
mApplication = application;
}
@Provides
@Singleton
Application providesApplication() {
return mApplication;
}
@Provides
@Singleton
public AsyncExecutor provideAsyncExecutor() { | return new ThreadExecutor(); |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/di/module/AppModule.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/ThreadExecutor.java
// public class ThreadExecutor implements AsyncExecutor {
//
// private static final int CORE_POOL_SIZE = 3;
// private static final int MAX_POOL_SIZE = 5;
// private static final int KEEP_ALIVE_TIME = 120;
// private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS;
// private static final BlockingQueue<Runnable> WORK_QUEUE = new LinkedBlockingQueue<Runnable>();
//
// private ThreadPoolExecutor threadPoolExecutor;
//
// public ThreadExecutor() {
// int corePoolSize = CORE_POOL_SIZE;
// int maxPoolSize = MAX_POOL_SIZE;
// int keepAliveTime = KEEP_ALIVE_TIME;
// TimeUnit timeUnit = TIME_UNIT;
// BlockingQueue<Runnable> workQueue = WORK_QUEUE;
// threadPoolExecutor =
// new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, timeUnit, workQueue);
// }
//
// @Override
// public void run(final UseCase interactor) {
// if (interactor == null) {
// throw new IllegalArgumentException("Interactor to execute can't be null");
// }
//
// threadPoolExecutor.submit(new Runnable() {
// @Override public void run() {
// interactor.run();
// }
// });
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/UIThreadExecutor.java
// public class UIThreadExecutor implements MainExecutor {
//
// private Handler handler;
//
// @Inject
// public UIThreadExecutor() {
// this.handler = new Handler(Looper.getMainLooper());
// }
//
// public void run(Runnable runnable) {
// handler.post(runnable);
// }
// }
| import android.app.Application;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.presentation.executor.ThreadExecutor;
import com.xurxodev.moviesandroidkata.presentation.executor.UIThreadExecutor;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides; | package com.xurxodev.moviesandroidkata.di.module;
@Module
public class AppModule {
Application mApplication;
public AppModule(Application application) {
mApplication = application;
}
@Provides
@Singleton
Application providesApplication() {
return mApplication;
}
@Provides
@Singleton
public AsyncExecutor provideAsyncExecutor() {
return new ThreadExecutor();
}
@Provides
@Singleton | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/ThreadExecutor.java
// public class ThreadExecutor implements AsyncExecutor {
//
// private static final int CORE_POOL_SIZE = 3;
// private static final int MAX_POOL_SIZE = 5;
// private static final int KEEP_ALIVE_TIME = 120;
// private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS;
// private static final BlockingQueue<Runnable> WORK_QUEUE = new LinkedBlockingQueue<Runnable>();
//
// private ThreadPoolExecutor threadPoolExecutor;
//
// public ThreadExecutor() {
// int corePoolSize = CORE_POOL_SIZE;
// int maxPoolSize = MAX_POOL_SIZE;
// int keepAliveTime = KEEP_ALIVE_TIME;
// TimeUnit timeUnit = TIME_UNIT;
// BlockingQueue<Runnable> workQueue = WORK_QUEUE;
// threadPoolExecutor =
// new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, timeUnit, workQueue);
// }
//
// @Override
// public void run(final UseCase interactor) {
// if (interactor == null) {
// throw new IllegalArgumentException("Interactor to execute can't be null");
// }
//
// threadPoolExecutor.submit(new Runnable() {
// @Override public void run() {
// interactor.run();
// }
// });
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/UIThreadExecutor.java
// public class UIThreadExecutor implements MainExecutor {
//
// private Handler handler;
//
// @Inject
// public UIThreadExecutor() {
// this.handler = new Handler(Looper.getMainLooper());
// }
//
// public void run(Runnable runnable) {
// handler.post(runnable);
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/module/AppModule.java
import android.app.Application;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.presentation.executor.ThreadExecutor;
import com.xurxodev.moviesandroidkata.presentation.executor.UIThreadExecutor;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
package com.xurxodev.moviesandroidkata.di.module;
@Module
public class AppModule {
Application mApplication;
public AppModule(Application application) {
mApplication = application;
}
@Provides
@Singleton
Application providesApplication() {
return mApplication;
}
@Provides
@Singleton
public AsyncExecutor provideAsyncExecutor() {
return new ThreadExecutor();
}
@Provides
@Singleton | public MainExecutor provideMainExecutor() { |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/di/module/AppModule.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/ThreadExecutor.java
// public class ThreadExecutor implements AsyncExecutor {
//
// private static final int CORE_POOL_SIZE = 3;
// private static final int MAX_POOL_SIZE = 5;
// private static final int KEEP_ALIVE_TIME = 120;
// private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS;
// private static final BlockingQueue<Runnable> WORK_QUEUE = new LinkedBlockingQueue<Runnable>();
//
// private ThreadPoolExecutor threadPoolExecutor;
//
// public ThreadExecutor() {
// int corePoolSize = CORE_POOL_SIZE;
// int maxPoolSize = MAX_POOL_SIZE;
// int keepAliveTime = KEEP_ALIVE_TIME;
// TimeUnit timeUnit = TIME_UNIT;
// BlockingQueue<Runnable> workQueue = WORK_QUEUE;
// threadPoolExecutor =
// new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, timeUnit, workQueue);
// }
//
// @Override
// public void run(final UseCase interactor) {
// if (interactor == null) {
// throw new IllegalArgumentException("Interactor to execute can't be null");
// }
//
// threadPoolExecutor.submit(new Runnable() {
// @Override public void run() {
// interactor.run();
// }
// });
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/UIThreadExecutor.java
// public class UIThreadExecutor implements MainExecutor {
//
// private Handler handler;
//
// @Inject
// public UIThreadExecutor() {
// this.handler = new Handler(Looper.getMainLooper());
// }
//
// public void run(Runnable runnable) {
// handler.post(runnable);
// }
// }
| import android.app.Application;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.presentation.executor.ThreadExecutor;
import com.xurxodev.moviesandroidkata.presentation.executor.UIThreadExecutor;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides; | package com.xurxodev.moviesandroidkata.di.module;
@Module
public class AppModule {
Application mApplication;
public AppModule(Application application) {
mApplication = application;
}
@Provides
@Singleton
Application providesApplication() {
return mApplication;
}
@Provides
@Singleton
public AsyncExecutor provideAsyncExecutor() {
return new ThreadExecutor();
}
@Provides
@Singleton
public MainExecutor provideMainExecutor() { | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/ThreadExecutor.java
// public class ThreadExecutor implements AsyncExecutor {
//
// private static final int CORE_POOL_SIZE = 3;
// private static final int MAX_POOL_SIZE = 5;
// private static final int KEEP_ALIVE_TIME = 120;
// private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS;
// private static final BlockingQueue<Runnable> WORK_QUEUE = new LinkedBlockingQueue<Runnable>();
//
// private ThreadPoolExecutor threadPoolExecutor;
//
// public ThreadExecutor() {
// int corePoolSize = CORE_POOL_SIZE;
// int maxPoolSize = MAX_POOL_SIZE;
// int keepAliveTime = KEEP_ALIVE_TIME;
// TimeUnit timeUnit = TIME_UNIT;
// BlockingQueue<Runnable> workQueue = WORK_QUEUE;
// threadPoolExecutor =
// new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, timeUnit, workQueue);
// }
//
// @Override
// public void run(final UseCase interactor) {
// if (interactor == null) {
// throw new IllegalArgumentException("Interactor to execute can't be null");
// }
//
// threadPoolExecutor.submit(new Runnable() {
// @Override public void run() {
// interactor.run();
// }
// });
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/UIThreadExecutor.java
// public class UIThreadExecutor implements MainExecutor {
//
// private Handler handler;
//
// @Inject
// public UIThreadExecutor() {
// this.handler = new Handler(Looper.getMainLooper());
// }
//
// public void run(Runnable runnable) {
// handler.post(runnable);
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/module/AppModule.java
import android.app.Application;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.presentation.executor.ThreadExecutor;
import com.xurxodev.moviesandroidkata.presentation.executor.UIThreadExecutor;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
package com.xurxodev.moviesandroidkata.di.module;
@Module
public class AppModule {
Application mApplication;
public AppModule(Application application) {
mApplication = application;
}
@Provides
@Singleton
Application providesApplication() {
return mApplication;
}
@Provides
@Singleton
public AsyncExecutor provideAsyncExecutor() {
return new ThreadExecutor();
}
@Provides
@Singleton
public MainExecutor provideMainExecutor() { | return new UIThreadExecutor(); |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/MovieDetailPresenter.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMovieDetailUseCase.java
// public class GetMovieDetailUseCase implements UseCase {
//
// public interface Callback {
// void onCompetitorDetailLoaded(final Movie competitor);
//
// void onCompetitorDetailNotFound();
//
// void onConnectionError();
// }
//
// private MovieRepository competitorRepository;
// private AsyncExecutor asyncExecutor;
// private MainExecutor mainExecutor;
// private Callback callback;
// private String movieTitle;
//
// public GetMovieDetailUseCase(MovieRepository competitorRepository, AsyncExecutor asyncExecutor,
// MainExecutor mainExecutor) {
// this.competitorRepository = competitorRepository;
// this.asyncExecutor = asyncExecutor;
// this.mainExecutor = mainExecutor;
// }
//
// public void execute(String movieTitle, Callback callback) {
// this.movieTitle = movieTitle;
//
// this.callback = callback;
// this.asyncExecutor.run(this);
// }
//
// @Override
// public void run() {
// Movie movie = competitorRepository.getMovieByTitle(this.movieTitle);
//
// notifyCompetitorDetailsLoaded(movie);
//
// //TODO:call to notify error
// }
//
// private void notifyError() {
// mainExecutor.run(new Runnable() {
// @Override
// public void run() {
// callback.onConnectionError();
// }
// });
// }
//
// private void notifyCompetitorDetailsLoaded(final Movie movie) {
// mainExecutor.run(new Runnable() {
// @Override
// public void run() {
// callback.onCompetitorDetailLoaded(movie);
// }
// });
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/boundary/Navigator.java
// public interface Navigator {
// void openMovieDetail(Movie movie);
// }
| import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import com.xurxodev.moviesandroidkata.domain.usecase.GetMovieDetailUseCase;
import com.xurxodev.moviesandroidkata.presentation.presenter.boundary.Navigator; | package com.xurxodev.moviesandroidkata.presentation.presenter;
public class MovieDetailPresenter {
private View view; | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMovieDetailUseCase.java
// public class GetMovieDetailUseCase implements UseCase {
//
// public interface Callback {
// void onCompetitorDetailLoaded(final Movie competitor);
//
// void onCompetitorDetailNotFound();
//
// void onConnectionError();
// }
//
// private MovieRepository competitorRepository;
// private AsyncExecutor asyncExecutor;
// private MainExecutor mainExecutor;
// private Callback callback;
// private String movieTitle;
//
// public GetMovieDetailUseCase(MovieRepository competitorRepository, AsyncExecutor asyncExecutor,
// MainExecutor mainExecutor) {
// this.competitorRepository = competitorRepository;
// this.asyncExecutor = asyncExecutor;
// this.mainExecutor = mainExecutor;
// }
//
// public void execute(String movieTitle, Callback callback) {
// this.movieTitle = movieTitle;
//
// this.callback = callback;
// this.asyncExecutor.run(this);
// }
//
// @Override
// public void run() {
// Movie movie = competitorRepository.getMovieByTitle(this.movieTitle);
//
// notifyCompetitorDetailsLoaded(movie);
//
// //TODO:call to notify error
// }
//
// private void notifyError() {
// mainExecutor.run(new Runnable() {
// @Override
// public void run() {
// callback.onConnectionError();
// }
// });
// }
//
// private void notifyCompetitorDetailsLoaded(final Movie movie) {
// mainExecutor.run(new Runnable() {
// @Override
// public void run() {
// callback.onCompetitorDetailLoaded(movie);
// }
// });
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/boundary/Navigator.java
// public interface Navigator {
// void openMovieDetail(Movie movie);
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/MovieDetailPresenter.java
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import com.xurxodev.moviesandroidkata.domain.usecase.GetMovieDetailUseCase;
import com.xurxodev.moviesandroidkata.presentation.presenter.boundary.Navigator;
package com.xurxodev.moviesandroidkata.presentation.presenter;
public class MovieDetailPresenter {
private View view; | private GetMovieDetailUseCase getMovieDetailUseCase; |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/MovieDetailPresenter.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMovieDetailUseCase.java
// public class GetMovieDetailUseCase implements UseCase {
//
// public interface Callback {
// void onCompetitorDetailLoaded(final Movie competitor);
//
// void onCompetitorDetailNotFound();
//
// void onConnectionError();
// }
//
// private MovieRepository competitorRepository;
// private AsyncExecutor asyncExecutor;
// private MainExecutor mainExecutor;
// private Callback callback;
// private String movieTitle;
//
// public GetMovieDetailUseCase(MovieRepository competitorRepository, AsyncExecutor asyncExecutor,
// MainExecutor mainExecutor) {
// this.competitorRepository = competitorRepository;
// this.asyncExecutor = asyncExecutor;
// this.mainExecutor = mainExecutor;
// }
//
// public void execute(String movieTitle, Callback callback) {
// this.movieTitle = movieTitle;
//
// this.callback = callback;
// this.asyncExecutor.run(this);
// }
//
// @Override
// public void run() {
// Movie movie = competitorRepository.getMovieByTitle(this.movieTitle);
//
// notifyCompetitorDetailsLoaded(movie);
//
// //TODO:call to notify error
// }
//
// private void notifyError() {
// mainExecutor.run(new Runnable() {
// @Override
// public void run() {
// callback.onConnectionError();
// }
// });
// }
//
// private void notifyCompetitorDetailsLoaded(final Movie movie) {
// mainExecutor.run(new Runnable() {
// @Override
// public void run() {
// callback.onCompetitorDetailLoaded(movie);
// }
// });
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/boundary/Navigator.java
// public interface Navigator {
// void openMovieDetail(Movie movie);
// }
| import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import com.xurxodev.moviesandroidkata.domain.usecase.GetMovieDetailUseCase;
import com.xurxodev.moviesandroidkata.presentation.presenter.boundary.Navigator; | package com.xurxodev.moviesandroidkata.presentation.presenter;
public class MovieDetailPresenter {
private View view;
private GetMovieDetailUseCase getMovieDetailUseCase;
| // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMovieDetailUseCase.java
// public class GetMovieDetailUseCase implements UseCase {
//
// public interface Callback {
// void onCompetitorDetailLoaded(final Movie competitor);
//
// void onCompetitorDetailNotFound();
//
// void onConnectionError();
// }
//
// private MovieRepository competitorRepository;
// private AsyncExecutor asyncExecutor;
// private MainExecutor mainExecutor;
// private Callback callback;
// private String movieTitle;
//
// public GetMovieDetailUseCase(MovieRepository competitorRepository, AsyncExecutor asyncExecutor,
// MainExecutor mainExecutor) {
// this.competitorRepository = competitorRepository;
// this.asyncExecutor = asyncExecutor;
// this.mainExecutor = mainExecutor;
// }
//
// public void execute(String movieTitle, Callback callback) {
// this.movieTitle = movieTitle;
//
// this.callback = callback;
// this.asyncExecutor.run(this);
// }
//
// @Override
// public void run() {
// Movie movie = competitorRepository.getMovieByTitle(this.movieTitle);
//
// notifyCompetitorDetailsLoaded(movie);
//
// //TODO:call to notify error
// }
//
// private void notifyError() {
// mainExecutor.run(new Runnable() {
// @Override
// public void run() {
// callback.onConnectionError();
// }
// });
// }
//
// private void notifyCompetitorDetailsLoaded(final Movie movie) {
// mainExecutor.run(new Runnable() {
// @Override
// public void run() {
// callback.onCompetitorDetailLoaded(movie);
// }
// });
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/boundary/Navigator.java
// public interface Navigator {
// void openMovieDetail(Movie movie);
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/MovieDetailPresenter.java
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import com.xurxodev.moviesandroidkata.domain.usecase.GetMovieDetailUseCase;
import com.xurxodev.moviesandroidkata.presentation.presenter.boundary.Navigator;
package com.xurxodev.moviesandroidkata.presentation.presenter;
public class MovieDetailPresenter {
private View view;
private GetMovieDetailUseCase getMovieDetailUseCase;
| private Movie movie; |
xurxodev/Movies-Android-Kata | app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/adapter/MoviesAdapter.java
// public class MoviesAdapter
// extends RecyclerView.Adapter<MoviesAdapter.ViewHolder> {
//
// public interface OnMovieClickListener {
// void onItemClick(View view, Movie movie);
// }
//
// private OnMovieClickListener onMovieClickListener;
//
// public List<Movie> movies = new ArrayList<>();
//
// public void setMovies(List<Movie> movies) {
// this.movies = movies;
// notifyDataSetChanged();
// }
//
// public void clearMovies() {
// movies = new ArrayList<>();
// notifyDataSetChanged();
// }
//
// public void setOnMovieClickListener(OnMovieClickListener listener) {
// onMovieClickListener = listener;
// }
//
// @Override
// public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View view = LayoutInflater.from(parent.getContext())
// .inflate(R.layout.item_movies, parent, false);
//
// return new ViewHolder(view);
// }
//
// @Override
// public void onBindViewHolder(final ViewHolder holder, final int position) {
// holder.movieItem = movies.get(position);
//
// Picasso.with(holder.movieImageView.getContext())
// .load(holder.movieItem.getImage())
// .into(holder.movieImageView);
//
// holder.titleTextView.setText(holder.movieItem .getTitle());
//
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// Movie clickedItem = movies.get(position);
//
// onMovieClickListener.onItemClick(view, clickedItem);
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return movies.size();
// }
//
// public class ViewHolder extends RecyclerView.ViewHolder {
// public final ImageView movieImageView;
// public final TextView titleTextView;
//
// public Movie movieItem;
//
// public ViewHolder(View view) {
// super(view);
//
// movieImageView = (ImageView) view.findViewById(R.id.item_movie_poster);
// titleTextView = (TextView) view.findViewById(R.id.item_movie_title);
// }
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/util/idlingresource/ProgressbarIdlingResource.java
// public class ProgressbarIdlingResource implements IdlingResource {
//
// private Activity activity;
// private ResourceCallback callback;
//
// public ProgressbarIdlingResource(Activity activity){
// this.activity = activity;
// }
//
// @Override
// public String getName() {
// return "ProgressbarIdlingResource";
// }
//
// @Override
// public boolean isIdleNow() {
//
// View view = activity.findViewById(R.id.pb_loading);
//
// boolean loadingHide = !view.isShown();
//
// if (loadingHide)
// callback.onTransitionToIdle();
//
// return loadingHide;
// }
//
// @Override
// public void registerIdleTransitionCallback(ResourceCallback callback) {
// this.callback = callback;
// }
// }
| import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.CoreMatchers.not;
import android.graphics.drawable.Drawable;
import android.support.test.espresso.Espresso;
import android.support.test.espresso.contrib.RecyclerViewActions;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.widget.ProgressBar;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.presentation.view.adapter.MoviesAdapter;
import com.xurxodev.moviesandroidkata.util.idlingresource.ProgressbarIdlingResource; | package com.xurxodev.moviesandroidkata.robot;
public class MoviesRobot {
private MoviesActivity activity;
RecyclerView recyclerView; | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/adapter/MoviesAdapter.java
// public class MoviesAdapter
// extends RecyclerView.Adapter<MoviesAdapter.ViewHolder> {
//
// public interface OnMovieClickListener {
// void onItemClick(View view, Movie movie);
// }
//
// private OnMovieClickListener onMovieClickListener;
//
// public List<Movie> movies = new ArrayList<>();
//
// public void setMovies(List<Movie> movies) {
// this.movies = movies;
// notifyDataSetChanged();
// }
//
// public void clearMovies() {
// movies = new ArrayList<>();
// notifyDataSetChanged();
// }
//
// public void setOnMovieClickListener(OnMovieClickListener listener) {
// onMovieClickListener = listener;
// }
//
// @Override
// public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View view = LayoutInflater.from(parent.getContext())
// .inflate(R.layout.item_movies, parent, false);
//
// return new ViewHolder(view);
// }
//
// @Override
// public void onBindViewHolder(final ViewHolder holder, final int position) {
// holder.movieItem = movies.get(position);
//
// Picasso.with(holder.movieImageView.getContext())
// .load(holder.movieItem.getImage())
// .into(holder.movieImageView);
//
// holder.titleTextView.setText(holder.movieItem .getTitle());
//
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// Movie clickedItem = movies.get(position);
//
// onMovieClickListener.onItemClick(view, clickedItem);
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return movies.size();
// }
//
// public class ViewHolder extends RecyclerView.ViewHolder {
// public final ImageView movieImageView;
// public final TextView titleTextView;
//
// public Movie movieItem;
//
// public ViewHolder(View view) {
// super(view);
//
// movieImageView = (ImageView) view.findViewById(R.id.item_movie_poster);
// titleTextView = (TextView) view.findViewById(R.id.item_movie_title);
// }
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/util/idlingresource/ProgressbarIdlingResource.java
// public class ProgressbarIdlingResource implements IdlingResource {
//
// private Activity activity;
// private ResourceCallback callback;
//
// public ProgressbarIdlingResource(Activity activity){
// this.activity = activity;
// }
//
// @Override
// public String getName() {
// return "ProgressbarIdlingResource";
// }
//
// @Override
// public boolean isIdleNow() {
//
// View view = activity.findViewById(R.id.pb_loading);
//
// boolean loadingHide = !view.isShown();
//
// if (loadingHide)
// callback.onTransitionToIdle();
//
// return loadingHide;
// }
//
// @Override
// public void registerIdleTransitionCallback(ResourceCallback callback) {
// this.callback = callback;
// }
// }
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.CoreMatchers.not;
import android.graphics.drawable.Drawable;
import android.support.test.espresso.Espresso;
import android.support.test.espresso.contrib.RecyclerViewActions;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.widget.ProgressBar;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.presentation.view.adapter.MoviesAdapter;
import com.xurxodev.moviesandroidkata.util.idlingresource.ProgressbarIdlingResource;
package com.xurxodev.moviesandroidkata.robot;
public class MoviesRobot {
private MoviesActivity activity;
RecyclerView recyclerView; | ProgressbarIdlingResource progressbarIdlingResource; |
xurxodev/Movies-Android-Kata | app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/adapter/MoviesAdapter.java
// public class MoviesAdapter
// extends RecyclerView.Adapter<MoviesAdapter.ViewHolder> {
//
// public interface OnMovieClickListener {
// void onItemClick(View view, Movie movie);
// }
//
// private OnMovieClickListener onMovieClickListener;
//
// public List<Movie> movies = new ArrayList<>();
//
// public void setMovies(List<Movie> movies) {
// this.movies = movies;
// notifyDataSetChanged();
// }
//
// public void clearMovies() {
// movies = new ArrayList<>();
// notifyDataSetChanged();
// }
//
// public void setOnMovieClickListener(OnMovieClickListener listener) {
// onMovieClickListener = listener;
// }
//
// @Override
// public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View view = LayoutInflater.from(parent.getContext())
// .inflate(R.layout.item_movies, parent, false);
//
// return new ViewHolder(view);
// }
//
// @Override
// public void onBindViewHolder(final ViewHolder holder, final int position) {
// holder.movieItem = movies.get(position);
//
// Picasso.with(holder.movieImageView.getContext())
// .load(holder.movieItem.getImage())
// .into(holder.movieImageView);
//
// holder.titleTextView.setText(holder.movieItem .getTitle());
//
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// Movie clickedItem = movies.get(position);
//
// onMovieClickListener.onItemClick(view, clickedItem);
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return movies.size();
// }
//
// public class ViewHolder extends RecyclerView.ViewHolder {
// public final ImageView movieImageView;
// public final TextView titleTextView;
//
// public Movie movieItem;
//
// public ViewHolder(View view) {
// super(view);
//
// movieImageView = (ImageView) view.findViewById(R.id.item_movie_poster);
// titleTextView = (TextView) view.findViewById(R.id.item_movie_title);
// }
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/util/idlingresource/ProgressbarIdlingResource.java
// public class ProgressbarIdlingResource implements IdlingResource {
//
// private Activity activity;
// private ResourceCallback callback;
//
// public ProgressbarIdlingResource(Activity activity){
// this.activity = activity;
// }
//
// @Override
// public String getName() {
// return "ProgressbarIdlingResource";
// }
//
// @Override
// public boolean isIdleNow() {
//
// View view = activity.findViewById(R.id.pb_loading);
//
// boolean loadingHide = !view.isShown();
//
// if (loadingHide)
// callback.onTransitionToIdle();
//
// return loadingHide;
// }
//
// @Override
// public void registerIdleTransitionCallback(ResourceCallback callback) {
// this.callback = callback;
// }
// }
| import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.CoreMatchers.not;
import android.graphics.drawable.Drawable;
import android.support.test.espresso.Espresso;
import android.support.test.espresso.contrib.RecyclerViewActions;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.widget.ProgressBar;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.presentation.view.adapter.MoviesAdapter;
import com.xurxodev.moviesandroidkata.util.idlingresource.ProgressbarIdlingResource; | package com.xurxodev.moviesandroidkata.robot;
public class MoviesRobot {
private MoviesActivity activity;
RecyclerView recyclerView;
ProgressbarIdlingResource progressbarIdlingResource;
public MoviesRobot(MoviesActivity activity) {
this.activity = activity;
this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
removeAnimateDrawableFromProgressForTest();
}
public int getNumMoviesRows() {
return recyclerView.getAdapter().getItemCount();
}
public MoviesRobot waitForMovies() {
Espresso.registerIdlingResources(progressbarIdlingResource);
onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
Espresso.unregisterIdlingResources(progressbarIdlingResource);
return this;
}
public String getMovieTitle(int i) { | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/adapter/MoviesAdapter.java
// public class MoviesAdapter
// extends RecyclerView.Adapter<MoviesAdapter.ViewHolder> {
//
// public interface OnMovieClickListener {
// void onItemClick(View view, Movie movie);
// }
//
// private OnMovieClickListener onMovieClickListener;
//
// public List<Movie> movies = new ArrayList<>();
//
// public void setMovies(List<Movie> movies) {
// this.movies = movies;
// notifyDataSetChanged();
// }
//
// public void clearMovies() {
// movies = new ArrayList<>();
// notifyDataSetChanged();
// }
//
// public void setOnMovieClickListener(OnMovieClickListener listener) {
// onMovieClickListener = listener;
// }
//
// @Override
// public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View view = LayoutInflater.from(parent.getContext())
// .inflate(R.layout.item_movies, parent, false);
//
// return new ViewHolder(view);
// }
//
// @Override
// public void onBindViewHolder(final ViewHolder holder, final int position) {
// holder.movieItem = movies.get(position);
//
// Picasso.with(holder.movieImageView.getContext())
// .load(holder.movieItem.getImage())
// .into(holder.movieImageView);
//
// holder.titleTextView.setText(holder.movieItem .getTitle());
//
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// Movie clickedItem = movies.get(position);
//
// onMovieClickListener.onItemClick(view, clickedItem);
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return movies.size();
// }
//
// public class ViewHolder extends RecyclerView.ViewHolder {
// public final ImageView movieImageView;
// public final TextView titleTextView;
//
// public Movie movieItem;
//
// public ViewHolder(View view) {
// super(view);
//
// movieImageView = (ImageView) view.findViewById(R.id.item_movie_poster);
// titleTextView = (TextView) view.findViewById(R.id.item_movie_title);
// }
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/util/idlingresource/ProgressbarIdlingResource.java
// public class ProgressbarIdlingResource implements IdlingResource {
//
// private Activity activity;
// private ResourceCallback callback;
//
// public ProgressbarIdlingResource(Activity activity){
// this.activity = activity;
// }
//
// @Override
// public String getName() {
// return "ProgressbarIdlingResource";
// }
//
// @Override
// public boolean isIdleNow() {
//
// View view = activity.findViewById(R.id.pb_loading);
//
// boolean loadingHide = !view.isShown();
//
// if (loadingHide)
// callback.onTransitionToIdle();
//
// return loadingHide;
// }
//
// @Override
// public void registerIdleTransitionCallback(ResourceCallback callback) {
// this.callback = callback;
// }
// }
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.CoreMatchers.not;
import android.graphics.drawable.Drawable;
import android.support.test.espresso.Espresso;
import android.support.test.espresso.contrib.RecyclerViewActions;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.widget.ProgressBar;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.presentation.view.adapter.MoviesAdapter;
import com.xurxodev.moviesandroidkata.util.idlingresource.ProgressbarIdlingResource;
package com.xurxodev.moviesandroidkata.robot;
public class MoviesRobot {
private MoviesActivity activity;
RecyclerView recyclerView;
ProgressbarIdlingResource progressbarIdlingResource;
public MoviesRobot(MoviesActivity activity) {
this.activity = activity;
this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
removeAnimateDrawableFromProgressForTest();
}
public int getNumMoviesRows() {
return recyclerView.getAdapter().getItemCount();
}
public MoviesRobot waitForMovies() {
Espresso.registerIdlingResources(progressbarIdlingResource);
onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
Espresso.unregisterIdlingResources(progressbarIdlingResource);
return this;
}
public String getMovieTitle(int i) { | return ((MoviesAdapter) recyclerView.getAdapter()).movies.get(i).getTitle(); |
xurxodev/Movies-Android-Kata | app/src/androidTest/java/com/xurxodev/moviesandroidkata/test/MoviesLoadingTextFeature.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
// public class MoviesRobot {
// private MoviesActivity activity;
// RecyclerView recyclerView;
// ProgressbarIdlingResource progressbarIdlingResource;
//
// public MoviesRobot(MoviesActivity activity) {
// this.activity = activity;
// this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
// this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
//
// removeAnimateDrawableFromProgressForTest();
// }
//
// public int getNumMoviesRows() {
// return recyclerView.getAdapter().getItemCount();
// }
//
// public MoviesRobot waitForMovies() {
// Espresso.registerIdlingResources(progressbarIdlingResource);
//
// onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
//
// Espresso.unregisterIdlingResources(progressbarIdlingResource);
//
// return this;
// }
//
// public String getMovieTitle(int i) {
// return ((MoviesAdapter) recyclerView.getAdapter()).movies.get(i).getTitle();
// }
//
// public MovieDetailRobot navigateToMovie(int position) {
// onView(withId(R.id.recyclerview_movies))
// .perform(RecyclerViewActions.actionOnItemAtPosition(position, click()));
//
// return new MovieDetailRobot(this);
// }
//
// public MoviesRobot verifyTextWithMoviesCount(int numMovies) {
// String formatCountText = activity.getString(R.string.movies_count_text);
// String expectedText = String.format(formatCountText, numMovies);
//
// onView(withId(R.id.movies_title_text_view)).check(matches(withText(expectedText)));
//
// return this;
// }
//
// public MoviesRobot refreshMovies() {
// onView(withId(R.id.refresh_button)).perform(click());
// return this;
// }
//
// public MoviesRobot verifyLoadingText() {
// String text = activity.getString(R.string.loading_movies_text);
//
// onView(withId(R.id.movies_title_text_view)).check(
// matches(withText(text)));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsVisible() {
// onView(withId(R.id.pb_loading)).check(
// matches(isDisplayed()));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsHide() {
// onView(withId(R.id.pb_loading)).check(
// matches(not(isDisplayed())));
//
// return this;
// }
//
// private void removeAnimateDrawableFromProgressForTest() {
// Drawable notAnimatedDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_refresh);
// ((ProgressBar) activity.findViewById(R.id.pb_loading)).setIndeterminateDrawable(
// notAnimatedDrawable);
//
// }
// }
| import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.robot.MoviesRobot;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith; | package com.xurxodev.moviesandroidkata.test;
@RunWith(AndroidJUnit4.class)
public class MoviesLoadingTextFeature {
@Rule | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
// public class MoviesRobot {
// private MoviesActivity activity;
// RecyclerView recyclerView;
// ProgressbarIdlingResource progressbarIdlingResource;
//
// public MoviesRobot(MoviesActivity activity) {
// this.activity = activity;
// this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
// this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
//
// removeAnimateDrawableFromProgressForTest();
// }
//
// public int getNumMoviesRows() {
// return recyclerView.getAdapter().getItemCount();
// }
//
// public MoviesRobot waitForMovies() {
// Espresso.registerIdlingResources(progressbarIdlingResource);
//
// onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
//
// Espresso.unregisterIdlingResources(progressbarIdlingResource);
//
// return this;
// }
//
// public String getMovieTitle(int i) {
// return ((MoviesAdapter) recyclerView.getAdapter()).movies.get(i).getTitle();
// }
//
// public MovieDetailRobot navigateToMovie(int position) {
// onView(withId(R.id.recyclerview_movies))
// .perform(RecyclerViewActions.actionOnItemAtPosition(position, click()));
//
// return new MovieDetailRobot(this);
// }
//
// public MoviesRobot verifyTextWithMoviesCount(int numMovies) {
// String formatCountText = activity.getString(R.string.movies_count_text);
// String expectedText = String.format(formatCountText, numMovies);
//
// onView(withId(R.id.movies_title_text_view)).check(matches(withText(expectedText)));
//
// return this;
// }
//
// public MoviesRobot refreshMovies() {
// onView(withId(R.id.refresh_button)).perform(click());
// return this;
// }
//
// public MoviesRobot verifyLoadingText() {
// String text = activity.getString(R.string.loading_movies_text);
//
// onView(withId(R.id.movies_title_text_view)).check(
// matches(withText(text)));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsVisible() {
// onView(withId(R.id.pb_loading)).check(
// matches(isDisplayed()));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsHide() {
// onView(withId(R.id.pb_loading)).check(
// matches(not(isDisplayed())));
//
// return this;
// }
//
// private void removeAnimateDrawableFromProgressForTest() {
// Drawable notAnimatedDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_refresh);
// ((ProgressBar) activity.findViewById(R.id.pb_loading)).setIndeterminateDrawable(
// notAnimatedDrawable);
//
// }
// }
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/test/MoviesLoadingTextFeature.java
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.robot.MoviesRobot;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
package com.xurxodev.moviesandroidkata.test;
@RunWith(AndroidJUnit4.class)
public class MoviesLoadingTextFeature {
@Rule | public ActivityTestRule<MoviesActivity> activityTestRule = |
xurxodev/Movies-Android-Kata | app/src/androidTest/java/com/xurxodev/moviesandroidkata/test/MoviesLoadingTextFeature.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
// public class MoviesRobot {
// private MoviesActivity activity;
// RecyclerView recyclerView;
// ProgressbarIdlingResource progressbarIdlingResource;
//
// public MoviesRobot(MoviesActivity activity) {
// this.activity = activity;
// this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
// this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
//
// removeAnimateDrawableFromProgressForTest();
// }
//
// public int getNumMoviesRows() {
// return recyclerView.getAdapter().getItemCount();
// }
//
// public MoviesRobot waitForMovies() {
// Espresso.registerIdlingResources(progressbarIdlingResource);
//
// onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
//
// Espresso.unregisterIdlingResources(progressbarIdlingResource);
//
// return this;
// }
//
// public String getMovieTitle(int i) {
// return ((MoviesAdapter) recyclerView.getAdapter()).movies.get(i).getTitle();
// }
//
// public MovieDetailRobot navigateToMovie(int position) {
// onView(withId(R.id.recyclerview_movies))
// .perform(RecyclerViewActions.actionOnItemAtPosition(position, click()));
//
// return new MovieDetailRobot(this);
// }
//
// public MoviesRobot verifyTextWithMoviesCount(int numMovies) {
// String formatCountText = activity.getString(R.string.movies_count_text);
// String expectedText = String.format(formatCountText, numMovies);
//
// onView(withId(R.id.movies_title_text_view)).check(matches(withText(expectedText)));
//
// return this;
// }
//
// public MoviesRobot refreshMovies() {
// onView(withId(R.id.refresh_button)).perform(click());
// return this;
// }
//
// public MoviesRobot verifyLoadingText() {
// String text = activity.getString(R.string.loading_movies_text);
//
// onView(withId(R.id.movies_title_text_view)).check(
// matches(withText(text)));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsVisible() {
// onView(withId(R.id.pb_loading)).check(
// matches(isDisplayed()));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsHide() {
// onView(withId(R.id.pb_loading)).check(
// matches(not(isDisplayed())));
//
// return this;
// }
//
// private void removeAnimateDrawableFromProgressForTest() {
// Drawable notAnimatedDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_refresh);
// ((ProgressBar) activity.findViewById(R.id.pb_loading)).setIndeterminateDrawable(
// notAnimatedDrawable);
//
// }
// }
| import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.robot.MoviesRobot;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith; | package com.xurxodev.moviesandroidkata.test;
@RunWith(AndroidJUnit4.class)
public class MoviesLoadingTextFeature {
@Rule
public ActivityTestRule<MoviesActivity> activityTestRule =
new ActivityTestRule<>(MoviesActivity.class);
@Test
public void show_loading_text_while_retrieve_movies() { | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
// public class MoviesRobot {
// private MoviesActivity activity;
// RecyclerView recyclerView;
// ProgressbarIdlingResource progressbarIdlingResource;
//
// public MoviesRobot(MoviesActivity activity) {
// this.activity = activity;
// this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
// this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
//
// removeAnimateDrawableFromProgressForTest();
// }
//
// public int getNumMoviesRows() {
// return recyclerView.getAdapter().getItemCount();
// }
//
// public MoviesRobot waitForMovies() {
// Espresso.registerIdlingResources(progressbarIdlingResource);
//
// onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
//
// Espresso.unregisterIdlingResources(progressbarIdlingResource);
//
// return this;
// }
//
// public String getMovieTitle(int i) {
// return ((MoviesAdapter) recyclerView.getAdapter()).movies.get(i).getTitle();
// }
//
// public MovieDetailRobot navigateToMovie(int position) {
// onView(withId(R.id.recyclerview_movies))
// .perform(RecyclerViewActions.actionOnItemAtPosition(position, click()));
//
// return new MovieDetailRobot(this);
// }
//
// public MoviesRobot verifyTextWithMoviesCount(int numMovies) {
// String formatCountText = activity.getString(R.string.movies_count_text);
// String expectedText = String.format(formatCountText, numMovies);
//
// onView(withId(R.id.movies_title_text_view)).check(matches(withText(expectedText)));
//
// return this;
// }
//
// public MoviesRobot refreshMovies() {
// onView(withId(R.id.refresh_button)).perform(click());
// return this;
// }
//
// public MoviesRobot verifyLoadingText() {
// String text = activity.getString(R.string.loading_movies_text);
//
// onView(withId(R.id.movies_title_text_view)).check(
// matches(withText(text)));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsVisible() {
// onView(withId(R.id.pb_loading)).check(
// matches(isDisplayed()));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsHide() {
// onView(withId(R.id.pb_loading)).check(
// matches(not(isDisplayed())));
//
// return this;
// }
//
// private void removeAnimateDrawableFromProgressForTest() {
// Drawable notAnimatedDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_refresh);
// ((ProgressBar) activity.findViewById(R.id.pb_loading)).setIndeterminateDrawable(
// notAnimatedDrawable);
//
// }
// }
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/test/MoviesLoadingTextFeature.java
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.robot.MoviesRobot;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
package com.xurxodev.moviesandroidkata.test;
@RunWith(AndroidJUnit4.class)
public class MoviesLoadingTextFeature {
@Rule
public ActivityTestRule<MoviesActivity> activityTestRule =
new ActivityTestRule<>(MoviesActivity.class);
@Test
public void show_loading_text_while_retrieve_movies() { | MoviesRobot moviesRobot = new MoviesRobot(activityTestRule.getActivity()); |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/MoviesApplication.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/component/ApplicationComponent.java
// @Singleton
// @Component(modules = {AppModule.class, DataModule.class})
// public interface ApplicationComponent {
// ActivityComponent.Builder activityComponent();
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/module/AppModule.java
// @Module
// public class AppModule {
//
// Application mApplication;
//
// public AppModule(Application application) {
// mApplication = application;
// }
//
// @Provides
// @Singleton
// Application providesApplication() {
// return mApplication;
// }
//
// @Provides
// @Singleton
// public AsyncExecutor provideAsyncExecutor() {
// return new ThreadExecutor();
// }
//
// @Provides
// @Singleton
// public MainExecutor provideMainExecutor() {
// return new UIThreadExecutor();
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/module/DataModule.java
// @Module
// public class DataModule {
// @Provides
// @Singleton
// Gson provideGson() {
// GsonBuilder gsonBuilder = new GsonBuilder();
// gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
// return gsonBuilder.create();
// }
//
// @Provides
// @Singleton
// MovieRepository provideMovieRepository(Application applicationContext, Gson gson) {
// MovieRepository diskMovieRepository = new DiskMovieRepository(applicationContext, gson);
// return diskMovieRepository;
// }
//
// @Provides
// @Singleton
// GetMoviesUseCase provideGetMoviesUseCase(MovieRepository movieRepository,
// AsyncExecutor asyncExecutor, MainExecutor mainExecutor) {
// GetMoviesUseCase getMoviesUseCase = new GetMoviesUseCase(movieRepository, asyncExecutor,
// mainExecutor);
// return getMoviesUseCase;
// }
//
// @Provides
// @Singleton
// GetMovieDetailUseCase provideGetMovieDetailUseCase(MovieRepository movieRepository,
// AsyncExecutor asyncExecutor, MainExecutor mainExecutor) {
// GetMovieDetailUseCase getMovieDetailUseCase = new GetMovieDetailUseCase(movieRepository,
// asyncExecutor,
// mainExecutor);
// return getMovieDetailUseCase;
// }
// }
| import android.app.Application;
import com.xurxodev.moviesandroidkata.di.component.ApplicationComponent;
import com.xurxodev.moviesandroidkata.di.component.DaggerApplicationComponent;
import com.xurxodev.moviesandroidkata.di.module.AppModule;
import com.xurxodev.moviesandroidkata.di.module.DataModule; | package com.xurxodev.moviesandroidkata;
public class MoviesApplication extends Application {
private ApplicationComponent appComponent;
@Override
public void onCreate() {
super.onCreate();
// Dagger%COMPONENT_NAME%
appComponent = DaggerApplicationComponent.builder() | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/component/ApplicationComponent.java
// @Singleton
// @Component(modules = {AppModule.class, DataModule.class})
// public interface ApplicationComponent {
// ActivityComponent.Builder activityComponent();
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/module/AppModule.java
// @Module
// public class AppModule {
//
// Application mApplication;
//
// public AppModule(Application application) {
// mApplication = application;
// }
//
// @Provides
// @Singleton
// Application providesApplication() {
// return mApplication;
// }
//
// @Provides
// @Singleton
// public AsyncExecutor provideAsyncExecutor() {
// return new ThreadExecutor();
// }
//
// @Provides
// @Singleton
// public MainExecutor provideMainExecutor() {
// return new UIThreadExecutor();
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/module/DataModule.java
// @Module
// public class DataModule {
// @Provides
// @Singleton
// Gson provideGson() {
// GsonBuilder gsonBuilder = new GsonBuilder();
// gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
// return gsonBuilder.create();
// }
//
// @Provides
// @Singleton
// MovieRepository provideMovieRepository(Application applicationContext, Gson gson) {
// MovieRepository diskMovieRepository = new DiskMovieRepository(applicationContext, gson);
// return diskMovieRepository;
// }
//
// @Provides
// @Singleton
// GetMoviesUseCase provideGetMoviesUseCase(MovieRepository movieRepository,
// AsyncExecutor asyncExecutor, MainExecutor mainExecutor) {
// GetMoviesUseCase getMoviesUseCase = new GetMoviesUseCase(movieRepository, asyncExecutor,
// mainExecutor);
// return getMoviesUseCase;
// }
//
// @Provides
// @Singleton
// GetMovieDetailUseCase provideGetMovieDetailUseCase(MovieRepository movieRepository,
// AsyncExecutor asyncExecutor, MainExecutor mainExecutor) {
// GetMovieDetailUseCase getMovieDetailUseCase = new GetMovieDetailUseCase(movieRepository,
// asyncExecutor,
// mainExecutor);
// return getMovieDetailUseCase;
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/MoviesApplication.java
import android.app.Application;
import com.xurxodev.moviesandroidkata.di.component.ApplicationComponent;
import com.xurxodev.moviesandroidkata.di.component.DaggerApplicationComponent;
import com.xurxodev.moviesandroidkata.di.module.AppModule;
import com.xurxodev.moviesandroidkata.di.module.DataModule;
package com.xurxodev.moviesandroidkata;
public class MoviesApplication extends Application {
private ApplicationComponent appComponent;
@Override
public void onCreate() {
super.onCreate();
// Dagger%COMPONENT_NAME%
appComponent = DaggerApplicationComponent.builder() | .appModule(new AppModule(this)) |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/MoviesApplication.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/component/ApplicationComponent.java
// @Singleton
// @Component(modules = {AppModule.class, DataModule.class})
// public interface ApplicationComponent {
// ActivityComponent.Builder activityComponent();
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/module/AppModule.java
// @Module
// public class AppModule {
//
// Application mApplication;
//
// public AppModule(Application application) {
// mApplication = application;
// }
//
// @Provides
// @Singleton
// Application providesApplication() {
// return mApplication;
// }
//
// @Provides
// @Singleton
// public AsyncExecutor provideAsyncExecutor() {
// return new ThreadExecutor();
// }
//
// @Provides
// @Singleton
// public MainExecutor provideMainExecutor() {
// return new UIThreadExecutor();
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/module/DataModule.java
// @Module
// public class DataModule {
// @Provides
// @Singleton
// Gson provideGson() {
// GsonBuilder gsonBuilder = new GsonBuilder();
// gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
// return gsonBuilder.create();
// }
//
// @Provides
// @Singleton
// MovieRepository provideMovieRepository(Application applicationContext, Gson gson) {
// MovieRepository diskMovieRepository = new DiskMovieRepository(applicationContext, gson);
// return diskMovieRepository;
// }
//
// @Provides
// @Singleton
// GetMoviesUseCase provideGetMoviesUseCase(MovieRepository movieRepository,
// AsyncExecutor asyncExecutor, MainExecutor mainExecutor) {
// GetMoviesUseCase getMoviesUseCase = new GetMoviesUseCase(movieRepository, asyncExecutor,
// mainExecutor);
// return getMoviesUseCase;
// }
//
// @Provides
// @Singleton
// GetMovieDetailUseCase provideGetMovieDetailUseCase(MovieRepository movieRepository,
// AsyncExecutor asyncExecutor, MainExecutor mainExecutor) {
// GetMovieDetailUseCase getMovieDetailUseCase = new GetMovieDetailUseCase(movieRepository,
// asyncExecutor,
// mainExecutor);
// return getMovieDetailUseCase;
// }
// }
| import android.app.Application;
import com.xurxodev.moviesandroidkata.di.component.ApplicationComponent;
import com.xurxodev.moviesandroidkata.di.component.DaggerApplicationComponent;
import com.xurxodev.moviesandroidkata.di.module.AppModule;
import com.xurxodev.moviesandroidkata.di.module.DataModule; | package com.xurxodev.moviesandroidkata;
public class MoviesApplication extends Application {
private ApplicationComponent appComponent;
@Override
public void onCreate() {
super.onCreate();
// Dagger%COMPONENT_NAME%
appComponent = DaggerApplicationComponent.builder()
.appModule(new AppModule(this)) | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/component/ApplicationComponent.java
// @Singleton
// @Component(modules = {AppModule.class, DataModule.class})
// public interface ApplicationComponent {
// ActivityComponent.Builder activityComponent();
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/module/AppModule.java
// @Module
// public class AppModule {
//
// Application mApplication;
//
// public AppModule(Application application) {
// mApplication = application;
// }
//
// @Provides
// @Singleton
// Application providesApplication() {
// return mApplication;
// }
//
// @Provides
// @Singleton
// public AsyncExecutor provideAsyncExecutor() {
// return new ThreadExecutor();
// }
//
// @Provides
// @Singleton
// public MainExecutor provideMainExecutor() {
// return new UIThreadExecutor();
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/module/DataModule.java
// @Module
// public class DataModule {
// @Provides
// @Singleton
// Gson provideGson() {
// GsonBuilder gsonBuilder = new GsonBuilder();
// gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
// return gsonBuilder.create();
// }
//
// @Provides
// @Singleton
// MovieRepository provideMovieRepository(Application applicationContext, Gson gson) {
// MovieRepository diskMovieRepository = new DiskMovieRepository(applicationContext, gson);
// return diskMovieRepository;
// }
//
// @Provides
// @Singleton
// GetMoviesUseCase provideGetMoviesUseCase(MovieRepository movieRepository,
// AsyncExecutor asyncExecutor, MainExecutor mainExecutor) {
// GetMoviesUseCase getMoviesUseCase = new GetMoviesUseCase(movieRepository, asyncExecutor,
// mainExecutor);
// return getMoviesUseCase;
// }
//
// @Provides
// @Singleton
// GetMovieDetailUseCase provideGetMovieDetailUseCase(MovieRepository movieRepository,
// AsyncExecutor asyncExecutor, MainExecutor mainExecutor) {
// GetMovieDetailUseCase getMovieDetailUseCase = new GetMovieDetailUseCase(movieRepository,
// asyncExecutor,
// mainExecutor);
// return getMovieDetailUseCase;
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/MoviesApplication.java
import android.app.Application;
import com.xurxodev.moviesandroidkata.di.component.ApplicationComponent;
import com.xurxodev.moviesandroidkata.di.component.DaggerApplicationComponent;
import com.xurxodev.moviesandroidkata.di.module.AppModule;
import com.xurxodev.moviesandroidkata.di.module.DataModule;
package com.xurxodev.moviesandroidkata;
public class MoviesApplication extends Application {
private ApplicationComponent appComponent;
@Override
public void onCreate() {
super.onCreate();
// Dagger%COMPONENT_NAME%
appComponent = DaggerApplicationComponent.builder()
.appModule(new AppModule(this)) | .dataModule(new DataModule()) |
xurxodev/Movies-Android-Kata | app/src/androidTest/java/com/xurxodev/moviesandroidkata/test/MoviesCountFeature.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
// public class MoviesRobot {
// private MoviesActivity activity;
// RecyclerView recyclerView;
// ProgressbarIdlingResource progressbarIdlingResource;
//
// public MoviesRobot(MoviesActivity activity) {
// this.activity = activity;
// this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
// this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
//
// removeAnimateDrawableFromProgressForTest();
// }
//
// public int getNumMoviesRows() {
// return recyclerView.getAdapter().getItemCount();
// }
//
// public MoviesRobot waitForMovies() {
// Espresso.registerIdlingResources(progressbarIdlingResource);
//
// onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
//
// Espresso.unregisterIdlingResources(progressbarIdlingResource);
//
// return this;
// }
//
// public String getMovieTitle(int i) {
// return ((MoviesAdapter) recyclerView.getAdapter()).movies.get(i).getTitle();
// }
//
// public MovieDetailRobot navigateToMovie(int position) {
// onView(withId(R.id.recyclerview_movies))
// .perform(RecyclerViewActions.actionOnItemAtPosition(position, click()));
//
// return new MovieDetailRobot(this);
// }
//
// public MoviesRobot verifyTextWithMoviesCount(int numMovies) {
// String formatCountText = activity.getString(R.string.movies_count_text);
// String expectedText = String.format(formatCountText, numMovies);
//
// onView(withId(R.id.movies_title_text_view)).check(matches(withText(expectedText)));
//
// return this;
// }
//
// public MoviesRobot refreshMovies() {
// onView(withId(R.id.refresh_button)).perform(click());
// return this;
// }
//
// public MoviesRobot verifyLoadingText() {
// String text = activity.getString(R.string.loading_movies_text);
//
// onView(withId(R.id.movies_title_text_view)).check(
// matches(withText(text)));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsVisible() {
// onView(withId(R.id.pb_loading)).check(
// matches(isDisplayed()));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsHide() {
// onView(withId(R.id.pb_loading)).check(
// matches(not(isDisplayed())));
//
// return this;
// }
//
// private void removeAnimateDrawableFromProgressForTest() {
// Drawable notAnimatedDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_refresh);
// ((ProgressBar) activity.findViewById(R.id.pb_loading)).setIndeterminateDrawable(
// notAnimatedDrawable);
//
// }
// }
| import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.robot.MoviesRobot;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith; | package com.xurxodev.moviesandroidkata.test;
@RunWith(AndroidJUnit4.class)
public class MoviesCountFeature {
@Rule | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
// public class MoviesRobot {
// private MoviesActivity activity;
// RecyclerView recyclerView;
// ProgressbarIdlingResource progressbarIdlingResource;
//
// public MoviesRobot(MoviesActivity activity) {
// this.activity = activity;
// this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
// this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
//
// removeAnimateDrawableFromProgressForTest();
// }
//
// public int getNumMoviesRows() {
// return recyclerView.getAdapter().getItemCount();
// }
//
// public MoviesRobot waitForMovies() {
// Espresso.registerIdlingResources(progressbarIdlingResource);
//
// onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
//
// Espresso.unregisterIdlingResources(progressbarIdlingResource);
//
// return this;
// }
//
// public String getMovieTitle(int i) {
// return ((MoviesAdapter) recyclerView.getAdapter()).movies.get(i).getTitle();
// }
//
// public MovieDetailRobot navigateToMovie(int position) {
// onView(withId(R.id.recyclerview_movies))
// .perform(RecyclerViewActions.actionOnItemAtPosition(position, click()));
//
// return new MovieDetailRobot(this);
// }
//
// public MoviesRobot verifyTextWithMoviesCount(int numMovies) {
// String formatCountText = activity.getString(R.string.movies_count_text);
// String expectedText = String.format(formatCountText, numMovies);
//
// onView(withId(R.id.movies_title_text_view)).check(matches(withText(expectedText)));
//
// return this;
// }
//
// public MoviesRobot refreshMovies() {
// onView(withId(R.id.refresh_button)).perform(click());
// return this;
// }
//
// public MoviesRobot verifyLoadingText() {
// String text = activity.getString(R.string.loading_movies_text);
//
// onView(withId(R.id.movies_title_text_view)).check(
// matches(withText(text)));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsVisible() {
// onView(withId(R.id.pb_loading)).check(
// matches(isDisplayed()));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsHide() {
// onView(withId(R.id.pb_loading)).check(
// matches(not(isDisplayed())));
//
// return this;
// }
//
// private void removeAnimateDrawableFromProgressForTest() {
// Drawable notAnimatedDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_refresh);
// ((ProgressBar) activity.findViewById(R.id.pb_loading)).setIndeterminateDrawable(
// notAnimatedDrawable);
//
// }
// }
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/test/MoviesCountFeature.java
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.robot.MoviesRobot;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
package com.xurxodev.moviesandroidkata.test;
@RunWith(AndroidJUnit4.class)
public class MoviesCountFeature {
@Rule | public ActivityTestRule<MoviesActivity> activityTestRule = |
xurxodev/Movies-Android-Kata | app/src/androidTest/java/com/xurxodev/moviesandroidkata/test/MoviesCountFeature.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
// public class MoviesRobot {
// private MoviesActivity activity;
// RecyclerView recyclerView;
// ProgressbarIdlingResource progressbarIdlingResource;
//
// public MoviesRobot(MoviesActivity activity) {
// this.activity = activity;
// this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
// this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
//
// removeAnimateDrawableFromProgressForTest();
// }
//
// public int getNumMoviesRows() {
// return recyclerView.getAdapter().getItemCount();
// }
//
// public MoviesRobot waitForMovies() {
// Espresso.registerIdlingResources(progressbarIdlingResource);
//
// onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
//
// Espresso.unregisterIdlingResources(progressbarIdlingResource);
//
// return this;
// }
//
// public String getMovieTitle(int i) {
// return ((MoviesAdapter) recyclerView.getAdapter()).movies.get(i).getTitle();
// }
//
// public MovieDetailRobot navigateToMovie(int position) {
// onView(withId(R.id.recyclerview_movies))
// .perform(RecyclerViewActions.actionOnItemAtPosition(position, click()));
//
// return new MovieDetailRobot(this);
// }
//
// public MoviesRobot verifyTextWithMoviesCount(int numMovies) {
// String formatCountText = activity.getString(R.string.movies_count_text);
// String expectedText = String.format(formatCountText, numMovies);
//
// onView(withId(R.id.movies_title_text_view)).check(matches(withText(expectedText)));
//
// return this;
// }
//
// public MoviesRobot refreshMovies() {
// onView(withId(R.id.refresh_button)).perform(click());
// return this;
// }
//
// public MoviesRobot verifyLoadingText() {
// String text = activity.getString(R.string.loading_movies_text);
//
// onView(withId(R.id.movies_title_text_view)).check(
// matches(withText(text)));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsVisible() {
// onView(withId(R.id.pb_loading)).check(
// matches(isDisplayed()));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsHide() {
// onView(withId(R.id.pb_loading)).check(
// matches(not(isDisplayed())));
//
// return this;
// }
//
// private void removeAnimateDrawableFromProgressForTest() {
// Drawable notAnimatedDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_refresh);
// ((ProgressBar) activity.findViewById(R.id.pb_loading)).setIndeterminateDrawable(
// notAnimatedDrawable);
//
// }
// }
| import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.robot.MoviesRobot;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith; | package com.xurxodev.moviesandroidkata.test;
@RunWith(AndroidJUnit4.class)
public class MoviesCountFeature {
@Rule
public ActivityTestRule<MoviesActivity> activityTestRule =
new ActivityTestRule<>(MoviesActivity.class);
@Test
public void show_count_text_equal_to_rows_count() { | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
// public class MoviesRobot {
// private MoviesActivity activity;
// RecyclerView recyclerView;
// ProgressbarIdlingResource progressbarIdlingResource;
//
// public MoviesRobot(MoviesActivity activity) {
// this.activity = activity;
// this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
// this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
//
// removeAnimateDrawableFromProgressForTest();
// }
//
// public int getNumMoviesRows() {
// return recyclerView.getAdapter().getItemCount();
// }
//
// public MoviesRobot waitForMovies() {
// Espresso.registerIdlingResources(progressbarIdlingResource);
//
// onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
//
// Espresso.unregisterIdlingResources(progressbarIdlingResource);
//
// return this;
// }
//
// public String getMovieTitle(int i) {
// return ((MoviesAdapter) recyclerView.getAdapter()).movies.get(i).getTitle();
// }
//
// public MovieDetailRobot navigateToMovie(int position) {
// onView(withId(R.id.recyclerview_movies))
// .perform(RecyclerViewActions.actionOnItemAtPosition(position, click()));
//
// return new MovieDetailRobot(this);
// }
//
// public MoviesRobot verifyTextWithMoviesCount(int numMovies) {
// String formatCountText = activity.getString(R.string.movies_count_text);
// String expectedText = String.format(formatCountText, numMovies);
//
// onView(withId(R.id.movies_title_text_view)).check(matches(withText(expectedText)));
//
// return this;
// }
//
// public MoviesRobot refreshMovies() {
// onView(withId(R.id.refresh_button)).perform(click());
// return this;
// }
//
// public MoviesRobot verifyLoadingText() {
// String text = activity.getString(R.string.loading_movies_text);
//
// onView(withId(R.id.movies_title_text_view)).check(
// matches(withText(text)));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsVisible() {
// onView(withId(R.id.pb_loading)).check(
// matches(isDisplayed()));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsHide() {
// onView(withId(R.id.pb_loading)).check(
// matches(not(isDisplayed())));
//
// return this;
// }
//
// private void removeAnimateDrawableFromProgressForTest() {
// Drawable notAnimatedDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_refresh);
// ((ProgressBar) activity.findViewById(R.id.pb_loading)).setIndeterminateDrawable(
// notAnimatedDrawable);
//
// }
// }
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/test/MoviesCountFeature.java
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.robot.MoviesRobot;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
package com.xurxodev.moviesandroidkata.test;
@RunWith(AndroidJUnit4.class)
public class MoviesCountFeature {
@Rule
public ActivityTestRule<MoviesActivity> activityTestRule =
new ActivityTestRule<>(MoviesActivity.class);
@Test
public void show_count_text_equal_to_rows_count() { | MoviesRobot moviesRobot = new MoviesRobot(activityTestRule.getActivity()); |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MovieDetailActivity.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/fragment/MovieDetailFragment.java
// public class MovieDetailFragment extends Fragment implements MovieDetailPresenter.View {
//
// View rootView;
//
// @Inject
// public MovieDetailPresenter presenter;
//
// private RecyclerView recyclerView;
//
//
//
// AppBarLayout appBarLayout;
// private ProgressBar progressBarLoading;
//
// /**
// * Mandatory empty constructor for the fragment manager to instantiate the
// * fragment (e.g. upon screen orientation changes).
// */
// public MovieDetailFragment() {
// }
//
// @Override
// public void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// ((MoviesApplication) getActivity().getApplication()).getAppComponent().activityComponent
// ().activityModule(
// new ActivityModule(getActivity())).build().inject(this);
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Bundle savedInstanceState) {
// rootView = inflater.inflate(R.layout.fragment_movie_detail, container, false);
//
//
// if (getArguments().containsKey(MOVIE_TITLE)) {
//
// String competitorName = (String) getArguments().get(MOVIE_TITLE);
//
// appBarLayout = (AppBarLayout) getActivity().findViewById(R.id.app_bar);
// progressBarLoading = (ProgressBar) getActivity().findViewById(R.id.pb_loading);
//
// initializePresenter(competitorName);
// }
//
// return rootView;
// }
//
// private void initializePresenter(String competitorName) {
// presenter.attachView(this, competitorName);
// }
//
// @Override
// public void renderImage(String image) {
// Activity activity = this.getActivity();
//
// ImageView imgtoolbar = (ImageView) activity.findViewById(R.id.imgToolbar);
//
// if (imgtoolbar != null) {
// Picasso.with(activity.getApplicationContext()).load(image)
// .into(imgtoolbar);
// }
// }
//
// @Override
// public void renderOverview(String biography) {
// ((TextView) rootView.findViewById(R.id.movie_overview_content)).setText(biography);
// }
//
// @Override
// public void renderTitle(String name) {
// //setTitle from background working in phone
// CollapsingToolbarLayout collapsingToolbar =
// (CollapsingToolbarLayout) getActivity().findViewById(R.id.toolbar_layout);
// collapsingToolbar.setTitle(name);
//
// //setTitle from background working in tablet
// getActivity().setTitle(name);
// }
//
// @Override
// public void showLoading() {
// appBarLayout.setVisibility(View.GONE);
// rootView.setVisibility(View.GONE);
// progressBarLoading.setVisibility(View.VISIBLE);
// }
//
// @Override
// public void hideLoading() {
// appBarLayout.setVisibility(View.VISIBLE);
// rootView.setVisibility(View.VISIBLE);
// progressBarLoading.setVisibility(View.GONE);
// }
//
// @Override
// public boolean isReady() {
// return isAdded();
// }
// }
| import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.presentation.view.fragment.MovieDetailFragment; | package com.xurxodev.moviesandroidkata.presentation.view.activity;
public class MovieDetailActivity extends AppCompatActivity {
public static final String MOVIE_TITLE = "MovieTitle";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_movie_detail);
initializeToolBar();
showUpButtonInActionBar();
if (savedInstanceState == null) {
showDetailFragment();
}
}
private void showDetailFragment() {
String movieTitle = (String) getIntent().getStringExtra(MovieDetailActivity.MOVIE_TITLE);
Bundle arguments = new Bundle();
arguments.putSerializable(MovieDetailActivity.MOVIE_TITLE, movieTitle);
| // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/fragment/MovieDetailFragment.java
// public class MovieDetailFragment extends Fragment implements MovieDetailPresenter.View {
//
// View rootView;
//
// @Inject
// public MovieDetailPresenter presenter;
//
// private RecyclerView recyclerView;
//
//
//
// AppBarLayout appBarLayout;
// private ProgressBar progressBarLoading;
//
// /**
// * Mandatory empty constructor for the fragment manager to instantiate the
// * fragment (e.g. upon screen orientation changes).
// */
// public MovieDetailFragment() {
// }
//
// @Override
// public void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// ((MoviesApplication) getActivity().getApplication()).getAppComponent().activityComponent
// ().activityModule(
// new ActivityModule(getActivity())).build().inject(this);
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Bundle savedInstanceState) {
// rootView = inflater.inflate(R.layout.fragment_movie_detail, container, false);
//
//
// if (getArguments().containsKey(MOVIE_TITLE)) {
//
// String competitorName = (String) getArguments().get(MOVIE_TITLE);
//
// appBarLayout = (AppBarLayout) getActivity().findViewById(R.id.app_bar);
// progressBarLoading = (ProgressBar) getActivity().findViewById(R.id.pb_loading);
//
// initializePresenter(competitorName);
// }
//
// return rootView;
// }
//
// private void initializePresenter(String competitorName) {
// presenter.attachView(this, competitorName);
// }
//
// @Override
// public void renderImage(String image) {
// Activity activity = this.getActivity();
//
// ImageView imgtoolbar = (ImageView) activity.findViewById(R.id.imgToolbar);
//
// if (imgtoolbar != null) {
// Picasso.with(activity.getApplicationContext()).load(image)
// .into(imgtoolbar);
// }
// }
//
// @Override
// public void renderOverview(String biography) {
// ((TextView) rootView.findViewById(R.id.movie_overview_content)).setText(biography);
// }
//
// @Override
// public void renderTitle(String name) {
// //setTitle from background working in phone
// CollapsingToolbarLayout collapsingToolbar =
// (CollapsingToolbarLayout) getActivity().findViewById(R.id.toolbar_layout);
// collapsingToolbar.setTitle(name);
//
// //setTitle from background working in tablet
// getActivity().setTitle(name);
// }
//
// @Override
// public void showLoading() {
// appBarLayout.setVisibility(View.GONE);
// rootView.setVisibility(View.GONE);
// progressBarLoading.setVisibility(View.VISIBLE);
// }
//
// @Override
// public void hideLoading() {
// appBarLayout.setVisibility(View.VISIBLE);
// rootView.setVisibility(View.VISIBLE);
// progressBarLoading.setVisibility(View.GONE);
// }
//
// @Override
// public boolean isReady() {
// return isAdded();
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MovieDetailActivity.java
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.presentation.view.fragment.MovieDetailFragment;
package com.xurxodev.moviesandroidkata.presentation.view.activity;
public class MovieDetailActivity extends AppCompatActivity {
public static final String MOVIE_TITLE = "MovieTitle";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_movie_detail);
initializeToolBar();
showUpButtonInActionBar();
if (savedInstanceState == null) {
showDetailFragment();
}
}
private void showDetailFragment() {
String movieTitle = (String) getIntent().getStringExtra(MovieDetailActivity.MOVIE_TITLE);
Bundle arguments = new Bundle();
arguments.putSerializable(MovieDetailActivity.MOVIE_TITLE, movieTitle);
| MovieDetailFragment fragment = new MovieDetailFragment(); |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/data/DiskMovieRepository.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
| import static android.R.attr.name;
import android.app.Application;
import android.content.Context;
import com.google.gson.Gson;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import javax.inject.Inject; | package com.xurxodev.moviesandroidkata.data;
public class DiskMovieRepository implements MovieRepository {
private Context applicationContext;
private Gson gson;
@Inject
public DiskMovieRepository(Application applicationContext, Gson gson){
this.applicationContext = applicationContext;
this.gson = gson;
}
@Override | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/data/DiskMovieRepository.java
import static android.R.attr.name;
import android.app.Application;
import android.content.Context;
import com.google.gson.Gson;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import javax.inject.Inject;
package com.xurxodev.moviesandroidkata.data;
public class DiskMovieRepository implements MovieRepository {
private Context applicationContext;
private Gson gson;
@Inject
public DiskMovieRepository(Application applicationContext, Gson gson){
this.applicationContext = applicationContext;
this.gson = gson;
}
@Override | public List<Movie> getMovies() { |
xurxodev/Movies-Android-Kata | app/src/androidTest/java/com/xurxodev/moviesandroidkata/test/MoviesProgressBarFeature.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
// public class MoviesRobot {
// private MoviesActivity activity;
// RecyclerView recyclerView;
// ProgressbarIdlingResource progressbarIdlingResource;
//
// public MoviesRobot(MoviesActivity activity) {
// this.activity = activity;
// this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
// this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
//
// removeAnimateDrawableFromProgressForTest();
// }
//
// public int getNumMoviesRows() {
// return recyclerView.getAdapter().getItemCount();
// }
//
// public MoviesRobot waitForMovies() {
// Espresso.registerIdlingResources(progressbarIdlingResource);
//
// onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
//
// Espresso.unregisterIdlingResources(progressbarIdlingResource);
//
// return this;
// }
//
// public String getMovieTitle(int i) {
// return ((MoviesAdapter) recyclerView.getAdapter()).movies.get(i).getTitle();
// }
//
// public MovieDetailRobot navigateToMovie(int position) {
// onView(withId(R.id.recyclerview_movies))
// .perform(RecyclerViewActions.actionOnItemAtPosition(position, click()));
//
// return new MovieDetailRobot(this);
// }
//
// public MoviesRobot verifyTextWithMoviesCount(int numMovies) {
// String formatCountText = activity.getString(R.string.movies_count_text);
// String expectedText = String.format(formatCountText, numMovies);
//
// onView(withId(R.id.movies_title_text_view)).check(matches(withText(expectedText)));
//
// return this;
// }
//
// public MoviesRobot refreshMovies() {
// onView(withId(R.id.refresh_button)).perform(click());
// return this;
// }
//
// public MoviesRobot verifyLoadingText() {
// String text = activity.getString(R.string.loading_movies_text);
//
// onView(withId(R.id.movies_title_text_view)).check(
// matches(withText(text)));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsVisible() {
// onView(withId(R.id.pb_loading)).check(
// matches(isDisplayed()));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsHide() {
// onView(withId(R.id.pb_loading)).check(
// matches(not(isDisplayed())));
//
// return this;
// }
//
// private void removeAnimateDrawableFromProgressForTest() {
// Drawable notAnimatedDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_refresh);
// ((ProgressBar) activity.findViewById(R.id.pb_loading)).setIndeterminateDrawable(
// notAnimatedDrawable);
//
// }
// }
| import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.robot.MoviesRobot;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith; | package com.xurxodev.moviesandroidkata.test;
@RunWith(AndroidJUnit4.class)
public class MoviesProgressBarFeature {
@Rule | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
// public class MoviesRobot {
// private MoviesActivity activity;
// RecyclerView recyclerView;
// ProgressbarIdlingResource progressbarIdlingResource;
//
// public MoviesRobot(MoviesActivity activity) {
// this.activity = activity;
// this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
// this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
//
// removeAnimateDrawableFromProgressForTest();
// }
//
// public int getNumMoviesRows() {
// return recyclerView.getAdapter().getItemCount();
// }
//
// public MoviesRobot waitForMovies() {
// Espresso.registerIdlingResources(progressbarIdlingResource);
//
// onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
//
// Espresso.unregisterIdlingResources(progressbarIdlingResource);
//
// return this;
// }
//
// public String getMovieTitle(int i) {
// return ((MoviesAdapter) recyclerView.getAdapter()).movies.get(i).getTitle();
// }
//
// public MovieDetailRobot navigateToMovie(int position) {
// onView(withId(R.id.recyclerview_movies))
// .perform(RecyclerViewActions.actionOnItemAtPosition(position, click()));
//
// return new MovieDetailRobot(this);
// }
//
// public MoviesRobot verifyTextWithMoviesCount(int numMovies) {
// String formatCountText = activity.getString(R.string.movies_count_text);
// String expectedText = String.format(formatCountText, numMovies);
//
// onView(withId(R.id.movies_title_text_view)).check(matches(withText(expectedText)));
//
// return this;
// }
//
// public MoviesRobot refreshMovies() {
// onView(withId(R.id.refresh_button)).perform(click());
// return this;
// }
//
// public MoviesRobot verifyLoadingText() {
// String text = activity.getString(R.string.loading_movies_text);
//
// onView(withId(R.id.movies_title_text_view)).check(
// matches(withText(text)));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsVisible() {
// onView(withId(R.id.pb_loading)).check(
// matches(isDisplayed()));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsHide() {
// onView(withId(R.id.pb_loading)).check(
// matches(not(isDisplayed())));
//
// return this;
// }
//
// private void removeAnimateDrawableFromProgressForTest() {
// Drawable notAnimatedDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_refresh);
// ((ProgressBar) activity.findViewById(R.id.pb_loading)).setIndeterminateDrawable(
// notAnimatedDrawable);
//
// }
// }
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/test/MoviesProgressBarFeature.java
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.robot.MoviesRobot;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
package com.xurxodev.moviesandroidkata.test;
@RunWith(AndroidJUnit4.class)
public class MoviesProgressBarFeature {
@Rule | public ActivityTestRule<MoviesActivity> activityTestRule = |
xurxodev/Movies-Android-Kata | app/src/androidTest/java/com/xurxodev/moviesandroidkata/test/MoviesProgressBarFeature.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
// public class MoviesRobot {
// private MoviesActivity activity;
// RecyclerView recyclerView;
// ProgressbarIdlingResource progressbarIdlingResource;
//
// public MoviesRobot(MoviesActivity activity) {
// this.activity = activity;
// this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
// this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
//
// removeAnimateDrawableFromProgressForTest();
// }
//
// public int getNumMoviesRows() {
// return recyclerView.getAdapter().getItemCount();
// }
//
// public MoviesRobot waitForMovies() {
// Espresso.registerIdlingResources(progressbarIdlingResource);
//
// onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
//
// Espresso.unregisterIdlingResources(progressbarIdlingResource);
//
// return this;
// }
//
// public String getMovieTitle(int i) {
// return ((MoviesAdapter) recyclerView.getAdapter()).movies.get(i).getTitle();
// }
//
// public MovieDetailRobot navigateToMovie(int position) {
// onView(withId(R.id.recyclerview_movies))
// .perform(RecyclerViewActions.actionOnItemAtPosition(position, click()));
//
// return new MovieDetailRobot(this);
// }
//
// public MoviesRobot verifyTextWithMoviesCount(int numMovies) {
// String formatCountText = activity.getString(R.string.movies_count_text);
// String expectedText = String.format(formatCountText, numMovies);
//
// onView(withId(R.id.movies_title_text_view)).check(matches(withText(expectedText)));
//
// return this;
// }
//
// public MoviesRobot refreshMovies() {
// onView(withId(R.id.refresh_button)).perform(click());
// return this;
// }
//
// public MoviesRobot verifyLoadingText() {
// String text = activity.getString(R.string.loading_movies_text);
//
// onView(withId(R.id.movies_title_text_view)).check(
// matches(withText(text)));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsVisible() {
// onView(withId(R.id.pb_loading)).check(
// matches(isDisplayed()));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsHide() {
// onView(withId(R.id.pb_loading)).check(
// matches(not(isDisplayed())));
//
// return this;
// }
//
// private void removeAnimateDrawableFromProgressForTest() {
// Drawable notAnimatedDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_refresh);
// ((ProgressBar) activity.findViewById(R.id.pb_loading)).setIndeterminateDrawable(
// notAnimatedDrawable);
//
// }
// }
| import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.robot.MoviesRobot;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith; | package com.xurxodev.moviesandroidkata.test;
@RunWith(AndroidJUnit4.class)
public class MoviesProgressBarFeature {
@Rule
public ActivityTestRule<MoviesActivity> activityTestRule =
new ActivityTestRule<>(MoviesActivity.class);
@Test
public void show_loading_text_while_retrieve_movies() { | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movies);
//
// initializeToolBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// MoviesFragment fragment = new MoviesFragment();
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movies_list_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
// }
// }
//
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
// public class MoviesRobot {
// private MoviesActivity activity;
// RecyclerView recyclerView;
// ProgressbarIdlingResource progressbarIdlingResource;
//
// public MoviesRobot(MoviesActivity activity) {
// this.activity = activity;
// this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
// this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);
//
// removeAnimateDrawableFromProgressForTest();
// }
//
// public int getNumMoviesRows() {
// return recyclerView.getAdapter().getItemCount();
// }
//
// public MoviesRobot waitForMovies() {
// Espresso.registerIdlingResources(progressbarIdlingResource);
//
// onView(withId(R.id.recyclerview_movies)).check(matches(isDisplayed()));
//
// Espresso.unregisterIdlingResources(progressbarIdlingResource);
//
// return this;
// }
//
// public String getMovieTitle(int i) {
// return ((MoviesAdapter) recyclerView.getAdapter()).movies.get(i).getTitle();
// }
//
// public MovieDetailRobot navigateToMovie(int position) {
// onView(withId(R.id.recyclerview_movies))
// .perform(RecyclerViewActions.actionOnItemAtPosition(position, click()));
//
// return new MovieDetailRobot(this);
// }
//
// public MoviesRobot verifyTextWithMoviesCount(int numMovies) {
// String formatCountText = activity.getString(R.string.movies_count_text);
// String expectedText = String.format(formatCountText, numMovies);
//
// onView(withId(R.id.movies_title_text_view)).check(matches(withText(expectedText)));
//
// return this;
// }
//
// public MoviesRobot refreshMovies() {
// onView(withId(R.id.refresh_button)).perform(click());
// return this;
// }
//
// public MoviesRobot verifyLoadingText() {
// String text = activity.getString(R.string.loading_movies_text);
//
// onView(withId(R.id.movies_title_text_view)).check(
// matches(withText(text)));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsVisible() {
// onView(withId(R.id.pb_loading)).check(
// matches(isDisplayed()));
//
// return this;
// }
//
// public MoviesRobot verifyProgressIsHide() {
// onView(withId(R.id.pb_loading)).check(
// matches(not(isDisplayed())));
//
// return this;
// }
//
// private void removeAnimateDrawableFromProgressForTest() {
// Drawable notAnimatedDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_refresh);
// ((ProgressBar) activity.findViewById(R.id.pb_loading)).setIndeterminateDrawable(
// notAnimatedDrawable);
//
// }
// }
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/test/MoviesProgressBarFeature.java
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.robot.MoviesRobot;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
package com.xurxodev.moviesandroidkata.test;
@RunWith(AndroidJUnit4.class)
public class MoviesProgressBarFeature {
@Rule
public ActivityTestRule<MoviesActivity> activityTestRule =
new ActivityTestRule<>(MoviesActivity.class);
@Test
public void show_loading_text_while_retrieve_movies() { | MoviesRobot moviesRobot = new MoviesRobot(activityTestRule.getActivity()); |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMoviesUseCase.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
| import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import java.util.List; | package com.xurxodev.moviesandroidkata.domain.usecase;
public class GetMoviesUseCase implements UseCase {
public interface Callback { | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMoviesUseCase.java
import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import java.util.List;
package com.xurxodev.moviesandroidkata.domain.usecase;
public class GetMoviesUseCase implements UseCase {
public interface Callback { | void onMoviesLoaded(List<Movie> movies); |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMoviesUseCase.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
| import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import java.util.List; | package com.xurxodev.moviesandroidkata.domain.usecase;
public class GetMoviesUseCase implements UseCase {
public interface Callback {
void onMoviesLoaded(List<Movie> movies);
void onConnectionError();
}
| // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMoviesUseCase.java
import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import java.util.List;
package com.xurxodev.moviesandroidkata.domain.usecase;
public class GetMoviesUseCase implements UseCase {
public interface Callback {
void onMoviesLoaded(List<Movie> movies);
void onConnectionError();
}
| private MovieRepository movieRepository; |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMoviesUseCase.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
| import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import java.util.List; | package com.xurxodev.moviesandroidkata.domain.usecase;
public class GetMoviesUseCase implements UseCase {
public interface Callback {
void onMoviesLoaded(List<Movie> movies);
void onConnectionError();
}
private MovieRepository movieRepository; | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMoviesUseCase.java
import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import java.util.List;
package com.xurxodev.moviesandroidkata.domain.usecase;
public class GetMoviesUseCase implements UseCase {
public interface Callback {
void onMoviesLoaded(List<Movie> movies);
void onConnectionError();
}
private MovieRepository movieRepository; | private AsyncExecutor asyncExecutor; |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMoviesUseCase.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
| import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import java.util.List; | package com.xurxodev.moviesandroidkata.domain.usecase;
public class GetMoviesUseCase implements UseCase {
public interface Callback {
void onMoviesLoaded(List<Movie> movies);
void onConnectionError();
}
private MovieRepository movieRepository;
private AsyncExecutor asyncExecutor; | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/Repository/MovieRepository.java
// public interface MovieRepository {
// List<Movie> getMovies();
//
// Movie getMovieByTitle(String movieTitle);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/MainExecutor.java
// public interface MainExecutor {
// void run(final Runnable runnable);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMoviesUseCase.java
import com.xurxodev.moviesandroidkata.domain.boundary.repository.MovieRepository;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.boundary.executor.MainExecutor;
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import java.util.List;
package com.xurxodev.moviesandroidkata.domain.usecase;
public class GetMoviesUseCase implements UseCase {
public interface Callback {
void onMoviesLoaded(List<Movie> movies);
void onConnectionError();
}
private MovieRepository movieRepository;
private AsyncExecutor asyncExecutor; | private MainExecutor mainExecutor; |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/MoviesPresenter.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMoviesUseCase.java
// public class GetMoviesUseCase implements UseCase {
// public interface Callback {
// void onMoviesLoaded(List<Movie> movies);
//
// void onConnectionError();
// }
//
// private MovieRepository movieRepository;
// private AsyncExecutor asyncExecutor;
// private MainExecutor mainExecutor;
// private Callback callback;
//
// public GetMoviesUseCase(MovieRepository movieRepository, AsyncExecutor asyncExecutor,
// MainExecutor mainExecutor) {
// this.movieRepository = movieRepository;
// this.mainExecutor = mainExecutor;
// this.asyncExecutor = asyncExecutor;
// }
//
// public void execute(final Callback callback) {
// this.callback = callback;
//
// asyncExecutor.run(this);
// }
//
// @Override
// public void run() {
// try {
// List<Movie> movies = movieRepository.getMovies();
//
// notifyMoviesLoaded(movies);
// } catch (Exception ex) {
// notifyConnectionError();
// }
// }
//
// private void notifyConnectionError() {
// mainExecutor.run(new Runnable() {
// @Override
// public void run() {
// callback.onConnectionError();
// }
// });
// }
//
// private void notifyMoviesLoaded(final List<Movie> movies) {
// mainExecutor.run(new Runnable() {
// @Override
// public void run() {
// callback.onMoviesLoaded(movies);
// }
// });
// }
//
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/boundary/Navigator.java
// public interface Navigator {
// void openMovieDetail(Movie movie);
// }
| import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import com.xurxodev.moviesandroidkata.domain.usecase.GetMoviesUseCase;
import com.xurxodev.moviesandroidkata.presentation.presenter.boundary.Navigator;
import java.util.List;
import javax.inject.Inject; | package com.xurxodev.moviesandroidkata.presentation.presenter;
public class MoviesPresenter {
GetMoviesUseCase getMoviesUseCase; | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMoviesUseCase.java
// public class GetMoviesUseCase implements UseCase {
// public interface Callback {
// void onMoviesLoaded(List<Movie> movies);
//
// void onConnectionError();
// }
//
// private MovieRepository movieRepository;
// private AsyncExecutor asyncExecutor;
// private MainExecutor mainExecutor;
// private Callback callback;
//
// public GetMoviesUseCase(MovieRepository movieRepository, AsyncExecutor asyncExecutor,
// MainExecutor mainExecutor) {
// this.movieRepository = movieRepository;
// this.mainExecutor = mainExecutor;
// this.asyncExecutor = asyncExecutor;
// }
//
// public void execute(final Callback callback) {
// this.callback = callback;
//
// asyncExecutor.run(this);
// }
//
// @Override
// public void run() {
// try {
// List<Movie> movies = movieRepository.getMovies();
//
// notifyMoviesLoaded(movies);
// } catch (Exception ex) {
// notifyConnectionError();
// }
// }
//
// private void notifyConnectionError() {
// mainExecutor.run(new Runnable() {
// @Override
// public void run() {
// callback.onConnectionError();
// }
// });
// }
//
// private void notifyMoviesLoaded(final List<Movie> movies) {
// mainExecutor.run(new Runnable() {
// @Override
// public void run() {
// callback.onMoviesLoaded(movies);
// }
// });
// }
//
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/boundary/Navigator.java
// public interface Navigator {
// void openMovieDetail(Movie movie);
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/MoviesPresenter.java
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import com.xurxodev.moviesandroidkata.domain.usecase.GetMoviesUseCase;
import com.xurxodev.moviesandroidkata.presentation.presenter.boundary.Navigator;
import java.util.List;
import javax.inject.Inject;
package com.xurxodev.moviesandroidkata.presentation.presenter;
public class MoviesPresenter {
GetMoviesUseCase getMoviesUseCase; | Navigator navigator; |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/MoviesPresenter.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMoviesUseCase.java
// public class GetMoviesUseCase implements UseCase {
// public interface Callback {
// void onMoviesLoaded(List<Movie> movies);
//
// void onConnectionError();
// }
//
// private MovieRepository movieRepository;
// private AsyncExecutor asyncExecutor;
// private MainExecutor mainExecutor;
// private Callback callback;
//
// public GetMoviesUseCase(MovieRepository movieRepository, AsyncExecutor asyncExecutor,
// MainExecutor mainExecutor) {
// this.movieRepository = movieRepository;
// this.mainExecutor = mainExecutor;
// this.asyncExecutor = asyncExecutor;
// }
//
// public void execute(final Callback callback) {
// this.callback = callback;
//
// asyncExecutor.run(this);
// }
//
// @Override
// public void run() {
// try {
// List<Movie> movies = movieRepository.getMovies();
//
// notifyMoviesLoaded(movies);
// } catch (Exception ex) {
// notifyConnectionError();
// }
// }
//
// private void notifyConnectionError() {
// mainExecutor.run(new Runnable() {
// @Override
// public void run() {
// callback.onConnectionError();
// }
// });
// }
//
// private void notifyMoviesLoaded(final List<Movie> movies) {
// mainExecutor.run(new Runnable() {
// @Override
// public void run() {
// callback.onMoviesLoaded(movies);
// }
// });
// }
//
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/boundary/Navigator.java
// public interface Navigator {
// void openMovieDetail(Movie movie);
// }
| import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import com.xurxodev.moviesandroidkata.domain.usecase.GetMoviesUseCase;
import com.xurxodev.moviesandroidkata.presentation.presenter.boundary.Navigator;
import java.util.List;
import javax.inject.Inject; | package com.xurxodev.moviesandroidkata.presentation.presenter;
public class MoviesPresenter {
GetMoviesUseCase getMoviesUseCase;
Navigator navigator;
MoviesView view;
@Inject
public MoviesPresenter(Navigator navigator,GetMoviesUseCase getMoviesUseCase) {
this.navigator = navigator;
this.getMoviesUseCase = getMoviesUseCase;
}
public void attachView(MoviesView moviesView) {
this.view = moviesView;
loadMovies();
}
private void loadMovies() {
loadingMovies();
getMoviesUseCase.execute(new GetMoviesUseCase.Callback() {
@Override | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/GetMoviesUseCase.java
// public class GetMoviesUseCase implements UseCase {
// public interface Callback {
// void onMoviesLoaded(List<Movie> movies);
//
// void onConnectionError();
// }
//
// private MovieRepository movieRepository;
// private AsyncExecutor asyncExecutor;
// private MainExecutor mainExecutor;
// private Callback callback;
//
// public GetMoviesUseCase(MovieRepository movieRepository, AsyncExecutor asyncExecutor,
// MainExecutor mainExecutor) {
// this.movieRepository = movieRepository;
// this.mainExecutor = mainExecutor;
// this.asyncExecutor = asyncExecutor;
// }
//
// public void execute(final Callback callback) {
// this.callback = callback;
//
// asyncExecutor.run(this);
// }
//
// @Override
// public void run() {
// try {
// List<Movie> movies = movieRepository.getMovies();
//
// notifyMoviesLoaded(movies);
// } catch (Exception ex) {
// notifyConnectionError();
// }
// }
//
// private void notifyConnectionError() {
// mainExecutor.run(new Runnable() {
// @Override
// public void run() {
// callback.onConnectionError();
// }
// });
// }
//
// private void notifyMoviesLoaded(final List<Movie> movies) {
// mainExecutor.run(new Runnable() {
// @Override
// public void run() {
// callback.onMoviesLoaded(movies);
// }
// });
// }
//
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/boundary/Navigator.java
// public interface Navigator {
// void openMovieDetail(Movie movie);
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/MoviesPresenter.java
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import com.xurxodev.moviesandroidkata.domain.usecase.GetMoviesUseCase;
import com.xurxodev.moviesandroidkata.presentation.presenter.boundary.Navigator;
import java.util.List;
import javax.inject.Inject;
package com.xurxodev.moviesandroidkata.presentation.presenter;
public class MoviesPresenter {
GetMoviesUseCase getMoviesUseCase;
Navigator navigator;
MoviesView view;
@Inject
public MoviesPresenter(Navigator navigator,GetMoviesUseCase getMoviesUseCase) {
this.navigator = navigator;
this.getMoviesUseCase = getMoviesUseCase;
}
public void attachView(MoviesView moviesView) {
this.view = moviesView;
loadMovies();
}
private void loadMovies() {
loadingMovies();
getMoviesUseCase.execute(new GetMoviesUseCase.Callback() {
@Override | public void onMoviesLoaded(List<Movie> movies) { |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/fragment/MovieDetailFragment.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/MoviesApplication.java
// public class MoviesApplication extends Application {
// private ApplicationComponent appComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Dagger%COMPONENT_NAME%
// appComponent = DaggerApplicationComponent.builder()
// .appModule(new AppModule(this))
// .dataModule(new DataModule())
// .build();
//
// }
//
// public ApplicationComponent getAppComponent() {
// return appComponent;
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/module/ActivityModule.java
// @Module
// public class ActivityModule {
// private final Activity activityContext;
//
// public ActivityModule(Activity activityContext) {
// this.activityContext = activityContext;
// }
//
// @Provides
// @ActivityScope
// Activity provideActivityContext() {
// return this.activityContext;
// }
//
// @Provides
// @ActivityScope
// Navigator provideNavigator(Activity activityContext) {
// return new TransitionAnimationNavigator(activityContext);
// }
//
// @Provides
// @ActivityScope
// MoviesPresenter provideMoviesPresenter(
// Navigator navigator, GetMoviesUseCase getGetMoviesUseCase) {
// return new MoviesPresenter(navigator, getGetMoviesUseCase);
// }
//
// @Provides
// @ActivityScope
// MovieDetailPresenter provideMovieDetailPresenter(GetMovieDetailUseCase getMovieDetailUseCase) {
// return new MovieDetailPresenter(getMovieDetailUseCase);
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/MovieDetailPresenter.java
// public class MovieDetailPresenter {
//
// private View view;
// private GetMovieDetailUseCase getMovieDetailUseCase;
//
//
// private Movie movie;
//
// public MovieDetailPresenter(GetMovieDetailUseCase getCompetitorDetailsUseCase) {
// this.getMovieDetailUseCase = getCompetitorDetailsUseCase;
// }
//
// public void attachView(View view, String movieName) {
// if (view == null) {
// throw new IllegalArgumentException("You can't set a null view");
// }
// this.view = view;
// loadCompetitor(movieName);
// }
//
// public void loadCompetitor(String movieTitle) {
// view.showLoading();
//
// getMovieDetailUseCase.execute(movieTitle,
// new GetMovieDetailUseCase.Callback() {
// @Override
// public void onCompetitorDetailLoaded(Movie retrievedMovie) {
//
// movie = retrievedMovie;
//
// if (view.isReady()) {
// view.hideLoading();
// view.renderImage(movie.getImage());
// view.renderOverview(movie.getOverview());
// view.renderTitle(movie.getTitle());
// }
// }
//
// @Override
// public void onCompetitorDetailNotFound() {
// view.hideLoading();
// //TODO: show message in view
// }
//
// @Override
// public void onConnectionError() {
// view.hideLoading();
// //TODO: show message in view
// }
// });
//
// }
//
//
// public interface View {
// void renderImage(String image);
//
// void renderOverview(String biography);
//
// void renderTitle(String title);
//
// void showLoading();
//
// void hideLoading();
//
// boolean isReady();
// }
// }
| import static com.xurxodev.moviesandroidkata.presentation.view.activity.MovieDetailActivity
.MOVIE_TITLE;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import com.xurxodev.moviesandroidkata.MoviesApplication;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.di.module.ActivityModule;
import com.xurxodev.moviesandroidkata.presentation.presenter.MovieDetailPresenter;
import javax.inject.Inject; | package com.xurxodev.moviesandroidkata.presentation.view.fragment;
public class MovieDetailFragment extends Fragment implements MovieDetailPresenter.View {
View rootView;
@Inject
public MovieDetailPresenter presenter;
private RecyclerView recyclerView;
AppBarLayout appBarLayout;
private ProgressBar progressBarLoading;
/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
*/
public MovieDetailFragment() {
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
| // Path: app/src/main/java/com/xurxodev/moviesandroidkata/MoviesApplication.java
// public class MoviesApplication extends Application {
// private ApplicationComponent appComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Dagger%COMPONENT_NAME%
// appComponent = DaggerApplicationComponent.builder()
// .appModule(new AppModule(this))
// .dataModule(new DataModule())
// .build();
//
// }
//
// public ApplicationComponent getAppComponent() {
// return appComponent;
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/module/ActivityModule.java
// @Module
// public class ActivityModule {
// private final Activity activityContext;
//
// public ActivityModule(Activity activityContext) {
// this.activityContext = activityContext;
// }
//
// @Provides
// @ActivityScope
// Activity provideActivityContext() {
// return this.activityContext;
// }
//
// @Provides
// @ActivityScope
// Navigator provideNavigator(Activity activityContext) {
// return new TransitionAnimationNavigator(activityContext);
// }
//
// @Provides
// @ActivityScope
// MoviesPresenter provideMoviesPresenter(
// Navigator navigator, GetMoviesUseCase getGetMoviesUseCase) {
// return new MoviesPresenter(navigator, getGetMoviesUseCase);
// }
//
// @Provides
// @ActivityScope
// MovieDetailPresenter provideMovieDetailPresenter(GetMovieDetailUseCase getMovieDetailUseCase) {
// return new MovieDetailPresenter(getMovieDetailUseCase);
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/MovieDetailPresenter.java
// public class MovieDetailPresenter {
//
// private View view;
// private GetMovieDetailUseCase getMovieDetailUseCase;
//
//
// private Movie movie;
//
// public MovieDetailPresenter(GetMovieDetailUseCase getCompetitorDetailsUseCase) {
// this.getMovieDetailUseCase = getCompetitorDetailsUseCase;
// }
//
// public void attachView(View view, String movieName) {
// if (view == null) {
// throw new IllegalArgumentException("You can't set a null view");
// }
// this.view = view;
// loadCompetitor(movieName);
// }
//
// public void loadCompetitor(String movieTitle) {
// view.showLoading();
//
// getMovieDetailUseCase.execute(movieTitle,
// new GetMovieDetailUseCase.Callback() {
// @Override
// public void onCompetitorDetailLoaded(Movie retrievedMovie) {
//
// movie = retrievedMovie;
//
// if (view.isReady()) {
// view.hideLoading();
// view.renderImage(movie.getImage());
// view.renderOverview(movie.getOverview());
// view.renderTitle(movie.getTitle());
// }
// }
//
// @Override
// public void onCompetitorDetailNotFound() {
// view.hideLoading();
// //TODO: show message in view
// }
//
// @Override
// public void onConnectionError() {
// view.hideLoading();
// //TODO: show message in view
// }
// });
//
// }
//
//
// public interface View {
// void renderImage(String image);
//
// void renderOverview(String biography);
//
// void renderTitle(String title);
//
// void showLoading();
//
// void hideLoading();
//
// boolean isReady();
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/fragment/MovieDetailFragment.java
import static com.xurxodev.moviesandroidkata.presentation.view.activity.MovieDetailActivity
.MOVIE_TITLE;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import com.xurxodev.moviesandroidkata.MoviesApplication;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.di.module.ActivityModule;
import com.xurxodev.moviesandroidkata.presentation.presenter.MovieDetailPresenter;
import javax.inject.Inject;
package com.xurxodev.moviesandroidkata.presentation.view.fragment;
public class MovieDetailFragment extends Fragment implements MovieDetailPresenter.View {
View rootView;
@Inject
public MovieDetailPresenter presenter;
private RecyclerView recyclerView;
AppBarLayout appBarLayout;
private ProgressBar progressBarLoading;
/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
*/
public MovieDetailFragment() {
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
| ((MoviesApplication) getActivity().getApplication()).getAppComponent().activityComponent |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/fragment/MovieDetailFragment.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/MoviesApplication.java
// public class MoviesApplication extends Application {
// private ApplicationComponent appComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Dagger%COMPONENT_NAME%
// appComponent = DaggerApplicationComponent.builder()
// .appModule(new AppModule(this))
// .dataModule(new DataModule())
// .build();
//
// }
//
// public ApplicationComponent getAppComponent() {
// return appComponent;
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/module/ActivityModule.java
// @Module
// public class ActivityModule {
// private final Activity activityContext;
//
// public ActivityModule(Activity activityContext) {
// this.activityContext = activityContext;
// }
//
// @Provides
// @ActivityScope
// Activity provideActivityContext() {
// return this.activityContext;
// }
//
// @Provides
// @ActivityScope
// Navigator provideNavigator(Activity activityContext) {
// return new TransitionAnimationNavigator(activityContext);
// }
//
// @Provides
// @ActivityScope
// MoviesPresenter provideMoviesPresenter(
// Navigator navigator, GetMoviesUseCase getGetMoviesUseCase) {
// return new MoviesPresenter(navigator, getGetMoviesUseCase);
// }
//
// @Provides
// @ActivityScope
// MovieDetailPresenter provideMovieDetailPresenter(GetMovieDetailUseCase getMovieDetailUseCase) {
// return new MovieDetailPresenter(getMovieDetailUseCase);
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/MovieDetailPresenter.java
// public class MovieDetailPresenter {
//
// private View view;
// private GetMovieDetailUseCase getMovieDetailUseCase;
//
//
// private Movie movie;
//
// public MovieDetailPresenter(GetMovieDetailUseCase getCompetitorDetailsUseCase) {
// this.getMovieDetailUseCase = getCompetitorDetailsUseCase;
// }
//
// public void attachView(View view, String movieName) {
// if (view == null) {
// throw new IllegalArgumentException("You can't set a null view");
// }
// this.view = view;
// loadCompetitor(movieName);
// }
//
// public void loadCompetitor(String movieTitle) {
// view.showLoading();
//
// getMovieDetailUseCase.execute(movieTitle,
// new GetMovieDetailUseCase.Callback() {
// @Override
// public void onCompetitorDetailLoaded(Movie retrievedMovie) {
//
// movie = retrievedMovie;
//
// if (view.isReady()) {
// view.hideLoading();
// view.renderImage(movie.getImage());
// view.renderOverview(movie.getOverview());
// view.renderTitle(movie.getTitle());
// }
// }
//
// @Override
// public void onCompetitorDetailNotFound() {
// view.hideLoading();
// //TODO: show message in view
// }
//
// @Override
// public void onConnectionError() {
// view.hideLoading();
// //TODO: show message in view
// }
// });
//
// }
//
//
// public interface View {
// void renderImage(String image);
//
// void renderOverview(String biography);
//
// void renderTitle(String title);
//
// void showLoading();
//
// void hideLoading();
//
// boolean isReady();
// }
// }
| import static com.xurxodev.moviesandroidkata.presentation.view.activity.MovieDetailActivity
.MOVIE_TITLE;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import com.xurxodev.moviesandroidkata.MoviesApplication;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.di.module.ActivityModule;
import com.xurxodev.moviesandroidkata.presentation.presenter.MovieDetailPresenter;
import javax.inject.Inject; | package com.xurxodev.moviesandroidkata.presentation.view.fragment;
public class MovieDetailFragment extends Fragment implements MovieDetailPresenter.View {
View rootView;
@Inject
public MovieDetailPresenter presenter;
private RecyclerView recyclerView;
AppBarLayout appBarLayout;
private ProgressBar progressBarLoading;
/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
*/
public MovieDetailFragment() {
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((MoviesApplication) getActivity().getApplication()).getAppComponent().activityComponent
().activityModule( | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/MoviesApplication.java
// public class MoviesApplication extends Application {
// private ApplicationComponent appComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// // Dagger%COMPONENT_NAME%
// appComponent = DaggerApplicationComponent.builder()
// .appModule(new AppModule(this))
// .dataModule(new DataModule())
// .build();
//
// }
//
// public ApplicationComponent getAppComponent() {
// return appComponent;
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/di/module/ActivityModule.java
// @Module
// public class ActivityModule {
// private final Activity activityContext;
//
// public ActivityModule(Activity activityContext) {
// this.activityContext = activityContext;
// }
//
// @Provides
// @ActivityScope
// Activity provideActivityContext() {
// return this.activityContext;
// }
//
// @Provides
// @ActivityScope
// Navigator provideNavigator(Activity activityContext) {
// return new TransitionAnimationNavigator(activityContext);
// }
//
// @Provides
// @ActivityScope
// MoviesPresenter provideMoviesPresenter(
// Navigator navigator, GetMoviesUseCase getGetMoviesUseCase) {
// return new MoviesPresenter(navigator, getGetMoviesUseCase);
// }
//
// @Provides
// @ActivityScope
// MovieDetailPresenter provideMovieDetailPresenter(GetMovieDetailUseCase getMovieDetailUseCase) {
// return new MovieDetailPresenter(getMovieDetailUseCase);
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/MovieDetailPresenter.java
// public class MovieDetailPresenter {
//
// private View view;
// private GetMovieDetailUseCase getMovieDetailUseCase;
//
//
// private Movie movie;
//
// public MovieDetailPresenter(GetMovieDetailUseCase getCompetitorDetailsUseCase) {
// this.getMovieDetailUseCase = getCompetitorDetailsUseCase;
// }
//
// public void attachView(View view, String movieName) {
// if (view == null) {
// throw new IllegalArgumentException("You can't set a null view");
// }
// this.view = view;
// loadCompetitor(movieName);
// }
//
// public void loadCompetitor(String movieTitle) {
// view.showLoading();
//
// getMovieDetailUseCase.execute(movieTitle,
// new GetMovieDetailUseCase.Callback() {
// @Override
// public void onCompetitorDetailLoaded(Movie retrievedMovie) {
//
// movie = retrievedMovie;
//
// if (view.isReady()) {
// view.hideLoading();
// view.renderImage(movie.getImage());
// view.renderOverview(movie.getOverview());
// view.renderTitle(movie.getTitle());
// }
// }
//
// @Override
// public void onCompetitorDetailNotFound() {
// view.hideLoading();
// //TODO: show message in view
// }
//
// @Override
// public void onConnectionError() {
// view.hideLoading();
// //TODO: show message in view
// }
// });
//
// }
//
//
// public interface View {
// void renderImage(String image);
//
// void renderOverview(String biography);
//
// void renderTitle(String title);
//
// void showLoading();
//
// void hideLoading();
//
// boolean isReady();
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/fragment/MovieDetailFragment.java
import static com.xurxodev.moviesandroidkata.presentation.view.activity.MovieDetailActivity
.MOVIE_TITLE;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import com.xurxodev.moviesandroidkata.MoviesApplication;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.di.module.ActivityModule;
import com.xurxodev.moviesandroidkata.presentation.presenter.MovieDetailPresenter;
import javax.inject.Inject;
package com.xurxodev.moviesandroidkata.presentation.view.fragment;
public class MovieDetailFragment extends Fragment implements MovieDetailPresenter.View {
View rootView;
@Inject
public MovieDetailPresenter presenter;
private RecyclerView recyclerView;
AppBarLayout appBarLayout;
private ProgressBar progressBarLoading;
/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
*/
public MovieDetailFragment() {
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((MoviesApplication) getActivity().getApplication()).getAppComponent().activityComponent
().activityModule( | new ActivityModule(getActivity())).build().inject(this); |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/presentation/navigator/TransitionAnimationNavigator.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/boundary/Navigator.java
// public interface Navigator {
// void openMovieDetail(Movie movie);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MovieDetailActivity.java
// public class MovieDetailActivity extends AppCompatActivity {
//
// public static final String MOVIE_TITLE = "MovieTitle";
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movie_detail);
//
// initializeToolBar();
// showUpButtonInActionBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// String movieTitle = (String) getIntent().getStringExtra(MovieDetailActivity.MOVIE_TITLE);
//
// Bundle arguments = new Bundle();
// arguments.putSerializable(MovieDetailActivity.MOVIE_TITLE, movieTitle);
//
// MovieDetailFragment fragment = new MovieDetailFragment();
//
// fragment.setArguments(arguments);
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movie_detail_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.detail_toolbar);
// setSupportActionBar(toolbar);
// }
//
// private void showUpButtonInActionBar() {
// ActionBar actionBar = getSupportActionBar();
// if (actionBar != null) {
// actionBar.setDisplayHomeAsUpEnabled(true);
// }
// }
//
// public static Intent createIntent(Context context, String movieTitle) {
// Intent intent = new Intent(context, MovieDetailActivity.class);
//
// intent.putExtra(MOVIE_TITLE, movieTitle);
//
// return intent;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// int id = item.getItemId();
//
// if (id == android.R.id.home) {
// supportFinishAfterTransition();
//
// return true;
// }
// return super.onOptionsItemSelected(item);
//
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/adapter/MoviesAdapter.java
// public class MoviesAdapter
// extends RecyclerView.Adapter<MoviesAdapter.ViewHolder> {
//
// public interface OnMovieClickListener {
// void onItemClick(View view, Movie movie);
// }
//
// private OnMovieClickListener onMovieClickListener;
//
// public List<Movie> movies = new ArrayList<>();
//
// public void setMovies(List<Movie> movies) {
// this.movies = movies;
// notifyDataSetChanged();
// }
//
// public void clearMovies() {
// movies = new ArrayList<>();
// notifyDataSetChanged();
// }
//
// public void setOnMovieClickListener(OnMovieClickListener listener) {
// onMovieClickListener = listener;
// }
//
// @Override
// public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View view = LayoutInflater.from(parent.getContext())
// .inflate(R.layout.item_movies, parent, false);
//
// return new ViewHolder(view);
// }
//
// @Override
// public void onBindViewHolder(final ViewHolder holder, final int position) {
// holder.movieItem = movies.get(position);
//
// Picasso.with(holder.movieImageView.getContext())
// .load(holder.movieItem.getImage())
// .into(holder.movieImageView);
//
// holder.titleTextView.setText(holder.movieItem .getTitle());
//
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// Movie clickedItem = movies.get(position);
//
// onMovieClickListener.onItemClick(view, clickedItem);
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return movies.size();
// }
//
// public class ViewHolder extends RecyclerView.ViewHolder {
// public final ImageView movieImageView;
// public final TextView titleTextView;
//
// public Movie movieItem;
//
// public ViewHolder(View view) {
// super(view);
//
// movieImageView = (ImageView) view.findViewById(R.id.item_movie_poster);
// titleTextView = (TextView) view.findViewById(R.id.item_movie_title);
// }
// }
// }
| import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import com.xurxodev.moviesandroidkata.presentation.presenter.boundary.Navigator;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MovieDetailActivity;
import com.xurxodev.moviesandroidkata.presentation.view.adapter.MoviesAdapter; | package com.xurxodev.moviesandroidkata.presentation.navigator;
public class TransitionAnimationNavigator implements Navigator {
private final Context activityContext;
public TransitionAnimationNavigator(Context activityContext) {
this.activityContext = activityContext;
}
| // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java
// public class Movie {
// private String image;
// private String title;
// private String overview;
//
// public Movie(String image, String title, String overview) {
// this.image = image;
// this.title = title;
// this.overview = overview;
// }
//
// public String getImage() {
// return image;
// }
//
// public String getTitle() {
// return title;
// }
//
// public String getOverview() {
// return overview;
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/presenter/boundary/Navigator.java
// public interface Navigator {
// void openMovieDetail(Movie movie);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MovieDetailActivity.java
// public class MovieDetailActivity extends AppCompatActivity {
//
// public static final String MOVIE_TITLE = "MovieTitle";
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_movie_detail);
//
// initializeToolBar();
// showUpButtonInActionBar();
//
// if (savedInstanceState == null) {
// showDetailFragment();
// }
// }
//
// private void showDetailFragment() {
// String movieTitle = (String) getIntent().getStringExtra(MovieDetailActivity.MOVIE_TITLE);
//
// Bundle arguments = new Bundle();
// arguments.putSerializable(MovieDetailActivity.MOVIE_TITLE, movieTitle);
//
// MovieDetailFragment fragment = new MovieDetailFragment();
//
// fragment.setArguments(arguments);
//
// getSupportFragmentManager().beginTransaction()
// .add(R.id.movie_detail_container, fragment)
// .commit();
// }
//
// private void initializeToolBar() {
// Toolbar toolbar = (Toolbar) findViewById(R.id.detail_toolbar);
// setSupportActionBar(toolbar);
// }
//
// private void showUpButtonInActionBar() {
// ActionBar actionBar = getSupportActionBar();
// if (actionBar != null) {
// actionBar.setDisplayHomeAsUpEnabled(true);
// }
// }
//
// public static Intent createIntent(Context context, String movieTitle) {
// Intent intent = new Intent(context, MovieDetailActivity.class);
//
// intent.putExtra(MOVIE_TITLE, movieTitle);
//
// return intent;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// int id = item.getItemId();
//
// if (id == android.R.id.home) {
// supportFinishAfterTransition();
//
// return true;
// }
// return super.onOptionsItemSelected(item);
//
// }
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/adapter/MoviesAdapter.java
// public class MoviesAdapter
// extends RecyclerView.Adapter<MoviesAdapter.ViewHolder> {
//
// public interface OnMovieClickListener {
// void onItemClick(View view, Movie movie);
// }
//
// private OnMovieClickListener onMovieClickListener;
//
// public List<Movie> movies = new ArrayList<>();
//
// public void setMovies(List<Movie> movies) {
// this.movies = movies;
// notifyDataSetChanged();
// }
//
// public void clearMovies() {
// movies = new ArrayList<>();
// notifyDataSetChanged();
// }
//
// public void setOnMovieClickListener(OnMovieClickListener listener) {
// onMovieClickListener = listener;
// }
//
// @Override
// public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View view = LayoutInflater.from(parent.getContext())
// .inflate(R.layout.item_movies, parent, false);
//
// return new ViewHolder(view);
// }
//
// @Override
// public void onBindViewHolder(final ViewHolder holder, final int position) {
// holder.movieItem = movies.get(position);
//
// Picasso.with(holder.movieImageView.getContext())
// .load(holder.movieItem.getImage())
// .into(holder.movieImageView);
//
// holder.titleTextView.setText(holder.movieItem .getTitle());
//
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// Movie clickedItem = movies.get(position);
//
// onMovieClickListener.onItemClick(view, clickedItem);
// }
// });
// }
//
// @Override
// public int getItemCount() {
// return movies.size();
// }
//
// public class ViewHolder extends RecyclerView.ViewHolder {
// public final ImageView movieImageView;
// public final TextView titleTextView;
//
// public Movie movieItem;
//
// public ViewHolder(View view) {
// super(view);
//
// movieImageView = (ImageView) view.findViewById(R.id.item_movie_poster);
// titleTextView = (TextView) view.findViewById(R.id.item_movie_title);
// }
// }
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/navigator/TransitionAnimationNavigator.java
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.domain.entity.Movie;
import com.xurxodev.moviesandroidkata.presentation.presenter.boundary.Navigator;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MovieDetailActivity;
import com.xurxodev.moviesandroidkata.presentation.view.adapter.MoviesAdapter;
package com.xurxodev.moviesandroidkata.presentation.navigator;
public class TransitionAnimationNavigator implements Navigator {
private final Context activityContext;
public TransitionAnimationNavigator(Context activityContext) {
this.activityContext = activityContext;
}
| public void openMovieDetail(Movie movie) { |
xurxodev/Movies-Android-Kata | app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/ThreadExecutor.java | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/UseCase.java
// public interface UseCase extends Runnable{
// }
| import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.usecase.UseCase;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; | package com.xurxodev.moviesandroidkata.presentation.executor;
public class ThreadExecutor implements AsyncExecutor {
private static final int CORE_POOL_SIZE = 3;
private static final int MAX_POOL_SIZE = 5;
private static final int KEEP_ALIVE_TIME = 120;
private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS;
private static final BlockingQueue<Runnable> WORK_QUEUE = new LinkedBlockingQueue<Runnable>();
private ThreadPoolExecutor threadPoolExecutor;
public ThreadExecutor() {
int corePoolSize = CORE_POOL_SIZE;
int maxPoolSize = MAX_POOL_SIZE;
int keepAliveTime = KEEP_ALIVE_TIME;
TimeUnit timeUnit = TIME_UNIT;
BlockingQueue<Runnable> workQueue = WORK_QUEUE;
threadPoolExecutor =
new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, timeUnit, workQueue);
}
@Override | // Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/boundary/executor/AsyncExecutor.java
// public interface AsyncExecutor {
//
// void run(final UseCase interactor);
// }
//
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/usecase/UseCase.java
// public interface UseCase extends Runnable{
// }
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/executor/ThreadExecutor.java
import com.xurxodev.moviesandroidkata.domain.boundary.executor.AsyncExecutor;
import com.xurxodev.moviesandroidkata.domain.usecase.UseCase;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
package com.xurxodev.moviesandroidkata.presentation.executor;
public class ThreadExecutor implements AsyncExecutor {
private static final int CORE_POOL_SIZE = 3;
private static final int MAX_POOL_SIZE = 5;
private static final int KEEP_ALIVE_TIME = 120;
private static final TimeUnit TIME_UNIT = TimeUnit.SECONDS;
private static final BlockingQueue<Runnable> WORK_QUEUE = new LinkedBlockingQueue<Runnable>();
private ThreadPoolExecutor threadPoolExecutor;
public ThreadExecutor() {
int corePoolSize = CORE_POOL_SIZE;
int maxPoolSize = MAX_POOL_SIZE;
int keepAliveTime = KEEP_ALIVE_TIME;
TimeUnit timeUnit = TIME_UNIT;
BlockingQueue<Runnable> workQueue = WORK_QUEUE;
threadPoolExecutor =
new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, timeUnit, workQueue);
}
@Override | public void run(final UseCase interactor) { |
Stratio/stratio-connector-commons | connector-commons/src/main/java/com/stratio/connector/commons/util/PropertyValueRecovered.java | // Path: connector-commons/src/main/java/com/stratio/connector/commons/util/TypeDecisor.java
// public static boolean isBoolean(Class field) {
// //to compatibility to scala
// return Boolean.class.getSimpleName().equalsIgnoreCase(field.getSimpleName());
//
// }
//
// Path: connector-commons/src/main/java/com/stratio/connector/commons/util/TypeDecisor.java
// public static boolean isString(Class field) {
// //to compatibility to scala
// return String.class.getSimpleName().equalsIgnoreCase(field.getSimpleName());
//
// }
| import com.stratio.crossdata.common.exceptions.ExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import static com.stratio.connector.commons.util.TypeDecisor.isBoolean;
import static com.stratio.connector.commons.util.TypeDecisor.isString; | /*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.stratio.connector.commons.util;
/**
* Created by jmgomez on 25/03/15.
*/
public class PropertyValueRecovered {
/**
* The Log.
*/
private static final transient Logger LOGGER = LoggerFactory.getLogger(PropertyValueRecovered.class);
/**
* Constructor.
*/
private PropertyValueRecovered() {
}
/**
* This method recovered the array of properties.
*
* @param properties the string which represents the properties to recovered.
* @param type the type to recovered.
* @return the properties.
* @throws ExecutionException if an error happens.
*/
public static <T> T[] recoveredValueASArray(Class<T> type, String properties) throws ExecutionException {
LOGGER.info(String.format("Recovered propeties [%s] as [%s]", properties, type));
String[] stringParseProperties = properties.replaceAll("\\s+", "").replaceAll("\\[", "").replaceAll("]", "").split(",");
T[] returnValue = null; | // Path: connector-commons/src/main/java/com/stratio/connector/commons/util/TypeDecisor.java
// public static boolean isBoolean(Class field) {
// //to compatibility to scala
// return Boolean.class.getSimpleName().equalsIgnoreCase(field.getSimpleName());
//
// }
//
// Path: connector-commons/src/main/java/com/stratio/connector/commons/util/TypeDecisor.java
// public static boolean isString(Class field) {
// //to compatibility to scala
// return String.class.getSimpleName().equalsIgnoreCase(field.getSimpleName());
//
// }
// Path: connector-commons/src/main/java/com/stratio/connector/commons/util/PropertyValueRecovered.java
import com.stratio.crossdata.common.exceptions.ExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import static com.stratio.connector.commons.util.TypeDecisor.isBoolean;
import static com.stratio.connector.commons.util.TypeDecisor.isString;
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.stratio.connector.commons.util;
/**
* Created by jmgomez on 25/03/15.
*/
public class PropertyValueRecovered {
/**
* The Log.
*/
private static final transient Logger LOGGER = LoggerFactory.getLogger(PropertyValueRecovered.class);
/**
* Constructor.
*/
private PropertyValueRecovered() {
}
/**
* This method recovered the array of properties.
*
* @param properties the string which represents the properties to recovered.
* @param type the type to recovered.
* @return the properties.
* @throws ExecutionException if an error happens.
*/
public static <T> T[] recoveredValueASArray(Class<T> type, String properties) throws ExecutionException {
LOGGER.info(String.format("Recovered propeties [%s] as [%s]", properties, type));
String[] stringParseProperties = properties.replaceAll("\\s+", "").replaceAll("\\[", "").replaceAll("]", "").split(",");
T[] returnValue = null; | if (isString(type)) { |
Stratio/stratio-connector-commons | connector-commons/src/main/java/com/stratio/connector/commons/util/PropertyValueRecovered.java | // Path: connector-commons/src/main/java/com/stratio/connector/commons/util/TypeDecisor.java
// public static boolean isBoolean(Class field) {
// //to compatibility to scala
// return Boolean.class.getSimpleName().equalsIgnoreCase(field.getSimpleName());
//
// }
//
// Path: connector-commons/src/main/java/com/stratio/connector/commons/util/TypeDecisor.java
// public static boolean isString(Class field) {
// //to compatibility to scala
// return String.class.getSimpleName().equalsIgnoreCase(field.getSimpleName());
//
// }
| import com.stratio.crossdata.common.exceptions.ExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import static com.stratio.connector.commons.util.TypeDecisor.isBoolean;
import static com.stratio.connector.commons.util.TypeDecisor.isString; | /*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.stratio.connector.commons.util;
/**
* Created by jmgomez on 25/03/15.
*/
public class PropertyValueRecovered {
/**
* The Log.
*/
private static final transient Logger LOGGER = LoggerFactory.getLogger(PropertyValueRecovered.class);
/**
* Constructor.
*/
private PropertyValueRecovered() {
}
/**
* This method recovered the array of properties.
*
* @param properties the string which represents the properties to recovered.
* @param type the type to recovered.
* @return the properties.
* @throws ExecutionException if an error happens.
*/
public static <T> T[] recoveredValueASArray(Class<T> type, String properties) throws ExecutionException {
LOGGER.info(String.format("Recovered propeties [%s] as [%s]", properties, type));
String[] stringParseProperties = properties.replaceAll("\\s+", "").replaceAll("\\[", "").replaceAll("]", "").split(",");
T[] returnValue = null;
if (isString(type)) {
returnValue = (T[]) stringParseProperties; | // Path: connector-commons/src/main/java/com/stratio/connector/commons/util/TypeDecisor.java
// public static boolean isBoolean(Class field) {
// //to compatibility to scala
// return Boolean.class.getSimpleName().equalsIgnoreCase(field.getSimpleName());
//
// }
//
// Path: connector-commons/src/main/java/com/stratio/connector/commons/util/TypeDecisor.java
// public static boolean isString(Class field) {
// //to compatibility to scala
// return String.class.getSimpleName().equalsIgnoreCase(field.getSimpleName());
//
// }
// Path: connector-commons/src/main/java/com/stratio/connector/commons/util/PropertyValueRecovered.java
import com.stratio.crossdata.common.exceptions.ExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import static com.stratio.connector.commons.util.TypeDecisor.isBoolean;
import static com.stratio.connector.commons.util.TypeDecisor.isString;
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.stratio.connector.commons.util;
/**
* Created by jmgomez on 25/03/15.
*/
public class PropertyValueRecovered {
/**
* The Log.
*/
private static final transient Logger LOGGER = LoggerFactory.getLogger(PropertyValueRecovered.class);
/**
* Constructor.
*/
private PropertyValueRecovered() {
}
/**
* This method recovered the array of properties.
*
* @param properties the string which represents the properties to recovered.
* @param type the type to recovered.
* @return the properties.
* @throws ExecutionException if an error happens.
*/
public static <T> T[] recoveredValueASArray(Class<T> type, String properties) throws ExecutionException {
LOGGER.info(String.format("Recovered propeties [%s] as [%s]", properties, type));
String[] stringParseProperties = properties.replaceAll("\\s+", "").replaceAll("\\[", "").replaceAll("]", "").split(",");
T[] returnValue = null;
if (isString(type)) {
returnValue = (T[]) stringParseProperties; | } else if (isBoolean(type)) { |
Stratio/stratio-connector-commons | connector-commons/src/test/java/com/stratio/connector/commons/connection/ConnectionTest.java | // Path: connector-commons/src/test/java/com/stratio/connector/commons/connection/dummy/DummyConnector.java
// public class DummyConnector extends Connection {
//
// @Override
// public void close() {
//
// }
//
// @Override
// public boolean isConnected() {
// return false;
// }
//
// @Override
// public Object getNativeConnection() {
// return null;
// }
// }
| import com.stratio.connector.commons.connection.dummy.DummyConnector;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static junit.framework.Assert.assertSame;
import static junit.framework.TestCase.assertNotNull; | /*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.stratio.connector.commons.connection;
/**
* Connection Tester.
*
* @author <Authors name>
* @version 1.0
* @since <pre>dic 12, 2014</pre>
*/
public class ConnectionTest {
@Before
public void before() throws Exception {
}
@After
public void after() throws Exception {
}
/**
* Method: getSessionObject(Class<T> type, String name)
*/
@Test
public void testSession() throws Exception { | // Path: connector-commons/src/test/java/com/stratio/connector/commons/connection/dummy/DummyConnector.java
// public class DummyConnector extends Connection {
//
// @Override
// public void close() {
//
// }
//
// @Override
// public boolean isConnected() {
// return false;
// }
//
// @Override
// public Object getNativeConnection() {
// return null;
// }
// }
// Path: connector-commons/src/test/java/com/stratio/connector/commons/connection/ConnectionTest.java
import com.stratio.connector.commons.connection.dummy.DummyConnector;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static junit.framework.Assert.assertSame;
import static junit.framework.TestCase.assertNotNull;
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.stratio.connector.commons.connection;
/**
* Connection Tester.
*
* @author <Authors name>
* @version 1.0
* @since <pre>dic 12, 2014</pre>
*/
public class ConnectionTest {
@Before
public void before() throws Exception {
}
@After
public void after() throws Exception {
}
/**
* Method: getSessionObject(Class<T> type, String name)
*/
@Test
public void testSession() throws Exception { | DummyConnector connector = new DummyConnector(); |
lmazuel/onagui | src/main/java/fr/onagui/gui/AlignmentGUIRunner.java | // Path: src/main/java/fr/onagui/alignment/io/AlignmentFormat.java
// public enum AlignmentFormat {
//
// EDOAL,
// SKOS,
// CSV;
//
// }
| import java.io.File;
import fr.onagui.alignment.io.AlignmentFormat; | package fr.onagui.gui;
/**
* Classe de lancement permettant de lancer l'application en chargeant directement les vocabulaires 1 et 2
* et optionnement un alignement.
* Utilisé pour accélérer les tests !
*
* @author thomas
*
*/
public class AlignmentGUIRunner {
public static void main(String[] args) {
System.out.println("Starting OnaGUI..."); //$NON-NLS-1$
String file1Path = args[0];
String file2Path = args[1];
String alignmentPath = (args.length >= 3)?args[2]:null;
//Schedule a job for the event dispatch thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
AlignmentGUI gui = new AlignmentGUI();
gui.loadOntologyFromFileReference(OntologyType.FIRST_ONTO_SKOS, new File(file1Path).toURI());
gui.loadOntologyFromFileReference(OntologyType.SECOND_ONTO_SKOS, new File(file2Path).toURI()); | // Path: src/main/java/fr/onagui/alignment/io/AlignmentFormat.java
// public enum AlignmentFormat {
//
// EDOAL,
// SKOS,
// CSV;
//
// }
// Path: src/main/java/fr/onagui/gui/AlignmentGUIRunner.java
import java.io.File;
import fr.onagui.alignment.io.AlignmentFormat;
package fr.onagui.gui;
/**
* Classe de lancement permettant de lancer l'application en chargeant directement les vocabulaires 1 et 2
* et optionnement un alignement.
* Utilisé pour accélérer les tests !
*
* @author thomas
*
*/
public class AlignmentGUIRunner {
public static void main(String[] args) {
System.out.println("Starting OnaGUI..."); //$NON-NLS-1$
String file1Path = args[0];
String file2Path = args[1];
String alignmentPath = (args.length >= 3)?args[2]:null;
//Schedule a job for the event dispatch thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
AlignmentGUI gui = new AlignmentGUI();
gui.loadOntologyFromFileReference(OntologyType.FIRST_ONTO_SKOS, new File(file1Path).toURI());
gui.loadOntologyFromFileReference(OntologyType.SECOND_ONTO_SKOS, new File(file2Path).toURI()); | gui.loadAlignmentFromFileReference(new File(alignmentPath), AlignmentFormat.EDOAL); |
lmazuel/onagui | src/main/java/fr/onagui/gui/ScoreColorRenderer.java | // Path: src/main/java/fr/onagui/config/ScoreColorConfiguration.java
// public interface ScoreColorConfiguration {
//
// public Color getColorFromScore(double score);
//
// public Color getColorImpossibleToAlign();
//
// public Color getColorNeutral();
//
// }
| import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.border.Border;
import javax.swing.table.TableCellRenderer;
import fr.onagui.config.ScoreColorConfiguration;
import java.awt.Color;
import java.awt.Component; | package fr.onagui.gui;
public class ScoreColorRenderer extends JLabel
implements TableCellRenderer {
/** To make Java happy... */
private static final long serialVersionUID = 8269983184162200636L;
private Border unselectedBorder = null;
private Border selectedBorder = null;
| // Path: src/main/java/fr/onagui/config/ScoreColorConfiguration.java
// public interface ScoreColorConfiguration {
//
// public Color getColorFromScore(double score);
//
// public Color getColorImpossibleToAlign();
//
// public Color getColorNeutral();
//
// }
// Path: src/main/java/fr/onagui/gui/ScoreColorRenderer.java
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.border.Border;
import javax.swing.table.TableCellRenderer;
import fr.onagui.config.ScoreColorConfiguration;
import java.awt.Color;
import java.awt.Component;
package fr.onagui.gui;
public class ScoreColorRenderer extends JLabel
implements TableCellRenderer {
/** To make Java happy... */
private static final long serialVersionUID = 8269983184162200636L;
private Border unselectedBorder = null;
private Border selectedBorder = null;
| private ScoreColorConfiguration scc; |
lmazuel/onagui | src/main/java/fr/onagui/control/TreeNodeOntologyObject.java | // Path: src/main/java/fr/onagui/alignment/OntoContainer.java
// public interface OntoContainer<ONTORES> {
//
// /* **************** *
// * Partie technique *
// * **************** */
//
// /** Une chaine de caractere representant le type de formalisme de cette ontologie.
// * @return Une chaine de caractere representant le type de formalisme de cette ontologie.
// */
// public String getFormalism();
//
// /** Renvoie l'URI d'un concept.
// * @param cpt Un concept.
// * @return L'URI de ce concept.
// * @see #getConceptFromURI(URI)
// */
// public URI getURI(ONTORES cpt);
//
// /** L'ensemble des concepts (classes) de ce modèle.
// * @return L'ensemble des concepts (classes) de ce modèle.
// */
// public Set<ONTORES> getAllConcepts();
//
// /** L'ensemble des propriétés de ce modèle.
// * @return L'ensemble des propriétés de ce modèle.
// */
// public Set<ONTORES> getAllProperties();
//
// /** Get Annotation of this concept
// * @param cpt a Concept
// * @return A set of URIs
// */
// public Set<String> getAnnotations(ONTORES cpt);
//
// /** Get labels for this predicate
// * @param cpt The concept
// * @param prop The predicate
// * @return The set of labels
// */
// public Set<String> getLabels(ONTORES cpt, String prop);
//
// /** Recupère un concept à partir de l'URI.
// * @param uri L'URI d'un concept.
// * @return Un concept.
// * @see #getURI()
// */
// public ONTORES getConceptFromURI(URI uri);
//
// /** Renvoie l'URI de l'ontologie.
// * @return L'URI de l'ontologie.
// */
// public URI getURI();
//
// /** Renvoie la racine de l'ontologie.
// * @return La racine de l'ontologie.
// */
// public ONTORES getRoot();
//
// /** Decrit si le concept courant est une instance ou pas.
// * @param cpt Un concept
// * @return <code>true</code> si instance, <code>false</code> sinon. */
// public boolean isIndividual(ONTORES cpt);
//
// /** Les fils de ce concept.
// * @param cpt Un concept
// * @return Les fils de ce concept.
// */
// public Set<ONTORES> getChildren(ONTORES cpt);
//
// /**
// * Renvoi la date de modification du concept passé en paramètre
// * @param cpt
// * @return
// */
//
// public Optional<Date> getModifiedDate(ONTORES cpt);
//
// /** Les parents de ce concept
// * @param cpt Un concept
// * @return Les parents directs de ce concept
// */
// public Set<ONTORES> getParents(ONTORES cpt);
//
// /** A visitor which accept a callback on the concept
// *
// * @param visitor A visitor implementation
// */
// public void accept(OntoVisitor<ONTORES> visitor);
//
// /* *************** *
// * Partie lexicale *
// * *************** */
//
// /** Renvoie la liste des langages utilisés dans les labels.
// * @return
// */
// public SortedSet<String> getAllLanguageInLabels();
//
// /** Retourne l'ensemble des termes préférés de ce concept de la langue en parametre.
// * En general, le resultat est un singleton.
// * @param cpt Un concept.
// * @param lang La langue demandée, format normalisé selon l'entrée "xml:lang".
// * La chaine vide "" pour n'avoir que les noeuds sans précision.
// * @return L'ensemble des termes préférés de ce concept.
// * @throws IllegalArgumentException Si l'un des paramètres est <code>null</code>.
// */
// public Set<String> getPrefLabels(ONTORES cpt, String lang);
//
// /** Retourne l'ensemble des termes préférés de ce concept, quelque soit la langue.
// * @param cpt Un concept.
// * @return L'ensemble des termes préférés de ce concept.
// * @throws IllegalArgumentException Si l'un des paramètres est <code>null</code>.
// */
// public Set<String> getPrefLabels(ONTORES cpt);
//
// /** Retourne l'ensemble des termes alternatifs de ce concept de la langue en parametre.
// * @param cpt Un concept.
// * @param lang La langue demandée, format normalisé selon l'entrée "xml:lang".
// * La chaine vide "" pour n'avoir que les noeuds sans précision.
// * @return L'ensemble des termes alternatifs de ce concept.
// * @throws IllegalArgumentException Si l'un des paramètres est <code>null</code>.
// */
// public Set<String> getAltLabels(ONTORES cpt, String lang);
//
// /** Retourne l'ensemble des termes alternatifs de ce concept, quelque soit la langue.
// * @param cpt Un concept.
// * @return L'ensemble des termes alternatifs de ce concept.
// * @throws IllegalArgumentException Si l'un des paramètres est <code>null</code>.
// */
// public Set<String> getAltLabels(ONTORES cpt);
//
// }
| import java.net.URI;
import java.util.HashSet;
import java.util.Set;
import javax.swing.tree.DefaultMutableTreeNode;
import fr.onagui.alignment.OntoContainer; | package fr.onagui.control;
/** Use as an "UserObject" of a TreeNode.
* @author Laurent Mazuel
*
* @param <ONTORES>
*/
public class TreeNodeOntologyObject<ONTORES> {
private ONTORES concept = null; | // Path: src/main/java/fr/onagui/alignment/OntoContainer.java
// public interface OntoContainer<ONTORES> {
//
// /* **************** *
// * Partie technique *
// * **************** */
//
// /** Une chaine de caractere representant le type de formalisme de cette ontologie.
// * @return Une chaine de caractere representant le type de formalisme de cette ontologie.
// */
// public String getFormalism();
//
// /** Renvoie l'URI d'un concept.
// * @param cpt Un concept.
// * @return L'URI de ce concept.
// * @see #getConceptFromURI(URI)
// */
// public URI getURI(ONTORES cpt);
//
// /** L'ensemble des concepts (classes) de ce modèle.
// * @return L'ensemble des concepts (classes) de ce modèle.
// */
// public Set<ONTORES> getAllConcepts();
//
// /** L'ensemble des propriétés de ce modèle.
// * @return L'ensemble des propriétés de ce modèle.
// */
// public Set<ONTORES> getAllProperties();
//
// /** Get Annotation of this concept
// * @param cpt a Concept
// * @return A set of URIs
// */
// public Set<String> getAnnotations(ONTORES cpt);
//
// /** Get labels for this predicate
// * @param cpt The concept
// * @param prop The predicate
// * @return The set of labels
// */
// public Set<String> getLabels(ONTORES cpt, String prop);
//
// /** Recupère un concept à partir de l'URI.
// * @param uri L'URI d'un concept.
// * @return Un concept.
// * @see #getURI()
// */
// public ONTORES getConceptFromURI(URI uri);
//
// /** Renvoie l'URI de l'ontologie.
// * @return L'URI de l'ontologie.
// */
// public URI getURI();
//
// /** Renvoie la racine de l'ontologie.
// * @return La racine de l'ontologie.
// */
// public ONTORES getRoot();
//
// /** Decrit si le concept courant est une instance ou pas.
// * @param cpt Un concept
// * @return <code>true</code> si instance, <code>false</code> sinon. */
// public boolean isIndividual(ONTORES cpt);
//
// /** Les fils de ce concept.
// * @param cpt Un concept
// * @return Les fils de ce concept.
// */
// public Set<ONTORES> getChildren(ONTORES cpt);
//
// /**
// * Renvoi la date de modification du concept passé en paramètre
// * @param cpt
// * @return
// */
//
// public Optional<Date> getModifiedDate(ONTORES cpt);
//
// /** Les parents de ce concept
// * @param cpt Un concept
// * @return Les parents directs de ce concept
// */
// public Set<ONTORES> getParents(ONTORES cpt);
//
// /** A visitor which accept a callback on the concept
// *
// * @param visitor A visitor implementation
// */
// public void accept(OntoVisitor<ONTORES> visitor);
//
// /* *************** *
// * Partie lexicale *
// * *************** */
//
// /** Renvoie la liste des langages utilisés dans les labels.
// * @return
// */
// public SortedSet<String> getAllLanguageInLabels();
//
// /** Retourne l'ensemble des termes préférés de ce concept de la langue en parametre.
// * En general, le resultat est un singleton.
// * @param cpt Un concept.
// * @param lang La langue demandée, format normalisé selon l'entrée "xml:lang".
// * La chaine vide "" pour n'avoir que les noeuds sans précision.
// * @return L'ensemble des termes préférés de ce concept.
// * @throws IllegalArgumentException Si l'un des paramètres est <code>null</code>.
// */
// public Set<String> getPrefLabels(ONTORES cpt, String lang);
//
// /** Retourne l'ensemble des termes préférés de ce concept, quelque soit la langue.
// * @param cpt Un concept.
// * @return L'ensemble des termes préférés de ce concept.
// * @throws IllegalArgumentException Si l'un des paramètres est <code>null</code>.
// */
// public Set<String> getPrefLabels(ONTORES cpt);
//
// /** Retourne l'ensemble des termes alternatifs de ce concept de la langue en parametre.
// * @param cpt Un concept.
// * @param lang La langue demandée, format normalisé selon l'entrée "xml:lang".
// * La chaine vide "" pour n'avoir que les noeuds sans précision.
// * @return L'ensemble des termes alternatifs de ce concept.
// * @throws IllegalArgumentException Si l'un des paramètres est <code>null</code>.
// */
// public Set<String> getAltLabels(ONTORES cpt, String lang);
//
// /** Retourne l'ensemble des termes alternatifs de ce concept, quelque soit la langue.
// * @param cpt Un concept.
// * @return L'ensemble des termes alternatifs de ce concept.
// * @throws IllegalArgumentException Si l'un des paramètres est <code>null</code>.
// */
// public Set<String> getAltLabels(ONTORES cpt);
//
// }
// Path: src/main/java/fr/onagui/control/TreeNodeOntologyObject.java
import java.net.URI;
import java.util.HashSet;
import java.util.Set;
import javax.swing.tree.DefaultMutableTreeNode;
import fr.onagui.alignment.OntoContainer;
package fr.onagui.control;
/** Use as an "UserObject" of a TreeNode.
* @author Laurent Mazuel
*
* @param <ONTORES>
*/
public class TreeNodeOntologyObject<ONTORES> {
private ONTORES concept = null; | private OntoContainer<ONTORES> container = null; |
lmazuel/onagui | src/main/java/fr/onagui/alignment/AlignmentFactory.java | // Path: src/main/java/fr/onagui/alignment/method/LevenshteinAlignmentMethod.java
// public class LevenshteinAlignmentMethod<ONTORES1, ONTORES2> extends LabelAlignmentMethod<ONTORES1, ONTORES2> {
//
// public static final double DEFAULT_LEVENSHTEIN_THRESHOLD = 0.97;
//
// /**
// * @param current_threshlod
// */
// public LevenshteinAlignmentMethod(double current_threshlod) {
// setThreshold(current_threshlod);
// }
//
// /** Constructeur par défaut.
// * Utilise le seuil {@link #DEFAULT_LEVENSHTEIN_THRESHOLD}.
// *
// */
// public LevenshteinAlignmentMethod() {
// this(DEFAULT_LEVENSHTEIN_THRESHOLD);
// }
//
// /* (non-Javadoc)
// * @see agui.alignment.AbstractAlignmentMethod#computeMapping(agui.alignment.OntoContainer, java.lang.Object, java.util.Collection, agui.alignment.OntoContainer, java.lang.Object, java.util.Collection)
// */
// @Override
// public Mapping<ONTORES1, ONTORES2> computeMapping(
// OntoContainer<ONTORES1> model1,
// ONTORES1 cpt1Inst,
// OntoContainer<ONTORES2> model2,
// ONTORES2 cpt2Inst) {
//
// // Verifier que des labels existents, sinon je ne peux rien
// SortedSet<String> langs1 = getLangsFrom1();
// SortedSet<String> langs2 = getLangsFrom2();
//
// Collection<LabelInformation> cpt1Labels = getLabelsForAlignement(model1, cpt1Inst, langs1);
// if(cpt1Labels.isEmpty()) return null;
// Collection<LabelInformation> cpt2Labels = getLabelsForAlignement(model2, cpt2Inst, langs2);
// if(cpt2Labels.isEmpty()) return null;
// LabelAlignmentMethod.applyNLPFilterToLabels(cpt1Labels);
// LabelAlignmentMethod.applyNLPFilterToLabels(cpt2Labels);
//
// // Bon, maintenant au boulot!
// Mapping<ONTORES1, ONTORES2> currentBestMapping = null;
// for(LabelInformation oneLabelFrom1 : cpt1Labels) {
// for(LabelInformation oneLabelFrom2 : cpt2Labels) {
// String rawLabel1 = oneLabelFrom1.getLabel();
// String rawLabel2 = oneLabelFrom2.getLabel();
// // The local meta map, if necessary
// LexicalisationMetaMap meta = LexicalisationMetaMap.createMetaMap(
// rawLabel1,
// rawLabel2,
// oneLabelFrom1.getPrefLabel(),
// oneLabelFrom2.getPrefLabel(),
// oneLabelFrom1.getOrigins().toString(),
// oneLabelFrom2.getOrigins().toString());
//
// if(rawLabel1.equals(rawLabel2)) {
// Mapping<ONTORES1, ONTORES2> mapping = new Mapping<ONTORES1, ONTORES2>(cpt1Inst, cpt2Inst);
// // System.out.println(mapping);
// mapping.setMeta(meta);
// return mapping; // Pas possible de faire mieux...
// }
//
// double levenScore = 1.0 - LevenshteinDistance.computeNormalizedLevenshteinDistance(rawLabel1.toCharArray(), rawLabel2.toCharArray());
//
// if(levenScore >= getThreshold() &&
// (currentBestMapping == null ||
// (currentBestMapping != null && currentBestMapping.getScore() < levenScore))) { // Meilleur que celui qu'on a déjà
//
// Mapping<ONTORES1, ONTORES2> mapping = new Mapping<ONTORES1, ONTORES2>(cpt1Inst, cpt2Inst, levenScore, MAPPING_TYPE.EQUIV);
// mapping.setMeta(meta);
// currentBestMapping = mapping;
// // System.out.println(mapping);
// }
// // Tentative de detection de sous-classe:
// // Trop violent comme test: [delivrance_du_placenta_suite_a_un_accouchement_hors_hopital-cou:1.0-SUB]
// // else if(snoCptLabel.contains(pneCptLabel) || pneCptLabel.contains(snoCptLabel)) {
// // LabelMapping<String> mapping = new LabelMapping<String>(snoCptLabel, pneCptLabel, 1.0, MAPPING_TYPE.SUB);
// // result.add(mapping);
// // }
// }
// }
// return currentBestMapping;
// }
//
// @Override
// public String toString() {
// return "Distance de Levenshtein";
// }
//
// }
| import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.HashSet;
import java.util.Set;
import fr.onagui.alignment.method.LevenshteinAlignmentMethod; | /**
*
*/
package fr.onagui.alignment;
/**
* @author Laurent Mazuel
*/
public class AlignmentFactory<ONTORES1, ONTORES2> {
private PropertyChangeSupport propertyManagement = null;
private boolean DEBUG_MODE = false;
/** The event name used in property change listener */
public static final String PROGRESS_EVENT_NAME = "progressRatio";
private AbstractAlignmentMethod<ONTORES1, ONTORES2> alignmentMethod = null;
public AlignmentFactory(AbstractAlignmentMethod<ONTORES1, ONTORES2> method) {
propertyManagement = new PropertyChangeSupport(this);
alignmentMethod = method;
}
public AlignmentFactory() { | // Path: src/main/java/fr/onagui/alignment/method/LevenshteinAlignmentMethod.java
// public class LevenshteinAlignmentMethod<ONTORES1, ONTORES2> extends LabelAlignmentMethod<ONTORES1, ONTORES2> {
//
// public static final double DEFAULT_LEVENSHTEIN_THRESHOLD = 0.97;
//
// /**
// * @param current_threshlod
// */
// public LevenshteinAlignmentMethod(double current_threshlod) {
// setThreshold(current_threshlod);
// }
//
// /** Constructeur par défaut.
// * Utilise le seuil {@link #DEFAULT_LEVENSHTEIN_THRESHOLD}.
// *
// */
// public LevenshteinAlignmentMethod() {
// this(DEFAULT_LEVENSHTEIN_THRESHOLD);
// }
//
// /* (non-Javadoc)
// * @see agui.alignment.AbstractAlignmentMethod#computeMapping(agui.alignment.OntoContainer, java.lang.Object, java.util.Collection, agui.alignment.OntoContainer, java.lang.Object, java.util.Collection)
// */
// @Override
// public Mapping<ONTORES1, ONTORES2> computeMapping(
// OntoContainer<ONTORES1> model1,
// ONTORES1 cpt1Inst,
// OntoContainer<ONTORES2> model2,
// ONTORES2 cpt2Inst) {
//
// // Verifier que des labels existents, sinon je ne peux rien
// SortedSet<String> langs1 = getLangsFrom1();
// SortedSet<String> langs2 = getLangsFrom2();
//
// Collection<LabelInformation> cpt1Labels = getLabelsForAlignement(model1, cpt1Inst, langs1);
// if(cpt1Labels.isEmpty()) return null;
// Collection<LabelInformation> cpt2Labels = getLabelsForAlignement(model2, cpt2Inst, langs2);
// if(cpt2Labels.isEmpty()) return null;
// LabelAlignmentMethod.applyNLPFilterToLabels(cpt1Labels);
// LabelAlignmentMethod.applyNLPFilterToLabels(cpt2Labels);
//
// // Bon, maintenant au boulot!
// Mapping<ONTORES1, ONTORES2> currentBestMapping = null;
// for(LabelInformation oneLabelFrom1 : cpt1Labels) {
// for(LabelInformation oneLabelFrom2 : cpt2Labels) {
// String rawLabel1 = oneLabelFrom1.getLabel();
// String rawLabel2 = oneLabelFrom2.getLabel();
// // The local meta map, if necessary
// LexicalisationMetaMap meta = LexicalisationMetaMap.createMetaMap(
// rawLabel1,
// rawLabel2,
// oneLabelFrom1.getPrefLabel(),
// oneLabelFrom2.getPrefLabel(),
// oneLabelFrom1.getOrigins().toString(),
// oneLabelFrom2.getOrigins().toString());
//
// if(rawLabel1.equals(rawLabel2)) {
// Mapping<ONTORES1, ONTORES2> mapping = new Mapping<ONTORES1, ONTORES2>(cpt1Inst, cpt2Inst);
// // System.out.println(mapping);
// mapping.setMeta(meta);
// return mapping; // Pas possible de faire mieux...
// }
//
// double levenScore = 1.0 - LevenshteinDistance.computeNormalizedLevenshteinDistance(rawLabel1.toCharArray(), rawLabel2.toCharArray());
//
// if(levenScore >= getThreshold() &&
// (currentBestMapping == null ||
// (currentBestMapping != null && currentBestMapping.getScore() < levenScore))) { // Meilleur que celui qu'on a déjà
//
// Mapping<ONTORES1, ONTORES2> mapping = new Mapping<ONTORES1, ONTORES2>(cpt1Inst, cpt2Inst, levenScore, MAPPING_TYPE.EQUIV);
// mapping.setMeta(meta);
// currentBestMapping = mapping;
// // System.out.println(mapping);
// }
// // Tentative de detection de sous-classe:
// // Trop violent comme test: [delivrance_du_placenta_suite_a_un_accouchement_hors_hopital-cou:1.0-SUB]
// // else if(snoCptLabel.contains(pneCptLabel) || pneCptLabel.contains(snoCptLabel)) {
// // LabelMapping<String> mapping = new LabelMapping<String>(snoCptLabel, pneCptLabel, 1.0, MAPPING_TYPE.SUB);
// // result.add(mapping);
// // }
// }
// }
// return currentBestMapping;
// }
//
// @Override
// public String toString() {
// return "Distance de Levenshtein";
// }
//
// }
// Path: src/main/java/fr/onagui/alignment/AlignmentFactory.java
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.HashSet;
import java.util.Set;
import fr.onagui.alignment.method.LevenshteinAlignmentMethod;
/**
*
*/
package fr.onagui.alignment;
/**
* @author Laurent Mazuel
*/
public class AlignmentFactory<ONTORES1, ONTORES2> {
private PropertyChangeSupport propertyManagement = null;
private boolean DEBUG_MODE = false;
/** The event name used in property change listener */
public static final String PROGRESS_EVENT_NAME = "progressRatio";
private AbstractAlignmentMethod<ONTORES1, ONTORES2> alignmentMethod = null;
public AlignmentFactory(AbstractAlignmentMethod<ONTORES1, ONTORES2> method) {
propertyManagement = new PropertyChangeSupport(this);
alignmentMethod = method;
}
public AlignmentFactory() { | this(new LevenshteinAlignmentMethod<ONTORES1, ONTORES2>()); |
gallandarakhneorg/3dxware | sdk/java/src/org/arakhne/dxware/SpaceMouse.java | // Path: sdk/java/src/org/arakhne/dxware/X11/XSpaceMouse.java
// public class XSpaceMouse extends SpaceMouse implements XEventListener {
//
// private final EventDispatcher eventDispatcher = new EventDispatcher();
//
// /**
// * @param window is the AWT component that must be binded
// * to the space mouse driver.
// */
// public XSpaceMouse(JFrame window) {
// super(window);
// }
//
// /**
// * @param window is the AWT component that must be binded
// * to the space mouse driver.
// */
// public XSpaceMouse(JDialog window) {
// super(window);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// protected void initializeDevice(Component peerComponent) {
// this.eventDispatcher.start();
// Toolkit toolkit = Toolkit.getDefaultToolkit();
// if (toolkit instanceof XToolkit) {
// ((XToolkit)toolkit).addXEventListener(this);
// }
// else {
// throw new RuntimeException("unsupported AWT toolkit"); //$NON-NLS-1$
// }
// super.initializeDevice(peerComponent);
// }
//
// /** Dispose the resources.
// */
// @Override
// public void dispose() {
// this.eventDispatcher.stop();
// super.dispose();
// }
//
// /**
// * {@inheritDoc}
// */
// public void eventProcessed(XEvent e) {
// DeviceEvent event;
// switch(e.get_type()) {
// case XConstants.KeyPress:
// if (isKeyboardEventFired()) {
// event = new DeviceEvent(this);
// if (treatNativeEvent(e.getPData(), event)) {
// fireKeyPressed(event);
// }
// }
// break;
// case XConstants.KeyRelease:
// if (isKeyboardEventFired()) {
// event = new DeviceEvent(this);
// if (treatNativeEvent(e.getPData(), event)) {
// fireKeyReleased(event);
// }
// }
// break;
// case XConstants.ClientMessage:
// event = new DeviceEvent(this);
// if (treatNativeEvent(e.getPData(), event)) {
// this.eventDispatcher.offer(event);
// }
// break;
// }
// }
//
// /**
// * Dispatch 3DxWare events.
// *
// * @author Stéphane GALLAND <galland@arakhne.org>
// * @version $Name$ $Revision$ $Date$
// */
// private class EventDispatcher implements Runnable {
//
// private volatile boolean mustStop;
//
// private final Queue<DeviceEvent> queue = new ConcurrentLinkedQueue<DeviceEvent>();
//
// /**
// */
// public EventDispatcher() {
// //
// }
//
// /** Offer an event for dispatching.
// *
// * @param event
// */
// public void offer(DeviceEvent event) {
// this.queue.offer(event);
// }
//
// /**
// * {@inheritDoc}
// */
// public void run() {
// DeviceEvent event;
// this.mustStop = false;
// while (!this.mustStop) {
// event = this.queue.poll();
// if (event!=null) {
// switch(event.getType()) {
// case BUTTON3D_PRESSED:
// fireButton3DPressed(event);
// break;
// case BUTTON3D_RELEASED:
// fireButton3DReleased(event);
// break;
// case MOUSE3D_MOTION:
// fireMouse3DMotion(event);
// break;
// default:
// }
// }
// Thread.yield();
// }
// }
//
// /** Start the dispatcher.
// */
// public void start() {
// Thread thread = Executors.defaultThreadFactory().newThread(this);
// thread.setName("XSpaceMouse Event Dispatcher"); //$NON-NLS-1$
// thread.start();
// }
//
// /** Stop the dispatcher.
// */
// public void stop() {
// this.mustStop = true;
// }
//
// }
//
// }
| import org.arakhne.dxware.X11.XSpaceMouse;
import sun.awt.X11.XToolkit;
import java.awt.Component;
import java.awt.Toolkit;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.ArrayList;
import java.util.Collection;
import javax.swing.JDialog;
import javax.swing.JFrame; | /*
* $Id$
*
* Copyright (C) 2008 Stéphane GALLAND
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* This program is free software; you can redistribute it and/or modify
*/
package org.arakhne.dxware;
/**
* This class represents a 3D device named a SpaceMouse.
*
* @author Stéphane GALLAND <galland@arakhne.org>
* @version $Name$ $Revision$ $Date$
*/
public abstract class SpaceMouse {
/** Create an instance of the SpaceMouse device.
*
* @param peerComponent is the AWt component that must be connected to
* the physical device.
* @return the new instance of the SpaceMouse
*/
public static SpaceMouse createInstance(JFrame peerComponent) {
Toolkit toolkit = Toolkit.getDefaultToolkit();
if (toolkit instanceof XToolkit) { | // Path: sdk/java/src/org/arakhne/dxware/X11/XSpaceMouse.java
// public class XSpaceMouse extends SpaceMouse implements XEventListener {
//
// private final EventDispatcher eventDispatcher = new EventDispatcher();
//
// /**
// * @param window is the AWT component that must be binded
// * to the space mouse driver.
// */
// public XSpaceMouse(JFrame window) {
// super(window);
// }
//
// /**
// * @param window is the AWT component that must be binded
// * to the space mouse driver.
// */
// public XSpaceMouse(JDialog window) {
// super(window);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// protected void initializeDevice(Component peerComponent) {
// this.eventDispatcher.start();
// Toolkit toolkit = Toolkit.getDefaultToolkit();
// if (toolkit instanceof XToolkit) {
// ((XToolkit)toolkit).addXEventListener(this);
// }
// else {
// throw new RuntimeException("unsupported AWT toolkit"); //$NON-NLS-1$
// }
// super.initializeDevice(peerComponent);
// }
//
// /** Dispose the resources.
// */
// @Override
// public void dispose() {
// this.eventDispatcher.stop();
// super.dispose();
// }
//
// /**
// * {@inheritDoc}
// */
// public void eventProcessed(XEvent e) {
// DeviceEvent event;
// switch(e.get_type()) {
// case XConstants.KeyPress:
// if (isKeyboardEventFired()) {
// event = new DeviceEvent(this);
// if (treatNativeEvent(e.getPData(), event)) {
// fireKeyPressed(event);
// }
// }
// break;
// case XConstants.KeyRelease:
// if (isKeyboardEventFired()) {
// event = new DeviceEvent(this);
// if (treatNativeEvent(e.getPData(), event)) {
// fireKeyReleased(event);
// }
// }
// break;
// case XConstants.ClientMessage:
// event = new DeviceEvent(this);
// if (treatNativeEvent(e.getPData(), event)) {
// this.eventDispatcher.offer(event);
// }
// break;
// }
// }
//
// /**
// * Dispatch 3DxWare events.
// *
// * @author Stéphane GALLAND <galland@arakhne.org>
// * @version $Name$ $Revision$ $Date$
// */
// private class EventDispatcher implements Runnable {
//
// private volatile boolean mustStop;
//
// private final Queue<DeviceEvent> queue = new ConcurrentLinkedQueue<DeviceEvent>();
//
// /**
// */
// public EventDispatcher() {
// //
// }
//
// /** Offer an event for dispatching.
// *
// * @param event
// */
// public void offer(DeviceEvent event) {
// this.queue.offer(event);
// }
//
// /**
// * {@inheritDoc}
// */
// public void run() {
// DeviceEvent event;
// this.mustStop = false;
// while (!this.mustStop) {
// event = this.queue.poll();
// if (event!=null) {
// switch(event.getType()) {
// case BUTTON3D_PRESSED:
// fireButton3DPressed(event);
// break;
// case BUTTON3D_RELEASED:
// fireButton3DReleased(event);
// break;
// case MOUSE3D_MOTION:
// fireMouse3DMotion(event);
// break;
// default:
// }
// }
// Thread.yield();
// }
// }
//
// /** Start the dispatcher.
// */
// public void start() {
// Thread thread = Executors.defaultThreadFactory().newThread(this);
// thread.setName("XSpaceMouse Event Dispatcher"); //$NON-NLS-1$
// thread.start();
// }
//
// /** Stop the dispatcher.
// */
// public void stop() {
// this.mustStop = true;
// }
//
// }
//
// }
// Path: sdk/java/src/org/arakhne/dxware/SpaceMouse.java
import org.arakhne.dxware.X11.XSpaceMouse;
import sun.awt.X11.XToolkit;
import java.awt.Component;
import java.awt.Toolkit;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.ArrayList;
import java.util.Collection;
import javax.swing.JDialog;
import javax.swing.JFrame;
/*
* $Id$
*
* Copyright (C) 2008 Stéphane GALLAND
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* This program is free software; you can redistribute it and/or modify
*/
package org.arakhne.dxware;
/**
* This class represents a 3D device named a SpaceMouse.
*
* @author Stéphane GALLAND <galland@arakhne.org>
* @version $Name$ $Revision$ $Date$
*/
public abstract class SpaceMouse {
/** Create an instance of the SpaceMouse device.
*
* @param peerComponent is the AWt component that must be connected to
* the physical device.
* @return the new instance of the SpaceMouse
*/
public static SpaceMouse createInstance(JFrame peerComponent) {
Toolkit toolkit = Toolkit.getDefaultToolkit();
if (toolkit instanceof XToolkit) { | return new XSpaceMouse(peerComponent); |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/VoidSpawn.java | // Path: src/main/java/com/endercrest/voidspawn/commands/VoidSpawnTabCompleter.java
// public class VoidSpawnTabCompleter implements TabCompleter {
//
// private CommandHandler handler;
//
// public VoidSpawnTabCompleter(CommandHandler handler) {
// this.handler = handler;
// }
//
// @Override
// public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
// if(!cmd.getName().equalsIgnoreCase("voidspawn") || !(sender instanceof Player)) {
// return null;
// }
// List<String> output = new ArrayList<>();
// Player player = (Player) sender;
// // Send all sub-commands that user has perms for
// if(args.length <= 1) {
// for(Map.Entry<String, SubCommand> subCommand: handler.getCommands()) {
// String permission = subCommand.getValue().permission();
// if(permission == null || !player.hasPermission(permission))
// continue;
//
// if(args.length == 0 || subCommand.getKey().startsWith(args[0])) {
// output.add(subCommand.getKey());
// }
// }
//
// return output;
// }
//
// SubCommand subCommand = handler.getSubCommand(args[0]);
// return subCommand != null ? subCommand.getTabCompletion(player, Arrays.copyOfRange(args, 1, args.length)) : null;
// }
//
// /////////////////////////////////////////////
// //// Common Auto Completes ////
// /////////////////////////////////////////////
//
//
// static List<String> getBooleanWorldCompletion(String[] args) {
// switch(args.length) {
// case 1:
// return new ArrayList<String>() {{
// add("true");
// add("false");
// }}
// .stream()
// .filter(s -> s.startsWith(args[0].toLowerCase()))
// .collect(Collectors.toList());
// case 2:
// return WorldUtil.getMatchingWorlds(args[1]);
// default:
// return new ArrayList<>();
// }
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/utils/MessageUtil.java
// public class MessageUtil {
//
// /**
// * Add Color to Messages
// *
// * @param str The String
// * @return Coloured String
// */
// public static String colorize(String str){
// return str.replaceAll("(?i)&([a-f0-9k-or])", "\u00a7$1");
// }
//
// public static String colorize(String str, Object... args){
// return colorize(String.format(str, args));
// }
// }
| import java.util.logging.Level;
import com.endercrest.voidspawn.commands.VoidSpawnTabCompleter;
import com.endercrest.voidspawn.utils.MessageUtil;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; | package com.endercrest.voidspawn;
public class VoidSpawn extends JavaPlugin {
public static String prefix = "[&6VS&f] ";
public void onEnable(){
try {
// This is the class we check for as it was added in 1.13 and should remain in place for the long term.
Class.forName("org.bukkit.Tag");
} catch (ClassNotFoundException e) {
log("&cERROR: Unsupported version of Spigot/Paper detected!");
log("&cERROR: Disabling plugin! Please update to latest version");
log("&cERROR: or use an unsupported version of VoidSpawn");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
/* if[PROD] */
Metrics metrics = new Metrics(this, 3514);
/* end[PROD] */
loadConfiguration();
ConfigManager.getInstance().setUp(this);
TeleportManager.getInstance().setUp(this);
ModeManager.getInstance().setUp(this);
DetectorManager.getInstance().setUp();
getServer().getPluginManager().registerEvents(new VoidListener(this), this);
getServer().getPluginManager().registerEvents(new QuitListener(), this);
PluginCommand command = getCommand("voidspawn");
CommandHandler commandHandler = new CommandHandler(this);
command.setExecutor(commandHandler); | // Path: src/main/java/com/endercrest/voidspawn/commands/VoidSpawnTabCompleter.java
// public class VoidSpawnTabCompleter implements TabCompleter {
//
// private CommandHandler handler;
//
// public VoidSpawnTabCompleter(CommandHandler handler) {
// this.handler = handler;
// }
//
// @Override
// public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
// if(!cmd.getName().equalsIgnoreCase("voidspawn") || !(sender instanceof Player)) {
// return null;
// }
// List<String> output = new ArrayList<>();
// Player player = (Player) sender;
// // Send all sub-commands that user has perms for
// if(args.length <= 1) {
// for(Map.Entry<String, SubCommand> subCommand: handler.getCommands()) {
// String permission = subCommand.getValue().permission();
// if(permission == null || !player.hasPermission(permission))
// continue;
//
// if(args.length == 0 || subCommand.getKey().startsWith(args[0])) {
// output.add(subCommand.getKey());
// }
// }
//
// return output;
// }
//
// SubCommand subCommand = handler.getSubCommand(args[0]);
// return subCommand != null ? subCommand.getTabCompletion(player, Arrays.copyOfRange(args, 1, args.length)) : null;
// }
//
// /////////////////////////////////////////////
// //// Common Auto Completes ////
// /////////////////////////////////////////////
//
//
// static List<String> getBooleanWorldCompletion(String[] args) {
// switch(args.length) {
// case 1:
// return new ArrayList<String>() {{
// add("true");
// add("false");
// }}
// .stream()
// .filter(s -> s.startsWith(args[0].toLowerCase()))
// .collect(Collectors.toList());
// case 2:
// return WorldUtil.getMatchingWorlds(args[1]);
// default:
// return new ArrayList<>();
// }
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/utils/MessageUtil.java
// public class MessageUtil {
//
// /**
// * Add Color to Messages
// *
// * @param str The String
// * @return Coloured String
// */
// public static String colorize(String str){
// return str.replaceAll("(?i)&([a-f0-9k-or])", "\u00a7$1");
// }
//
// public static String colorize(String str, Object... args){
// return colorize(String.format(str, args));
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/VoidSpawn.java
import java.util.logging.Level;
import com.endercrest.voidspawn.commands.VoidSpawnTabCompleter;
import com.endercrest.voidspawn.utils.MessageUtil;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
package com.endercrest.voidspawn;
public class VoidSpawn extends JavaPlugin {
public static String prefix = "[&6VS&f] ";
public void onEnable(){
try {
// This is the class we check for as it was added in 1.13 and should remain in place for the long term.
Class.forName("org.bukkit.Tag");
} catch (ClassNotFoundException e) {
log("&cERROR: Unsupported version of Spigot/Paper detected!");
log("&cERROR: Disabling plugin! Please update to latest version");
log("&cERROR: or use an unsupported version of VoidSpawn");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
/* if[PROD] */
Metrics metrics = new Metrics(this, 3514);
/* end[PROD] */
loadConfiguration();
ConfigManager.getInstance().setUp(this);
TeleportManager.getInstance().setUp(this);
ModeManager.getInstance().setUp(this);
DetectorManager.getInstance().setUp();
getServer().getPluginManager().registerEvents(new VoidListener(this), this);
getServer().getPluginManager().registerEvents(new QuitListener(), this);
PluginCommand command = getCommand("voidspawn");
CommandHandler commandHandler = new CommandHandler(this);
command.setExecutor(commandHandler); | command.setTabCompleter(new VoidSpawnTabCompleter(commandHandler)); |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/VoidSpawn.java | // Path: src/main/java/com/endercrest/voidspawn/commands/VoidSpawnTabCompleter.java
// public class VoidSpawnTabCompleter implements TabCompleter {
//
// private CommandHandler handler;
//
// public VoidSpawnTabCompleter(CommandHandler handler) {
// this.handler = handler;
// }
//
// @Override
// public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
// if(!cmd.getName().equalsIgnoreCase("voidspawn") || !(sender instanceof Player)) {
// return null;
// }
// List<String> output = new ArrayList<>();
// Player player = (Player) sender;
// // Send all sub-commands that user has perms for
// if(args.length <= 1) {
// for(Map.Entry<String, SubCommand> subCommand: handler.getCommands()) {
// String permission = subCommand.getValue().permission();
// if(permission == null || !player.hasPermission(permission))
// continue;
//
// if(args.length == 0 || subCommand.getKey().startsWith(args[0])) {
// output.add(subCommand.getKey());
// }
// }
//
// return output;
// }
//
// SubCommand subCommand = handler.getSubCommand(args[0]);
// return subCommand != null ? subCommand.getTabCompletion(player, Arrays.copyOfRange(args, 1, args.length)) : null;
// }
//
// /////////////////////////////////////////////
// //// Common Auto Completes ////
// /////////////////////////////////////////////
//
//
// static List<String> getBooleanWorldCompletion(String[] args) {
// switch(args.length) {
// case 1:
// return new ArrayList<String>() {{
// add("true");
// add("false");
// }}
// .stream()
// .filter(s -> s.startsWith(args[0].toLowerCase()))
// .collect(Collectors.toList());
// case 2:
// return WorldUtil.getMatchingWorlds(args[1]);
// default:
// return new ArrayList<>();
// }
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/utils/MessageUtil.java
// public class MessageUtil {
//
// /**
// * Add Color to Messages
// *
// * @param str The String
// * @return Coloured String
// */
// public static String colorize(String str){
// return str.replaceAll("(?i)&([a-f0-9k-or])", "\u00a7$1");
// }
//
// public static String colorize(String str, Object... args){
// return colorize(String.format(str, args));
// }
// }
| import java.util.logging.Level;
import com.endercrest.voidspawn.commands.VoidSpawnTabCompleter;
import com.endercrest.voidspawn.utils.MessageUtil;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; | package com.endercrest.voidspawn;
public class VoidSpawn extends JavaPlugin {
public static String prefix = "[&6VS&f] ";
public void onEnable(){
try {
// This is the class we check for as it was added in 1.13 and should remain in place for the long term.
Class.forName("org.bukkit.Tag");
} catch (ClassNotFoundException e) {
log("&cERROR: Unsupported version of Spigot/Paper detected!");
log("&cERROR: Disabling plugin! Please update to latest version");
log("&cERROR: or use an unsupported version of VoidSpawn");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
/* if[PROD] */
Metrics metrics = new Metrics(this, 3514);
/* end[PROD] */
loadConfiguration();
ConfigManager.getInstance().setUp(this);
TeleportManager.getInstance().setUp(this);
ModeManager.getInstance().setUp(this);
DetectorManager.getInstance().setUp();
getServer().getPluginManager().registerEvents(new VoidListener(this), this);
getServer().getPluginManager().registerEvents(new QuitListener(), this);
PluginCommand command = getCommand("voidspawn");
CommandHandler commandHandler = new CommandHandler(this);
command.setExecutor(commandHandler);
command.setTabCompleter(new VoidSpawnTabCompleter(commandHandler));
Bukkit.getScheduler().runTaskTimer(this, new TouchTracker(), 5, 5);
log("&ev" + getDescription().getVersion() + " by EnderCrest enabled");
}
public void onDisable(){
log("&ev" + getDescription().getVersion() + " saving config");
ConfigManager.getInstance().saveConfig();
log("&ev" + getDescription().getVersion() + " disabled");
}
public void loadConfiguration(){
if(!getConfig().contains("color-logs")){
getConfig().addDefault("color-logs", true);
}
getConfig().options().copyDefaults(true);
saveConfig();
}
/**
* Sends Messages to Console
*
* @param obj The Obj(Message)
*/
public void log(Object obj){
if(getConfig().getBoolean("color-logs", true)){ | // Path: src/main/java/com/endercrest/voidspawn/commands/VoidSpawnTabCompleter.java
// public class VoidSpawnTabCompleter implements TabCompleter {
//
// private CommandHandler handler;
//
// public VoidSpawnTabCompleter(CommandHandler handler) {
// this.handler = handler;
// }
//
// @Override
// public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
// if(!cmd.getName().equalsIgnoreCase("voidspawn") || !(sender instanceof Player)) {
// return null;
// }
// List<String> output = new ArrayList<>();
// Player player = (Player) sender;
// // Send all sub-commands that user has perms for
// if(args.length <= 1) {
// for(Map.Entry<String, SubCommand> subCommand: handler.getCommands()) {
// String permission = subCommand.getValue().permission();
// if(permission == null || !player.hasPermission(permission))
// continue;
//
// if(args.length == 0 || subCommand.getKey().startsWith(args[0])) {
// output.add(subCommand.getKey());
// }
// }
//
// return output;
// }
//
// SubCommand subCommand = handler.getSubCommand(args[0]);
// return subCommand != null ? subCommand.getTabCompletion(player, Arrays.copyOfRange(args, 1, args.length)) : null;
// }
//
// /////////////////////////////////////////////
// //// Common Auto Completes ////
// /////////////////////////////////////////////
//
//
// static List<String> getBooleanWorldCompletion(String[] args) {
// switch(args.length) {
// case 1:
// return new ArrayList<String>() {{
// add("true");
// add("false");
// }}
// .stream()
// .filter(s -> s.startsWith(args[0].toLowerCase()))
// .collect(Collectors.toList());
// case 2:
// return WorldUtil.getMatchingWorlds(args[1]);
// default:
// return new ArrayList<>();
// }
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/utils/MessageUtil.java
// public class MessageUtil {
//
// /**
// * Add Color to Messages
// *
// * @param str The String
// * @return Coloured String
// */
// public static String colorize(String str){
// return str.replaceAll("(?i)&([a-f0-9k-or])", "\u00a7$1");
// }
//
// public static String colorize(String str, Object... args){
// return colorize(String.format(str, args));
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/VoidSpawn.java
import java.util.logging.Level;
import com.endercrest.voidspawn.commands.VoidSpawnTabCompleter;
import com.endercrest.voidspawn.utils.MessageUtil;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
package com.endercrest.voidspawn;
public class VoidSpawn extends JavaPlugin {
public static String prefix = "[&6VS&f] ";
public void onEnable(){
try {
// This is the class we check for as it was added in 1.13 and should remain in place for the long term.
Class.forName("org.bukkit.Tag");
} catch (ClassNotFoundException e) {
log("&cERROR: Unsupported version of Spigot/Paper detected!");
log("&cERROR: Disabling plugin! Please update to latest version");
log("&cERROR: or use an unsupported version of VoidSpawn");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
/* if[PROD] */
Metrics metrics = new Metrics(this, 3514);
/* end[PROD] */
loadConfiguration();
ConfigManager.getInstance().setUp(this);
TeleportManager.getInstance().setUp(this);
ModeManager.getInstance().setUp(this);
DetectorManager.getInstance().setUp();
getServer().getPluginManager().registerEvents(new VoidListener(this), this);
getServer().getPluginManager().registerEvents(new QuitListener(), this);
PluginCommand command = getCommand("voidspawn");
CommandHandler commandHandler = new CommandHandler(this);
command.setExecutor(commandHandler);
command.setTabCompleter(new VoidSpawnTabCompleter(commandHandler));
Bukkit.getScheduler().runTaskTimer(this, new TouchTracker(), 5, 5);
log("&ev" + getDescription().getVersion() + " by EnderCrest enabled");
}
public void onDisable(){
log("&ev" + getDescription().getVersion() + " saving config");
ConfigManager.getInstance().saveConfig();
log("&ev" + getDescription().getVersion() + " disabled");
}
public void loadConfiguration(){
if(!getConfig().contains("color-logs")){
getConfig().addDefault("color-logs", true);
}
getConfig().options().copyDefaults(true);
saveConfig();
}
/**
* Sends Messages to Console
*
* @param obj The Obj(Message)
*/
public void log(Object obj){
if(getConfig().getBoolean("color-logs", true)){ | getServer().getConsoleSender().sendMessage(MessageUtil.colorize("&3[&d" + getName() + "&3] &r" + obj)); |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/options/Option.java | // Path: src/main/java/com/endercrest/voidspawn/modes/status/Status.java
// public class Status {
// private final Type type;
// private final String message;
//
// public Status(Type type, String message) {
// this.type = type;
// this.message = message;
// }
//
// public Type getType() {
// return type;
// }
//
// public String getMessage() {
// return message;
// }
//
// public enum Type {
// COMPLETE("[&a+&f]"),
// INCOMPLETE("[&cx&f]"),
// INFO("[&b@&f]"),
// UNSET("[&7-&f]");
//
// private String symbol;
//
// Type(String symbol) {
// this.symbol = symbol;
// }
//
// public String getSymbol() {
// return symbol;
// }
// }
// }
| import com.endercrest.voidspawn.modes.status.Status;
import org.bukkit.World;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Optional; | package com.endercrest.voidspawn.options;
public interface Option<T> {
/**
* Get the option identifer for this object.
*/
@NotNull
OptionIdentifier<T> getIdentifier();
/**
* Get the type that this option contains.
*/
@NotNull
Class<T> getType();
/**
* Get the value of the option for the given world.
* @param world The value to retrieve the value for
* @return Empty if value is not set.
*/
Optional<T> getValue(World world);
/**
* Set the value of this option
* @param world The world the value is being set for.
* @param value String value will be contained with the the {@link #getOptions()}
*/
void setValue(@NotNull World world, String value) throws IllegalArgumentException;
/**
* Set the value of this option
* @param world The world the value is being set for.
* @param args The arguments
*/
void setValue(@NotNull World world, String[] args) throws IllegalArgumentException;
/**
* Specifies all the values that are acceptable as a value.
* @return A non-null set of accepted values or null if any value is accepted.
*/
List<String> getOptions();
/**
* Get description of the option.
*/
String getDescription();
/**
* Get the status of this option. This is useful to get a state of the option
* @param world The world
* @return
*/
@NotNull | // Path: src/main/java/com/endercrest/voidspawn/modes/status/Status.java
// public class Status {
// private final Type type;
// private final String message;
//
// public Status(Type type, String message) {
// this.type = type;
// this.message = message;
// }
//
// public Type getType() {
// return type;
// }
//
// public String getMessage() {
// return message;
// }
//
// public enum Type {
// COMPLETE("[&a+&f]"),
// INCOMPLETE("[&cx&f]"),
// INFO("[&b@&f]"),
// UNSET("[&7-&f]");
//
// private String symbol;
//
// Type(String symbol) {
// this.symbol = symbol;
// }
//
// public String getSymbol() {
// return symbol;
// }
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/options/Option.java
import com.endercrest.voidspawn.modes.status.Status;
import org.bukkit.World;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Optional;
package com.endercrest.voidspawn.options;
public interface Option<T> {
/**
* Get the option identifer for this object.
*/
@NotNull
OptionIdentifier<T> getIdentifier();
/**
* Get the type that this option contains.
*/
@NotNull
Class<T> getType();
/**
* Get the value of the option for the given world.
* @param world The value to retrieve the value for
* @return Empty if value is not set.
*/
Optional<T> getValue(World world);
/**
* Set the value of this option
* @param world The world the value is being set for.
* @param value String value will be contained with the the {@link #getOptions()}
*/
void setValue(@NotNull World world, String value) throws IllegalArgumentException;
/**
* Set the value of this option
* @param world The world the value is being set for.
* @param args The arguments
*/
void setValue(@NotNull World world, String[] args) throws IllegalArgumentException;
/**
* Specifies all the values that are acceptable as a value.
* @return A non-null set of accepted values or null if any value is accepted.
*/
List<String> getOptions();
/**
* Get description of the option.
*/
String getDescription();
/**
* Get the status of this option. This is useful to get a state of the option
* @param world The world
* @return
*/
@NotNull | Status getStatus(World world); |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/options/container/BasicOptionContainer.java | // Path: src/main/java/com/endercrest/voidspawn/options/EmptyOption.java
// public final class EmptyOption<T> extends BaseOption<T> {
// public EmptyOption(@NotNull OptionIdentifier<T> identifier) {
// super(identifier);
// }
//
// @Override
// public Optional<T> getLoadedValue(@NotNull World world) {
// return Optional.empty();
// }
//
// @Override
// public void setValue(@NotNull World world, String value) {}
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {}
//
// @Override
// public List<String> getOptions() {
// return Collections.emptyList();
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/Option.java
// public interface Option<T> {
// /**
// * Get the option identifer for this object.
// */
// @NotNull
// OptionIdentifier<T> getIdentifier();
//
// /**
// * Get the type that this option contains.
// */
// @NotNull
// Class<T> getType();
//
// /**
// * Get the value of the option for the given world.
// * @param world The value to retrieve the value for
// * @return Empty if value is not set.
// */
// Optional<T> getValue(World world);
//
// /**
// * Set the value of this option
// * @param world The world the value is being set for.
// * @param value String value will be contained with the the {@link #getOptions()}
// */
// void setValue(@NotNull World world, String value) throws IllegalArgumentException;
//
// /**
// * Set the value of this option
// * @param world The world the value is being set for.
// * @param args The arguments
// */
// void setValue(@NotNull World world, String[] args) throws IllegalArgumentException;
//
// /**
// * Specifies all the values that are acceptable as a value.
// * @return A non-null set of accepted values or null if any value is accepted.
// */
// List<String> getOptions();
//
// /**
// * Get description of the option.
// */
// String getDescription();
//
// /**
// * Get the status of this option. This is useful to get a state of the option
// * @param world The world
// * @return
// */
// @NotNull
// Status getStatus(World world);
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/container/OptionContainer.java
// public interface OptionContainer {
// /**
// * Attempt to retrieve a option of the given name.
// *
// * @param <T> The type the option will be casted to.
// * @param identifier The identifier for the option.
// * @return The option if it exists, returns empty if no existing option or
// * if the option identifier type does not match option type.
// */
// @NotNull <T> Option<T> getOption(OptionIdentifier<T> identifier);
//
// /**
// * Attempt to retrieve a option of the given name by the name. If possible, use {@link #getOption(OptionIdentifier)} as
// * that guarantees a type.
// *
// * @param name The name of the option to retrieve.
// * @return The option or null if doesn't exist.
// */
// @Nullable Option<?> getOption(String name);
//
// /**
// * Get a list of all options for this mode.
// *
// * @return non-null list of options
// */
// Collection<Option<?>> getOptions();
// }
| import com.endercrest.voidspawn.options.EmptyOption;
import com.endercrest.voidspawn.options.Option;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.options.container.OptionContainer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map; | package com.endercrest.voidspawn.options.container;
public abstract class BasicOptionContainer implements OptionContainer {
private final Map<String, Option<?>> options = new HashMap<>();
protected void attachOption(Option<?> option) {
options.put(option.getIdentifier().getName(), option);
}
| // Path: src/main/java/com/endercrest/voidspawn/options/EmptyOption.java
// public final class EmptyOption<T> extends BaseOption<T> {
// public EmptyOption(@NotNull OptionIdentifier<T> identifier) {
// super(identifier);
// }
//
// @Override
// public Optional<T> getLoadedValue(@NotNull World world) {
// return Optional.empty();
// }
//
// @Override
// public void setValue(@NotNull World world, String value) {}
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {}
//
// @Override
// public List<String> getOptions() {
// return Collections.emptyList();
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/Option.java
// public interface Option<T> {
// /**
// * Get the option identifer for this object.
// */
// @NotNull
// OptionIdentifier<T> getIdentifier();
//
// /**
// * Get the type that this option contains.
// */
// @NotNull
// Class<T> getType();
//
// /**
// * Get the value of the option for the given world.
// * @param world The value to retrieve the value for
// * @return Empty if value is not set.
// */
// Optional<T> getValue(World world);
//
// /**
// * Set the value of this option
// * @param world The world the value is being set for.
// * @param value String value will be contained with the the {@link #getOptions()}
// */
// void setValue(@NotNull World world, String value) throws IllegalArgumentException;
//
// /**
// * Set the value of this option
// * @param world The world the value is being set for.
// * @param args The arguments
// */
// void setValue(@NotNull World world, String[] args) throws IllegalArgumentException;
//
// /**
// * Specifies all the values that are acceptable as a value.
// * @return A non-null set of accepted values or null if any value is accepted.
// */
// List<String> getOptions();
//
// /**
// * Get description of the option.
// */
// String getDescription();
//
// /**
// * Get the status of this option. This is useful to get a state of the option
// * @param world The world
// * @return
// */
// @NotNull
// Status getStatus(World world);
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/container/OptionContainer.java
// public interface OptionContainer {
// /**
// * Attempt to retrieve a option of the given name.
// *
// * @param <T> The type the option will be casted to.
// * @param identifier The identifier for the option.
// * @return The option if it exists, returns empty if no existing option or
// * if the option identifier type does not match option type.
// */
// @NotNull <T> Option<T> getOption(OptionIdentifier<T> identifier);
//
// /**
// * Attempt to retrieve a option of the given name by the name. If possible, use {@link #getOption(OptionIdentifier)} as
// * that guarantees a type.
// *
// * @param name The name of the option to retrieve.
// * @return The option or null if doesn't exist.
// */
// @Nullable Option<?> getOption(String name);
//
// /**
// * Get a list of all options for this mode.
// *
// * @return non-null list of options
// */
// Collection<Option<?>> getOptions();
// }
// Path: src/main/java/com/endercrest/voidspawn/options/container/BasicOptionContainer.java
import com.endercrest.voidspawn.options.EmptyOption;
import com.endercrest.voidspawn.options.Option;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.options.container.OptionContainer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
package com.endercrest.voidspawn.options.container;
public abstract class BasicOptionContainer implements OptionContainer {
private final Map<String, Option<?>> options = new HashMap<>();
protected void attachOption(Option<?> option) {
options.put(option.getIdentifier().getName(), option);
}
| protected void detachOption(@NotNull OptionIdentifier<?> identifier) { |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/options/container/BasicOptionContainer.java | // Path: src/main/java/com/endercrest/voidspawn/options/EmptyOption.java
// public final class EmptyOption<T> extends BaseOption<T> {
// public EmptyOption(@NotNull OptionIdentifier<T> identifier) {
// super(identifier);
// }
//
// @Override
// public Optional<T> getLoadedValue(@NotNull World world) {
// return Optional.empty();
// }
//
// @Override
// public void setValue(@NotNull World world, String value) {}
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {}
//
// @Override
// public List<String> getOptions() {
// return Collections.emptyList();
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/Option.java
// public interface Option<T> {
// /**
// * Get the option identifer for this object.
// */
// @NotNull
// OptionIdentifier<T> getIdentifier();
//
// /**
// * Get the type that this option contains.
// */
// @NotNull
// Class<T> getType();
//
// /**
// * Get the value of the option for the given world.
// * @param world The value to retrieve the value for
// * @return Empty if value is not set.
// */
// Optional<T> getValue(World world);
//
// /**
// * Set the value of this option
// * @param world The world the value is being set for.
// * @param value String value will be contained with the the {@link #getOptions()}
// */
// void setValue(@NotNull World world, String value) throws IllegalArgumentException;
//
// /**
// * Set the value of this option
// * @param world The world the value is being set for.
// * @param args The arguments
// */
// void setValue(@NotNull World world, String[] args) throws IllegalArgumentException;
//
// /**
// * Specifies all the values that are acceptable as a value.
// * @return A non-null set of accepted values or null if any value is accepted.
// */
// List<String> getOptions();
//
// /**
// * Get description of the option.
// */
// String getDescription();
//
// /**
// * Get the status of this option. This is useful to get a state of the option
// * @param world The world
// * @return
// */
// @NotNull
// Status getStatus(World world);
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/container/OptionContainer.java
// public interface OptionContainer {
// /**
// * Attempt to retrieve a option of the given name.
// *
// * @param <T> The type the option will be casted to.
// * @param identifier The identifier for the option.
// * @return The option if it exists, returns empty if no existing option or
// * if the option identifier type does not match option type.
// */
// @NotNull <T> Option<T> getOption(OptionIdentifier<T> identifier);
//
// /**
// * Attempt to retrieve a option of the given name by the name. If possible, use {@link #getOption(OptionIdentifier)} as
// * that guarantees a type.
// *
// * @param name The name of the option to retrieve.
// * @return The option or null if doesn't exist.
// */
// @Nullable Option<?> getOption(String name);
//
// /**
// * Get a list of all options for this mode.
// *
// * @return non-null list of options
// */
// Collection<Option<?>> getOptions();
// }
| import com.endercrest.voidspawn.options.EmptyOption;
import com.endercrest.voidspawn.options.Option;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.options.container.OptionContainer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map; | package com.endercrest.voidspawn.options.container;
public abstract class BasicOptionContainer implements OptionContainer {
private final Map<String, Option<?>> options = new HashMap<>();
protected void attachOption(Option<?> option) {
options.put(option.getIdentifier().getName(), option);
}
protected void detachOption(@NotNull OptionIdentifier<?> identifier) {
options.remove(identifier.getName());
}
@SuppressWarnings("unchecked")
@Override
public @NotNull <T> Option<T> getOption(OptionIdentifier<T> identifier) {
Option<?> option = options.get(identifier.getName());
if (option == null || option.getType() != identifier.getType()) { | // Path: src/main/java/com/endercrest/voidspawn/options/EmptyOption.java
// public final class EmptyOption<T> extends BaseOption<T> {
// public EmptyOption(@NotNull OptionIdentifier<T> identifier) {
// super(identifier);
// }
//
// @Override
// public Optional<T> getLoadedValue(@NotNull World world) {
// return Optional.empty();
// }
//
// @Override
// public void setValue(@NotNull World world, String value) {}
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {}
//
// @Override
// public List<String> getOptions() {
// return Collections.emptyList();
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/Option.java
// public interface Option<T> {
// /**
// * Get the option identifer for this object.
// */
// @NotNull
// OptionIdentifier<T> getIdentifier();
//
// /**
// * Get the type that this option contains.
// */
// @NotNull
// Class<T> getType();
//
// /**
// * Get the value of the option for the given world.
// * @param world The value to retrieve the value for
// * @return Empty if value is not set.
// */
// Optional<T> getValue(World world);
//
// /**
// * Set the value of this option
// * @param world The world the value is being set for.
// * @param value String value will be contained with the the {@link #getOptions()}
// */
// void setValue(@NotNull World world, String value) throws IllegalArgumentException;
//
// /**
// * Set the value of this option
// * @param world The world the value is being set for.
// * @param args The arguments
// */
// void setValue(@NotNull World world, String[] args) throws IllegalArgumentException;
//
// /**
// * Specifies all the values that are acceptable as a value.
// * @return A non-null set of accepted values or null if any value is accepted.
// */
// List<String> getOptions();
//
// /**
// * Get description of the option.
// */
// String getDescription();
//
// /**
// * Get the status of this option. This is useful to get a state of the option
// * @param world The world
// * @return
// */
// @NotNull
// Status getStatus(World world);
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/container/OptionContainer.java
// public interface OptionContainer {
// /**
// * Attempt to retrieve a option of the given name.
// *
// * @param <T> The type the option will be casted to.
// * @param identifier The identifier for the option.
// * @return The option if it exists, returns empty if no existing option or
// * if the option identifier type does not match option type.
// */
// @NotNull <T> Option<T> getOption(OptionIdentifier<T> identifier);
//
// /**
// * Attempt to retrieve a option of the given name by the name. If possible, use {@link #getOption(OptionIdentifier)} as
// * that guarantees a type.
// *
// * @param name The name of the option to retrieve.
// * @return The option or null if doesn't exist.
// */
// @Nullable Option<?> getOption(String name);
//
// /**
// * Get a list of all options for this mode.
// *
// * @return non-null list of options
// */
// Collection<Option<?>> getOptions();
// }
// Path: src/main/java/com/endercrest/voidspawn/options/container/BasicOptionContainer.java
import com.endercrest.voidspawn.options.EmptyOption;
import com.endercrest.voidspawn.options.Option;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.options.container.OptionContainer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
package com.endercrest.voidspawn.options.container;
public abstract class BasicOptionContainer implements OptionContainer {
private final Map<String, Option<?>> options = new HashMap<>();
protected void attachOption(Option<?> option) {
options.put(option.getIdentifier().getName(), option);
}
protected void detachOption(@NotNull OptionIdentifier<?> identifier) {
options.remove(identifier.getName());
}
@SuppressWarnings("unchecked")
@Override
public @NotNull <T> Option<T> getOption(OptionIdentifier<T> identifier) {
Option<?> option = options.get(identifier.getName());
if (option == null || option.getType() != identifier.getType()) { | return new EmptyOption<>(identifier); |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/modes/island/SuperiorSkyblockIslandMode.java | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
| import com.bgsoftware.superiorskyblock.api.SuperiorSkyblockAPI;
import com.bgsoftware.superiorskyblock.api.island.Island;
import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer;
import com.endercrest.voidspawn.TeleportResult;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player; | package com.endercrest.voidspawn.modes.island;
public class SuperiorSkyblockIslandMode extends BaseIslandMode{
@Override
public boolean isEnabled() {
return isModeEnabled();
}
@Override | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/modes/island/SuperiorSkyblockIslandMode.java
import com.bgsoftware.superiorskyblock.api.SuperiorSkyblockAPI;
import com.bgsoftware.superiorskyblock.api.island.Island;
import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer;
import com.endercrest.voidspawn.TeleportResult;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
package com.endercrest.voidspawn.modes.island;
public class SuperiorSkyblockIslandMode extends BaseIslandMode{
@Override
public boolean isEnabled() {
return isModeEnabled();
}
@Override | public TeleportResult onActivateIsland(Player player, String worldname) { |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/modes/island/DisabledIslandMode.java | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
| import com.endercrest.voidspawn.TeleportResult;
import org.bukkit.entity.Player; | package com.endercrest.voidspawn.modes.island;
public class DisabledIslandMode extends BaseIslandMode {
@Override
public boolean isEnabled() {
return false;
}
@Override | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/modes/island/DisabledIslandMode.java
import com.endercrest.voidspawn.TeleportResult;
import org.bukkit.entity.Player;
package com.endercrest.voidspawn.modes.island;
public class DisabledIslandMode extends BaseIslandMode {
@Override
public boolean isEnabled() {
return false;
}
@Override | public TeleportResult onActivateIsland(Player player, String worldname) { |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/modes/island/USkyBlockIslandMode.java | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/modes/status/Status.java
// public class Status {
// private final Type type;
// private final String message;
//
// public Status(Type type, String message) {
// this.type = type;
// this.message = message;
// }
//
// public Type getType() {
// return type;
// }
//
// public String getMessage() {
// return message;
// }
//
// public enum Type {
// COMPLETE("[&a+&f]"),
// INCOMPLETE("[&cx&f]"),
// INFO("[&b@&f]"),
// UNSET("[&7-&f]");
//
// private String symbol;
//
// Type(String symbol) {
// this.symbol = symbol;
// }
//
// public String getSymbol() {
// return symbol;
// }
// }
// }
| import com.endercrest.voidspawn.TeleportResult;
import com.endercrest.voidspawn.modes.status.Status;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import us.talabrek.ultimateskyblock.api.IslandInfo;
import us.talabrek.ultimateskyblock.api.uSkyBlockAPI; | package com.endercrest.voidspawn.modes.island;
public class USkyBlockIslandMode extends BaseIslandMode {
private final uSkyBlockAPI usb;
public USkyBlockIslandMode() {
this.usb = (uSkyBlockAPI) Bukkit.getPluginManager().getPlugin("uSkyBlock");
}
@Override | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/modes/status/Status.java
// public class Status {
// private final Type type;
// private final String message;
//
// public Status(Type type, String message) {
// this.type = type;
// this.message = message;
// }
//
// public Type getType() {
// return type;
// }
//
// public String getMessage() {
// return message;
// }
//
// public enum Type {
// COMPLETE("[&a+&f]"),
// INCOMPLETE("[&cx&f]"),
// INFO("[&b@&f]"),
// UNSET("[&7-&f]");
//
// private String symbol;
//
// Type(String symbol) {
// this.symbol = symbol;
// }
//
// public String getSymbol() {
// return symbol;
// }
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/modes/island/USkyBlockIslandMode.java
import com.endercrest.voidspawn.TeleportResult;
import com.endercrest.voidspawn.modes.status.Status;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import us.talabrek.ultimateskyblock.api.IslandInfo;
import us.talabrek.ultimateskyblock.api.uSkyBlockAPI;
package com.endercrest.voidspawn.modes.island;
public class USkyBlockIslandMode extends BaseIslandMode {
private final uSkyBlockAPI usb;
public USkyBlockIslandMode() {
this.usb = (uSkyBlockAPI) Bukkit.getPluginManager().getPlugin("uSkyBlock");
}
@Override | public TeleportResult onActivateIsland(Player player, String worldname) { |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/modes/island/USkyBlockIslandMode.java | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/modes/status/Status.java
// public class Status {
// private final Type type;
// private final String message;
//
// public Status(Type type, String message) {
// this.type = type;
// this.message = message;
// }
//
// public Type getType() {
// return type;
// }
//
// public String getMessage() {
// return message;
// }
//
// public enum Type {
// COMPLETE("[&a+&f]"),
// INCOMPLETE("[&cx&f]"),
// INFO("[&b@&f]"),
// UNSET("[&7-&f]");
//
// private String symbol;
//
// Type(String symbol) {
// this.symbol = symbol;
// }
//
// public String getSymbol() {
// return symbol;
// }
// }
// }
| import com.endercrest.voidspawn.TeleportResult;
import com.endercrest.voidspawn.modes.status.Status;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import us.talabrek.ultimateskyblock.api.IslandInfo;
import us.talabrek.ultimateskyblock.api.uSkyBlockAPI; | package com.endercrest.voidspawn.modes.island;
public class USkyBlockIslandMode extends BaseIslandMode {
private final uSkyBlockAPI usb;
public USkyBlockIslandMode() {
this.usb = (uSkyBlockAPI) Bukkit.getPluginManager().getPlugin("uSkyBlock");
}
@Override
public TeleportResult onActivateIsland(Player player, String worldname) {
IslandInfo info = usb.getIslandInfo(player);
if (info.getWarpLocation() != null) {
player.teleport(info.getWarpLocation());
return TeleportResult.SUCCESS;
}
if (info.getIslandLocation() != null) {
player.teleport(info.getIslandLocation());
return TeleportResult.SUCCESS;
}
return TeleportResult.MISSING_ISLAND;
}
@Override | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/modes/status/Status.java
// public class Status {
// private final Type type;
// private final String message;
//
// public Status(Type type, String message) {
// this.type = type;
// this.message = message;
// }
//
// public Type getType() {
// return type;
// }
//
// public String getMessage() {
// return message;
// }
//
// public enum Type {
// COMPLETE("[&a+&f]"),
// INCOMPLETE("[&cx&f]"),
// INFO("[&b@&f]"),
// UNSET("[&7-&f]");
//
// private String symbol;
//
// Type(String symbol) {
// this.symbol = symbol;
// }
//
// public String getSymbol() {
// return symbol;
// }
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/modes/island/USkyBlockIslandMode.java
import com.endercrest.voidspawn.TeleportResult;
import com.endercrest.voidspawn.modes.status.Status;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import us.talabrek.ultimateskyblock.api.IslandInfo;
import us.talabrek.ultimateskyblock.api.uSkyBlockAPI;
package com.endercrest.voidspawn.modes.island;
public class USkyBlockIslandMode extends BaseIslandMode {
private final uSkyBlockAPI usb;
public USkyBlockIslandMode() {
this.usb = (uSkyBlockAPI) Bukkit.getPluginManager().getPlugin("uSkyBlock");
}
@Override
public TeleportResult onActivateIsland(Player player, String worldname) {
IslandInfo info = usb.getIslandInfo(player);
if (info.getWarpLocation() != null) {
player.teleport(info.getWarpLocation());
return TeleportResult.SUCCESS;
}
if (info.getIslandLocation() != null) {
player.teleport(info.getIslandLocation());
return TeleportResult.SUCCESS;
}
return TeleportResult.MISSING_ISLAND;
}
@Override | public Status[] getStatus(String worldName) { |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/CommandHandler.java | // Path: src/main/java/com/endercrest/voidspawn/utils/MessageUtil.java
// public class MessageUtil {
//
// /**
// * Add Color to Messages
// *
// * @param str The String
// * @return Coloured String
// */
// public static String colorize(String str){
// return str.replaceAll("(?i)&([a-f0-9k-or])", "\u00a7$1");
// }
//
// public static String colorize(String str, Object... args){
// return colorize(String.format(str, args));
// }
// }
| import com.endercrest.voidspawn.commands.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import com.endercrest.voidspawn.utils.MessageUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; |
/**
* Load the commands into the HashMap that makes it accessible to players.
*/
private void loadCommands(){
commands.put("set", new SetCommand());
commands.put("remove", new RemoveCommand());
commands.put("reload", new ReloadCommand());
commands.put("modes", new ModesCommand());
commands.put("mode", new ModeCommand());
commands.put("help", new HelpCommand(commands));
commands.put("toggle", new ToggleCommand());
commands.put("detector", new DetectorCommand());
commands.put("info", new InfoCommand());
commands.put("option", new OptionCommand());
}
public Set<Map.Entry<String, SubCommand>> getCommands() {
return commands.entrySet();
}
public SubCommand getSubCommand(String cmd) {
return commands.get(cmd);
}
@Override
public boolean onCommand(@NotNull CommandSender cs, @NotNull Command cmd, @NotNull String s, String[] args){
if(!(cs instanceof Player)){
if((args.length >= 1) && (args[0].equalsIgnoreCase("reload"))){
ConfigManager.getInstance().reloadConfig(); | // Path: src/main/java/com/endercrest/voidspawn/utils/MessageUtil.java
// public class MessageUtil {
//
// /**
// * Add Color to Messages
// *
// * @param str The String
// * @return Coloured String
// */
// public static String colorize(String str){
// return str.replaceAll("(?i)&([a-f0-9k-or])", "\u00a7$1");
// }
//
// public static String colorize(String str, Object... args){
// return colorize(String.format(str, args));
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/CommandHandler.java
import com.endercrest.voidspawn.commands.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import com.endercrest.voidspawn.utils.MessageUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
/**
* Load the commands into the HashMap that makes it accessible to players.
*/
private void loadCommands(){
commands.put("set", new SetCommand());
commands.put("remove", new RemoveCommand());
commands.put("reload", new ReloadCommand());
commands.put("modes", new ModesCommand());
commands.put("mode", new ModeCommand());
commands.put("help", new HelpCommand(commands));
commands.put("toggle", new ToggleCommand());
commands.put("detector", new DetectorCommand());
commands.put("info", new InfoCommand());
commands.put("option", new OptionCommand());
}
public Set<Map.Entry<String, SubCommand>> getCommands() {
return commands.entrySet();
}
public SubCommand getSubCommand(String cmd) {
return commands.get(cmd);
}
@Override
public boolean onCommand(@NotNull CommandSender cs, @NotNull Command cmd, @NotNull String s, String[] args){
if(!(cs instanceof Player)){
if((args.length >= 1) && (args[0].equalsIgnoreCase("reload"))){
ConfigManager.getInstance().reloadConfig(); | cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "&6Plugin Reloaded")); |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/commands/HelpCommand.java | // Path: src/main/java/com/endercrest/voidspawn/VoidSpawn.java
// public class VoidSpawn extends JavaPlugin {
// public static String prefix = "[&6VS&f] ";
//
// public void onEnable(){
// try {
// // This is the class we check for as it was added in 1.13 and should remain in place for the long term.
// Class.forName("org.bukkit.Tag");
// } catch (ClassNotFoundException e) {
// log("&cERROR: Unsupported version of Spigot/Paper detected!");
// log("&cERROR: Disabling plugin! Please update to latest version");
// log("&cERROR: or use an unsupported version of VoidSpawn");
// Bukkit.getPluginManager().disablePlugin(this);
// return;
// }
//
// /* if[PROD] */
// Metrics metrics = new Metrics(this, 3514);
// /* end[PROD] */
//
// loadConfiguration();
// ConfigManager.getInstance().setUp(this);
// TeleportManager.getInstance().setUp(this);
// ModeManager.getInstance().setUp(this);
// DetectorManager.getInstance().setUp();
// getServer().getPluginManager().registerEvents(new VoidListener(this), this);
// getServer().getPluginManager().registerEvents(new QuitListener(), this);
//
// PluginCommand command = getCommand("voidspawn");
// CommandHandler commandHandler = new CommandHandler(this);
// command.setExecutor(commandHandler);
// command.setTabCompleter(new VoidSpawnTabCompleter(commandHandler));
//
// Bukkit.getScheduler().runTaskTimer(this, new TouchTracker(), 5, 5);
//
// log("&ev" + getDescription().getVersion() + " by EnderCrest enabled");
// }
//
// public void onDisable(){
// log("&ev" + getDescription().getVersion() + " saving config");
// ConfigManager.getInstance().saveConfig();
// log("&ev" + getDescription().getVersion() + " disabled");
// }
//
// public void loadConfiguration(){
// if(!getConfig().contains("color-logs")){
// getConfig().addDefault("color-logs", true);
// }
// getConfig().options().copyDefaults(true);
// saveConfig();
// }
//
// /**
// * Sends Messages to Console
// *
// * @param obj The Obj(Message)
// */
// public void log(Object obj){
// if(getConfig().getBoolean("color-logs", true)){
// getServer().getConsoleSender().sendMessage(MessageUtil.colorize("&3[&d" + getName() + "&3] &r" + obj));
// }else{
// Bukkit.getLogger().log(Level.INFO, "[" + getName() + "] " + MessageUtil.colorize((String) obj).replaceAll("(?)\u00a7([a-f0-9k-or])", ""));
// }
// }
//
// }
//
// Path: src/main/java/com/endercrest/voidspawn/utils/MessageUtil.java
// public class MessageUtil {
//
// /**
// * Add Color to Messages
// *
// * @param str The String
// * @return Coloured String
// */
// public static String colorize(String str){
// return str.replaceAll("(?i)&([a-f0-9k-or])", "\u00a7$1");
// }
//
// public static String colorize(String str, Object... args){
// return colorize(String.format(str, args));
// }
// }
| import com.endercrest.voidspawn.VoidSpawn;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.endercrest.voidspawn.utils.MessageUtil;
import org.bukkit.entity.Player; | package com.endercrest.voidspawn.commands;
public class HelpCommand implements SubCommand {
HashMap<String, SubCommand> commands;
public HelpCommand(HashMap<String, SubCommand> commands){
this.commands = commands;
}
@Override
public boolean onCommand(Player p, String[] args){ | // Path: src/main/java/com/endercrest/voidspawn/VoidSpawn.java
// public class VoidSpawn extends JavaPlugin {
// public static String prefix = "[&6VS&f] ";
//
// public void onEnable(){
// try {
// // This is the class we check for as it was added in 1.13 and should remain in place for the long term.
// Class.forName("org.bukkit.Tag");
// } catch (ClassNotFoundException e) {
// log("&cERROR: Unsupported version of Spigot/Paper detected!");
// log("&cERROR: Disabling plugin! Please update to latest version");
// log("&cERROR: or use an unsupported version of VoidSpawn");
// Bukkit.getPluginManager().disablePlugin(this);
// return;
// }
//
// /* if[PROD] */
// Metrics metrics = new Metrics(this, 3514);
// /* end[PROD] */
//
// loadConfiguration();
// ConfigManager.getInstance().setUp(this);
// TeleportManager.getInstance().setUp(this);
// ModeManager.getInstance().setUp(this);
// DetectorManager.getInstance().setUp();
// getServer().getPluginManager().registerEvents(new VoidListener(this), this);
// getServer().getPluginManager().registerEvents(new QuitListener(), this);
//
// PluginCommand command = getCommand("voidspawn");
// CommandHandler commandHandler = new CommandHandler(this);
// command.setExecutor(commandHandler);
// command.setTabCompleter(new VoidSpawnTabCompleter(commandHandler));
//
// Bukkit.getScheduler().runTaskTimer(this, new TouchTracker(), 5, 5);
//
// log("&ev" + getDescription().getVersion() + " by EnderCrest enabled");
// }
//
// public void onDisable(){
// log("&ev" + getDescription().getVersion() + " saving config");
// ConfigManager.getInstance().saveConfig();
// log("&ev" + getDescription().getVersion() + " disabled");
// }
//
// public void loadConfiguration(){
// if(!getConfig().contains("color-logs")){
// getConfig().addDefault("color-logs", true);
// }
// getConfig().options().copyDefaults(true);
// saveConfig();
// }
//
// /**
// * Sends Messages to Console
// *
// * @param obj The Obj(Message)
// */
// public void log(Object obj){
// if(getConfig().getBoolean("color-logs", true)){
// getServer().getConsoleSender().sendMessage(MessageUtil.colorize("&3[&d" + getName() + "&3] &r" + obj));
// }else{
// Bukkit.getLogger().log(Level.INFO, "[" + getName() + "] " + MessageUtil.colorize((String) obj).replaceAll("(?)\u00a7([a-f0-9k-or])", ""));
// }
// }
//
// }
//
// Path: src/main/java/com/endercrest/voidspawn/utils/MessageUtil.java
// public class MessageUtil {
//
// /**
// * Add Color to Messages
// *
// * @param str The String
// * @return Coloured String
// */
// public static String colorize(String str){
// return str.replaceAll("(?i)&([a-f0-9k-or])", "\u00a7$1");
// }
//
// public static String colorize(String str, Object... args){
// return colorize(String.format(str, args));
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/commands/HelpCommand.java
import com.endercrest.voidspawn.VoidSpawn;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.endercrest.voidspawn.utils.MessageUtil;
import org.bukkit.entity.Player;
package com.endercrest.voidspawn.commands;
public class HelpCommand implements SubCommand {
HashMap<String, SubCommand> commands;
public HelpCommand(HashMap<String, SubCommand> commands){
this.commands = commands;
}
@Override
public boolean onCommand(Player p, String[] args){ | p.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "--- &6Help Menu&f ---")); |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/commands/HelpCommand.java | // Path: src/main/java/com/endercrest/voidspawn/VoidSpawn.java
// public class VoidSpawn extends JavaPlugin {
// public static String prefix = "[&6VS&f] ";
//
// public void onEnable(){
// try {
// // This is the class we check for as it was added in 1.13 and should remain in place for the long term.
// Class.forName("org.bukkit.Tag");
// } catch (ClassNotFoundException e) {
// log("&cERROR: Unsupported version of Spigot/Paper detected!");
// log("&cERROR: Disabling plugin! Please update to latest version");
// log("&cERROR: or use an unsupported version of VoidSpawn");
// Bukkit.getPluginManager().disablePlugin(this);
// return;
// }
//
// /* if[PROD] */
// Metrics metrics = new Metrics(this, 3514);
// /* end[PROD] */
//
// loadConfiguration();
// ConfigManager.getInstance().setUp(this);
// TeleportManager.getInstance().setUp(this);
// ModeManager.getInstance().setUp(this);
// DetectorManager.getInstance().setUp();
// getServer().getPluginManager().registerEvents(new VoidListener(this), this);
// getServer().getPluginManager().registerEvents(new QuitListener(), this);
//
// PluginCommand command = getCommand("voidspawn");
// CommandHandler commandHandler = new CommandHandler(this);
// command.setExecutor(commandHandler);
// command.setTabCompleter(new VoidSpawnTabCompleter(commandHandler));
//
// Bukkit.getScheduler().runTaskTimer(this, new TouchTracker(), 5, 5);
//
// log("&ev" + getDescription().getVersion() + " by EnderCrest enabled");
// }
//
// public void onDisable(){
// log("&ev" + getDescription().getVersion() + " saving config");
// ConfigManager.getInstance().saveConfig();
// log("&ev" + getDescription().getVersion() + " disabled");
// }
//
// public void loadConfiguration(){
// if(!getConfig().contains("color-logs")){
// getConfig().addDefault("color-logs", true);
// }
// getConfig().options().copyDefaults(true);
// saveConfig();
// }
//
// /**
// * Sends Messages to Console
// *
// * @param obj The Obj(Message)
// */
// public void log(Object obj){
// if(getConfig().getBoolean("color-logs", true)){
// getServer().getConsoleSender().sendMessage(MessageUtil.colorize("&3[&d" + getName() + "&3] &r" + obj));
// }else{
// Bukkit.getLogger().log(Level.INFO, "[" + getName() + "] " + MessageUtil.colorize((String) obj).replaceAll("(?)\u00a7([a-f0-9k-or])", ""));
// }
// }
//
// }
//
// Path: src/main/java/com/endercrest/voidspawn/utils/MessageUtil.java
// public class MessageUtil {
//
// /**
// * Add Color to Messages
// *
// * @param str The String
// * @return Coloured String
// */
// public static String colorize(String str){
// return str.replaceAll("(?i)&([a-f0-9k-or])", "\u00a7$1");
// }
//
// public static String colorize(String str, Object... args){
// return colorize(String.format(str, args));
// }
// }
| import com.endercrest.voidspawn.VoidSpawn;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.endercrest.voidspawn.utils.MessageUtil;
import org.bukkit.entity.Player; | package com.endercrest.voidspawn.commands;
public class HelpCommand implements SubCommand {
HashMap<String, SubCommand> commands;
public HelpCommand(HashMap<String, SubCommand> commands){
this.commands = commands;
}
@Override
public boolean onCommand(Player p, String[] args){ | // Path: src/main/java/com/endercrest/voidspawn/VoidSpawn.java
// public class VoidSpawn extends JavaPlugin {
// public static String prefix = "[&6VS&f] ";
//
// public void onEnable(){
// try {
// // This is the class we check for as it was added in 1.13 and should remain in place for the long term.
// Class.forName("org.bukkit.Tag");
// } catch (ClassNotFoundException e) {
// log("&cERROR: Unsupported version of Spigot/Paper detected!");
// log("&cERROR: Disabling plugin! Please update to latest version");
// log("&cERROR: or use an unsupported version of VoidSpawn");
// Bukkit.getPluginManager().disablePlugin(this);
// return;
// }
//
// /* if[PROD] */
// Metrics metrics = new Metrics(this, 3514);
// /* end[PROD] */
//
// loadConfiguration();
// ConfigManager.getInstance().setUp(this);
// TeleportManager.getInstance().setUp(this);
// ModeManager.getInstance().setUp(this);
// DetectorManager.getInstance().setUp();
// getServer().getPluginManager().registerEvents(new VoidListener(this), this);
// getServer().getPluginManager().registerEvents(new QuitListener(), this);
//
// PluginCommand command = getCommand("voidspawn");
// CommandHandler commandHandler = new CommandHandler(this);
// command.setExecutor(commandHandler);
// command.setTabCompleter(new VoidSpawnTabCompleter(commandHandler));
//
// Bukkit.getScheduler().runTaskTimer(this, new TouchTracker(), 5, 5);
//
// log("&ev" + getDescription().getVersion() + " by EnderCrest enabled");
// }
//
// public void onDisable(){
// log("&ev" + getDescription().getVersion() + " saving config");
// ConfigManager.getInstance().saveConfig();
// log("&ev" + getDescription().getVersion() + " disabled");
// }
//
// public void loadConfiguration(){
// if(!getConfig().contains("color-logs")){
// getConfig().addDefault("color-logs", true);
// }
// getConfig().options().copyDefaults(true);
// saveConfig();
// }
//
// /**
// * Sends Messages to Console
// *
// * @param obj The Obj(Message)
// */
// public void log(Object obj){
// if(getConfig().getBoolean("color-logs", true)){
// getServer().getConsoleSender().sendMessage(MessageUtil.colorize("&3[&d" + getName() + "&3] &r" + obj));
// }else{
// Bukkit.getLogger().log(Level.INFO, "[" + getName() + "] " + MessageUtil.colorize((String) obj).replaceAll("(?)\u00a7([a-f0-9k-or])", ""));
// }
// }
//
// }
//
// Path: src/main/java/com/endercrest/voidspawn/utils/MessageUtil.java
// public class MessageUtil {
//
// /**
// * Add Color to Messages
// *
// * @param str The String
// * @return Coloured String
// */
// public static String colorize(String str){
// return str.replaceAll("(?i)&([a-f0-9k-or])", "\u00a7$1");
// }
//
// public static String colorize(String str, Object... args){
// return colorize(String.format(str, args));
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/commands/HelpCommand.java
import com.endercrest.voidspawn.VoidSpawn;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.endercrest.voidspawn.utils.MessageUtil;
import org.bukkit.entity.Player;
package com.endercrest.voidspawn.commands;
public class HelpCommand implements SubCommand {
HashMap<String, SubCommand> commands;
public HelpCommand(HashMap<String, SubCommand> commands){
this.commands = commands;
}
@Override
public boolean onCommand(Player p, String[] args){ | p.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "--- &6Help Menu&f ---")); |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/commands/VoidSpawnTabCompleter.java | // Path: src/main/java/com/endercrest/voidspawn/CommandHandler.java
// public class CommandHandler implements CommandExecutor {
// private final VoidSpawn plugin;
// private final HashMap<String, SubCommand> commands = new HashMap<>();
//
// public CommandHandler(VoidSpawn plugin){
// this.plugin = plugin;
// loadCommands();
// }
//
// /**
// * Load the commands into the HashMap that makes it accessible to players.
// */
// private void loadCommands(){
// commands.put("set", new SetCommand());
// commands.put("remove", new RemoveCommand());
// commands.put("reload", new ReloadCommand());
// commands.put("modes", new ModesCommand());
// commands.put("mode", new ModeCommand());
// commands.put("help", new HelpCommand(commands));
// commands.put("toggle", new ToggleCommand());
// commands.put("detector", new DetectorCommand());
// commands.put("info", new InfoCommand());
// commands.put("option", new OptionCommand());
// }
//
// public Set<Map.Entry<String, SubCommand>> getCommands() {
// return commands.entrySet();
// }
//
// public SubCommand getSubCommand(String cmd) {
// return commands.get(cmd);
// }
//
// @Override
// public boolean onCommand(@NotNull CommandSender cs, @NotNull Command cmd, @NotNull String s, String[] args){
// if(!(cs instanceof Player)){
// if((args.length >= 1) && (args[0].equalsIgnoreCase("reload"))){
// ConfigManager.getInstance().reloadConfig();
// cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "&6Plugin Reloaded"));
// return true;
// }
//
// cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "&cOnly Players can use these commands"));
// return false;
// }
// if(cmd.getName().equalsIgnoreCase("voidspawn")){
// if((args == null) || (args.length < 1)){
// cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "Version &6" + plugin.getDescription().getVersion() + "&f by &6EnderCrest"));
// cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "Type &6/vs help &ffor command information"));
// return true;
// }
// String sub = args[0].toLowerCase();
// if(!commands.containsKey(sub)){
// cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "&cThat command does not exist"));
// cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "Type &6/vs help &ffor command information"));
// return true;
// }
// SubCommand command = commands.get(sub);
// Player player = (Player)cs;
// if(command.permission() != null && !player.hasPermission(command.permission())) {
// player.sendMessage(MessageUtil.colorize("&cYou do not have permission."));
// return true;
// }
//
//
// try {
// command.onCommand(player, args);
// } catch (Exception e) {
// e.printStackTrace();
// cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "&cThere was an error"));
// cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "Type &6/vs help &ffor command information"));
// }
// }
// return false;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/utils/WorldUtil.java
// public class WorldUtil {
//
// public static String configSafe(String worldName){
// return worldName.replace(" ", "_");
// }
//
// /**
// * Checks if the selected world is a valid world.
// *
// * @param worldName The world name that will be checked.
// * @return True if the world does not return null.
// */
// public static boolean isValidWorld(String worldName){
// return Bukkit.getWorld(worldName) != null;
// }
//
// /**
// * get a list of world names that begin with partial. If partial is
// * empty, all worlds are returned.
// * @param partial String to compare against.
// * @return List of world names.
// */
// public static List<String> getMatchingWorlds(String partial) {
// return Bukkit.getWorlds().stream()
// .map(World::getName)
// .filter(world -> world.toLowerCase().startsWith(partial.toLowerCase()))
// .collect(Collectors.toList());
// }
// }
| import com.endercrest.voidspawn.CommandHandler;
import com.endercrest.voidspawn.utils.WorldUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; | continue;
if(args.length == 0 || subCommand.getKey().startsWith(args[0])) {
output.add(subCommand.getKey());
}
}
return output;
}
SubCommand subCommand = handler.getSubCommand(args[0]);
return subCommand != null ? subCommand.getTabCompletion(player, Arrays.copyOfRange(args, 1, args.length)) : null;
}
/////////////////////////////////////////////
//// Common Auto Completes ////
/////////////////////////////////////////////
static List<String> getBooleanWorldCompletion(String[] args) {
switch(args.length) {
case 1:
return new ArrayList<String>() {{
add("true");
add("false");
}}
.stream()
.filter(s -> s.startsWith(args[0].toLowerCase()))
.collect(Collectors.toList());
case 2: | // Path: src/main/java/com/endercrest/voidspawn/CommandHandler.java
// public class CommandHandler implements CommandExecutor {
// private final VoidSpawn plugin;
// private final HashMap<String, SubCommand> commands = new HashMap<>();
//
// public CommandHandler(VoidSpawn plugin){
// this.plugin = plugin;
// loadCommands();
// }
//
// /**
// * Load the commands into the HashMap that makes it accessible to players.
// */
// private void loadCommands(){
// commands.put("set", new SetCommand());
// commands.put("remove", new RemoveCommand());
// commands.put("reload", new ReloadCommand());
// commands.put("modes", new ModesCommand());
// commands.put("mode", new ModeCommand());
// commands.put("help", new HelpCommand(commands));
// commands.put("toggle", new ToggleCommand());
// commands.put("detector", new DetectorCommand());
// commands.put("info", new InfoCommand());
// commands.put("option", new OptionCommand());
// }
//
// public Set<Map.Entry<String, SubCommand>> getCommands() {
// return commands.entrySet();
// }
//
// public SubCommand getSubCommand(String cmd) {
// return commands.get(cmd);
// }
//
// @Override
// public boolean onCommand(@NotNull CommandSender cs, @NotNull Command cmd, @NotNull String s, String[] args){
// if(!(cs instanceof Player)){
// if((args.length >= 1) && (args[0].equalsIgnoreCase("reload"))){
// ConfigManager.getInstance().reloadConfig();
// cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "&6Plugin Reloaded"));
// return true;
// }
//
// cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "&cOnly Players can use these commands"));
// return false;
// }
// if(cmd.getName().equalsIgnoreCase("voidspawn")){
// if((args == null) || (args.length < 1)){
// cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "Version &6" + plugin.getDescription().getVersion() + "&f by &6EnderCrest"));
// cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "Type &6/vs help &ffor command information"));
// return true;
// }
// String sub = args[0].toLowerCase();
// if(!commands.containsKey(sub)){
// cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "&cThat command does not exist"));
// cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "Type &6/vs help &ffor command information"));
// return true;
// }
// SubCommand command = commands.get(sub);
// Player player = (Player)cs;
// if(command.permission() != null && !player.hasPermission(command.permission())) {
// player.sendMessage(MessageUtil.colorize("&cYou do not have permission."));
// return true;
// }
//
//
// try {
// command.onCommand(player, args);
// } catch (Exception e) {
// e.printStackTrace();
// cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "&cThere was an error"));
// cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "Type &6/vs help &ffor command information"));
// }
// }
// return false;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/utils/WorldUtil.java
// public class WorldUtil {
//
// public static String configSafe(String worldName){
// return worldName.replace(" ", "_");
// }
//
// /**
// * Checks if the selected world is a valid world.
// *
// * @param worldName The world name that will be checked.
// * @return True if the world does not return null.
// */
// public static boolean isValidWorld(String worldName){
// return Bukkit.getWorld(worldName) != null;
// }
//
// /**
// * get a list of world names that begin with partial. If partial is
// * empty, all worlds are returned.
// * @param partial String to compare against.
// * @return List of world names.
// */
// public static List<String> getMatchingWorlds(String partial) {
// return Bukkit.getWorlds().stream()
// .map(World::getName)
// .filter(world -> world.toLowerCase().startsWith(partial.toLowerCase()))
// .collect(Collectors.toList());
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/commands/VoidSpawnTabCompleter.java
import com.endercrest.voidspawn.CommandHandler;
import com.endercrest.voidspawn.utils.WorldUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
continue;
if(args.length == 0 || subCommand.getKey().startsWith(args[0])) {
output.add(subCommand.getKey());
}
}
return output;
}
SubCommand subCommand = handler.getSubCommand(args[0]);
return subCommand != null ? subCommand.getTabCompletion(player, Arrays.copyOfRange(args, 1, args.length)) : null;
}
/////////////////////////////////////////////
//// Common Auto Completes ////
/////////////////////////////////////////////
static List<String> getBooleanWorldCompletion(String[] args) {
switch(args.length) {
case 1:
return new ArrayList<String>() {{
add("true");
add("false");
}}
.stream()
.filter(s -> s.startsWith(args[0].toLowerCase()))
.collect(Collectors.toList());
case 2: | return WorldUtil.getMatchingWorlds(args[1]); |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/modes/island/BentoBoxIslandMode.java | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
| import com.endercrest.voidspawn.TeleportResult;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.user.User; | package com.endercrest.voidspawn.modes.island;
public class BentoBoxIslandMode extends BaseIslandMode {
private final BentoBox bentoBox;
public BentoBoxIslandMode() {
this.bentoBox = (BentoBox) Bukkit.getPluginManager().getPlugin("BentoBox");
if (this.bentoBox == null) {
throw new IllegalStateException("BentoBoxIslandMode is missing!");
}
}
@Override | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/modes/island/BentoBoxIslandMode.java
import com.endercrest.voidspawn.TeleportResult;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.user.User;
package com.endercrest.voidspawn.modes.island;
public class BentoBoxIslandMode extends BaseIslandMode {
private final BentoBox bentoBox;
public BentoBoxIslandMode() {
this.bentoBox = (BentoBox) Bukkit.getPluginManager().getPlugin("BentoBox");
if (this.bentoBox == null) {
throw new IllegalStateException("BentoBoxIslandMode is missing!");
}
}
@Override | public TeleportResult onActivateIsland(Player player, String worldName) { |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/ModeManager.java | // Path: src/main/java/com/endercrest/voidspawn/modes/Mode.java
// public interface Mode extends OptionContainer {
//
// /**
// * Called when the player enters the void.
// *
// * @param player The player who has entered the void and be teleported or whatever the action is.
// * @param worldName The world name in which the player resides.
// * @return Returns whether the action successfully occurred.
// */
// TeleportResult onActivate(Player player, String worldName);
//
// /**
// * This method is called when this mode is set in a world. This is meant to give any additional instructions should a mode require it.
// * As well as change any settings if necessary.
// *
// * @param args The args from the command on the set.
// * @param worldName The world name where the mode was set.
// * @param p The player who invoked the command to set the mode.
// * @return Returns whether the onSet method successfully executed and gave proper details.
// */
// default boolean onSet(String[] args, String worldName, Player p) {
// ConfigManager.getInstance().setMode(worldName, args[1]);
// return true;
// }
//
// /**
// * The statuses of the current mode. Used for providing information on whether this mode is configured correctly or
// * providing any other information to the user.
// *
// * @param worldName The name of world to get the status of.
// * @return Must always return a non-null array.
// */
// Status[] getStatus(String worldName);
//
// boolean isEnabled();
//
// /**
// * Get the details about the mode. This should be an unformatted string.
// * ex. "Will teleport player to set spot."
// *
// * @return Returns the string that will be displayed upon player request details of the mode.
// */
// String getDescription();
//
// /**
// * Get the name of the mode.
// *
// * @return The string version of the mode.
// */
// String getName();
// }
| import com.endercrest.voidspawn.modes.Mode;
import com.endercrest.voidspawn.modes.*;
import com.endercrest.voidspawn.modes.island.*;
import javax.naming.NameAlreadyBoundException;
import java.util.HashMap; | package com.endercrest.voidspawn;
public class ModeManager {
private static final ModeManager instance = new ModeManager(); | // Path: src/main/java/com/endercrest/voidspawn/modes/Mode.java
// public interface Mode extends OptionContainer {
//
// /**
// * Called when the player enters the void.
// *
// * @param player The player who has entered the void and be teleported or whatever the action is.
// * @param worldName The world name in which the player resides.
// * @return Returns whether the action successfully occurred.
// */
// TeleportResult onActivate(Player player, String worldName);
//
// /**
// * This method is called when this mode is set in a world. This is meant to give any additional instructions should a mode require it.
// * As well as change any settings if necessary.
// *
// * @param args The args from the command on the set.
// * @param worldName The world name where the mode was set.
// * @param p The player who invoked the command to set the mode.
// * @return Returns whether the onSet method successfully executed and gave proper details.
// */
// default boolean onSet(String[] args, String worldName, Player p) {
// ConfigManager.getInstance().setMode(worldName, args[1]);
// return true;
// }
//
// /**
// * The statuses of the current mode. Used for providing information on whether this mode is configured correctly or
// * providing any other information to the user.
// *
// * @param worldName The name of world to get the status of.
// * @return Must always return a non-null array.
// */
// Status[] getStatus(String worldName);
//
// boolean isEnabled();
//
// /**
// * Get the details about the mode. This should be an unformatted string.
// * ex. "Will teleport player to set spot."
// *
// * @return Returns the string that will be displayed upon player request details of the mode.
// */
// String getDescription();
//
// /**
// * Get the name of the mode.
// *
// * @return The string version of the mode.
// */
// String getName();
// }
// Path: src/main/java/com/endercrest/voidspawn/ModeManager.java
import com.endercrest.voidspawn.modes.Mode;
import com.endercrest.voidspawn.modes.*;
import com.endercrest.voidspawn.modes.island.*;
import javax.naming.NameAlreadyBoundException;
import java.util.HashMap;
package com.endercrest.voidspawn;
public class ModeManager {
private static final ModeManager instance = new ModeManager(); | private final HashMap<String, Mode> modes = new HashMap<>(); |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/ConfigManager.java | // Path: src/main/java/com/endercrest/voidspawn/modes/BaseMode.java
// public abstract class BaseMode extends BasicOptionContainer implements Mode {
// public static final OptionIdentifier<Sound> OPTION_SOUND = new OptionIdentifier<>(Sound.class, "sound", "The sound played when detected in void");
// public static final OptionIdentifier<Float> OPTION_SOUND_VOLUME = new OptionIdentifier<>(Float.class, "sound_volume", "The sound volume");
// public static final OptionIdentifier<Float> OPTION_SOUND_PITCH = new OptionIdentifier<>(Float.class, "sound_pitch", "The sound pitch");
// public static final OptionIdentifier<Boolean> OPTION_HYBRID = new OptionIdentifier<>(Boolean.class, "hybrid", "Whether to run in hybrid mode (mode and command)");
// public static final OptionIdentifier<Boolean> OPTION_KEEP_INVENTORY = new OptionIdentifier<>(Boolean.class, "keep_inventory", "Whether players keep inventory");
// public static final OptionIdentifier<String> OPTION_MESSAGE = new OptionIdentifier<>(String.class, "message", "Message sent when detected in void");
// public static final OptionIdentifier<String> OPTION_COMMAND = new OptionIdentifier<>(String.class, "command", "The command(s) for either command mode or hybrid");
// public static final OptionIdentifier<Boolean> OPTION_INC_DEATH_STAT = new OptionIdentifier<>(Boolean.class, "inc_death_stat", "Whether to increment the death statistic");
// public static final OptionIdentifier<Integer> OPTION_DAMAGE = new OptionIdentifier<>(Integer.class, "damage", "Amount of damage applied upon entering the void");
// public static final OptionIdentifier<Integer> OPTION_BOUNCE = new OptionIdentifier<>(Integer.class, "bounce", "Number of times to bounce from the void before activating mode");
// public static final OptionIdentifier<Float> OPTION_MIN_BOUNCE_VELOCITY = new OptionIdentifier<>(Float.class, "min_bounce_velocity", "The minimum bounce velocity");
//
// public BaseMode() {
// attachOption(new SoundOption(OPTION_SOUND));
// attachOption(new FloatOption(OPTION_SOUND_VOLUME, 1f));
// attachOption(new FloatOption(OPTION_SOUND_PITCH, 1f));
// attachOption(new BooleanOption(OPTION_HYBRID, false));
// attachOption(new BooleanOption(OPTION_KEEP_INVENTORY, true));
// attachOption(new StringOption(OPTION_MESSAGE));
// attachOption(new StringOption(OPTION_COMMAND));
// attachOption(new BooleanOption(OPTION_INC_DEATH_STAT, false));
// attachOption(new IntegerOption(OPTION_DAMAGE, 0));
// attachOption(new IntegerOption(OPTION_BOUNCE, 0));
// attachOption(new FloatOption(OPTION_MIN_BOUNCE_VELOCITY, 2.0f));
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/utils/WorldUtil.java
// public class WorldUtil {
//
// public static String configSafe(String worldName){
// return worldName.replace(" ", "_");
// }
//
// /**
// * Checks if the selected world is a valid world.
// *
// * @param worldName The world name that will be checked.
// * @return True if the world does not return null.
// */
// public static boolean isValidWorld(String worldName){
// return Bukkit.getWorld(worldName) != null;
// }
//
// /**
// * get a list of world names that begin with partial. If partial is
// * empty, all worlds are returned.
// * @param partial String to compare against.
// * @return List of world names.
// */
// public static List<String> getMatchingWorlds(String partial) {
// return Bukkit.getWorlds().stream()
// .map(World::getName)
// .filter(world -> world.toLowerCase().startsWith(partial.toLowerCase()))
// .collect(Collectors.toList());
// }
// }
| import com.endercrest.voidspawn.modes.BaseMode;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.utils.WorldUtil;
import java.io.File;
import java.io.IOException;
import java.time.Instant;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable; | }
//Run Migration
migrate();
}
/**
* Migrate the config to new versions.
*/
private void migrate() {
migrateV1();
migrateV2();
saveConfig();
}
/**
* Migrate the config to version 1 from 0.
* <p>
* This migration involves converting names to safe names that do not contain spaces.
*/
private void migrateV1() {
if (!config.isSet("version")) {
plugin.log("Converting worlds.yml to version 1");
config.set("version", 1);
ConfigurationSection section = config.getRoot();
if (section != null) {
for (String key: section.getKeys(false)) {
//Convert world names into safe world names. | // Path: src/main/java/com/endercrest/voidspawn/modes/BaseMode.java
// public abstract class BaseMode extends BasicOptionContainer implements Mode {
// public static final OptionIdentifier<Sound> OPTION_SOUND = new OptionIdentifier<>(Sound.class, "sound", "The sound played when detected in void");
// public static final OptionIdentifier<Float> OPTION_SOUND_VOLUME = new OptionIdentifier<>(Float.class, "sound_volume", "The sound volume");
// public static final OptionIdentifier<Float> OPTION_SOUND_PITCH = new OptionIdentifier<>(Float.class, "sound_pitch", "The sound pitch");
// public static final OptionIdentifier<Boolean> OPTION_HYBRID = new OptionIdentifier<>(Boolean.class, "hybrid", "Whether to run in hybrid mode (mode and command)");
// public static final OptionIdentifier<Boolean> OPTION_KEEP_INVENTORY = new OptionIdentifier<>(Boolean.class, "keep_inventory", "Whether players keep inventory");
// public static final OptionIdentifier<String> OPTION_MESSAGE = new OptionIdentifier<>(String.class, "message", "Message sent when detected in void");
// public static final OptionIdentifier<String> OPTION_COMMAND = new OptionIdentifier<>(String.class, "command", "The command(s) for either command mode or hybrid");
// public static final OptionIdentifier<Boolean> OPTION_INC_DEATH_STAT = new OptionIdentifier<>(Boolean.class, "inc_death_stat", "Whether to increment the death statistic");
// public static final OptionIdentifier<Integer> OPTION_DAMAGE = new OptionIdentifier<>(Integer.class, "damage", "Amount of damage applied upon entering the void");
// public static final OptionIdentifier<Integer> OPTION_BOUNCE = new OptionIdentifier<>(Integer.class, "bounce", "Number of times to bounce from the void before activating mode");
// public static final OptionIdentifier<Float> OPTION_MIN_BOUNCE_VELOCITY = new OptionIdentifier<>(Float.class, "min_bounce_velocity", "The minimum bounce velocity");
//
// public BaseMode() {
// attachOption(new SoundOption(OPTION_SOUND));
// attachOption(new FloatOption(OPTION_SOUND_VOLUME, 1f));
// attachOption(new FloatOption(OPTION_SOUND_PITCH, 1f));
// attachOption(new BooleanOption(OPTION_HYBRID, false));
// attachOption(new BooleanOption(OPTION_KEEP_INVENTORY, true));
// attachOption(new StringOption(OPTION_MESSAGE));
// attachOption(new StringOption(OPTION_COMMAND));
// attachOption(new BooleanOption(OPTION_INC_DEATH_STAT, false));
// attachOption(new IntegerOption(OPTION_DAMAGE, 0));
// attachOption(new IntegerOption(OPTION_BOUNCE, 0));
// attachOption(new FloatOption(OPTION_MIN_BOUNCE_VELOCITY, 2.0f));
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/utils/WorldUtil.java
// public class WorldUtil {
//
// public static String configSafe(String worldName){
// return worldName.replace(" ", "_");
// }
//
// /**
// * Checks if the selected world is a valid world.
// *
// * @param worldName The world name that will be checked.
// * @return True if the world does not return null.
// */
// public static boolean isValidWorld(String worldName){
// return Bukkit.getWorld(worldName) != null;
// }
//
// /**
// * get a list of world names that begin with partial. If partial is
// * empty, all worlds are returned.
// * @param partial String to compare against.
// * @return List of world names.
// */
// public static List<String> getMatchingWorlds(String partial) {
// return Bukkit.getWorlds().stream()
// .map(World::getName)
// .filter(world -> world.toLowerCase().startsWith(partial.toLowerCase()))
// .collect(Collectors.toList());
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/ConfigManager.java
import com.endercrest.voidspawn.modes.BaseMode;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.utils.WorldUtil;
import java.io.File;
import java.io.IOException;
import java.time.Instant;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
}
//Run Migration
migrate();
}
/**
* Migrate the config to new versions.
*/
private void migrate() {
migrateV1();
migrateV2();
saveConfig();
}
/**
* Migrate the config to version 1 from 0.
* <p>
* This migration involves converting names to safe names that do not contain spaces.
*/
private void migrateV1() {
if (!config.isSet("version")) {
plugin.log("Converting worlds.yml to version 1");
config.set("version", 1);
ConfigurationSection section = config.getRoot();
if (section != null) {
for (String key: section.getKeys(false)) {
//Convert world names into safe world names. | if ((!key.equalsIgnoreCase("version")) && (!key.equals(WorldUtil.configSafe(key)))) { |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/ConfigManager.java | // Path: src/main/java/com/endercrest/voidspawn/modes/BaseMode.java
// public abstract class BaseMode extends BasicOptionContainer implements Mode {
// public static final OptionIdentifier<Sound> OPTION_SOUND = new OptionIdentifier<>(Sound.class, "sound", "The sound played when detected in void");
// public static final OptionIdentifier<Float> OPTION_SOUND_VOLUME = new OptionIdentifier<>(Float.class, "sound_volume", "The sound volume");
// public static final OptionIdentifier<Float> OPTION_SOUND_PITCH = new OptionIdentifier<>(Float.class, "sound_pitch", "The sound pitch");
// public static final OptionIdentifier<Boolean> OPTION_HYBRID = new OptionIdentifier<>(Boolean.class, "hybrid", "Whether to run in hybrid mode (mode and command)");
// public static final OptionIdentifier<Boolean> OPTION_KEEP_INVENTORY = new OptionIdentifier<>(Boolean.class, "keep_inventory", "Whether players keep inventory");
// public static final OptionIdentifier<String> OPTION_MESSAGE = new OptionIdentifier<>(String.class, "message", "Message sent when detected in void");
// public static final OptionIdentifier<String> OPTION_COMMAND = new OptionIdentifier<>(String.class, "command", "The command(s) for either command mode or hybrid");
// public static final OptionIdentifier<Boolean> OPTION_INC_DEATH_STAT = new OptionIdentifier<>(Boolean.class, "inc_death_stat", "Whether to increment the death statistic");
// public static final OptionIdentifier<Integer> OPTION_DAMAGE = new OptionIdentifier<>(Integer.class, "damage", "Amount of damage applied upon entering the void");
// public static final OptionIdentifier<Integer> OPTION_BOUNCE = new OptionIdentifier<>(Integer.class, "bounce", "Number of times to bounce from the void before activating mode");
// public static final OptionIdentifier<Float> OPTION_MIN_BOUNCE_VELOCITY = new OptionIdentifier<>(Float.class, "min_bounce_velocity", "The minimum bounce velocity");
//
// public BaseMode() {
// attachOption(new SoundOption(OPTION_SOUND));
// attachOption(new FloatOption(OPTION_SOUND_VOLUME, 1f));
// attachOption(new FloatOption(OPTION_SOUND_PITCH, 1f));
// attachOption(new BooleanOption(OPTION_HYBRID, false));
// attachOption(new BooleanOption(OPTION_KEEP_INVENTORY, true));
// attachOption(new StringOption(OPTION_MESSAGE));
// attachOption(new StringOption(OPTION_COMMAND));
// attachOption(new BooleanOption(OPTION_INC_DEATH_STAT, false));
// attachOption(new IntegerOption(OPTION_DAMAGE, 0));
// attachOption(new IntegerOption(OPTION_BOUNCE, 0));
// attachOption(new FloatOption(OPTION_MIN_BOUNCE_VELOCITY, 2.0f));
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/utils/WorldUtil.java
// public class WorldUtil {
//
// public static String configSafe(String worldName){
// return worldName.replace(" ", "_");
// }
//
// /**
// * Checks if the selected world is a valid world.
// *
// * @param worldName The world name that will be checked.
// * @return True if the world does not return null.
// */
// public static boolean isValidWorld(String worldName){
// return Bukkit.getWorld(worldName) != null;
// }
//
// /**
// * get a list of world names that begin with partial. If partial is
// * empty, all worlds are returned.
// * @param partial String to compare against.
// * @return List of world names.
// */
// public static List<String> getMatchingWorlds(String partial) {
// return Bukkit.getWorlds().stream()
// .map(World::getName)
// .filter(world -> world.toLowerCase().startsWith(partial.toLowerCase()))
// .collect(Collectors.toList());
// }
// }
| import com.endercrest.voidspawn.modes.BaseMode;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.utils.WorldUtil;
import java.io.File;
import java.io.IOException;
import java.time.Instant;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable; | }
private void migrateV2() {
if (config.getInt("version", 0) >= 2)
return;
long time = Instant.now().toEpochMilli();
String newName = String.format("worlds.%s.yml", time);
File file = new File(plugin.getDataFolder(), newName);
plugin.log(String.format("Backing up worlds.yml to %s", newName));
try {
config.save(file);
} catch (IOException e) {
plugin.log("Failed to backup worlds.yml");
e.printStackTrace();
return;
}
plugin.log("Converting world.yml to version 2");
config.set("version", 2);
for (String key: config.getKeys(false)) {
if (!config.isConfigurationSection(key))
continue;
ConfigurationSection section = config.getConfigurationSection(key);
if (section == null)
continue;
section.set("options.offset", section.get("offset")); | // Path: src/main/java/com/endercrest/voidspawn/modes/BaseMode.java
// public abstract class BaseMode extends BasicOptionContainer implements Mode {
// public static final OptionIdentifier<Sound> OPTION_SOUND = new OptionIdentifier<>(Sound.class, "sound", "The sound played when detected in void");
// public static final OptionIdentifier<Float> OPTION_SOUND_VOLUME = new OptionIdentifier<>(Float.class, "sound_volume", "The sound volume");
// public static final OptionIdentifier<Float> OPTION_SOUND_PITCH = new OptionIdentifier<>(Float.class, "sound_pitch", "The sound pitch");
// public static final OptionIdentifier<Boolean> OPTION_HYBRID = new OptionIdentifier<>(Boolean.class, "hybrid", "Whether to run in hybrid mode (mode and command)");
// public static final OptionIdentifier<Boolean> OPTION_KEEP_INVENTORY = new OptionIdentifier<>(Boolean.class, "keep_inventory", "Whether players keep inventory");
// public static final OptionIdentifier<String> OPTION_MESSAGE = new OptionIdentifier<>(String.class, "message", "Message sent when detected in void");
// public static final OptionIdentifier<String> OPTION_COMMAND = new OptionIdentifier<>(String.class, "command", "The command(s) for either command mode or hybrid");
// public static final OptionIdentifier<Boolean> OPTION_INC_DEATH_STAT = new OptionIdentifier<>(Boolean.class, "inc_death_stat", "Whether to increment the death statistic");
// public static final OptionIdentifier<Integer> OPTION_DAMAGE = new OptionIdentifier<>(Integer.class, "damage", "Amount of damage applied upon entering the void");
// public static final OptionIdentifier<Integer> OPTION_BOUNCE = new OptionIdentifier<>(Integer.class, "bounce", "Number of times to bounce from the void before activating mode");
// public static final OptionIdentifier<Float> OPTION_MIN_BOUNCE_VELOCITY = new OptionIdentifier<>(Float.class, "min_bounce_velocity", "The minimum bounce velocity");
//
// public BaseMode() {
// attachOption(new SoundOption(OPTION_SOUND));
// attachOption(new FloatOption(OPTION_SOUND_VOLUME, 1f));
// attachOption(new FloatOption(OPTION_SOUND_PITCH, 1f));
// attachOption(new BooleanOption(OPTION_HYBRID, false));
// attachOption(new BooleanOption(OPTION_KEEP_INVENTORY, true));
// attachOption(new StringOption(OPTION_MESSAGE));
// attachOption(new StringOption(OPTION_COMMAND));
// attachOption(new BooleanOption(OPTION_INC_DEATH_STAT, false));
// attachOption(new IntegerOption(OPTION_DAMAGE, 0));
// attachOption(new IntegerOption(OPTION_BOUNCE, 0));
// attachOption(new FloatOption(OPTION_MIN_BOUNCE_VELOCITY, 2.0f));
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/utils/WorldUtil.java
// public class WorldUtil {
//
// public static String configSafe(String worldName){
// return worldName.replace(" ", "_");
// }
//
// /**
// * Checks if the selected world is a valid world.
// *
// * @param worldName The world name that will be checked.
// * @return True if the world does not return null.
// */
// public static boolean isValidWorld(String worldName){
// return Bukkit.getWorld(worldName) != null;
// }
//
// /**
// * get a list of world names that begin with partial. If partial is
// * empty, all worlds are returned.
// * @param partial String to compare against.
// * @return List of world names.
// */
// public static List<String> getMatchingWorlds(String partial) {
// return Bukkit.getWorlds().stream()
// .map(World::getName)
// .filter(world -> world.toLowerCase().startsWith(partial.toLowerCase()))
// .collect(Collectors.toList());
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/ConfigManager.java
import com.endercrest.voidspawn.modes.BaseMode;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.utils.WorldUtil;
import java.io.File;
import java.io.IOException;
import java.time.Instant;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
}
private void migrateV2() {
if (config.getInt("version", 0) >= 2)
return;
long time = Instant.now().toEpochMilli();
String newName = String.format("worlds.%s.yml", time);
File file = new File(plugin.getDataFolder(), newName);
plugin.log(String.format("Backing up worlds.yml to %s", newName));
try {
config.save(file);
} catch (IOException e) {
plugin.log("Failed to backup worlds.yml");
e.printStackTrace();
return;
}
plugin.log("Converting world.yml to version 2");
config.set("version", 2);
for (String key: config.getKeys(false)) {
if (!config.isConfigurationSection(key))
continue;
ConfigurationSection section = config.getConfigurationSection(key);
if (section == null)
continue;
section.set("options.offset", section.get("offset")); | section.set("options." + BaseMode.OPTION_MESSAGE.getName(), section.get("message")); |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/ConfigManager.java | // Path: src/main/java/com/endercrest/voidspawn/modes/BaseMode.java
// public abstract class BaseMode extends BasicOptionContainer implements Mode {
// public static final OptionIdentifier<Sound> OPTION_SOUND = new OptionIdentifier<>(Sound.class, "sound", "The sound played when detected in void");
// public static final OptionIdentifier<Float> OPTION_SOUND_VOLUME = new OptionIdentifier<>(Float.class, "sound_volume", "The sound volume");
// public static final OptionIdentifier<Float> OPTION_SOUND_PITCH = new OptionIdentifier<>(Float.class, "sound_pitch", "The sound pitch");
// public static final OptionIdentifier<Boolean> OPTION_HYBRID = new OptionIdentifier<>(Boolean.class, "hybrid", "Whether to run in hybrid mode (mode and command)");
// public static final OptionIdentifier<Boolean> OPTION_KEEP_INVENTORY = new OptionIdentifier<>(Boolean.class, "keep_inventory", "Whether players keep inventory");
// public static final OptionIdentifier<String> OPTION_MESSAGE = new OptionIdentifier<>(String.class, "message", "Message sent when detected in void");
// public static final OptionIdentifier<String> OPTION_COMMAND = new OptionIdentifier<>(String.class, "command", "The command(s) for either command mode or hybrid");
// public static final OptionIdentifier<Boolean> OPTION_INC_DEATH_STAT = new OptionIdentifier<>(Boolean.class, "inc_death_stat", "Whether to increment the death statistic");
// public static final OptionIdentifier<Integer> OPTION_DAMAGE = new OptionIdentifier<>(Integer.class, "damage", "Amount of damage applied upon entering the void");
// public static final OptionIdentifier<Integer> OPTION_BOUNCE = new OptionIdentifier<>(Integer.class, "bounce", "Number of times to bounce from the void before activating mode");
// public static final OptionIdentifier<Float> OPTION_MIN_BOUNCE_VELOCITY = new OptionIdentifier<>(Float.class, "min_bounce_velocity", "The minimum bounce velocity");
//
// public BaseMode() {
// attachOption(new SoundOption(OPTION_SOUND));
// attachOption(new FloatOption(OPTION_SOUND_VOLUME, 1f));
// attachOption(new FloatOption(OPTION_SOUND_PITCH, 1f));
// attachOption(new BooleanOption(OPTION_HYBRID, false));
// attachOption(new BooleanOption(OPTION_KEEP_INVENTORY, true));
// attachOption(new StringOption(OPTION_MESSAGE));
// attachOption(new StringOption(OPTION_COMMAND));
// attachOption(new BooleanOption(OPTION_INC_DEATH_STAT, false));
// attachOption(new IntegerOption(OPTION_DAMAGE, 0));
// attachOption(new IntegerOption(OPTION_BOUNCE, 0));
// attachOption(new FloatOption(OPTION_MIN_BOUNCE_VELOCITY, 2.0f));
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/utils/WorldUtil.java
// public class WorldUtil {
//
// public static String configSafe(String worldName){
// return worldName.replace(" ", "_");
// }
//
// /**
// * Checks if the selected world is a valid world.
// *
// * @param worldName The world name that will be checked.
// * @return True if the world does not return null.
// */
// public static boolean isValidWorld(String worldName){
// return Bukkit.getWorld(worldName) != null;
// }
//
// /**
// * get a list of world names that begin with partial. If partial is
// * empty, all worlds are returned.
// * @param partial String to compare against.
// * @return List of world names.
// */
// public static List<String> getMatchingWorlds(String partial) {
// return Bukkit.getWorlds().stream()
// .map(World::getName)
// .filter(world -> world.toLowerCase().startsWith(partial.toLowerCase()))
// .collect(Collectors.toList());
// }
// }
| import com.endercrest.voidspawn.modes.BaseMode;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.utils.WorldUtil;
import java.io.File;
import java.io.IOException;
import java.time.Instant;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable; | * Removes the spawn of a world based on the world name.
*
* @param world The world name.
*/
public void removeSpawn(String world) {
world = WorldUtil.configSafe(world);
set(world + ".spawn", null);
saveConfig();
}
/**
* Checks if the world data file exists.
*
* @return True if world.yml exists.
*/
public boolean isFileCreated() {
return worldFile.exists();
}
/**
* Create the world file.
*/
public void createFile() {
try {
worldFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
| // Path: src/main/java/com/endercrest/voidspawn/modes/BaseMode.java
// public abstract class BaseMode extends BasicOptionContainer implements Mode {
// public static final OptionIdentifier<Sound> OPTION_SOUND = new OptionIdentifier<>(Sound.class, "sound", "The sound played when detected in void");
// public static final OptionIdentifier<Float> OPTION_SOUND_VOLUME = new OptionIdentifier<>(Float.class, "sound_volume", "The sound volume");
// public static final OptionIdentifier<Float> OPTION_SOUND_PITCH = new OptionIdentifier<>(Float.class, "sound_pitch", "The sound pitch");
// public static final OptionIdentifier<Boolean> OPTION_HYBRID = new OptionIdentifier<>(Boolean.class, "hybrid", "Whether to run in hybrid mode (mode and command)");
// public static final OptionIdentifier<Boolean> OPTION_KEEP_INVENTORY = new OptionIdentifier<>(Boolean.class, "keep_inventory", "Whether players keep inventory");
// public static final OptionIdentifier<String> OPTION_MESSAGE = new OptionIdentifier<>(String.class, "message", "Message sent when detected in void");
// public static final OptionIdentifier<String> OPTION_COMMAND = new OptionIdentifier<>(String.class, "command", "The command(s) for either command mode or hybrid");
// public static final OptionIdentifier<Boolean> OPTION_INC_DEATH_STAT = new OptionIdentifier<>(Boolean.class, "inc_death_stat", "Whether to increment the death statistic");
// public static final OptionIdentifier<Integer> OPTION_DAMAGE = new OptionIdentifier<>(Integer.class, "damage", "Amount of damage applied upon entering the void");
// public static final OptionIdentifier<Integer> OPTION_BOUNCE = new OptionIdentifier<>(Integer.class, "bounce", "Number of times to bounce from the void before activating mode");
// public static final OptionIdentifier<Float> OPTION_MIN_BOUNCE_VELOCITY = new OptionIdentifier<>(Float.class, "min_bounce_velocity", "The minimum bounce velocity");
//
// public BaseMode() {
// attachOption(new SoundOption(OPTION_SOUND));
// attachOption(new FloatOption(OPTION_SOUND_VOLUME, 1f));
// attachOption(new FloatOption(OPTION_SOUND_PITCH, 1f));
// attachOption(new BooleanOption(OPTION_HYBRID, false));
// attachOption(new BooleanOption(OPTION_KEEP_INVENTORY, true));
// attachOption(new StringOption(OPTION_MESSAGE));
// attachOption(new StringOption(OPTION_COMMAND));
// attachOption(new BooleanOption(OPTION_INC_DEATH_STAT, false));
// attachOption(new IntegerOption(OPTION_DAMAGE, 0));
// attachOption(new IntegerOption(OPTION_BOUNCE, 0));
// attachOption(new FloatOption(OPTION_MIN_BOUNCE_VELOCITY, 2.0f));
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/utils/WorldUtil.java
// public class WorldUtil {
//
// public static String configSafe(String worldName){
// return worldName.replace(" ", "_");
// }
//
// /**
// * Checks if the selected world is a valid world.
// *
// * @param worldName The world name that will be checked.
// * @return True if the world does not return null.
// */
// public static boolean isValidWorld(String worldName){
// return Bukkit.getWorld(worldName) != null;
// }
//
// /**
// * get a list of world names that begin with partial. If partial is
// * empty, all worlds are returned.
// * @param partial String to compare against.
// * @return List of world names.
// */
// public static List<String> getMatchingWorlds(String partial) {
// return Bukkit.getWorlds().stream()
// .map(World::getName)
// .filter(world -> world.toLowerCase().startsWith(partial.toLowerCase()))
// .collect(Collectors.toList());
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/ConfigManager.java
import com.endercrest.voidspawn.modes.BaseMode;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.utils.WorldUtil;
import java.io.File;
import java.io.IOException;
import java.time.Instant;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
* Removes the spawn of a world based on the world name.
*
* @param world The world name.
*/
public void removeSpawn(String world) {
world = WorldUtil.configSafe(world);
set(world + ".spawn", null);
saveConfig();
}
/**
* Checks if the world data file exists.
*
* @return True if world.yml exists.
*/
public boolean isFileCreated() {
return worldFile.exists();
}
/**
* Create the world file.
*/
public void createFile() {
try {
worldFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
| public String getOption(String world, OptionIdentifier<?> identifier) { |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/detectors/BaseDetector.java | // Path: src/main/java/com/endercrest/voidspawn/options/IntegerOption.java
// public class IntegerOption extends BaseOption<Integer> {
// public IntegerOption(@NotNull OptionIdentifier<Integer> identifier) {
// super(identifier);
// }
//
// public IntegerOption(@NotNull OptionIdentifier<Integer> identifier, Integer defaultValue) {
// super(identifier, defaultValue);
// }
//
// @Override
// public Optional<Integer> getLoadedValue(@NotNull World world) {
// String value = ConfigManager.getInstance().getOption(world.getName(), getIdentifier());
// if (value == null)
// return Optional.empty();
//
// try {
// return Optional.of(Integer.parseInt(value));
// } catch (NumberFormatException e) {
// return Optional.empty();
// }
// }
//
// @Override
// public void setValue(@NotNull World world, String value) {
// if (value == null) {
// super.setValue(world, (String) null);
// return;
// }
//
// try {
// Integer.parseInt(value); // Check if number
// super.setValue(world, value);
// } catch (NumberFormatException e) {
// throw new IllegalArgumentException("Must be a number");
// }
// }
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {
// setValue(world, String.join(" ", args));
// }
//
// @Override
// public List<String> getOptions() {
// return null;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/container/BasicOptionContainer.java
// public abstract class BasicOptionContainer implements OptionContainer {
// private final Map<String, Option<?>> options = new HashMap<>();
//
// protected void attachOption(Option<?> option) {
// options.put(option.getIdentifier().getName(), option);
// }
//
// protected void detachOption(@NotNull OptionIdentifier<?> identifier) {
// options.remove(identifier.getName());
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public @NotNull <T> Option<T> getOption(OptionIdentifier<T> identifier) {
// Option<?> option = options.get(identifier.getName());
// if (option == null || option.getType() != identifier.getType()) {
// return new EmptyOption<>(identifier);
// }
// return (Option<T>) option;
// }
//
// @Override
// public @Nullable Option<?> getOption(String name) {
// return options.get(name);
// }
//
// @Override
// public Collection<Option<?>> getOptions() {
// return options.values();
// }
// }
| import com.endercrest.voidspawn.options.IntegerOption;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.options.container.BasicOptionContainer; | package com.endercrest.voidspawn.detectors;
public abstract class BaseDetector extends BasicOptionContainer implements Detector {
public static final OptionIdentifier<Integer> OPTION_VOID = new OptionIdentifier<>(Integer.class, "void_height", "The height to detect at (default just below the void)");
public BaseDetector() { | // Path: src/main/java/com/endercrest/voidspawn/options/IntegerOption.java
// public class IntegerOption extends BaseOption<Integer> {
// public IntegerOption(@NotNull OptionIdentifier<Integer> identifier) {
// super(identifier);
// }
//
// public IntegerOption(@NotNull OptionIdentifier<Integer> identifier, Integer defaultValue) {
// super(identifier, defaultValue);
// }
//
// @Override
// public Optional<Integer> getLoadedValue(@NotNull World world) {
// String value = ConfigManager.getInstance().getOption(world.getName(), getIdentifier());
// if (value == null)
// return Optional.empty();
//
// try {
// return Optional.of(Integer.parseInt(value));
// } catch (NumberFormatException e) {
// return Optional.empty();
// }
// }
//
// @Override
// public void setValue(@NotNull World world, String value) {
// if (value == null) {
// super.setValue(world, (String) null);
// return;
// }
//
// try {
// Integer.parseInt(value); // Check if number
// super.setValue(world, value);
// } catch (NumberFormatException e) {
// throw new IllegalArgumentException("Must be a number");
// }
// }
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {
// setValue(world, String.join(" ", args));
// }
//
// @Override
// public List<String> getOptions() {
// return null;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/container/BasicOptionContainer.java
// public abstract class BasicOptionContainer implements OptionContainer {
// private final Map<String, Option<?>> options = new HashMap<>();
//
// protected void attachOption(Option<?> option) {
// options.put(option.getIdentifier().getName(), option);
// }
//
// protected void detachOption(@NotNull OptionIdentifier<?> identifier) {
// options.remove(identifier.getName());
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public @NotNull <T> Option<T> getOption(OptionIdentifier<T> identifier) {
// Option<?> option = options.get(identifier.getName());
// if (option == null || option.getType() != identifier.getType()) {
// return new EmptyOption<>(identifier);
// }
// return (Option<T>) option;
// }
//
// @Override
// public @Nullable Option<?> getOption(String name) {
// return options.get(name);
// }
//
// @Override
// public Collection<Option<?>> getOptions() {
// return options.values();
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/detectors/BaseDetector.java
import com.endercrest.voidspawn.options.IntegerOption;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.options.container.BasicOptionContainer;
package com.endercrest.voidspawn.detectors;
public abstract class BaseDetector extends BasicOptionContainer implements Detector {
public static final OptionIdentifier<Integer> OPTION_VOID = new OptionIdentifier<>(Integer.class, "void_height", "The height to detect at (default just below the void)");
public BaseDetector() { | attachOption(new IntegerOption(OPTION_VOID)); |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/DetectorManager.java | // Path: src/main/java/com/endercrest/voidspawn/detectors/NetherDetector.java
// public class NetherDetector extends VoidDetector {
// public static final OptionIdentifier<Integer> OPTION_ROOF = new OptionIdentifier<>(Integer.class, "roof_height", "The height to detect at on the roof (default 128)");
//
// public NetherDetector() {
// attachOption(new IntegerOption(OPTION_ROOF, 128));
// }
//
// @Override
// public boolean isDetected(Mode mode, Player player, World world) {
// Option<Integer> voidOption = getOption(OPTION_ROOF);
// int checkHeight = voidOption.getValue(world).orElse(128);
//
// return player.getLocation().getBlockY() > checkHeight || super.isDetected(mode, player, world);
// }
//
// @Override
// public String getDescription() {
// return "Activated when entering the void or going above nether bedrock level.";
// }
//
// @Override
// public String getName() {
// return "Nether";
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/detectors/Detector.java
// public interface Detector extends OptionContainer {
//
// /**
// * Checks if the current player is within the 'detected' region. This is used to signal to the mode whether it
// * should activate
// * @param mode The current mode
// * @param player The player
// * @param world The world
// */
// boolean isDetected(Mode mode, Player player, World world);
//
// String getDescription();
//
// /**
// * Get the name of the detector.
// *
// * @return The string version of the mode.
// */
// String getName();
// }
//
// Path: src/main/java/com/endercrest/voidspawn/detectors/VoidDetector.java
// public class VoidDetector extends BaseDetector {
// @Override
// public boolean isDetected(Mode mode, Player player, World world) {
// Option<Integer> voidOption = getOption(BaseDetector.OPTION_VOID);
// int checkHeight = voidOption.getValue(world).orElse(world.getMinHeight());
//
// return player.getLocation().getBlockY() < checkHeight;
// }
//
// @Override
// public String getDescription() {
// return "Activated by entering the void. [Default]";
// }
//
// @Override
// public String getName() {
// return "Void";
// }
// }
| import com.endercrest.voidspawn.detectors.NetherDetector;
import com.endercrest.voidspawn.detectors.Detector;
import com.endercrest.voidspawn.detectors.VoidDetector;
import javax.naming.NameAlreadyBoundException;
import java.util.HashMap; | package com.endercrest.voidspawn;
public class DetectorManager {
private static DetectorManager instance = new DetectorManager();
public static DetectorManager getInstance() {
return instance;
}
| // Path: src/main/java/com/endercrest/voidspawn/detectors/NetherDetector.java
// public class NetherDetector extends VoidDetector {
// public static final OptionIdentifier<Integer> OPTION_ROOF = new OptionIdentifier<>(Integer.class, "roof_height", "The height to detect at on the roof (default 128)");
//
// public NetherDetector() {
// attachOption(new IntegerOption(OPTION_ROOF, 128));
// }
//
// @Override
// public boolean isDetected(Mode mode, Player player, World world) {
// Option<Integer> voidOption = getOption(OPTION_ROOF);
// int checkHeight = voidOption.getValue(world).orElse(128);
//
// return player.getLocation().getBlockY() > checkHeight || super.isDetected(mode, player, world);
// }
//
// @Override
// public String getDescription() {
// return "Activated when entering the void or going above nether bedrock level.";
// }
//
// @Override
// public String getName() {
// return "Nether";
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/detectors/Detector.java
// public interface Detector extends OptionContainer {
//
// /**
// * Checks if the current player is within the 'detected' region. This is used to signal to the mode whether it
// * should activate
// * @param mode The current mode
// * @param player The player
// * @param world The world
// */
// boolean isDetected(Mode mode, Player player, World world);
//
// String getDescription();
//
// /**
// * Get the name of the detector.
// *
// * @return The string version of the mode.
// */
// String getName();
// }
//
// Path: src/main/java/com/endercrest/voidspawn/detectors/VoidDetector.java
// public class VoidDetector extends BaseDetector {
// @Override
// public boolean isDetected(Mode mode, Player player, World world) {
// Option<Integer> voidOption = getOption(BaseDetector.OPTION_VOID);
// int checkHeight = voidOption.getValue(world).orElse(world.getMinHeight());
//
// return player.getLocation().getBlockY() < checkHeight;
// }
//
// @Override
// public String getDescription() {
// return "Activated by entering the void. [Default]";
// }
//
// @Override
// public String getName() {
// return "Void";
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/DetectorManager.java
import com.endercrest.voidspawn.detectors.NetherDetector;
import com.endercrest.voidspawn.detectors.Detector;
import com.endercrest.voidspawn.detectors.VoidDetector;
import javax.naming.NameAlreadyBoundException;
import java.util.HashMap;
package com.endercrest.voidspawn;
public class DetectorManager {
private static DetectorManager instance = new DetectorManager();
public static DetectorManager getInstance() {
return instance;
}
| private Detector defaultDetector; |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/DetectorManager.java | // Path: src/main/java/com/endercrest/voidspawn/detectors/NetherDetector.java
// public class NetherDetector extends VoidDetector {
// public static final OptionIdentifier<Integer> OPTION_ROOF = new OptionIdentifier<>(Integer.class, "roof_height", "The height to detect at on the roof (default 128)");
//
// public NetherDetector() {
// attachOption(new IntegerOption(OPTION_ROOF, 128));
// }
//
// @Override
// public boolean isDetected(Mode mode, Player player, World world) {
// Option<Integer> voidOption = getOption(OPTION_ROOF);
// int checkHeight = voidOption.getValue(world).orElse(128);
//
// return player.getLocation().getBlockY() > checkHeight || super.isDetected(mode, player, world);
// }
//
// @Override
// public String getDescription() {
// return "Activated when entering the void or going above nether bedrock level.";
// }
//
// @Override
// public String getName() {
// return "Nether";
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/detectors/Detector.java
// public interface Detector extends OptionContainer {
//
// /**
// * Checks if the current player is within the 'detected' region. This is used to signal to the mode whether it
// * should activate
// * @param mode The current mode
// * @param player The player
// * @param world The world
// */
// boolean isDetected(Mode mode, Player player, World world);
//
// String getDescription();
//
// /**
// * Get the name of the detector.
// *
// * @return The string version of the mode.
// */
// String getName();
// }
//
// Path: src/main/java/com/endercrest/voidspawn/detectors/VoidDetector.java
// public class VoidDetector extends BaseDetector {
// @Override
// public boolean isDetected(Mode mode, Player player, World world) {
// Option<Integer> voidOption = getOption(BaseDetector.OPTION_VOID);
// int checkHeight = voidOption.getValue(world).orElse(world.getMinHeight());
//
// return player.getLocation().getBlockY() < checkHeight;
// }
//
// @Override
// public String getDescription() {
// return "Activated by entering the void. [Default]";
// }
//
// @Override
// public String getName() {
// return "Void";
// }
// }
| import com.endercrest.voidspawn.detectors.NetherDetector;
import com.endercrest.voidspawn.detectors.Detector;
import com.endercrest.voidspawn.detectors.VoidDetector;
import javax.naming.NameAlreadyBoundException;
import java.util.HashMap; | package com.endercrest.voidspawn;
public class DetectorManager {
private static DetectorManager instance = new DetectorManager();
public static DetectorManager getInstance() {
return instance;
}
private Detector defaultDetector;
private HashMap<String, Detector> detectors;
/**
* Setup the DetectorManager, should only be called once.
*/
public void setUp() { | // Path: src/main/java/com/endercrest/voidspawn/detectors/NetherDetector.java
// public class NetherDetector extends VoidDetector {
// public static final OptionIdentifier<Integer> OPTION_ROOF = new OptionIdentifier<>(Integer.class, "roof_height", "The height to detect at on the roof (default 128)");
//
// public NetherDetector() {
// attachOption(new IntegerOption(OPTION_ROOF, 128));
// }
//
// @Override
// public boolean isDetected(Mode mode, Player player, World world) {
// Option<Integer> voidOption = getOption(OPTION_ROOF);
// int checkHeight = voidOption.getValue(world).orElse(128);
//
// return player.getLocation().getBlockY() > checkHeight || super.isDetected(mode, player, world);
// }
//
// @Override
// public String getDescription() {
// return "Activated when entering the void or going above nether bedrock level.";
// }
//
// @Override
// public String getName() {
// return "Nether";
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/detectors/Detector.java
// public interface Detector extends OptionContainer {
//
// /**
// * Checks if the current player is within the 'detected' region. This is used to signal to the mode whether it
// * should activate
// * @param mode The current mode
// * @param player The player
// * @param world The world
// */
// boolean isDetected(Mode mode, Player player, World world);
//
// String getDescription();
//
// /**
// * Get the name of the detector.
// *
// * @return The string version of the mode.
// */
// String getName();
// }
//
// Path: src/main/java/com/endercrest/voidspawn/detectors/VoidDetector.java
// public class VoidDetector extends BaseDetector {
// @Override
// public boolean isDetected(Mode mode, Player player, World world) {
// Option<Integer> voidOption = getOption(BaseDetector.OPTION_VOID);
// int checkHeight = voidOption.getValue(world).orElse(world.getMinHeight());
//
// return player.getLocation().getBlockY() < checkHeight;
// }
//
// @Override
// public String getDescription() {
// return "Activated by entering the void. [Default]";
// }
//
// @Override
// public String getName() {
// return "Void";
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/DetectorManager.java
import com.endercrest.voidspawn.detectors.NetherDetector;
import com.endercrest.voidspawn.detectors.Detector;
import com.endercrest.voidspawn.detectors.VoidDetector;
import javax.naming.NameAlreadyBoundException;
import java.util.HashMap;
package com.endercrest.voidspawn;
public class DetectorManager {
private static DetectorManager instance = new DetectorManager();
public static DetectorManager getInstance() {
return instance;
}
private Detector defaultDetector;
private HashMap<String, Detector> detectors;
/**
* Setup the DetectorManager, should only be called once.
*/
public void setUp() { | defaultDetector = new VoidDetector(); |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/DetectorManager.java | // Path: src/main/java/com/endercrest/voidspawn/detectors/NetherDetector.java
// public class NetherDetector extends VoidDetector {
// public static final OptionIdentifier<Integer> OPTION_ROOF = new OptionIdentifier<>(Integer.class, "roof_height", "The height to detect at on the roof (default 128)");
//
// public NetherDetector() {
// attachOption(new IntegerOption(OPTION_ROOF, 128));
// }
//
// @Override
// public boolean isDetected(Mode mode, Player player, World world) {
// Option<Integer> voidOption = getOption(OPTION_ROOF);
// int checkHeight = voidOption.getValue(world).orElse(128);
//
// return player.getLocation().getBlockY() > checkHeight || super.isDetected(mode, player, world);
// }
//
// @Override
// public String getDescription() {
// return "Activated when entering the void or going above nether bedrock level.";
// }
//
// @Override
// public String getName() {
// return "Nether";
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/detectors/Detector.java
// public interface Detector extends OptionContainer {
//
// /**
// * Checks if the current player is within the 'detected' region. This is used to signal to the mode whether it
// * should activate
// * @param mode The current mode
// * @param player The player
// * @param world The world
// */
// boolean isDetected(Mode mode, Player player, World world);
//
// String getDescription();
//
// /**
// * Get the name of the detector.
// *
// * @return The string version of the mode.
// */
// String getName();
// }
//
// Path: src/main/java/com/endercrest/voidspawn/detectors/VoidDetector.java
// public class VoidDetector extends BaseDetector {
// @Override
// public boolean isDetected(Mode mode, Player player, World world) {
// Option<Integer> voidOption = getOption(BaseDetector.OPTION_VOID);
// int checkHeight = voidOption.getValue(world).orElse(world.getMinHeight());
//
// return player.getLocation().getBlockY() < checkHeight;
// }
//
// @Override
// public String getDescription() {
// return "Activated by entering the void. [Default]";
// }
//
// @Override
// public String getName() {
// return "Void";
// }
// }
| import com.endercrest.voidspawn.detectors.NetherDetector;
import com.endercrest.voidspawn.detectors.Detector;
import com.endercrest.voidspawn.detectors.VoidDetector;
import javax.naming.NameAlreadyBoundException;
import java.util.HashMap; | package com.endercrest.voidspawn;
public class DetectorManager {
private static DetectorManager instance = new DetectorManager();
public static DetectorManager getInstance() {
return instance;
}
private Detector defaultDetector;
private HashMap<String, Detector> detectors;
/**
* Setup the DetectorManager, should only be called once.
*/
public void setUp() {
defaultDetector = new VoidDetector();
detectors = new HashMap<String, Detector>() {{
put("void", defaultDetector); | // Path: src/main/java/com/endercrest/voidspawn/detectors/NetherDetector.java
// public class NetherDetector extends VoidDetector {
// public static final OptionIdentifier<Integer> OPTION_ROOF = new OptionIdentifier<>(Integer.class, "roof_height", "The height to detect at on the roof (default 128)");
//
// public NetherDetector() {
// attachOption(new IntegerOption(OPTION_ROOF, 128));
// }
//
// @Override
// public boolean isDetected(Mode mode, Player player, World world) {
// Option<Integer> voidOption = getOption(OPTION_ROOF);
// int checkHeight = voidOption.getValue(world).orElse(128);
//
// return player.getLocation().getBlockY() > checkHeight || super.isDetected(mode, player, world);
// }
//
// @Override
// public String getDescription() {
// return "Activated when entering the void or going above nether bedrock level.";
// }
//
// @Override
// public String getName() {
// return "Nether";
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/detectors/Detector.java
// public interface Detector extends OptionContainer {
//
// /**
// * Checks if the current player is within the 'detected' region. This is used to signal to the mode whether it
// * should activate
// * @param mode The current mode
// * @param player The player
// * @param world The world
// */
// boolean isDetected(Mode mode, Player player, World world);
//
// String getDescription();
//
// /**
// * Get the name of the detector.
// *
// * @return The string version of the mode.
// */
// String getName();
// }
//
// Path: src/main/java/com/endercrest/voidspawn/detectors/VoidDetector.java
// public class VoidDetector extends BaseDetector {
// @Override
// public boolean isDetected(Mode mode, Player player, World world) {
// Option<Integer> voidOption = getOption(BaseDetector.OPTION_VOID);
// int checkHeight = voidOption.getValue(world).orElse(world.getMinHeight());
//
// return player.getLocation().getBlockY() < checkHeight;
// }
//
// @Override
// public String getDescription() {
// return "Activated by entering the void. [Default]";
// }
//
// @Override
// public String getName() {
// return "Void";
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/DetectorManager.java
import com.endercrest.voidspawn.detectors.NetherDetector;
import com.endercrest.voidspawn.detectors.Detector;
import com.endercrest.voidspawn.detectors.VoidDetector;
import javax.naming.NameAlreadyBoundException;
import java.util.HashMap;
package com.endercrest.voidspawn;
public class DetectorManager {
private static DetectorManager instance = new DetectorManager();
public static DetectorManager getInstance() {
return instance;
}
private Detector defaultDetector;
private HashMap<String, Detector> detectors;
/**
* Setup the DetectorManager, should only be called once.
*/
public void setUp() {
defaultDetector = new VoidDetector();
detectors = new HashMap<String, Detector>() {{
put("void", defaultDetector); | put("nether", new NetherDetector()); |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/modes/LooperMode.java | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/BooleanOption.java
// public class BooleanOption extends BaseOption<Boolean> {
// private static final List<String> options = Collections.unmodifiableList(new ArrayList<String>() {{
// add("true");
// add("false");
// }});
//
// public BooleanOption(OptionIdentifier<Boolean> identifier) {
// super(identifier);
// }
//
// public BooleanOption(OptionIdentifier<Boolean> identifier, Boolean defaultValue) {
// super(identifier, defaultValue);
// }
//
// @Override
// public Optional<Boolean> getLoadedValue(@NotNull World world) {
// String value = ConfigManager.getInstance().getOption(world.getName(), getIdentifier());
// if (value == null)
// return Optional.empty();
//
// if (options.contains(value)) {
// return Optional.of(Boolean.valueOf(value));
// }
// return Optional.empty();
// }
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {
// setValue(world, String.join(" ", args));
// }
//
// @Override
// public List<String> getOptions() {
// return options;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/IntegerOption.java
// public class IntegerOption extends BaseOption<Integer> {
// public IntegerOption(@NotNull OptionIdentifier<Integer> identifier) {
// super(identifier);
// }
//
// public IntegerOption(@NotNull OptionIdentifier<Integer> identifier, Integer defaultValue) {
// super(identifier, defaultValue);
// }
//
// @Override
// public Optional<Integer> getLoadedValue(@NotNull World world) {
// String value = ConfigManager.getInstance().getOption(world.getName(), getIdentifier());
// if (value == null)
// return Optional.empty();
//
// try {
// return Optional.of(Integer.parseInt(value));
// } catch (NumberFormatException e) {
// return Optional.empty();
// }
// }
//
// @Override
// public void setValue(@NotNull World world, String value) {
// if (value == null) {
// super.setValue(world, (String) null);
// return;
// }
//
// try {
// Integer.parseInt(value); // Check if number
// super.setValue(world, value);
// } catch (NumberFormatException e) {
// throw new IllegalArgumentException("Must be a number");
// }
// }
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {
// setValue(world, String.join(" ", args));
// }
//
// @Override
// public List<String> getOptions() {
// return null;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/modes/status/Status.java
// public class Status {
// private final Type type;
// private final String message;
//
// public Status(Type type, String message) {
// this.type = type;
// this.message = message;
// }
//
// public Type getType() {
// return type;
// }
//
// public String getMessage() {
// return message;
// }
//
// public enum Type {
// COMPLETE("[&a+&f]"),
// INCOMPLETE("[&cx&f]"),
// INFO("[&b@&f]"),
// UNSET("[&7-&f]");
//
// private String symbol;
//
// Type(String symbol) {
// this.symbol = symbol;
// }
//
// public String getSymbol() {
// return symbol;
// }
// }
// }
| import com.endercrest.voidspawn.TeleportResult;
import com.endercrest.voidspawn.options.BooleanOption;
import com.endercrest.voidspawn.options.IntegerOption;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.modes.status.Status;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.util.Optional; | package com.endercrest.voidspawn.modes;
public class LooperMode extends BaseMode {
public static final OptionIdentifier<Integer> OPTION_VERTICAL_OFFSET = new OptionIdentifier<>(Integer.class, "vertical_offset", "The offset from the top of world to teleport the player");
public static final OptionIdentifier<Boolean> OPTION_KEEP_VELOCITY = new OptionIdentifier<>(Boolean.class, "keep_velocity", "Whether the players velocity should be maintained after being teleported");
public LooperMode() { | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/BooleanOption.java
// public class BooleanOption extends BaseOption<Boolean> {
// private static final List<String> options = Collections.unmodifiableList(new ArrayList<String>() {{
// add("true");
// add("false");
// }});
//
// public BooleanOption(OptionIdentifier<Boolean> identifier) {
// super(identifier);
// }
//
// public BooleanOption(OptionIdentifier<Boolean> identifier, Boolean defaultValue) {
// super(identifier, defaultValue);
// }
//
// @Override
// public Optional<Boolean> getLoadedValue(@NotNull World world) {
// String value = ConfigManager.getInstance().getOption(world.getName(), getIdentifier());
// if (value == null)
// return Optional.empty();
//
// if (options.contains(value)) {
// return Optional.of(Boolean.valueOf(value));
// }
// return Optional.empty();
// }
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {
// setValue(world, String.join(" ", args));
// }
//
// @Override
// public List<String> getOptions() {
// return options;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/IntegerOption.java
// public class IntegerOption extends BaseOption<Integer> {
// public IntegerOption(@NotNull OptionIdentifier<Integer> identifier) {
// super(identifier);
// }
//
// public IntegerOption(@NotNull OptionIdentifier<Integer> identifier, Integer defaultValue) {
// super(identifier, defaultValue);
// }
//
// @Override
// public Optional<Integer> getLoadedValue(@NotNull World world) {
// String value = ConfigManager.getInstance().getOption(world.getName(), getIdentifier());
// if (value == null)
// return Optional.empty();
//
// try {
// return Optional.of(Integer.parseInt(value));
// } catch (NumberFormatException e) {
// return Optional.empty();
// }
// }
//
// @Override
// public void setValue(@NotNull World world, String value) {
// if (value == null) {
// super.setValue(world, (String) null);
// return;
// }
//
// try {
// Integer.parseInt(value); // Check if number
// super.setValue(world, value);
// } catch (NumberFormatException e) {
// throw new IllegalArgumentException("Must be a number");
// }
// }
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {
// setValue(world, String.join(" ", args));
// }
//
// @Override
// public List<String> getOptions() {
// return null;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/modes/status/Status.java
// public class Status {
// private final Type type;
// private final String message;
//
// public Status(Type type, String message) {
// this.type = type;
// this.message = message;
// }
//
// public Type getType() {
// return type;
// }
//
// public String getMessage() {
// return message;
// }
//
// public enum Type {
// COMPLETE("[&a+&f]"),
// INCOMPLETE("[&cx&f]"),
// INFO("[&b@&f]"),
// UNSET("[&7-&f]");
//
// private String symbol;
//
// Type(String symbol) {
// this.symbol = symbol;
// }
//
// public String getSymbol() {
// return symbol;
// }
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/modes/LooperMode.java
import com.endercrest.voidspawn.TeleportResult;
import com.endercrest.voidspawn.options.BooleanOption;
import com.endercrest.voidspawn.options.IntegerOption;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.modes.status.Status;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.util.Optional;
package com.endercrest.voidspawn.modes;
public class LooperMode extends BaseMode {
public static final OptionIdentifier<Integer> OPTION_VERTICAL_OFFSET = new OptionIdentifier<>(Integer.class, "vertical_offset", "The offset from the top of world to teleport the player");
public static final OptionIdentifier<Boolean> OPTION_KEEP_VELOCITY = new OptionIdentifier<>(Boolean.class, "keep_velocity", "Whether the players velocity should be maintained after being teleported");
public LooperMode() { | attachOption(new IntegerOption(OPTION_VERTICAL_OFFSET)); |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/modes/LooperMode.java | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/BooleanOption.java
// public class BooleanOption extends BaseOption<Boolean> {
// private static final List<String> options = Collections.unmodifiableList(new ArrayList<String>() {{
// add("true");
// add("false");
// }});
//
// public BooleanOption(OptionIdentifier<Boolean> identifier) {
// super(identifier);
// }
//
// public BooleanOption(OptionIdentifier<Boolean> identifier, Boolean defaultValue) {
// super(identifier, defaultValue);
// }
//
// @Override
// public Optional<Boolean> getLoadedValue(@NotNull World world) {
// String value = ConfigManager.getInstance().getOption(world.getName(), getIdentifier());
// if (value == null)
// return Optional.empty();
//
// if (options.contains(value)) {
// return Optional.of(Boolean.valueOf(value));
// }
// return Optional.empty();
// }
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {
// setValue(world, String.join(" ", args));
// }
//
// @Override
// public List<String> getOptions() {
// return options;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/IntegerOption.java
// public class IntegerOption extends BaseOption<Integer> {
// public IntegerOption(@NotNull OptionIdentifier<Integer> identifier) {
// super(identifier);
// }
//
// public IntegerOption(@NotNull OptionIdentifier<Integer> identifier, Integer defaultValue) {
// super(identifier, defaultValue);
// }
//
// @Override
// public Optional<Integer> getLoadedValue(@NotNull World world) {
// String value = ConfigManager.getInstance().getOption(world.getName(), getIdentifier());
// if (value == null)
// return Optional.empty();
//
// try {
// return Optional.of(Integer.parseInt(value));
// } catch (NumberFormatException e) {
// return Optional.empty();
// }
// }
//
// @Override
// public void setValue(@NotNull World world, String value) {
// if (value == null) {
// super.setValue(world, (String) null);
// return;
// }
//
// try {
// Integer.parseInt(value); // Check if number
// super.setValue(world, value);
// } catch (NumberFormatException e) {
// throw new IllegalArgumentException("Must be a number");
// }
// }
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {
// setValue(world, String.join(" ", args));
// }
//
// @Override
// public List<String> getOptions() {
// return null;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/modes/status/Status.java
// public class Status {
// private final Type type;
// private final String message;
//
// public Status(Type type, String message) {
// this.type = type;
// this.message = message;
// }
//
// public Type getType() {
// return type;
// }
//
// public String getMessage() {
// return message;
// }
//
// public enum Type {
// COMPLETE("[&a+&f]"),
// INCOMPLETE("[&cx&f]"),
// INFO("[&b@&f]"),
// UNSET("[&7-&f]");
//
// private String symbol;
//
// Type(String symbol) {
// this.symbol = symbol;
// }
//
// public String getSymbol() {
// return symbol;
// }
// }
// }
| import com.endercrest.voidspawn.TeleportResult;
import com.endercrest.voidspawn.options.BooleanOption;
import com.endercrest.voidspawn.options.IntegerOption;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.modes.status.Status;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.util.Optional; | package com.endercrest.voidspawn.modes;
public class LooperMode extends BaseMode {
public static final OptionIdentifier<Integer> OPTION_VERTICAL_OFFSET = new OptionIdentifier<>(Integer.class, "vertical_offset", "The offset from the top of world to teleport the player");
public static final OptionIdentifier<Boolean> OPTION_KEEP_VELOCITY = new OptionIdentifier<>(Boolean.class, "keep_velocity", "Whether the players velocity should be maintained after being teleported");
public LooperMode() {
attachOption(new IntegerOption(OPTION_VERTICAL_OFFSET)); | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/BooleanOption.java
// public class BooleanOption extends BaseOption<Boolean> {
// private static final List<String> options = Collections.unmodifiableList(new ArrayList<String>() {{
// add("true");
// add("false");
// }});
//
// public BooleanOption(OptionIdentifier<Boolean> identifier) {
// super(identifier);
// }
//
// public BooleanOption(OptionIdentifier<Boolean> identifier, Boolean defaultValue) {
// super(identifier, defaultValue);
// }
//
// @Override
// public Optional<Boolean> getLoadedValue(@NotNull World world) {
// String value = ConfigManager.getInstance().getOption(world.getName(), getIdentifier());
// if (value == null)
// return Optional.empty();
//
// if (options.contains(value)) {
// return Optional.of(Boolean.valueOf(value));
// }
// return Optional.empty();
// }
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {
// setValue(world, String.join(" ", args));
// }
//
// @Override
// public List<String> getOptions() {
// return options;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/IntegerOption.java
// public class IntegerOption extends BaseOption<Integer> {
// public IntegerOption(@NotNull OptionIdentifier<Integer> identifier) {
// super(identifier);
// }
//
// public IntegerOption(@NotNull OptionIdentifier<Integer> identifier, Integer defaultValue) {
// super(identifier, defaultValue);
// }
//
// @Override
// public Optional<Integer> getLoadedValue(@NotNull World world) {
// String value = ConfigManager.getInstance().getOption(world.getName(), getIdentifier());
// if (value == null)
// return Optional.empty();
//
// try {
// return Optional.of(Integer.parseInt(value));
// } catch (NumberFormatException e) {
// return Optional.empty();
// }
// }
//
// @Override
// public void setValue(@NotNull World world, String value) {
// if (value == null) {
// super.setValue(world, (String) null);
// return;
// }
//
// try {
// Integer.parseInt(value); // Check if number
// super.setValue(world, value);
// } catch (NumberFormatException e) {
// throw new IllegalArgumentException("Must be a number");
// }
// }
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {
// setValue(world, String.join(" ", args));
// }
//
// @Override
// public List<String> getOptions() {
// return null;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/modes/status/Status.java
// public class Status {
// private final Type type;
// private final String message;
//
// public Status(Type type, String message) {
// this.type = type;
// this.message = message;
// }
//
// public Type getType() {
// return type;
// }
//
// public String getMessage() {
// return message;
// }
//
// public enum Type {
// COMPLETE("[&a+&f]"),
// INCOMPLETE("[&cx&f]"),
// INFO("[&b@&f]"),
// UNSET("[&7-&f]");
//
// private String symbol;
//
// Type(String symbol) {
// this.symbol = symbol;
// }
//
// public String getSymbol() {
// return symbol;
// }
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/modes/LooperMode.java
import com.endercrest.voidspawn.TeleportResult;
import com.endercrest.voidspawn.options.BooleanOption;
import com.endercrest.voidspawn.options.IntegerOption;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.modes.status.Status;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.util.Optional;
package com.endercrest.voidspawn.modes;
public class LooperMode extends BaseMode {
public static final OptionIdentifier<Integer> OPTION_VERTICAL_OFFSET = new OptionIdentifier<>(Integer.class, "vertical_offset", "The offset from the top of world to teleport the player");
public static final OptionIdentifier<Boolean> OPTION_KEEP_VELOCITY = new OptionIdentifier<>(Boolean.class, "keep_velocity", "Whether the players velocity should be maintained after being teleported");
public LooperMode() {
attachOption(new IntegerOption(OPTION_VERTICAL_OFFSET)); | attachOption(new BooleanOption(OPTION_KEEP_VELOCITY, true)); |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/modes/LooperMode.java | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/BooleanOption.java
// public class BooleanOption extends BaseOption<Boolean> {
// private static final List<String> options = Collections.unmodifiableList(new ArrayList<String>() {{
// add("true");
// add("false");
// }});
//
// public BooleanOption(OptionIdentifier<Boolean> identifier) {
// super(identifier);
// }
//
// public BooleanOption(OptionIdentifier<Boolean> identifier, Boolean defaultValue) {
// super(identifier, defaultValue);
// }
//
// @Override
// public Optional<Boolean> getLoadedValue(@NotNull World world) {
// String value = ConfigManager.getInstance().getOption(world.getName(), getIdentifier());
// if (value == null)
// return Optional.empty();
//
// if (options.contains(value)) {
// return Optional.of(Boolean.valueOf(value));
// }
// return Optional.empty();
// }
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {
// setValue(world, String.join(" ", args));
// }
//
// @Override
// public List<String> getOptions() {
// return options;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/IntegerOption.java
// public class IntegerOption extends BaseOption<Integer> {
// public IntegerOption(@NotNull OptionIdentifier<Integer> identifier) {
// super(identifier);
// }
//
// public IntegerOption(@NotNull OptionIdentifier<Integer> identifier, Integer defaultValue) {
// super(identifier, defaultValue);
// }
//
// @Override
// public Optional<Integer> getLoadedValue(@NotNull World world) {
// String value = ConfigManager.getInstance().getOption(world.getName(), getIdentifier());
// if (value == null)
// return Optional.empty();
//
// try {
// return Optional.of(Integer.parseInt(value));
// } catch (NumberFormatException e) {
// return Optional.empty();
// }
// }
//
// @Override
// public void setValue(@NotNull World world, String value) {
// if (value == null) {
// super.setValue(world, (String) null);
// return;
// }
//
// try {
// Integer.parseInt(value); // Check if number
// super.setValue(world, value);
// } catch (NumberFormatException e) {
// throw new IllegalArgumentException("Must be a number");
// }
// }
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {
// setValue(world, String.join(" ", args));
// }
//
// @Override
// public List<String> getOptions() {
// return null;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/modes/status/Status.java
// public class Status {
// private final Type type;
// private final String message;
//
// public Status(Type type, String message) {
// this.type = type;
// this.message = message;
// }
//
// public Type getType() {
// return type;
// }
//
// public String getMessage() {
// return message;
// }
//
// public enum Type {
// COMPLETE("[&a+&f]"),
// INCOMPLETE("[&cx&f]"),
// INFO("[&b@&f]"),
// UNSET("[&7-&f]");
//
// private String symbol;
//
// Type(String symbol) {
// this.symbol = symbol;
// }
//
// public String getSymbol() {
// return symbol;
// }
// }
// }
| import com.endercrest.voidspawn.TeleportResult;
import com.endercrest.voidspawn.options.BooleanOption;
import com.endercrest.voidspawn.options.IntegerOption;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.modes.status.Status;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.util.Optional; | package com.endercrest.voidspawn.modes;
public class LooperMode extends BaseMode {
public static final OptionIdentifier<Integer> OPTION_VERTICAL_OFFSET = new OptionIdentifier<>(Integer.class, "vertical_offset", "The offset from the top of world to teleport the player");
public static final OptionIdentifier<Boolean> OPTION_KEEP_VELOCITY = new OptionIdentifier<>(Boolean.class, "keep_velocity", "Whether the players velocity should be maintained after being teleported");
public LooperMode() {
attachOption(new IntegerOption(OPTION_VERTICAL_OFFSET));
attachOption(new BooleanOption(OPTION_KEEP_VELOCITY, true));
}
@Override | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/BooleanOption.java
// public class BooleanOption extends BaseOption<Boolean> {
// private static final List<String> options = Collections.unmodifiableList(new ArrayList<String>() {{
// add("true");
// add("false");
// }});
//
// public BooleanOption(OptionIdentifier<Boolean> identifier) {
// super(identifier);
// }
//
// public BooleanOption(OptionIdentifier<Boolean> identifier, Boolean defaultValue) {
// super(identifier, defaultValue);
// }
//
// @Override
// public Optional<Boolean> getLoadedValue(@NotNull World world) {
// String value = ConfigManager.getInstance().getOption(world.getName(), getIdentifier());
// if (value == null)
// return Optional.empty();
//
// if (options.contains(value)) {
// return Optional.of(Boolean.valueOf(value));
// }
// return Optional.empty();
// }
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {
// setValue(world, String.join(" ", args));
// }
//
// @Override
// public List<String> getOptions() {
// return options;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/IntegerOption.java
// public class IntegerOption extends BaseOption<Integer> {
// public IntegerOption(@NotNull OptionIdentifier<Integer> identifier) {
// super(identifier);
// }
//
// public IntegerOption(@NotNull OptionIdentifier<Integer> identifier, Integer defaultValue) {
// super(identifier, defaultValue);
// }
//
// @Override
// public Optional<Integer> getLoadedValue(@NotNull World world) {
// String value = ConfigManager.getInstance().getOption(world.getName(), getIdentifier());
// if (value == null)
// return Optional.empty();
//
// try {
// return Optional.of(Integer.parseInt(value));
// } catch (NumberFormatException e) {
// return Optional.empty();
// }
// }
//
// @Override
// public void setValue(@NotNull World world, String value) {
// if (value == null) {
// super.setValue(world, (String) null);
// return;
// }
//
// try {
// Integer.parseInt(value); // Check if number
// super.setValue(world, value);
// } catch (NumberFormatException e) {
// throw new IllegalArgumentException("Must be a number");
// }
// }
//
// @Override
// public void setValue(@NotNull World world, String[] args) throws IllegalArgumentException {
// setValue(world, String.join(" ", args));
// }
//
// @Override
// public List<String> getOptions() {
// return null;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/options/OptionIdentifier.java
// public class OptionIdentifier<T> {
// private final Class<T> type;
// private final String name;
// private final String description;
//
// public OptionIdentifier(Class<T> type, String name, String description) {
// this.type = type;
// this.name = name;
// this.description = description;
// }
//
// public Class<T> getType() {
// return type;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
// }
//
// Path: src/main/java/com/endercrest/voidspawn/modes/status/Status.java
// public class Status {
// private final Type type;
// private final String message;
//
// public Status(Type type, String message) {
// this.type = type;
// this.message = message;
// }
//
// public Type getType() {
// return type;
// }
//
// public String getMessage() {
// return message;
// }
//
// public enum Type {
// COMPLETE("[&a+&f]"),
// INCOMPLETE("[&cx&f]"),
// INFO("[&b@&f]"),
// UNSET("[&7-&f]");
//
// private String symbol;
//
// Type(String symbol) {
// this.symbol = symbol;
// }
//
// public String getSymbol() {
// return symbol;
// }
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/modes/LooperMode.java
import com.endercrest.voidspawn.TeleportResult;
import com.endercrest.voidspawn.options.BooleanOption;
import com.endercrest.voidspawn.options.IntegerOption;
import com.endercrest.voidspawn.options.OptionIdentifier;
import com.endercrest.voidspawn.modes.status.Status;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.util.Optional;
package com.endercrest.voidspawn.modes;
public class LooperMode extends BaseMode {
public static final OptionIdentifier<Integer> OPTION_VERTICAL_OFFSET = new OptionIdentifier<>(Integer.class, "vertical_offset", "The offset from the top of world to teleport the player");
public static final OptionIdentifier<Boolean> OPTION_KEEP_VELOCITY = new OptionIdentifier<>(Boolean.class, "keep_velocity", "Whether the players velocity should be maintained after being teleported");
public LooperMode() {
attachOption(new IntegerOption(OPTION_VERTICAL_OFFSET));
attachOption(new BooleanOption(OPTION_KEEP_VELOCITY, true));
}
@Override | public TeleportResult onActivate(Player player, String worldName) { |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/modes/island/ASkyblockIslandMode.java | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
| import com.endercrest.voidspawn.TeleportResult;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player; | package com.endercrest.voidspawn.modes.island;
public class ASkyblockIslandMode extends BaseIslandMode {
@Override | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/modes/island/ASkyblockIslandMode.java
import com.endercrest.voidspawn.TeleportResult;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
package com.endercrest.voidspawn.modes.island;
public class ASkyblockIslandMode extends BaseIslandMode {
@Override | public TeleportResult onActivateIsland(Player player, String worldname) { |
endercrest/VoidSpawn | src/main/java/com/endercrest/voidspawn/modes/island/IslandWorldIslandMode.java | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
| import com.endercrest.voidspawn.TeleportResult;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import pl.islandworld.IslandWorld;
import pl.islandworld.api.IslandWorldApi;
import pl.islandworld.entity.SimpleIsland; | package com.endercrest.voidspawn.modes.island;
public class IslandWorldIslandMode extends BaseIslandMode{
@Override
public boolean isEnabled() {
return isModeEnabled();
}
@Override | // Path: src/main/java/com/endercrest/voidspawn/TeleportResult.java
// public enum TeleportResult {
// SUCCESS("", false),
// INVALID_WORLD("Invalid world", true),
// MISSING_ISLAND_DEPEND("Missing skyblock plugin dependency", true),
// MISSING_ISLAND("No island found", false),
// INCOMPLETE_MODE("Mode has not been setup completely", true),
// FAILED_COMMAND("Command failed", true),
// MODE_DISABLED("The current mode is disabled!", true);
//
// private final String message;
// private final boolean error;
//
// TeleportResult(String message, boolean error) {
// this.message = message;
// this.error = error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public Boolean isError() {
// return error;
// }
// }
// Path: src/main/java/com/endercrest/voidspawn/modes/island/IslandWorldIslandMode.java
import com.endercrest.voidspawn.TeleportResult;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import pl.islandworld.IslandWorld;
import pl.islandworld.api.IslandWorldApi;
import pl.islandworld.entity.SimpleIsland;
package com.endercrest.voidspawn.modes.island;
public class IslandWorldIslandMode extends BaseIslandMode{
@Override
public boolean isEnabled() {
return isModeEnabled();
}
@Override | public TeleportResult onActivateIsland(Player player, String worldname) { |
steeleforge/ironsites | core/src/main/java/com/steeleforge/aem/ironsites/wcm/components/IronSitemapUse.java | // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/page/filter/HidePageFilter.java
// public class HidePageFilter extends AndPageFilter {
// public static final String DEFAULT_HIDE_PROPERTY = "hideInNav";
// private boolean includeInvalid;
// private boolean includeHidden;
// private String property = DEFAULT_HIDE_PROPERTY;
//
// public static final BooleanEqualsFilter PAGE_NOT_HIDDEN_FILTER = new BooleanEqualsFilter(DEFAULT_HIDE_PROPERTY, Boolean.TRUE, Boolean.TRUE);
// public static final HidePageFilter HIDE_IN_NAVIGATION_FILTER = new HidePageFilter(DEFAULT_HIDE_PROPERTY);
//
// public HidePageFilter(boolean includeInvalid, boolean includeHidden, String property) {
// super(null);
// this.includeInvalid = includeInvalid;
// this.includeHidden = includeHidden;
// this.property = property;
//
// if (!this.includeInvalid) {
// addFilter(InvalidPageFilter.INVALID_PAGE_FILTER);
// }
// if (!this.includeHidden) {
// if (StringUtils.isBlank(property)) {
// addFilter(PAGE_NOT_HIDDEN_FILTER);
// } else {
// addFilter(new BooleanEqualsFilter(this.property, Boolean.TRUE, Boolean.TRUE));
// }
// }
// }
//
// public HidePageFilter(String property) {
// this(false, false, property);
// }
// }
| import com.adobe.cq.sightly.WCMUse;
import com.day.cq.wcm.api.Page;
import com.day.cq.wcm.foundation.Sitemap.Link;
import com.steeleforge.aem.ironsites.wcm.page.filter.HidePageFilter;
import java.util.Arrays;
import java.util.Collections;
import java.util.List; | /**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.wcm.components;
/**
* IronSitemapUse leverages sightly WCMUse API to populate IronSitemap
*
* @author David Steele
*/
public class IronSitemapUse extends WCMUse {
private IronSitemap sitemap = null;
@Override
public void activate() throws Exception {
String path = getProperties().get("path", "");
String hide = getProperties().get("hideProperty", "hideInNav");
String[] inclusions = getProperties().get("inclusions", new String[0]);
String[] exclusions = getProperties().get("exclusions", new String[0]);
if (path.length() == 0 && null != getCurrentPage().getParent()) {
path = getCurrentPage().getParent().getPath();
}
Page root = getPageManager().getPage(path);
sitemap = new IronSitemap(getRequest(),
root, | // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/page/filter/HidePageFilter.java
// public class HidePageFilter extends AndPageFilter {
// public static final String DEFAULT_HIDE_PROPERTY = "hideInNav";
// private boolean includeInvalid;
// private boolean includeHidden;
// private String property = DEFAULT_HIDE_PROPERTY;
//
// public static final BooleanEqualsFilter PAGE_NOT_HIDDEN_FILTER = new BooleanEqualsFilter(DEFAULT_HIDE_PROPERTY, Boolean.TRUE, Boolean.TRUE);
// public static final HidePageFilter HIDE_IN_NAVIGATION_FILTER = new HidePageFilter(DEFAULT_HIDE_PROPERTY);
//
// public HidePageFilter(boolean includeInvalid, boolean includeHidden, String property) {
// super(null);
// this.includeInvalid = includeInvalid;
// this.includeHidden = includeHidden;
// this.property = property;
//
// if (!this.includeInvalid) {
// addFilter(InvalidPageFilter.INVALID_PAGE_FILTER);
// }
// if (!this.includeHidden) {
// if (StringUtils.isBlank(property)) {
// addFilter(PAGE_NOT_HIDDEN_FILTER);
// } else {
// addFilter(new BooleanEqualsFilter(this.property, Boolean.TRUE, Boolean.TRUE));
// }
// }
// }
//
// public HidePageFilter(String property) {
// this(false, false, property);
// }
// }
// Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/components/IronSitemapUse.java
import com.adobe.cq.sightly.WCMUse;
import com.day.cq.wcm.api.Page;
import com.day.cq.wcm.foundation.Sitemap.Link;
import com.steeleforge.aem.ironsites.wcm.page.filter.HidePageFilter;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.wcm.components;
/**
* IronSitemapUse leverages sightly WCMUse API to populate IronSitemap
*
* @author David Steele
*/
public class IronSitemapUse extends WCMUse {
private IronSitemap sitemap = null;
@Override
public void activate() throws Exception {
String path = getProperties().get("path", "");
String hide = getProperties().get("hideProperty", "hideInNav");
String[] inclusions = getProperties().get("inclusions", new String[0]);
String[] exclusions = getProperties().get("exclusions", new String[0]);
if (path.length() == 0 && null != getCurrentPage().getParent()) {
path = getCurrentPage().getParent().getPath();
}
Page root = getPageManager().getPage(path);
sitemap = new IronSitemap(getRequest(),
root, | new HidePageFilter(hide), |
steeleforge/ironsites | core/src/main/java/com/steeleforge/aem/ironsites/wcm/api/ApiService.java | // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/ResourceResolverSubservice.java
// public abstract class ResourceResolverSubservice {
// private static final Logger LOG = LoggerFactory.getLogger(ResourceResolverSubservice.class);
//
// protected ResourceResolver resourceResolver;
//
// /**
// * @return UserServiceMapper identity
// */
// public abstract String getServiceMapperIdentity();
//
// /**
// * Closes resource resolver
// */
// public void closeResolver() {
// if (null != this.resourceResolver && this.resourceResolver.isLive()) {
// this.resourceResolver.close();
// }
// }
//
// /**
// * Acquires JCR administrative session from a resource resolver
// *
// * @return JCR Session
// * @throws RepositoryException
// */
// public Session getSession(final ResourceResolverFactory resourceResolverFactory) {
// Session session = getResourceResolver(resourceResolverFactory).adaptTo(Session.class);
// if (null != session) {
// try {
// session.refresh(true);
// } catch (RepositoryException e) {
// LOG.trace("Could not refresh JCR session: ", e.getMessage());
// }
// }
// return session;
// }
//
// /**
// * @return ResourceResolver from factory
// */
// public ResourceResolver getResourceResolver(final ResourceResolverFactory resourceResolverFactory) {
// if (null == resourceResolverFactory || StringUtils.isBlank(getServiceMapperIdentity())) {
// return this.resourceResolver;
// }
// if (null == this.resourceResolver || !this.resourceResolver.isLive()) {
// try {
// this.resourceResolver = resourceResolverFactory.getServiceResourceResolver(Collections.unmodifiableMap(
// new HashMap<String,Object>() {
// private static final long serialVersionUID = 1L;
// { put(ResourceResolverFactory.SUBSERVICE, getServiceMapperIdentity() ); }
// }));
// } catch (LoginException e) {
// LOG.debug("Unable to retrieve resource resolver for {}:", getServiceMapperIdentity(), e.getMessage());
// }
// }
// return this.resourceResolver;
// }
//
// }
| import java.text.MessageFormat;
import java.util.Collections;
import java.util.Set;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.References;
import org.apache.felix.scr.annotations.Service;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import com.steeleforge.aem.ironsites.wcm.ResourceResolverSubservice; | /**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.wcm.api;
/**
* API Factory
*
* @author David Steele
*/
@Service(value = ApiService.class)
@Component(label = "ironsites - API Factory Service",
description = "Acquire API URLs from this service.",
immediate = true)
@References({
@Reference(cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
policy = ReferencePolicy.DYNAMIC,
referenceInterface = ApiConfig.class,
name = "ApiConfig",
bind = "bindConfigurations",
unbind = "unbindConfigurations")
}) | // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/ResourceResolverSubservice.java
// public abstract class ResourceResolverSubservice {
// private static final Logger LOG = LoggerFactory.getLogger(ResourceResolverSubservice.class);
//
// protected ResourceResolver resourceResolver;
//
// /**
// * @return UserServiceMapper identity
// */
// public abstract String getServiceMapperIdentity();
//
// /**
// * Closes resource resolver
// */
// public void closeResolver() {
// if (null != this.resourceResolver && this.resourceResolver.isLive()) {
// this.resourceResolver.close();
// }
// }
//
// /**
// * Acquires JCR administrative session from a resource resolver
// *
// * @return JCR Session
// * @throws RepositoryException
// */
// public Session getSession(final ResourceResolverFactory resourceResolverFactory) {
// Session session = getResourceResolver(resourceResolverFactory).adaptTo(Session.class);
// if (null != session) {
// try {
// session.refresh(true);
// } catch (RepositoryException e) {
// LOG.trace("Could not refresh JCR session: ", e.getMessage());
// }
// }
// return session;
// }
//
// /**
// * @return ResourceResolver from factory
// */
// public ResourceResolver getResourceResolver(final ResourceResolverFactory resourceResolverFactory) {
// if (null == resourceResolverFactory || StringUtils.isBlank(getServiceMapperIdentity())) {
// return this.resourceResolver;
// }
// if (null == this.resourceResolver || !this.resourceResolver.isLive()) {
// try {
// this.resourceResolver = resourceResolverFactory.getServiceResourceResolver(Collections.unmodifiableMap(
// new HashMap<String,Object>() {
// private static final long serialVersionUID = 1L;
// { put(ResourceResolverFactory.SUBSERVICE, getServiceMapperIdentity() ); }
// }));
// } catch (LoginException e) {
// LOG.debug("Unable to retrieve resource resolver for {}:", getServiceMapperIdentity(), e.getMessage());
// }
// }
// return this.resourceResolver;
// }
//
// }
// Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/api/ApiService.java
import java.text.MessageFormat;
import java.util.Collections;
import java.util.Set;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.References;
import org.apache.felix.scr.annotations.Service;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import com.steeleforge.aem.ironsites.wcm.ResourceResolverSubservice;
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.wcm.api;
/**
* API Factory
*
* @author David Steele
*/
@Service(value = ApiService.class)
@Component(label = "ironsites - API Factory Service",
description = "Acquire API URLs from this service.",
immediate = true)
@References({
@Reference(cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
policy = ReferencePolicy.DYNAMIC,
referenceInterface = ApiConfig.class,
name = "ApiConfig",
bind = "bindConfigurations",
unbind = "unbindConfigurations")
}) | public class ApiService extends ResourceResolverSubservice { |
steeleforge/ironsites | core/src/main/java/com/steeleforge/aem/ironsites/wcm/page/head/Meta.java | // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/WCMConstants.java
// public enum WCMConstants {
// INSTANCE;
// public static final String HTTP = "http";
// public static final String HTTPS = "https";
// public static final String PROTOCOL_RELATIVE = "//";
// public static final String DELIMITER_QUERY = "?";
// public static final String DELIMITER_FRAGMENT = "#";
// public static final String DELIMITER_PORT = ":";
// public static final String DELIMITER_PATH = "/";
// public static final String DELIMITER_PATH_IDENTIFIER = "--";
// public static final String DELIMITER_SUFFIX = DELIMITER_PATH;
// public static final String DELIMITER_EXTENSION = ".";
// public static final String DELIMITER_SELECTOR = DELIMITER_EXTENSION;
// public static final String DELIMITER_COMMA = ",";
// public static final String DELIMITER_COMMA_SPACED = ",";
// public static final String DELIMITER_MULTIFIELD = "|";
// public static final String PATH_FAVICON = "/favicon.ico";
// public static final String HTML = "html";
// public static final String HEADER_LOCATION = "Location";
// }
| import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import com.steeleforge.aem.ironsites.wcm.WCMConstants; | package com.steeleforge.aem.ironsites.wcm.page.head;
/**
* Page icons for <link/> tags
*
* @author david
*/
public class Meta {
// locals
private String name;
private String content;
public Meta(final String multifield) { | // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/WCMConstants.java
// public enum WCMConstants {
// INSTANCE;
// public static final String HTTP = "http";
// public static final String HTTPS = "https";
// public static final String PROTOCOL_RELATIVE = "//";
// public static final String DELIMITER_QUERY = "?";
// public static final String DELIMITER_FRAGMENT = "#";
// public static final String DELIMITER_PORT = ":";
// public static final String DELIMITER_PATH = "/";
// public static final String DELIMITER_PATH_IDENTIFIER = "--";
// public static final String DELIMITER_SUFFIX = DELIMITER_PATH;
// public static final String DELIMITER_EXTENSION = ".";
// public static final String DELIMITER_SELECTOR = DELIMITER_EXTENSION;
// public static final String DELIMITER_COMMA = ",";
// public static final String DELIMITER_COMMA_SPACED = ",";
// public static final String DELIMITER_MULTIFIELD = "|";
// public static final String PATH_FAVICON = "/favicon.ico";
// public static final String HTML = "html";
// public static final String HEADER_LOCATION = "Location";
// }
// Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/page/head/Meta.java
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import com.steeleforge.aem.ironsites.wcm.WCMConstants;
package com.steeleforge.aem.ironsites.wcm.page.head;
/**
* Page icons for <link/> tags
*
* @author david
*/
public class Meta {
// locals
private String name;
private String content;
public Meta(final String multifield) { | String[] fields = StringUtils.split(multifield, WCMConstants.DELIMITER_MULTIFIELD); |
steeleforge/ironsites | cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/impl/SimpleCacheConfigurationImpl.java | // Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheConfiguration.java
// public interface SimpleCacheConfiguration {
// /**
// * Cache name.
// *
// * @return cache name
// */
// public String getName();
//
// /**
// * Cache spec
// *
// * @return cache specfication String
// * @see <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheBuilderSpec.html">CacheBuilderSpec</a>
// */
// public String getSpecs();
//
// /**
// * Cache statistics tracking enabled/disabled
// *
// * @return cache stat toggle state
// */
// public Boolean isRecordStats();
// }
| import org.apache.felix.scr.annotations.ConfigurationPolicy;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.osgi.service.component.ComponentContext;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheConfiguration;
import java.util.Dictionary;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component; | /**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.cache.service.impl;
@Service
@Component(label = "ironsites - Simple Cache Configuration",
description = "Configuration pool for Google CacheBuilder",
immediate = true,
configurationFactory = true,
metatype = true,
policy = ConfigurationPolicy.REQUIRE) | // Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheConfiguration.java
// public interface SimpleCacheConfiguration {
// /**
// * Cache name.
// *
// * @return cache name
// */
// public String getName();
//
// /**
// * Cache spec
// *
// * @return cache specfication String
// * @see <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheBuilderSpec.html">CacheBuilderSpec</a>
// */
// public String getSpecs();
//
// /**
// * Cache statistics tracking enabled/disabled
// *
// * @return cache stat toggle state
// */
// public Boolean isRecordStats();
// }
// Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/impl/SimpleCacheConfigurationImpl.java
import org.apache.felix.scr.annotations.ConfigurationPolicy;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.osgi.service.component.ComponentContext;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheConfiguration;
import java.util.Dictionary;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.cache.service.impl;
@Service
@Component(label = "ironsites - Simple Cache Configuration",
description = "Configuration pool for Google CacheBuilder",
immediate = true,
configurationFactory = true,
metatype = true,
policy = ConfigurationPolicy.REQUIRE) | public class SimpleCacheConfigurationImpl implements SimpleCacheConfiguration { |
steeleforge/ironsites | core/src/main/java/com/steeleforge/aem/ironsites/wcm/page/filter/ShowPageFilter.java | // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/page/filter/property/BooleanEqualsFilter.java
// public class BooleanEqualsFilter extends PropertyEqualsFilter {
// public BooleanEqualsFilter(String property, Object value, Boolean negate) {
// super(property, value, negate);
// }
//
// public BooleanEqualsFilter(String property, Object value) {
// super(property, value);
// }
//
// public boolean propertyEquals(Page page, String property, Object value) {
// return page.getProperties().get(property, Boolean.FALSE).equals(value);
// }
// }
| import org.apache.commons.lang.StringUtils;
import com.steeleforge.aem.ironsites.wcm.page.filter.property.BooleanEqualsFilter; | /**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.wcm.page.filter;
/**
* Page Filter checking for page validity and an opt-in boolean property.
*
* Assumes default 'showInNav' opt-in property.
*
* @author David Steele
*/
public class ShowPageFilter extends AndPageFilter {
public static final String DEFAULT_SHOW_PROPERTY = "showInNav";
private boolean includeInvalid;
private boolean includeHidden;
private String property = DEFAULT_SHOW_PROPERTY;
| // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/page/filter/property/BooleanEqualsFilter.java
// public class BooleanEqualsFilter extends PropertyEqualsFilter {
// public BooleanEqualsFilter(String property, Object value, Boolean negate) {
// super(property, value, negate);
// }
//
// public BooleanEqualsFilter(String property, Object value) {
// super(property, value);
// }
//
// public boolean propertyEquals(Page page, String property, Object value) {
// return page.getProperties().get(property, Boolean.FALSE).equals(value);
// }
// }
// Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/page/filter/ShowPageFilter.java
import org.apache.commons.lang.StringUtils;
import com.steeleforge.aem.ironsites.wcm.page.filter.property.BooleanEqualsFilter;
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.wcm.page.filter;
/**
* Page Filter checking for page validity and an opt-in boolean property.
*
* Assumes default 'showInNav' opt-in property.
*
* @author David Steele
*/
public class ShowPageFilter extends AndPageFilter {
public static final String DEFAULT_SHOW_PROPERTY = "showInNav";
private boolean includeInvalid;
private boolean includeHidden;
private String property = DEFAULT_SHOW_PROPERTY;
| public static final BooleanEqualsFilter PAGE_SHOWN_FILTER = new BooleanEqualsFilter(DEFAULT_SHOW_PROPERTY, Boolean.TRUE); |
steeleforge/ironsites | core/src/main/java/com/steeleforge/aem/ironsites/wcm/components/ImageUse.java | // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/servlet/AdaptiveImageConfig.java
// @Service(value = AdaptiveImageConfig.class)
// @Component(label = "ironsites - Adaptive Image Configurations",
// description = "Adaptive Image width support configurations",
// immediate = true)
// public class AdaptiveImageConfig {
// // statics
// private static final Logger LOG = LoggerFactory.getLogger(AdaptiveImageConfig.class);
// private static final String ADAPTIVEIMAGE_SERVLET = "com.day.cq.wcm.foundation.impl.AdaptiveImageComponentServlet";
//
// // services
// @Reference
// private ConfigurationAdmin configAdmin;
//
// // locals
// private List<Integer> widths = null;
//
// // properties
// @Property(label = "Additional Supported Widths",
// description = "In addition Adobe CQ Adaptive Image Component Servlet dimensions",
// value = {
// "320", // iPhone 1 portrait
// "420",
// "480", // iPhone 1 landscape
// "620", // iPad 1 landscape
// "640",
// "768",
// "800",
// "992",
// "1024",
// "1200",
// "1280",
// "1400",
// "1440",
// "1920" })
// private static final String PN_SUPPORTED_WIDTHS = "adapt.supported.widths";
//
// @Activate
// protected void activate(ComponentContext componentContext) {
// Configuration config = null;
// Dictionary<?, ?> parentProperties = null;
// Dictionary<?, ?> properties = componentContext.getProperties();
// // acquire parent servlet properties
// try {
// config = (Configuration) configAdmin.getConfiguration(ADAPTIVEIMAGE_SERVLET);
// parentProperties = config.getProperties();
// } catch (IOException ioe) {
// LOG.debug("Cannot retrieve AdaptiveImageComponentServlet configuration", ioe.getMessage());
// }
//
// // acquire parent servlet widths
// String[] parentWidths = null;
// if (null != parentProperties) {
// parentWidths = PropertiesUtil.toStringArray(parentProperties.get(PN_SUPPORTED_WIDTHS));
// if (ArrayUtils.getLength(parentWidths) > 0) {
// for (String width : parentWidths) {
// getWidths().add(Integer.parseInt(width));
// }
// }
// }
//
// // acquire local servlet widths
// String[] localWidths = PropertiesUtil.toStringArray(properties.get(PN_SUPPORTED_WIDTHS));
// if (ArrayUtils.getLength(localWidths) > 0) {
// for (String width : localWidths) {
// getWidths().add(Integer.parseInt(width));
// }
// }
// }
//
// /**
// * @return lazily invoke/return set of configurable widths
// */
// public List<Integer> getWidths() {
// if (null == widths) {
// widths = new LinkedList<Integer>();
// }
// return widths;
// }
// }
| import java.util.List;
import java.util.Map;
import javax.jcr.RepositoryException;
import org.apache.commons.lang.ArrayUtils;
import org.apache.sling.api.resource.Resource;
import com.adobe.cq.sightly.WCMUse;
import com.steeleforge.aem.ironsites.wcm.servlet.AdaptiveImageConfig;
import java.text.MessageFormat;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList; | /**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.wcm.components;
public class ImageUse extends WCMUse {
// statics
private static final String PN_PATH_IMAGE = "image";
private static final String PN_WIDTHS_IMAGE = "widths";
private static final String DEFAULT_PATH_IMAGE = "/image";
private static final String ATTR_SOURCE_SRCSET = "srcset";
private static final String ATTR_SOURCE_MEDIA_MINWIDTH = "minWidth";
private static final String FMT_SOURCE_SRCSET = "{0}.img.{1,number,#}.high.{2}{3}";
private static final String FMT_SOURCE_FULL = "{0}.img.full.high.{1}{2}";
// local
private List<Integer> widths = null;
private IronImage image = null;
private List<Map<String, String>> sources = null;
@Override
public void activate() throws Exception { | // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/servlet/AdaptiveImageConfig.java
// @Service(value = AdaptiveImageConfig.class)
// @Component(label = "ironsites - Adaptive Image Configurations",
// description = "Adaptive Image width support configurations",
// immediate = true)
// public class AdaptiveImageConfig {
// // statics
// private static final Logger LOG = LoggerFactory.getLogger(AdaptiveImageConfig.class);
// private static final String ADAPTIVEIMAGE_SERVLET = "com.day.cq.wcm.foundation.impl.AdaptiveImageComponentServlet";
//
// // services
// @Reference
// private ConfigurationAdmin configAdmin;
//
// // locals
// private List<Integer> widths = null;
//
// // properties
// @Property(label = "Additional Supported Widths",
// description = "In addition Adobe CQ Adaptive Image Component Servlet dimensions",
// value = {
// "320", // iPhone 1 portrait
// "420",
// "480", // iPhone 1 landscape
// "620", // iPad 1 landscape
// "640",
// "768",
// "800",
// "992",
// "1024",
// "1200",
// "1280",
// "1400",
// "1440",
// "1920" })
// private static final String PN_SUPPORTED_WIDTHS = "adapt.supported.widths";
//
// @Activate
// protected void activate(ComponentContext componentContext) {
// Configuration config = null;
// Dictionary<?, ?> parentProperties = null;
// Dictionary<?, ?> properties = componentContext.getProperties();
// // acquire parent servlet properties
// try {
// config = (Configuration) configAdmin.getConfiguration(ADAPTIVEIMAGE_SERVLET);
// parentProperties = config.getProperties();
// } catch (IOException ioe) {
// LOG.debug("Cannot retrieve AdaptiveImageComponentServlet configuration", ioe.getMessage());
// }
//
// // acquire parent servlet widths
// String[] parentWidths = null;
// if (null != parentProperties) {
// parentWidths = PropertiesUtil.toStringArray(parentProperties.get(PN_SUPPORTED_WIDTHS));
// if (ArrayUtils.getLength(parentWidths) > 0) {
// for (String width : parentWidths) {
// getWidths().add(Integer.parseInt(width));
// }
// }
// }
//
// // acquire local servlet widths
// String[] localWidths = PropertiesUtil.toStringArray(properties.get(PN_SUPPORTED_WIDTHS));
// if (ArrayUtils.getLength(localWidths) > 0) {
// for (String width : localWidths) {
// getWidths().add(Integer.parseInt(width));
// }
// }
// }
//
// /**
// * @return lazily invoke/return set of configurable widths
// */
// public List<Integer> getWidths() {
// if (null == widths) {
// widths = new LinkedList<Integer>();
// }
// return widths;
// }
// }
// Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/components/ImageUse.java
import java.util.List;
import java.util.Map;
import javax.jcr.RepositoryException;
import org.apache.commons.lang.ArrayUtils;
import org.apache.sling.api.resource.Resource;
import com.adobe.cq.sightly.WCMUse;
import com.steeleforge.aem.ironsites.wcm.servlet.AdaptiveImageConfig;
import java.text.MessageFormat;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.wcm.components;
public class ImageUse extends WCMUse {
// statics
private static final String PN_PATH_IMAGE = "image";
private static final String PN_WIDTHS_IMAGE = "widths";
private static final String DEFAULT_PATH_IMAGE = "/image";
private static final String ATTR_SOURCE_SRCSET = "srcset";
private static final String ATTR_SOURCE_MEDIA_MINWIDTH = "minWidth";
private static final String FMT_SOURCE_SRCSET = "{0}.img.{1,number,#}.high.{2}{3}";
private static final String FMT_SOURCE_FULL = "{0}.img.full.high.{1}{2}";
// local
private List<Integer> widths = null;
private IronImage image = null;
private List<Map<String, String>> sources = null;
@Override
public void activate() throws Exception { | final AdaptiveImageConfig config = getSlingScriptHelper().getService(AdaptiveImageConfig.class); |
steeleforge/ironsites | cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/impl/SimpleCacheServiceMBeanImpl.java | // Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheService.java
// public interface SimpleCacheService {
// /**
// * Known cache names/keys
// *
// * @return set of cache keys
// */
// public Set<String> getCaches();
//
// /**
// * Access OSGi configured or application managed cache for name & options.
// *
// * @param name cache key
// * @param spec {@link <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheBuilderSpec.html">CacheBuilderSpec</a>}
// * @param stats true if recording statistics is desired
// * @return pre-existing or new cache
// */
// public Cache<Object, Object> getCache(String name, String spec, boolean stats);
//
// /**
// * Access OSGi configured or application managed cache by name.
// *
// * @param name cache key
// * @return pre-existing or new cache
// */
// public Cache<Object, Object> getCache(String name);
//
// /**
// * Cache by name as Map.
// *
// * @param name cache key
// * @return pre-existing/new cache or null
// */
// public Map<Object, Object> getCacheMap(String name);
//
// /**
// * Access cache statistics by name.
// *
// * @param name cache key
// * @return cache statistics
// * @see <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheStats.html">CacheStats</a>
// */
// public CacheStats getStats(String name);
//
// /**
// * Invalidate and destroy cache by name.
// *
// * @param name
// */
// public void clearCache(String name);
// }
//
// Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheServiceMBean.java
// @Description("SimpleCache MBean")
// public interface SimpleCacheServiceMBean {
// @Description("Caches")
// public Set<String> getCacheNames();
//
// @Description("Cache Size")
// public long getCacheSize(String cache);
//
// @Description("Cache Access/Miss Statistics")
// public CacheStats getCacheStats(String cache);
//
// @Description("Invalidate Cache")
// public void clearCache(String cache);
// }
| import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import com.adobe.granite.jmx.annotation.AnnotatedStandardMBean;
import com.google.common.cache.CacheStats;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheService;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheServiceMBean;
import java.util.Set;
import javax.management.DynamicMBean;
import javax.management.NotCompliantMBeanException; | /**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.cache.service.impl;
@Service(value = DynamicMBean.class)
@Component(name = "SimpleCacheService JMX", immediate = true)
@Property(name = "jmx.objectname", value = "com.steeleforge.aem.ironsites.cache:type=SimpleCacheServiceMBean") | // Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheService.java
// public interface SimpleCacheService {
// /**
// * Known cache names/keys
// *
// * @return set of cache keys
// */
// public Set<String> getCaches();
//
// /**
// * Access OSGi configured or application managed cache for name & options.
// *
// * @param name cache key
// * @param spec {@link <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheBuilderSpec.html">CacheBuilderSpec</a>}
// * @param stats true if recording statistics is desired
// * @return pre-existing or new cache
// */
// public Cache<Object, Object> getCache(String name, String spec, boolean stats);
//
// /**
// * Access OSGi configured or application managed cache by name.
// *
// * @param name cache key
// * @return pre-existing or new cache
// */
// public Cache<Object, Object> getCache(String name);
//
// /**
// * Cache by name as Map.
// *
// * @param name cache key
// * @return pre-existing/new cache or null
// */
// public Map<Object, Object> getCacheMap(String name);
//
// /**
// * Access cache statistics by name.
// *
// * @param name cache key
// * @return cache statistics
// * @see <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheStats.html">CacheStats</a>
// */
// public CacheStats getStats(String name);
//
// /**
// * Invalidate and destroy cache by name.
// *
// * @param name
// */
// public void clearCache(String name);
// }
//
// Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheServiceMBean.java
// @Description("SimpleCache MBean")
// public interface SimpleCacheServiceMBean {
// @Description("Caches")
// public Set<String> getCacheNames();
//
// @Description("Cache Size")
// public long getCacheSize(String cache);
//
// @Description("Cache Access/Miss Statistics")
// public CacheStats getCacheStats(String cache);
//
// @Description("Invalidate Cache")
// public void clearCache(String cache);
// }
// Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/impl/SimpleCacheServiceMBeanImpl.java
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import com.adobe.granite.jmx.annotation.AnnotatedStandardMBean;
import com.google.common.cache.CacheStats;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheService;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheServiceMBean;
import java.util.Set;
import javax.management.DynamicMBean;
import javax.management.NotCompliantMBeanException;
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.cache.service.impl;
@Service(value = DynamicMBean.class)
@Component(name = "SimpleCacheService JMX", immediate = true)
@Property(name = "jmx.objectname", value = "com.steeleforge.aem.ironsites.cache:type=SimpleCacheServiceMBean") | public class SimpleCacheServiceMBeanImpl extends AnnotatedStandardMBean implements SimpleCacheServiceMBean { |
steeleforge/ironsites | cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/impl/SimpleCacheServiceMBeanImpl.java | // Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheService.java
// public interface SimpleCacheService {
// /**
// * Known cache names/keys
// *
// * @return set of cache keys
// */
// public Set<String> getCaches();
//
// /**
// * Access OSGi configured or application managed cache for name & options.
// *
// * @param name cache key
// * @param spec {@link <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheBuilderSpec.html">CacheBuilderSpec</a>}
// * @param stats true if recording statistics is desired
// * @return pre-existing or new cache
// */
// public Cache<Object, Object> getCache(String name, String spec, boolean stats);
//
// /**
// * Access OSGi configured or application managed cache by name.
// *
// * @param name cache key
// * @return pre-existing or new cache
// */
// public Cache<Object, Object> getCache(String name);
//
// /**
// * Cache by name as Map.
// *
// * @param name cache key
// * @return pre-existing/new cache or null
// */
// public Map<Object, Object> getCacheMap(String name);
//
// /**
// * Access cache statistics by name.
// *
// * @param name cache key
// * @return cache statistics
// * @see <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheStats.html">CacheStats</a>
// */
// public CacheStats getStats(String name);
//
// /**
// * Invalidate and destroy cache by name.
// *
// * @param name
// */
// public void clearCache(String name);
// }
//
// Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheServiceMBean.java
// @Description("SimpleCache MBean")
// public interface SimpleCacheServiceMBean {
// @Description("Caches")
// public Set<String> getCacheNames();
//
// @Description("Cache Size")
// public long getCacheSize(String cache);
//
// @Description("Cache Access/Miss Statistics")
// public CacheStats getCacheStats(String cache);
//
// @Description("Invalidate Cache")
// public void clearCache(String cache);
// }
| import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import com.adobe.granite.jmx.annotation.AnnotatedStandardMBean;
import com.google.common.cache.CacheStats;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheService;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheServiceMBean;
import java.util.Set;
import javax.management.DynamicMBean;
import javax.management.NotCompliantMBeanException; | /**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.cache.service.impl;
@Service(value = DynamicMBean.class)
@Component(name = "SimpleCacheService JMX", immediate = true)
@Property(name = "jmx.objectname", value = "com.steeleforge.aem.ironsites.cache:type=SimpleCacheServiceMBean")
public class SimpleCacheServiceMBeanImpl extends AnnotatedStandardMBean implements SimpleCacheServiceMBean {
@Reference | // Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheService.java
// public interface SimpleCacheService {
// /**
// * Known cache names/keys
// *
// * @return set of cache keys
// */
// public Set<String> getCaches();
//
// /**
// * Access OSGi configured or application managed cache for name & options.
// *
// * @param name cache key
// * @param spec {@link <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheBuilderSpec.html">CacheBuilderSpec</a>}
// * @param stats true if recording statistics is desired
// * @return pre-existing or new cache
// */
// public Cache<Object, Object> getCache(String name, String spec, boolean stats);
//
// /**
// * Access OSGi configured or application managed cache by name.
// *
// * @param name cache key
// * @return pre-existing or new cache
// */
// public Cache<Object, Object> getCache(String name);
//
// /**
// * Cache by name as Map.
// *
// * @param name cache key
// * @return pre-existing/new cache or null
// */
// public Map<Object, Object> getCacheMap(String name);
//
// /**
// * Access cache statistics by name.
// *
// * @param name cache key
// * @return cache statistics
// * @see <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheStats.html">CacheStats</a>
// */
// public CacheStats getStats(String name);
//
// /**
// * Invalidate and destroy cache by name.
// *
// * @param name
// */
// public void clearCache(String name);
// }
//
// Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheServiceMBean.java
// @Description("SimpleCache MBean")
// public interface SimpleCacheServiceMBean {
// @Description("Caches")
// public Set<String> getCacheNames();
//
// @Description("Cache Size")
// public long getCacheSize(String cache);
//
// @Description("Cache Access/Miss Statistics")
// public CacheStats getCacheStats(String cache);
//
// @Description("Invalidate Cache")
// public void clearCache(String cache);
// }
// Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/impl/SimpleCacheServiceMBeanImpl.java
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import com.adobe.granite.jmx.annotation.AnnotatedStandardMBean;
import com.google.common.cache.CacheStats;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheService;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheServiceMBean;
import java.util.Set;
import javax.management.DynamicMBean;
import javax.management.NotCompliantMBeanException;
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.cache.service.impl;
@Service(value = DynamicMBean.class)
@Component(name = "SimpleCacheService JMX", immediate = true)
@Property(name = "jmx.objectname", value = "com.steeleforge.aem.ironsites.cache:type=SimpleCacheServiceMBean")
public class SimpleCacheServiceMBeanImpl extends AnnotatedStandardMBean implements SimpleCacheServiceMBean {
@Reference | private SimpleCacheService cacheService; |
steeleforge/ironsites | core/src/main/java/com/steeleforge/aem/ironsites/wcm/page/head/Icon.java | // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/WCMConstants.java
// public enum WCMConstants {
// INSTANCE;
// public static final String HTTP = "http";
// public static final String HTTPS = "https";
// public static final String PROTOCOL_RELATIVE = "//";
// public static final String DELIMITER_QUERY = "?";
// public static final String DELIMITER_FRAGMENT = "#";
// public static final String DELIMITER_PORT = ":";
// public static final String DELIMITER_PATH = "/";
// public static final String DELIMITER_PATH_IDENTIFIER = "--";
// public static final String DELIMITER_SUFFIX = DELIMITER_PATH;
// public static final String DELIMITER_EXTENSION = ".";
// public static final String DELIMITER_SELECTOR = DELIMITER_EXTENSION;
// public static final String DELIMITER_COMMA = ",";
// public static final String DELIMITER_COMMA_SPACED = ",";
// public static final String DELIMITER_MULTIFIELD = "|";
// public static final String PATH_FAVICON = "/favicon.ico";
// public static final String HTML = "html";
// public static final String HEADER_LOCATION = "Location";
// }
| import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import com.steeleforge.aem.ironsites.wcm.WCMConstants; | package com.steeleforge.aem.ironsites.wcm.page.head;
/**
* Page icons for <link/> tags
*
* @author david
*/
public class Icon {
// locals
private String rel;
private String sizes;
private String href;
private String type;
// constructor
public Icon(final String multifield) { | // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/WCMConstants.java
// public enum WCMConstants {
// INSTANCE;
// public static final String HTTP = "http";
// public static final String HTTPS = "https";
// public static final String PROTOCOL_RELATIVE = "//";
// public static final String DELIMITER_QUERY = "?";
// public static final String DELIMITER_FRAGMENT = "#";
// public static final String DELIMITER_PORT = ":";
// public static final String DELIMITER_PATH = "/";
// public static final String DELIMITER_PATH_IDENTIFIER = "--";
// public static final String DELIMITER_SUFFIX = DELIMITER_PATH;
// public static final String DELIMITER_EXTENSION = ".";
// public static final String DELIMITER_SELECTOR = DELIMITER_EXTENSION;
// public static final String DELIMITER_COMMA = ",";
// public static final String DELIMITER_COMMA_SPACED = ",";
// public static final String DELIMITER_MULTIFIELD = "|";
// public static final String PATH_FAVICON = "/favicon.ico";
// public static final String HTML = "html";
// public static final String HEADER_LOCATION = "Location";
// }
// Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/page/head/Icon.java
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import com.steeleforge.aem.ironsites.wcm.WCMConstants;
package com.steeleforge.aem.ironsites.wcm.page.head;
/**
* Page icons for <link/> tags
*
* @author david
*/
public class Icon {
// locals
private String rel;
private String sizes;
private String href;
private String type;
// constructor
public Icon(final String multifield) { | String[] fields = StringUtils.split(multifield, WCMConstants.DELIMITER_MULTIFIELD); |
steeleforge/ironsites | core/src/main/java/com/steeleforge/aem/ironsites/wcm/page/filter/HidePageFilter.java | // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/page/filter/property/BooleanEqualsFilter.java
// public class BooleanEqualsFilter extends PropertyEqualsFilter {
// public BooleanEqualsFilter(String property, Object value, Boolean negate) {
// super(property, value, negate);
// }
//
// public BooleanEqualsFilter(String property, Object value) {
// super(property, value);
// }
//
// public boolean propertyEquals(Page page, String property, Object value) {
// return page.getProperties().get(property, Boolean.FALSE).equals(value);
// }
// }
| import org.apache.commons.lang.StringUtils;
import com.steeleforge.aem.ironsites.wcm.page.filter.property.BooleanEqualsFilter; | /**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.wcm.page.filter;
/**
* Page Filter checking for page validity and a "hidden" boolean property.
* Drop-in replacement for com.day.cq.wcm.api.PageFilter
*
* Assumes default 'hideInNav' opt-out property.
*
* @author David Steele
*/
public class HidePageFilter extends AndPageFilter {
public static final String DEFAULT_HIDE_PROPERTY = "hideInNav";
private boolean includeInvalid;
private boolean includeHidden;
private String property = DEFAULT_HIDE_PROPERTY;
| // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/page/filter/property/BooleanEqualsFilter.java
// public class BooleanEqualsFilter extends PropertyEqualsFilter {
// public BooleanEqualsFilter(String property, Object value, Boolean negate) {
// super(property, value, negate);
// }
//
// public BooleanEqualsFilter(String property, Object value) {
// super(property, value);
// }
//
// public boolean propertyEquals(Page page, String property, Object value) {
// return page.getProperties().get(property, Boolean.FALSE).equals(value);
// }
// }
// Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/page/filter/HidePageFilter.java
import org.apache.commons.lang.StringUtils;
import com.steeleforge.aem.ironsites.wcm.page.filter.property.BooleanEqualsFilter;
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.wcm.page.filter;
/**
* Page Filter checking for page validity and a "hidden" boolean property.
* Drop-in replacement for com.day.cq.wcm.api.PageFilter
*
* Assumes default 'hideInNav' opt-out property.
*
* @author David Steele
*/
public class HidePageFilter extends AndPageFilter {
public static final String DEFAULT_HIDE_PROPERTY = "hideInNav";
private boolean includeInvalid;
private boolean includeHidden;
private String property = DEFAULT_HIDE_PROPERTY;
| public static final BooleanEqualsFilter PAGE_NOT_HIDDEN_FILTER = new BooleanEqualsFilter(DEFAULT_HIDE_PROPERTY, Boolean.TRUE, Boolean.TRUE); |
steeleforge/ironsites | syndicate/src/main/java/com/steeleforge/aem/ironsites/syndicate/service/TopicReplicationService.java | // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/ResourceResolverSubservice.java
// public abstract class ResourceResolverSubservice {
// private static final Logger LOG = LoggerFactory.getLogger(ResourceResolverSubservice.class);
//
// protected ResourceResolver resourceResolver;
//
// /**
// * @return UserServiceMapper identity
// */
// public abstract String getServiceMapperIdentity();
//
// /**
// * Closes resource resolver
// */
// public void closeResolver() {
// if (null != this.resourceResolver && this.resourceResolver.isLive()) {
// this.resourceResolver.close();
// }
// }
//
// /**
// * Acquires JCR administrative session from a resource resolver
// *
// * @return JCR Session
// * @throws RepositoryException
// */
// public Session getSession(final ResourceResolverFactory resourceResolverFactory) {
// Session session = getResourceResolver(resourceResolverFactory).adaptTo(Session.class);
// if (null != session) {
// try {
// session.refresh(true);
// } catch (RepositoryException e) {
// LOG.trace("Could not refresh JCR session: ", e.getMessage());
// }
// }
// return session;
// }
//
// /**
// * @return ResourceResolver from factory
// */
// public ResourceResolver getResourceResolver(final ResourceResolverFactory resourceResolverFactory) {
// if (null == resourceResolverFactory || StringUtils.isBlank(getServiceMapperIdentity())) {
// return this.resourceResolver;
// }
// if (null == this.resourceResolver || !this.resourceResolver.isLive()) {
// try {
// this.resourceResolver = resourceResolverFactory.getServiceResourceResolver(Collections.unmodifiableMap(
// new HashMap<String,Object>() {
// private static final long serialVersionUID = 1L;
// { put(ResourceResolverFactory.SUBSERVICE, getServiceMapperIdentity() ); }
// }));
// } catch (LoginException e) {
// LOG.debug("Unable to retrieve resource resolver for {}:", getServiceMapperIdentity(), e.getMessage());
// }
// }
// return this.resourceResolver;
// }
//
// }
| import java.text.MessageFormat;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.References;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.day.cq.replication.AgentFilter;
import com.day.cq.replication.AgentIdFilter;
import com.day.cq.replication.AgentManager;
import com.day.cq.replication.ReplicationActionType;
import com.day.cq.replication.ReplicationException;
import com.day.cq.replication.ReplicationOptions;
import com.day.cq.replication.ReplicationStatus;
import com.day.cq.replication.Replicator;
import com.google.common.collect.Maps;
import com.steeleforge.aem.ironsites.wcm.ResourceResolverSubservice; | /**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.syndicate.service;
/**
* OSGi service used to replicate a content path based on a specific topic
* against dedicated agentIds. This allows APIs, for example, to syndicate
* content across publish instances if replication agents to adjacent
* publish instances are configured.
*
* @author David Steele
*/
@Service(value = TopicReplicationService.class)
@Component(label = "ironsites - Topic Replication Service",
description = "Replicate resource through given agentIds per topic",
immediate = true)
@References({
@Reference(cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
policy = ReferencePolicy.DYNAMIC,
referenceInterface = TopicReplicationConfiguration.class,
name = "TopicReplicationConfiguration",
bind = "bindConfigurations",
unbind = "unbindConfigurations")
}) | // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/ResourceResolverSubservice.java
// public abstract class ResourceResolverSubservice {
// private static final Logger LOG = LoggerFactory.getLogger(ResourceResolverSubservice.class);
//
// protected ResourceResolver resourceResolver;
//
// /**
// * @return UserServiceMapper identity
// */
// public abstract String getServiceMapperIdentity();
//
// /**
// * Closes resource resolver
// */
// public void closeResolver() {
// if (null != this.resourceResolver && this.resourceResolver.isLive()) {
// this.resourceResolver.close();
// }
// }
//
// /**
// * Acquires JCR administrative session from a resource resolver
// *
// * @return JCR Session
// * @throws RepositoryException
// */
// public Session getSession(final ResourceResolverFactory resourceResolverFactory) {
// Session session = getResourceResolver(resourceResolverFactory).adaptTo(Session.class);
// if (null != session) {
// try {
// session.refresh(true);
// } catch (RepositoryException e) {
// LOG.trace("Could not refresh JCR session: ", e.getMessage());
// }
// }
// return session;
// }
//
// /**
// * @return ResourceResolver from factory
// */
// public ResourceResolver getResourceResolver(final ResourceResolverFactory resourceResolverFactory) {
// if (null == resourceResolverFactory || StringUtils.isBlank(getServiceMapperIdentity())) {
// return this.resourceResolver;
// }
// if (null == this.resourceResolver || !this.resourceResolver.isLive()) {
// try {
// this.resourceResolver = resourceResolverFactory.getServiceResourceResolver(Collections.unmodifiableMap(
// new HashMap<String,Object>() {
// private static final long serialVersionUID = 1L;
// { put(ResourceResolverFactory.SUBSERVICE, getServiceMapperIdentity() ); }
// }));
// } catch (LoginException e) {
// LOG.debug("Unable to retrieve resource resolver for {}:", getServiceMapperIdentity(), e.getMessage());
// }
// }
// return this.resourceResolver;
// }
//
// }
// Path: syndicate/src/main/java/com/steeleforge/aem/ironsites/syndicate/service/TopicReplicationService.java
import java.text.MessageFormat;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.References;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.day.cq.replication.AgentFilter;
import com.day.cq.replication.AgentIdFilter;
import com.day.cq.replication.AgentManager;
import com.day.cq.replication.ReplicationActionType;
import com.day.cq.replication.ReplicationException;
import com.day.cq.replication.ReplicationOptions;
import com.day.cq.replication.ReplicationStatus;
import com.day.cq.replication.Replicator;
import com.google.common.collect.Maps;
import com.steeleforge.aem.ironsites.wcm.ResourceResolverSubservice;
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.syndicate.service;
/**
* OSGi service used to replicate a content path based on a specific topic
* against dedicated agentIds. This allows APIs, for example, to syndicate
* content across publish instances if replication agents to adjacent
* publish instances are configured.
*
* @author David Steele
*/
@Service(value = TopicReplicationService.class)
@Component(label = "ironsites - Topic Replication Service",
description = "Replicate resource through given agentIds per topic",
immediate = true)
@References({
@Reference(cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
policy = ReferencePolicy.DYNAMIC,
referenceInterface = TopicReplicationConfiguration.class,
name = "TopicReplicationConfiguration",
bind = "bindConfigurations",
unbind = "unbindConfigurations")
}) | public class TopicReplicationService extends ResourceResolverSubservice { |
steeleforge/ironsites | cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/impl/SimpleCacheServiceImpl.java | // Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheConfiguration.java
// public interface SimpleCacheConfiguration {
// /**
// * Cache name.
// *
// * @return cache name
// */
// public String getName();
//
// /**
// * Cache spec
// *
// * @return cache specfication String
// * @see <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheBuilderSpec.html">CacheBuilderSpec</a>
// */
// public String getSpecs();
//
// /**
// * Cache statistics tracking enabled/disabled
// *
// * @return cache stat toggle state
// */
// public Boolean isRecordStats();
// }
//
// Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheService.java
// public interface SimpleCacheService {
// /**
// * Known cache names/keys
// *
// * @return set of cache keys
// */
// public Set<String> getCaches();
//
// /**
// * Access OSGi configured or application managed cache for name & options.
// *
// * @param name cache key
// * @param spec {@link <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheBuilderSpec.html">CacheBuilderSpec</a>}
// * @param stats true if recording statistics is desired
// * @return pre-existing or new cache
// */
// public Cache<Object, Object> getCache(String name, String spec, boolean stats);
//
// /**
// * Access OSGi configured or application managed cache by name.
// *
// * @param name cache key
// * @return pre-existing or new cache
// */
// public Cache<Object, Object> getCache(String name);
//
// /**
// * Cache by name as Map.
// *
// * @param name cache key
// * @return pre-existing/new cache or null
// */
// public Map<Object, Object> getCacheMap(String name);
//
// /**
// * Access cache statistics by name.
// *
// * @param name cache key
// * @return cache statistics
// * @see <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheStats.html">CacheStats</a>
// */
// public CacheStats getStats(String name);
//
// /**
// * Invalidate and destroy cache by name.
// *
// * @param name
// */
// public void clearCache(String name);
// }
| import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.References;
import org.apache.felix.scr.annotations.Service;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheStats;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheConfiguration;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheService; | /**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.cache.service.impl;
/**
* Provides access to OSGi factory configured Cache instances.
*
* @author David Steele
*/
@Service
@Component(label = "ironsites - Simple Cache Service",
description = "Acquire configured cache instances from this service.",
immediate = true)
@References({
@Reference(cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
policy = ReferencePolicy.DYNAMIC, | // Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheConfiguration.java
// public interface SimpleCacheConfiguration {
// /**
// * Cache name.
// *
// * @return cache name
// */
// public String getName();
//
// /**
// * Cache spec
// *
// * @return cache specfication String
// * @see <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheBuilderSpec.html">CacheBuilderSpec</a>
// */
// public String getSpecs();
//
// /**
// * Cache statistics tracking enabled/disabled
// *
// * @return cache stat toggle state
// */
// public Boolean isRecordStats();
// }
//
// Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheService.java
// public interface SimpleCacheService {
// /**
// * Known cache names/keys
// *
// * @return set of cache keys
// */
// public Set<String> getCaches();
//
// /**
// * Access OSGi configured or application managed cache for name & options.
// *
// * @param name cache key
// * @param spec {@link <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheBuilderSpec.html">CacheBuilderSpec</a>}
// * @param stats true if recording statistics is desired
// * @return pre-existing or new cache
// */
// public Cache<Object, Object> getCache(String name, String spec, boolean stats);
//
// /**
// * Access OSGi configured or application managed cache by name.
// *
// * @param name cache key
// * @return pre-existing or new cache
// */
// public Cache<Object, Object> getCache(String name);
//
// /**
// * Cache by name as Map.
// *
// * @param name cache key
// * @return pre-existing/new cache or null
// */
// public Map<Object, Object> getCacheMap(String name);
//
// /**
// * Access cache statistics by name.
// *
// * @param name cache key
// * @return cache statistics
// * @see <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheStats.html">CacheStats</a>
// */
// public CacheStats getStats(String name);
//
// /**
// * Invalidate and destroy cache by name.
// *
// * @param name
// */
// public void clearCache(String name);
// }
// Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/impl/SimpleCacheServiceImpl.java
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.References;
import org.apache.felix.scr.annotations.Service;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheStats;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheConfiguration;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheService;
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.cache.service.impl;
/**
* Provides access to OSGi factory configured Cache instances.
*
* @author David Steele
*/
@Service
@Component(label = "ironsites - Simple Cache Service",
description = "Acquire configured cache instances from this service.",
immediate = true)
@References({
@Reference(cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
policy = ReferencePolicy.DYNAMIC, | referenceInterface = SimpleCacheConfiguration.class, |
steeleforge/ironsites | cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/impl/SimpleCacheServiceImpl.java | // Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheConfiguration.java
// public interface SimpleCacheConfiguration {
// /**
// * Cache name.
// *
// * @return cache name
// */
// public String getName();
//
// /**
// * Cache spec
// *
// * @return cache specfication String
// * @see <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheBuilderSpec.html">CacheBuilderSpec</a>
// */
// public String getSpecs();
//
// /**
// * Cache statistics tracking enabled/disabled
// *
// * @return cache stat toggle state
// */
// public Boolean isRecordStats();
// }
//
// Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheService.java
// public interface SimpleCacheService {
// /**
// * Known cache names/keys
// *
// * @return set of cache keys
// */
// public Set<String> getCaches();
//
// /**
// * Access OSGi configured or application managed cache for name & options.
// *
// * @param name cache key
// * @param spec {@link <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheBuilderSpec.html">CacheBuilderSpec</a>}
// * @param stats true if recording statistics is desired
// * @return pre-existing or new cache
// */
// public Cache<Object, Object> getCache(String name, String spec, boolean stats);
//
// /**
// * Access OSGi configured or application managed cache by name.
// *
// * @param name cache key
// * @return pre-existing or new cache
// */
// public Cache<Object, Object> getCache(String name);
//
// /**
// * Cache by name as Map.
// *
// * @param name cache key
// * @return pre-existing/new cache or null
// */
// public Map<Object, Object> getCacheMap(String name);
//
// /**
// * Access cache statistics by name.
// *
// * @param name cache key
// * @return cache statistics
// * @see <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheStats.html">CacheStats</a>
// */
// public CacheStats getStats(String name);
//
// /**
// * Invalidate and destroy cache by name.
// *
// * @param name
// */
// public void clearCache(String name);
// }
| import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.References;
import org.apache.felix.scr.annotations.Service;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheStats;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheConfiguration;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheService; | /**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.cache.service.impl;
/**
* Provides access to OSGi factory configured Cache instances.
*
* @author David Steele
*/
@Service
@Component(label = "ironsites - Simple Cache Service",
description = "Acquire configured cache instances from this service.",
immediate = true)
@References({
@Reference(cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
policy = ReferencePolicy.DYNAMIC,
referenceInterface = SimpleCacheConfiguration.class,
name = "SimpleCacheConfiguration",
bind = "bindConfigurations",
unbind = "unbindConfigurations")
}) | // Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheConfiguration.java
// public interface SimpleCacheConfiguration {
// /**
// * Cache name.
// *
// * @return cache name
// */
// public String getName();
//
// /**
// * Cache spec
// *
// * @return cache specfication String
// * @see <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheBuilderSpec.html">CacheBuilderSpec</a>
// */
// public String getSpecs();
//
// /**
// * Cache statistics tracking enabled/disabled
// *
// * @return cache stat toggle state
// */
// public Boolean isRecordStats();
// }
//
// Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/SimpleCacheService.java
// public interface SimpleCacheService {
// /**
// * Known cache names/keys
// *
// * @return set of cache keys
// */
// public Set<String> getCaches();
//
// /**
// * Access OSGi configured or application managed cache for name & options.
// *
// * @param name cache key
// * @param spec {@link <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheBuilderSpec.html">CacheBuilderSpec</a>}
// * @param stats true if recording statistics is desired
// * @return pre-existing or new cache
// */
// public Cache<Object, Object> getCache(String name, String spec, boolean stats);
//
// /**
// * Access OSGi configured or application managed cache by name.
// *
// * @param name cache key
// * @return pre-existing or new cache
// */
// public Cache<Object, Object> getCache(String name);
//
// /**
// * Cache by name as Map.
// *
// * @param name cache key
// * @return pre-existing/new cache or null
// */
// public Map<Object, Object> getCacheMap(String name);
//
// /**
// * Access cache statistics by name.
// *
// * @param name cache key
// * @return cache statistics
// * @see <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/CacheStats.html">CacheStats</a>
// */
// public CacheStats getStats(String name);
//
// /**
// * Invalidate and destroy cache by name.
// *
// * @param name
// */
// public void clearCache(String name);
// }
// Path: cache/src/main/java/com/steeleforge/aem/ironsites/cache/service/impl/SimpleCacheServiceImpl.java
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.References;
import org.apache.felix.scr.annotations.Service;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheStats;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheConfiguration;
import com.steeleforge.aem.ironsites.cache.service.SimpleCacheService;
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to <http://unlicense.org/>
*/
package com.steeleforge.aem.ironsites.cache.service.impl;
/**
* Provides access to OSGi factory configured Cache instances.
*
* @author David Steele
*/
@Service
@Component(label = "ironsites - Simple Cache Service",
description = "Acquire configured cache instances from this service.",
immediate = true)
@References({
@Reference(cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
policy = ReferencePolicy.DYNAMIC,
referenceInterface = SimpleCacheConfiguration.class,
name = "SimpleCacheConfiguration",
bind = "bindConfigurations",
unbind = "unbindConfigurations")
}) | public class SimpleCacheServiceImpl implements SimpleCacheService { |
steeleforge/ironsites | core/src/main/java/com/steeleforge/aem/ironsites/wcm/components/StyleUse.java | // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/WCMConstants.java
// public enum WCMConstants {
// INSTANCE;
// public static final String HTTP = "http";
// public static final String HTTPS = "https";
// public static final String PROTOCOL_RELATIVE = "//";
// public static final String DELIMITER_QUERY = "?";
// public static final String DELIMITER_FRAGMENT = "#";
// public static final String DELIMITER_PORT = ":";
// public static final String DELIMITER_PATH = "/";
// public static final String DELIMITER_PATH_IDENTIFIER = "--";
// public static final String DELIMITER_SUFFIX = DELIMITER_PATH;
// public static final String DELIMITER_EXTENSION = ".";
// public static final String DELIMITER_SELECTOR = DELIMITER_EXTENSION;
// public static final String DELIMITER_COMMA = ",";
// public static final String DELIMITER_COMMA_SPACED = ",";
// public static final String DELIMITER_MULTIFIELD = "|";
// public static final String PATH_FAVICON = "/favicon.ico";
// public static final String HTML = "html";
// public static final String HEADER_LOCATION = "Location";
// }
| import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import com.adobe.cq.sightly.WCMUse;
import com.day.cq.tagging.Tag;
import com.day.cq.tagging.TagManager;
import com.steeleforge.aem.ironsites.wcm.WCMConstants;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List; | List<Tag> tags = new ArrayList<Tag>();
Tag tag = null;
for(String id : tagIDs) {
tag = tm.resolve(id);
if (null != tag) tags.add(tag);
tag = null;
}
return tags;
}
/**
* @param tagIDs
* @return list of tag descriptions given array of IDs
*/
public List<String> getTagDescriptions(final String[] tagIDs) {
List<String> descriptions = new ArrayList<String>();
for(Tag tag : getTags(style)) {
if (StringUtils.isNotBlank(tag.getDescription())) {
descriptions.add(tag.getDescription());
}
}
return descriptions;
}
/**
* @return style string from style option or property
*/
public String getStyles() { | // Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/WCMConstants.java
// public enum WCMConstants {
// INSTANCE;
// public static final String HTTP = "http";
// public static final String HTTPS = "https";
// public static final String PROTOCOL_RELATIVE = "//";
// public static final String DELIMITER_QUERY = "?";
// public static final String DELIMITER_FRAGMENT = "#";
// public static final String DELIMITER_PORT = ":";
// public static final String DELIMITER_PATH = "/";
// public static final String DELIMITER_PATH_IDENTIFIER = "--";
// public static final String DELIMITER_SUFFIX = DELIMITER_PATH;
// public static final String DELIMITER_EXTENSION = ".";
// public static final String DELIMITER_SELECTOR = DELIMITER_EXTENSION;
// public static final String DELIMITER_COMMA = ",";
// public static final String DELIMITER_COMMA_SPACED = ",";
// public static final String DELIMITER_MULTIFIELD = "|";
// public static final String PATH_FAVICON = "/favicon.ico";
// public static final String HTML = "html";
// public static final String HEADER_LOCATION = "Location";
// }
// Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/components/StyleUse.java
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import com.adobe.cq.sightly.WCMUse;
import com.day.cq.tagging.Tag;
import com.day.cq.tagging.TagManager;
import com.steeleforge.aem.ironsites.wcm.WCMConstants;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
List<Tag> tags = new ArrayList<Tag>();
Tag tag = null;
for(String id : tagIDs) {
tag = tm.resolve(id);
if (null != tag) tags.add(tag);
tag = null;
}
return tags;
}
/**
* @param tagIDs
* @return list of tag descriptions given array of IDs
*/
public List<String> getTagDescriptions(final String[] tagIDs) {
List<String> descriptions = new ArrayList<String>();
for(Tag tag : getTags(style)) {
if (StringUtils.isNotBlank(tag.getDescription())) {
descriptions.add(tag.getDescription());
}
}
return descriptions;
}
/**
* @return style string from style option or property
*/
public String getStyles() { | return StringUtils.join(getTagDescriptions(style), WCMConstants.DELIMITER_COMMA_SPACED); |
jbuchbinder/rtp-text-t140 | src/se/omnitor/media/content/text/t140/TextPlayer.java | // Path: src/se/omnitor/media/protocol/text/t140/TextFormat.java
// public class TextFormat extends AudioFormat {
//
// /**
// *
// */
// private static final long serialVersionUID = -618493149322318146L;
//
// /**
// * The enocding string must be one of those defined in the
// * latest version of java.nio.charset.Charset
// *
// * @param encoding Sets the encoding of this format, normally "UTF8".
// */
// public TextFormat(String encoding) {
// super(encoding,
// AudioFormat.NOT_SPECIFIED,
// AudioFormat.NOT_SPECIFIED,
// AudioFormat.NOT_SPECIFIED,
// AudioFormat.NOT_SPECIFIED,
// AudioFormat.NOT_SPECIFIED,
// AudioFormat.NOT_SPECIFIED,
// AudioFormat.NOT_SPECIFIED,
// null);
//
// this.encoding=encoding;
// }
//
// /**
// * Gets the encoding of the text.
// *
// * @return A string deifining the encoding of the text.
// */
// public String getEncoding() {
// return encoding;
// }
//
// }
| import javax.media.Buffer;
import javax.media.Control;
import javax.media.Format;
import javax.media.Owned;
import javax.media.Renderer;
import javax.media.ResourceUnavailableException;
import javax.media.control.BufferControl;
import javax.media.protocol.ContentDescriptor;
import se.omnitor.util.FifoBuffer;
import se.omnitor.media.protocol.text.t140.TextFormat; | /*
* RTP text/t140 Library
*
* Copyright (C) 2004-2008 Board of Regents of the University of Wisconsin System
* (Univ. of Wisconsin-Madison, Trace R&D Center)
* Copyright (C) 2004-2008 Omnitor AB
*
* This software was developed with support from the National Institute on
* Disability and Rehabilitation Research, US Dept of Education under Grant
* # H133E990006 and H133E040014
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Please send a copy of any improved versions of the library to:
* Gunnar Hellstrom, Omnitor AB, Renathvagen 2, SE 121 37 Johanneshov, SWEDEN
* Gregg Vanderheiden, Trace Center, U of Wisconsin, Madison, Wi 53706
*
*/
package se.omnitor.media.content.text.t140;
/**
* Receives text, and puts the text in a FifoBuffer.
*
* @author Erik Zetterström, Omnitor AB
* @author Andreas Piirimets, Omnitor AB
*/
public class TextPlayer implements Renderer, BufferControl, Owned {
/**
* The descriptive name of this renderer
*/
public static final String PLUGIN_NAME = "RTP-Text renderer";
| // Path: src/se/omnitor/media/protocol/text/t140/TextFormat.java
// public class TextFormat extends AudioFormat {
//
// /**
// *
// */
// private static final long serialVersionUID = -618493149322318146L;
//
// /**
// * The enocding string must be one of those defined in the
// * latest version of java.nio.charset.Charset
// *
// * @param encoding Sets the encoding of this format, normally "UTF8".
// */
// public TextFormat(String encoding) {
// super(encoding,
// AudioFormat.NOT_SPECIFIED,
// AudioFormat.NOT_SPECIFIED,
// AudioFormat.NOT_SPECIFIED,
// AudioFormat.NOT_SPECIFIED,
// AudioFormat.NOT_SPECIFIED,
// AudioFormat.NOT_SPECIFIED,
// AudioFormat.NOT_SPECIFIED,
// null);
//
// this.encoding=encoding;
// }
//
// /**
// * Gets the encoding of the text.
// *
// * @return A string deifining the encoding of the text.
// */
// public String getEncoding() {
// return encoding;
// }
//
// }
// Path: src/se/omnitor/media/content/text/t140/TextPlayer.java
import javax.media.Buffer;
import javax.media.Control;
import javax.media.Format;
import javax.media.Owned;
import javax.media.Renderer;
import javax.media.ResourceUnavailableException;
import javax.media.control.BufferControl;
import javax.media.protocol.ContentDescriptor;
import se.omnitor.util.FifoBuffer;
import se.omnitor.media.protocol.text.t140.TextFormat;
/*
* RTP text/t140 Library
*
* Copyright (C) 2004-2008 Board of Regents of the University of Wisconsin System
* (Univ. of Wisconsin-Madison, Trace R&D Center)
* Copyright (C) 2004-2008 Omnitor AB
*
* This software was developed with support from the National Institute on
* Disability and Rehabilitation Research, US Dept of Education under Grant
* # H133E990006 and H133E040014
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Please send a copy of any improved versions of the library to:
* Gunnar Hellstrom, Omnitor AB, Renathvagen 2, SE 121 37 Johanneshov, SWEDEN
* Gregg Vanderheiden, Trace Center, U of Wisconsin, Madison, Wi 53706
*
*/
package se.omnitor.media.content.text.t140;
/**
* Receives text, and puts the text in a FifoBuffer.
*
* @author Erik Zetterström, Omnitor AB
* @author Andreas Piirimets, Omnitor AB
*/
public class TextPlayer implements Renderer, BufferControl, Owned {
/**
* The descriptive name of this renderer
*/
public static final String PLUGIN_NAME = "RTP-Text renderer";
| private TextFormat[] supportedInputFormats; |
jbuchbinder/rtp-text-t140 | src/se/omnitor/protocol/rtp/RTPThreadHandler.java | // Path: src/se/omnitor/protocol/rtp/packets/RTPPacket.java
// public class RTPPacket {
//
// private long csrcCount;
// private long sequenceNumber;
// private long timeStamp;
// private long ssrc;
// private byte[] data;
// private byte markerByte;
//
// /**
// * Gets the CSRC count. <br>
// * <br>
// * The CSRC count contains the number of CSRC identifiers that
// * follow the fixed header.
// *
// * @return The CSRC count
// */
// public long getCsrcCount() {
// return csrcCount;
// }
//
// /**
// * Sets the CSRC count.
// *
// * @param csrcCount The CSRC count to set
// */
// public void setCsrcCount(long csrcCount) {
// this.csrcCount = csrcCount;
// }
//
// /**
// * Gets the sequence number. <br>
// * <br>
// * The sequence number increments by one for each RTP data packet
// * sent, and may be used by the receiver to detect packet loss and
// * to restore packet sequence. The initial value of the sequence
// * number is random (unpredictable) to make known-plaintext attacks
// * on encryption more difficult, even if the source itself does not
// * encrypt, because the packets may flow through a translator that
// * does.
// *
// * @return The sequence number
// */
// public long getSequenceNumber() {
// return sequenceNumber;
// }
//
// /**
// * Sets the sequence number
// *
// * @param seqNo The sequencenumber
// */
// public void setSequenceNumber(long seqNo) {
// this.sequenceNumber = seqNo;
// }
//
// /**
// * Gets the time stamp. <br>
// * <br>
// * The timestamp reflects the sampling instant of the first octet
// * in the RTP data packet.
// *
// * @return The time stamp
// */
// public long getTimeStamp() {
// return timeStamp;
// }
//
// /**
// * Sets the time stamp
// *
// * @param timeStamp The time stamp to set
// */
// public void setTimeStamp(long timeStamp) {
// this.timeStamp = timeStamp;
// }
//
// /**
// * Gets the SSRC. <br>
// * <br>
// * The SSRC field identifies the synchronization source. This
// * identifier is chosen randomly, with the intent that no two
// * synchronization sources within the same RTP session will have
// * the same SSRC identifier.
// *
// * @return The SSRC field
// */
// public long getSsrc() {
// return ssrc;
// }
//
// /**
// * Sets the SSRC.
// *
// * @param ssrc The SSRC to set
// */
// public void setSsrc(long ssrc) {
// this.ssrc = ssrc;
// }
//
// /**
// * Gets the payload, that is the actual payload contained in an RTP Packet.
// *
// * @return The payload data
// */
// public byte[] getPayloadData() {
// return data;
// }
//
// /**
// * Sets the payload data
// *
// * @param payloadData The payload data to set
// */
// public void setPayloadData(byte[] payloadData) {
// this.data = payloadData;
// }
//
// /**
// * Sets the marker bit for this packet.
// *
// * @param marker true = marker bit set
// */
// public void setMarker(boolean marker) {
// if(marker) {
// markerByte=0x1;
// return;
// }
// markerByte=0;
// }
//
// /**
// * Gets the marker bit for this packet.
// *
// * @return 1 if marker is set, 0 otherwise.
// */
// public byte getMarker() {
// return markerByte;
// }
//
// }
| import se.omnitor.protocol.rtp.packets.RTPPacket;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.SocketException;
import java.util.Random;
import java.io.IOException; | */
public boolean isTransmitSocketOpened() {
if (m_sockSend != null) {
if (m_sockSend.isClosed()) {
return false;
} else {
return true;
}
} else {
return false;
}
}
/**
* Starts the thread
*
*/
public void start() {
thisThread.start();
}
/**
* Constructs a datagram, assembles it into an RTP packet and sends it out.
*
* @param packet RTP packet to be sent out
*
* @return 0 if an error occured, 1 if everything is ok.
*/
// IP: Altered method and input parameter | // Path: src/se/omnitor/protocol/rtp/packets/RTPPacket.java
// public class RTPPacket {
//
// private long csrcCount;
// private long sequenceNumber;
// private long timeStamp;
// private long ssrc;
// private byte[] data;
// private byte markerByte;
//
// /**
// * Gets the CSRC count. <br>
// * <br>
// * The CSRC count contains the number of CSRC identifiers that
// * follow the fixed header.
// *
// * @return The CSRC count
// */
// public long getCsrcCount() {
// return csrcCount;
// }
//
// /**
// * Sets the CSRC count.
// *
// * @param csrcCount The CSRC count to set
// */
// public void setCsrcCount(long csrcCount) {
// this.csrcCount = csrcCount;
// }
//
// /**
// * Gets the sequence number. <br>
// * <br>
// * The sequence number increments by one for each RTP data packet
// * sent, and may be used by the receiver to detect packet loss and
// * to restore packet sequence. The initial value of the sequence
// * number is random (unpredictable) to make known-plaintext attacks
// * on encryption more difficult, even if the source itself does not
// * encrypt, because the packets may flow through a translator that
// * does.
// *
// * @return The sequence number
// */
// public long getSequenceNumber() {
// return sequenceNumber;
// }
//
// /**
// * Sets the sequence number
// *
// * @param seqNo The sequencenumber
// */
// public void setSequenceNumber(long seqNo) {
// this.sequenceNumber = seqNo;
// }
//
// /**
// * Gets the time stamp. <br>
// * <br>
// * The timestamp reflects the sampling instant of the first octet
// * in the RTP data packet.
// *
// * @return The time stamp
// */
// public long getTimeStamp() {
// return timeStamp;
// }
//
// /**
// * Sets the time stamp
// *
// * @param timeStamp The time stamp to set
// */
// public void setTimeStamp(long timeStamp) {
// this.timeStamp = timeStamp;
// }
//
// /**
// * Gets the SSRC. <br>
// * <br>
// * The SSRC field identifies the synchronization source. This
// * identifier is chosen randomly, with the intent that no two
// * synchronization sources within the same RTP session will have
// * the same SSRC identifier.
// *
// * @return The SSRC field
// */
// public long getSsrc() {
// return ssrc;
// }
//
// /**
// * Sets the SSRC.
// *
// * @param ssrc The SSRC to set
// */
// public void setSsrc(long ssrc) {
// this.ssrc = ssrc;
// }
//
// /**
// * Gets the payload, that is the actual payload contained in an RTP Packet.
// *
// * @return The payload data
// */
// public byte[] getPayloadData() {
// return data;
// }
//
// /**
// * Sets the payload data
// *
// * @param payloadData The payload data to set
// */
// public void setPayloadData(byte[] payloadData) {
// this.data = payloadData;
// }
//
// /**
// * Sets the marker bit for this packet.
// *
// * @param marker true = marker bit set
// */
// public void setMarker(boolean marker) {
// if(marker) {
// markerByte=0x1;
// return;
// }
// markerByte=0;
// }
//
// /**
// * Gets the marker bit for this packet.
// *
// * @return 1 if marker is set, 0 otherwise.
// */
// public byte getMarker() {
// return markerByte;
// }
//
// }
// Path: src/se/omnitor/protocol/rtp/RTPThreadHandler.java
import se.omnitor.protocol.rtp.packets.RTPPacket;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.SocketException;
import java.util.Random;
import java.io.IOException;
*/
public boolean isTransmitSocketOpened() {
if (m_sockSend != null) {
if (m_sockSend.isClosed()) {
return false;
} else {
return true;
}
} else {
return false;
}
}
/**
* Starts the thread
*
*/
public void start() {
thisThread.start();
}
/**
* Constructs a datagram, assembles it into an RTP packet and sends it out.
*
* @param packet RTP packet to be sent out
*
* @return 0 if an error occured, 1 if everything is ok.
*/
// IP: Altered method and input parameter | public int sendPacket(RTPPacket packet) { |
slyak/spring-data-jpa-extra | src/main/java/com/slyak/spring/jpa/FreemarkerTemplateQuery.java | // Path: src/main/java/com/slyak/util/AopTargetUtils.java
// public class AopTargetUtils {
//
// /**
// * 获取 目标对象
// *
// * @param proxy 代理对象
// * @return 目标对象
// */
// @SuppressWarnings("unchecked")
// public static <T> T getTarget(Object proxy) {
// if (Proxy.isProxyClass(proxy.getClass())) {
// return getJdkDynamicProxyTargetObject(proxy);
// }
// else if (ClassUtils.isCglibProxy(proxy)) {
// return getCglibProxyTargetObject(proxy);
// }
// else {
// return (T) proxy;
// }
// }
//
// @SuppressWarnings("unchecked")
// private static <T> T getCglibProxyTargetObject(Object proxy) {
// try {
// Field h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0");
// h.setAccessible(true);
// Object dynamicAdvisedInterceptor = h.get(proxy);
// Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised");
// advised.setAccessible(true);
// return (T) (((AdvisedSupport) advised.get(dynamicAdvisedInterceptor)).getTargetSource().getTarget());
// }
// catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// @SuppressWarnings("unchecked")
// private static <T> T getJdkDynamicProxyTargetObject(Object proxy) {
// try {
// Field h = proxy.getClass().getSuperclass().getDeclaredField("h");
// h.setAccessible(true);
// Object proxy_ = h.get(proxy);
// Field f = proxy_.getClass().getDeclaredField("target");
// f.setAccessible(true);
// return (T) f.get(proxy_);
// }
// catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
// }
| import com.slyak.util.AopTargetUtils;
import org.hibernate.query.NativeQuery;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.query.AbstractJpaQuery;
import org.springframework.data.jpa.repository.query.JpaParameters;
import org.springframework.data.jpa.repository.query.JpaQueryMethod;
import org.springframework.data.jpa.repository.query.QueryUtils;
import org.springframework.data.repository.query.Parameter;
import org.springframework.data.repository.query.ParameterAccessor;
import org.springframework.data.repository.query.ParametersParameterAccessor;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.util.CollectionUtils;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map; | Parameter parameter = parameters.getParameter(i);
if (value != null && canBindParameter(parameter)) {
if (!QueryBuilder.isValidValue(value)) {
continue;
}
Class<?> clz = value.getClass();
if (clz.isPrimitive() || String.class.isAssignableFrom(clz) || Number.class.isAssignableFrom(clz)
|| clz.isArray() || Collection.class.isAssignableFrom(clz) || clz.isEnum()) {
params.put(parameter.getName().orElse(null), value);
} else {
params = QueryBuilder.toParams(value);
}
}
}
return params;
}
private Query createJpaQuery(String queryString) {
Class<?> objectType = getQueryMethod().getReturnedObjectType();
//get original proxy query.
Query oriProxyQuery;
//must be hibernate QueryImpl
NativeQuery query;
if (useJpaSpec && getQueryMethod().isQueryForEntity()) {
oriProxyQuery = getEntityManager().createNativeQuery(queryString, objectType);
} else {
oriProxyQuery = getEntityManager().createNativeQuery(queryString); | // Path: src/main/java/com/slyak/util/AopTargetUtils.java
// public class AopTargetUtils {
//
// /**
// * 获取 目标对象
// *
// * @param proxy 代理对象
// * @return 目标对象
// */
// @SuppressWarnings("unchecked")
// public static <T> T getTarget(Object proxy) {
// if (Proxy.isProxyClass(proxy.getClass())) {
// return getJdkDynamicProxyTargetObject(proxy);
// }
// else if (ClassUtils.isCglibProxy(proxy)) {
// return getCglibProxyTargetObject(proxy);
// }
// else {
// return (T) proxy;
// }
// }
//
// @SuppressWarnings("unchecked")
// private static <T> T getCglibProxyTargetObject(Object proxy) {
// try {
// Field h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0");
// h.setAccessible(true);
// Object dynamicAdvisedInterceptor = h.get(proxy);
// Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised");
// advised.setAccessible(true);
// return (T) (((AdvisedSupport) advised.get(dynamicAdvisedInterceptor)).getTargetSource().getTarget());
// }
// catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// @SuppressWarnings("unchecked")
// private static <T> T getJdkDynamicProxyTargetObject(Object proxy) {
// try {
// Field h = proxy.getClass().getSuperclass().getDeclaredField("h");
// h.setAccessible(true);
// Object proxy_ = h.get(proxy);
// Field f = proxy_.getClass().getDeclaredField("target");
// f.setAccessible(true);
// return (T) f.get(proxy_);
// }
// catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
// }
// Path: src/main/java/com/slyak/spring/jpa/FreemarkerTemplateQuery.java
import com.slyak.util.AopTargetUtils;
import org.hibernate.query.NativeQuery;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.query.AbstractJpaQuery;
import org.springframework.data.jpa.repository.query.JpaParameters;
import org.springframework.data.jpa.repository.query.JpaQueryMethod;
import org.springframework.data.jpa.repository.query.QueryUtils;
import org.springframework.data.repository.query.Parameter;
import org.springframework.data.repository.query.ParameterAccessor;
import org.springframework.data.repository.query.ParametersParameterAccessor;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.util.CollectionUtils;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
Parameter parameter = parameters.getParameter(i);
if (value != null && canBindParameter(parameter)) {
if (!QueryBuilder.isValidValue(value)) {
continue;
}
Class<?> clz = value.getClass();
if (clz.isPrimitive() || String.class.isAssignableFrom(clz) || Number.class.isAssignableFrom(clz)
|| clz.isArray() || Collection.class.isAssignableFrom(clz) || clz.isEnum()) {
params.put(parameter.getName().orElse(null), value);
} else {
params = QueryBuilder.toParams(value);
}
}
}
return params;
}
private Query createJpaQuery(String queryString) {
Class<?> objectType = getQueryMethod().getReturnedObjectType();
//get original proxy query.
Query oriProxyQuery;
//must be hibernate QueryImpl
NativeQuery query;
if (useJpaSpec && getQueryMethod().isQueryForEntity()) {
oriProxyQuery = getEntityManager().createNativeQuery(queryString, objectType);
} else {
oriProxyQuery = getEntityManager().createNativeQuery(queryString); | query = AopTargetUtils.getTarget(oriProxyQuery); |
slyak/spring-data-jpa-extra | src/main/java/com/slyak/spring/jpa/auditing/BaseEntity.java | // Path: src/main/java/com/slyak/spring/jpa/util/SnowflakeGenerator.java
// public class SnowflakeGenerator implements IdentifierGenerator {
// public static final String TYPE = "com.slyak.spring.jpa.util.SnowflakeGenerator";
//
// private static final IdWorker idWorker = new IdWorker();
//
// @Override
// public Serializable generate(SharedSessionContractImplementor sharedSessionContractImplementor, Object o) throws HibernateException {
// return idWorker.getId();
// }
// }
| import com.slyak.spring.jpa.util.SnowflakeGenerator;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.domain.Persistable;
import org.springframework.data.jpa.domain.AbstractPersistable;
import org.springframework.util.ClassUtils;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.io.Serializable; | package com.slyak.spring.jpa.auditing;
/**
* .
*
* @author stormning on 16/6/13.
*/
@MappedSuperclass
public abstract class BaseEntity<PK extends Serializable> implements Persistable<PK> {
@Id | // Path: src/main/java/com/slyak/spring/jpa/util/SnowflakeGenerator.java
// public class SnowflakeGenerator implements IdentifierGenerator {
// public static final String TYPE = "com.slyak.spring.jpa.util.SnowflakeGenerator";
//
// private static final IdWorker idWorker = new IdWorker();
//
// @Override
// public Serializable generate(SharedSessionContractImplementor sharedSessionContractImplementor, Object o) throws HibernateException {
// return idWorker.getId();
// }
// }
// Path: src/main/java/com/slyak/spring/jpa/auditing/BaseEntity.java
import com.slyak.spring.jpa.util.SnowflakeGenerator;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.domain.Persistable;
import org.springframework.data.jpa.domain.AbstractPersistable;
import org.springframework.util.ClassUtils;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.io.Serializable;
package com.slyak.spring.jpa.auditing;
/**
* .
*
* @author stormning on 16/6/13.
*/
@MappedSuperclass
public abstract class BaseEntity<PK extends Serializable> implements Persistable<PK> {
@Id | @GenericGenerator(name="snowflake",strategy = SnowflakeGenerator.TYPE) |
jagrosh/Selfbot | src/jselfbot/JSelfBot.java | // Path: src/jselfbot/entities/Config.java
// public class Config {
// private final Logger LOG = LoggerFactory.getLogger("Config");
// private String userToken;
// private String prefix;
// private ZoneId zone = null;
// private OnlineStatus status;
// private boolean bot = false;
//
// public Config() throws Exception
// {
// List<String> lines = Files.readAllLines(Paths.get("config.txt"));
// for(String str : lines)
// {
// String[] parts = str.split("=",2);
// String key = parts[0].trim().toLowerCase();
// String value = parts.length>1 ? parts[1].trim() : null;
// switch(key)
// {
// case "token":
// userToken = value;
// break;
// case "prefix":
// if(value==null)
// {
// prefix = "";
// LOG.warn("The prefix was defined as empty!");
// }
// else
// prefix = value;
// break;
// case "timezone":
// if(value==null)
// {
// zone = ZoneId.systemDefault();
// LOG.warn("An empty timezone was provided; using the system default!");
// }
// else
// {
// try {
// zone = ZoneId.of(value);
// } catch(Exception e) {
// zone = ZoneId.systemDefault();
// LOG.warn("\""+value+"\" is not a valid timezone; using the system default!");
// }
// }
// break;
// case "status":
// status = OnlineStatus.fromKey(value);
// if(status == OnlineStatus.UNKNOWN)
// {
// status = OnlineStatus.IDLE;
// LOG.warn("\""+value+"\" is not a valid status; using the default IDLE! Valid statuses are ONLINE, IDLE, DND, and INVISIBLE.");
// }
// break;
// case "bot":
// bot = "true".equalsIgnoreCase(value);
// }
// }
// if(userToken==null)
// throw new Exception("No token provided int he config file!");
// if(prefix==null)
// throw new Exception("No prefix provided in the config file!");
// if(zone==null)
// {
// zone = ZoneId.systemDefault();
// LOG.warn("No timezone provided; using the system default!");
// }
// if(status==null)
// {
// status = OnlineStatus.IDLE;
// LOG.warn("No status provided; using IDLE!");
// }
// }
//
// public String getToken()
// {
// return userToken;
// }
//
// public String getprefix()
// {
// return prefix;
// }
//
// public ZoneId getZoneId()
// {
// return zone;
// }
//
// public OnlineStatus getStatus()
// {
// return status;
// }
//
// public boolean isForBot()
// {
// return bot;
// }
// }
| import javax.security.auth.login.LoginException;
import jselfbot.entities.Config;
import net.dv8tion.jda.core.AccountType;
import net.dv8tion.jda.core.JDABuilder;
import net.dv8tion.jda.core.exceptions.RateLimitedException;
import org.slf4j.LoggerFactory; | /*
* Copyright 2016 John Grosh (jagrosh).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jselfbot;
/**
*
* @author John Grosh (jagrosh)
*/
public class JSelfBot {
/**
* @param args the command line arguments
*/
public static void main(String[] args){ | // Path: src/jselfbot/entities/Config.java
// public class Config {
// private final Logger LOG = LoggerFactory.getLogger("Config");
// private String userToken;
// private String prefix;
// private ZoneId zone = null;
// private OnlineStatus status;
// private boolean bot = false;
//
// public Config() throws Exception
// {
// List<String> lines = Files.readAllLines(Paths.get("config.txt"));
// for(String str : lines)
// {
// String[] parts = str.split("=",2);
// String key = parts[0].trim().toLowerCase();
// String value = parts.length>1 ? parts[1].trim() : null;
// switch(key)
// {
// case "token":
// userToken = value;
// break;
// case "prefix":
// if(value==null)
// {
// prefix = "";
// LOG.warn("The prefix was defined as empty!");
// }
// else
// prefix = value;
// break;
// case "timezone":
// if(value==null)
// {
// zone = ZoneId.systemDefault();
// LOG.warn("An empty timezone was provided; using the system default!");
// }
// else
// {
// try {
// zone = ZoneId.of(value);
// } catch(Exception e) {
// zone = ZoneId.systemDefault();
// LOG.warn("\""+value+"\" is not a valid timezone; using the system default!");
// }
// }
// break;
// case "status":
// status = OnlineStatus.fromKey(value);
// if(status == OnlineStatus.UNKNOWN)
// {
// status = OnlineStatus.IDLE;
// LOG.warn("\""+value+"\" is not a valid status; using the default IDLE! Valid statuses are ONLINE, IDLE, DND, and INVISIBLE.");
// }
// break;
// case "bot":
// bot = "true".equalsIgnoreCase(value);
// }
// }
// if(userToken==null)
// throw new Exception("No token provided int he config file!");
// if(prefix==null)
// throw new Exception("No prefix provided in the config file!");
// if(zone==null)
// {
// zone = ZoneId.systemDefault();
// LOG.warn("No timezone provided; using the system default!");
// }
// if(status==null)
// {
// status = OnlineStatus.IDLE;
// LOG.warn("No status provided; using IDLE!");
// }
// }
//
// public String getToken()
// {
// return userToken;
// }
//
// public String getprefix()
// {
// return prefix;
// }
//
// public ZoneId getZoneId()
// {
// return zone;
// }
//
// public OnlineStatus getStatus()
// {
// return status;
// }
//
// public boolean isForBot()
// {
// return bot;
// }
// }
// Path: src/jselfbot/JSelfBot.java
import javax.security.auth.login.LoginException;
import jselfbot.entities.Config;
import net.dv8tion.jda.core.AccountType;
import net.dv8tion.jda.core.JDABuilder;
import net.dv8tion.jda.core.exceptions.RateLimitedException;
import org.slf4j.LoggerFactory;
/*
* Copyright 2016 John Grosh (jagrosh).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jselfbot;
/**
*
* @author John Grosh (jagrosh)
*/
public class JSelfBot {
/**
* @param args the command line arguments
*/
public static void main(String[] args){ | Config config; |
jagrosh/Selfbot | src/jselfbot/entities/Todolist.java | // Path: src/jselfbot/utils/FormatUtil.java
// public class FormatUtil
// {
//
// public static String join(List<String> strings, String joiner)
// {
// if(strings.isEmpty())
// return "";
// StringBuilder sb = new StringBuilder(strings.get(0));
// for(int i=1; i<strings.size(); i++)
// sb.append(joiner).append(strings.get(i));
// return sb.toString();
// }
// }
| import org.slf4j.LoggerFactory;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import jselfbot.utils.FormatUtil;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger; | /*
* Copyright 2016 John Grosh (jagrosh).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jselfbot.entities;
/**
*
* @author John Grosh (jagrosh)
*/
public class Todolist {
private final List<TodoItem> todolist;
private final static String FILENAME = "todo.json";
private final static Logger LOG = LoggerFactory.getLogger("Todo");
public Todolist()
{
todolist = new ArrayList<>();
JSONArray array;
try { | // Path: src/jselfbot/utils/FormatUtil.java
// public class FormatUtil
// {
//
// public static String join(List<String> strings, String joiner)
// {
// if(strings.isEmpty())
// return "";
// StringBuilder sb = new StringBuilder(strings.get(0));
// for(int i=1; i<strings.size(); i++)
// sb.append(joiner).append(strings.get(i));
// return sb.toString();
// }
// }
// Path: src/jselfbot/entities/Todolist.java
import org.slf4j.LoggerFactory;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import jselfbot.utils.FormatUtil;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
/*
* Copyright 2016 John Grosh (jagrosh).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jselfbot.entities;
/**
*
* @author John Grosh (jagrosh)
*/
public class Todolist {
private final List<TodoItem> todolist;
private final static String FILENAME = "todo.json";
private final static Logger LOG = LoggerFactory.getLogger("Todo");
public Todolist()
{
todolist = new ArrayList<>();
JSONArray array;
try { | array = new JSONArray(FormatUtil.join(Files.readAllLines(Paths.get(FILENAME)), "\n")); |
jagrosh/Selfbot | src/jselfbot/entities/Emojis.java | // Path: src/jselfbot/utils/FormatUtil.java
// public class FormatUtil
// {
//
// public static String join(List<String> strings, String joiner)
// {
// if(strings.isEmpty())
// return "";
// StringBuilder sb = new StringBuilder(strings.get(0));
// for(int i=1; i<strings.size(); i++)
// sb.append(joiner).append(strings.get(i));
// return sb.toString();
// }
// }
| import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.HashMap;
import jselfbot.utils.FormatUtil;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | /*
* Copyright 2016 John Grosh (jagrosh).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jselfbot.entities;
/**
*
* @author John Grosh (jagrosh)
*/
public class Emojis {
private final HashMap<String, String> emojis;
private final static String FILENAME = "emojis.json";
private final static Logger LOG = LoggerFactory.getLogger("Emojis");
public Emojis()
{
emojis = new HashMap<>();
JSONObject obj;
try { | // Path: src/jselfbot/utils/FormatUtil.java
// public class FormatUtil
// {
//
// public static String join(List<String> strings, String joiner)
// {
// if(strings.isEmpty())
// return "";
// StringBuilder sb = new StringBuilder(strings.get(0));
// for(int i=1; i<strings.size(); i++)
// sb.append(joiner).append(strings.get(i));
// return sb.toString();
// }
// }
// Path: src/jselfbot/entities/Emojis.java
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.HashMap;
import jselfbot.utils.FormatUtil;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* Copyright 2016 John Grosh (jagrosh).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jselfbot.entities;
/**
*
* @author John Grosh (jagrosh)
*/
public class Emojis {
private final HashMap<String, String> emojis;
private final static String FILENAME = "emojis.json";
private final static Logger LOG = LoggerFactory.getLogger("Emojis");
public Emojis()
{
emojis = new HashMap<>();
JSONObject obj;
try { | obj = new JSONObject(FormatUtil.join(Files.readAllLines(Paths.get(FILENAME)), "\n")); |
mixxit/npcx | src/net/gamerservices/npcx/mySpawngroup.java | // Path: src/net/gamerservices/npclibfork/NpcSpawner.java
// public class NpcSpawner {
//
// protected static WorldServer GetWorldServer(World world) {
// try {
// CraftWorld w = (CraftWorld) world;
// Field f;
// f = CraftWorld.class.getDeclaredField("world");
//
// f.setAccessible(true);
// return (WorldServer) f.get(w);
//
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// return null;
// }
//
// private static MinecraftServer GetMinecraftServer(Server server) {
//
// if (server instanceof CraftServer) {
// CraftServer cs = (CraftServer) server;
// Field f;
// try {
// f = CraftServer.class.getDeclaredField("console");
// } catch (NoSuchFieldException ex) {
// return null;
// } catch (SecurityException ex) {
// return null;
// }
// MinecraftServer ms;
// try {
// f.setAccessible(true);
// ms = (MinecraftServer) f.get(cs);
// } catch (IllegalArgumentException ex) {
// return null;
// } catch (IllegalAccessException ex) {
// return null;
// }
// return ms;
// }
// return null;
// }
//
// public static BasicHumanNpc SpawnBasicHumanNpc(myNPC parent, String uniqueId, String name, World world, double x, double y, double z, double yaw, double pitch) {
// try {
// WorldServer ws = GetWorldServer(world);
// MinecraftServer ms = GetMinecraftServer(ws.getServer());
//
// CHumanNpc eh = new CHumanNpc(ms, ws, name, new ItemInWorldManager(ws));
// eh.forceSetName(name);
// Float yaw2 = new Float(yaw);
// Float pitch2 = new Float(pitch);
//
// eh.setLocation(x, y, z, yaw2.floatValue(), pitch2.floatValue());
//
// int m = MathHelper.floor(eh.locX / 16.0D);
// int n = MathHelper.floor(eh.locZ / 16.0D);
//
// ws.getChunkAt(m, n).a(eh);
// ws.entityList.add(eh);
//
// // ws.b(eh);
// Class params[] = new Class[1];
// params[0] = Entity.class;
//
// Method method;
// method = net.minecraft.server.World.class.getDeclaredMethod("c", params);
// method.setAccessible(true);
// Object margs[] = new Object[1];
// margs[0] = eh;
// method.invoke(ws, margs);
//
// return new BasicHumanNpc(parent, eh, uniqueId, name, x, y, z, yaw2, pitch2);
//
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// return null;
// }
//
// public static void RemoveBasicHumanNpc(BasicHumanNpc npc) {
// try {
// npc.getMCEntity().world.removeEntity(npc.getMCEntity());
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// }
//
// public static LivingEntity SpawnMob(CreatureType type, World world, double x, double y, double z) {
// return world.spawnCreature(new org.bukkit.Location(world, x, y, z), type);
// }
//
// }
| import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import net.gamerservices.npclibfork.NpcSpawner;
import org.bukkit.World;
| package net.gamerservices.npcx;
public class mySpawngroup {
public int id;
public String name;
public String category;
public double x;
public double y;
public double z;
public npcx parent;
public boolean active = false;
public World world;
public HashMap<String, myNPC> npcs = new HashMap<String, myNPC>();
public int activecountdown = 0;
public float pitch;
public float yaw;
public myPathgroup pathgroup;
public boolean chunkactive = true;
public mySpawngroup(npcx parent) {
this.parent = parent;
}
public boolean DBDelete() {
// Go through my children
try {
for (myNPC npc : npcs.values()) {
// Deleting npc
sqlDeleteEntry(Integer.parseInt(npc.id));
// Remove npcs from world
if (npc.npc != null) {
| // Path: src/net/gamerservices/npclibfork/NpcSpawner.java
// public class NpcSpawner {
//
// protected static WorldServer GetWorldServer(World world) {
// try {
// CraftWorld w = (CraftWorld) world;
// Field f;
// f = CraftWorld.class.getDeclaredField("world");
//
// f.setAccessible(true);
// return (WorldServer) f.get(w);
//
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// return null;
// }
//
// private static MinecraftServer GetMinecraftServer(Server server) {
//
// if (server instanceof CraftServer) {
// CraftServer cs = (CraftServer) server;
// Field f;
// try {
// f = CraftServer.class.getDeclaredField("console");
// } catch (NoSuchFieldException ex) {
// return null;
// } catch (SecurityException ex) {
// return null;
// }
// MinecraftServer ms;
// try {
// f.setAccessible(true);
// ms = (MinecraftServer) f.get(cs);
// } catch (IllegalArgumentException ex) {
// return null;
// } catch (IllegalAccessException ex) {
// return null;
// }
// return ms;
// }
// return null;
// }
//
// public static BasicHumanNpc SpawnBasicHumanNpc(myNPC parent, String uniqueId, String name, World world, double x, double y, double z, double yaw, double pitch) {
// try {
// WorldServer ws = GetWorldServer(world);
// MinecraftServer ms = GetMinecraftServer(ws.getServer());
//
// CHumanNpc eh = new CHumanNpc(ms, ws, name, new ItemInWorldManager(ws));
// eh.forceSetName(name);
// Float yaw2 = new Float(yaw);
// Float pitch2 = new Float(pitch);
//
// eh.setLocation(x, y, z, yaw2.floatValue(), pitch2.floatValue());
//
// int m = MathHelper.floor(eh.locX / 16.0D);
// int n = MathHelper.floor(eh.locZ / 16.0D);
//
// ws.getChunkAt(m, n).a(eh);
// ws.entityList.add(eh);
//
// // ws.b(eh);
// Class params[] = new Class[1];
// params[0] = Entity.class;
//
// Method method;
// method = net.minecraft.server.World.class.getDeclaredMethod("c", params);
// method.setAccessible(true);
// Object margs[] = new Object[1];
// margs[0] = eh;
// method.invoke(ws, margs);
//
// return new BasicHumanNpc(parent, eh, uniqueId, name, x, y, z, yaw2, pitch2);
//
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// return null;
// }
//
// public static void RemoveBasicHumanNpc(BasicHumanNpc npc) {
// try {
// npc.getMCEntity().world.removeEntity(npc.getMCEntity());
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// }
//
// public static LivingEntity SpawnMob(CreatureType type, World world, double x, double y, double z) {
// return world.spawnCreature(new org.bukkit.Location(world, x, y, z), type);
// }
//
// }
// Path: src/net/gamerservices/npcx/mySpawngroup.java
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import net.gamerservices.npclibfork.NpcSpawner;
import org.bukkit.World;
package net.gamerservices.npcx;
public class mySpawngroup {
public int id;
public String name;
public String category;
public double x;
public double y;
public double z;
public npcx parent;
public boolean active = false;
public World world;
public HashMap<String, myNPC> npcs = new HashMap<String, myNPC>();
public int activecountdown = 0;
public float pitch;
public float yaw;
public myPathgroup pathgroup;
public boolean chunkactive = true;
public mySpawngroup(npcx parent) {
this.parent = parent;
}
public boolean DBDelete() {
// Go through my children
try {
for (myNPC npc : npcs.values()) {
// Deleting npc
sqlDeleteEntry(Integer.parseInt(npc.id));
// Remove npcs from world
if (npc.npc != null) {
| NpcSpawner.RemoveBasicHumanNpc(npc.npc);
|
octopus-platform/octopus | src/main/java/octopus/server/restServer/handlers/CreateProjectHandler.java | // Path: src/main/java/octopus/api/projects/ProjectManager.java
// public class ProjectManager {
//
// public void create(String projectName)
// {
// try {
// OctopusProjectManager.create(projectName);
// } catch (IOException e) {
// throw new RuntimeException("Error creating project");
// }
// }
//
// public boolean doesProjectExist(String projectName)
// {
// return OctopusProjectManager.doesProjectExist(projectName);
// }
//
// public void delete(String projectName)
// {
// try {
// OctopusProjectManager.delete(projectName);
// } catch (IOException e) {
// throw new RuntimeException("Error deleting project");
// }
// }
//
// public Iterable<String> listProjects()
// {
// return OctopusProjectManager.listProjects();
// }
//
// public OctopusProject getProjectByName(String name)
// {
// return OctopusProjectManager.getProjectByName(name);
// }
//
// }
//
// Path: src/main/java/octopus/server/restServer/OctopusRestHandler.java
// public interface OctopusRestHandler {
//
// public Object handle(Request req, Response resp);
//
// }
| import octopus.api.projects.ProjectManager;
import octopus.server.restServer.OctopusRestHandler;
import spark.Request;
import spark.Response; | package octopus.server.restServer.handlers;
public class CreateProjectHandler implements OctopusRestHandler {
@Override
public Object handle(Request req, Response resp)
{
String projectName = req.params(":projectName"); | // Path: src/main/java/octopus/api/projects/ProjectManager.java
// public class ProjectManager {
//
// public void create(String projectName)
// {
// try {
// OctopusProjectManager.create(projectName);
// } catch (IOException e) {
// throw new RuntimeException("Error creating project");
// }
// }
//
// public boolean doesProjectExist(String projectName)
// {
// return OctopusProjectManager.doesProjectExist(projectName);
// }
//
// public void delete(String projectName)
// {
// try {
// OctopusProjectManager.delete(projectName);
// } catch (IOException e) {
// throw new RuntimeException("Error deleting project");
// }
// }
//
// public Iterable<String> listProjects()
// {
// return OctopusProjectManager.listProjects();
// }
//
// public OctopusProject getProjectByName(String name)
// {
// return OctopusProjectManager.getProjectByName(name);
// }
//
// }
//
// Path: src/main/java/octopus/server/restServer/OctopusRestHandler.java
// public interface OctopusRestHandler {
//
// public Object handle(Request req, Response resp);
//
// }
// Path: src/main/java/octopus/server/restServer/handlers/CreateProjectHandler.java
import octopus.api.projects.ProjectManager;
import octopus.server.restServer.OctopusRestHandler;
import spark.Request;
import spark.Response;
package octopus.server.restServer.handlers;
public class CreateProjectHandler implements OctopusRestHandler {
@Override
public Object handle(Request req, Response resp)
{
String projectName = req.params(":projectName"); | ProjectManager manager = new ProjectManager(); |
octopus-platform/octopus | src/main/java/octopus/plugins/csvimporter/CSVImporterPlugin.java | // Path: src/main/java/octopus/api/csvImporter/CSVImporter.java
// public class CSVImporter {
//
// public void importCSV(ImportJob job)
// {
// (new ImportCSVRunnable(job)).run();
// }
//
// }
//
// Path: src/main/java/octopus/api/plugin/types/OctopusProjectPlugin.java
// public abstract class OctopusProjectPlugin implements Plugin
// {
//
// private OctopusProjectConnector projectConnector;
//
// public OctopusProjectPlugin()
// {
// setProjectConnector(new OctopusProjectConnector());
// }
//
// @Override
// public void configure(JSONObject settings)
// {
// String projectName = settings.getString("projectName");
// getProjectConnector().connect(projectName);
// }
//
// protected void setProjectConnector(OctopusProjectConnector connector)
// {
// this.projectConnector = connector;
// }
//
// protected OctopusProjectConnector getProjectConnector()
// {
// return projectConnector;
// }
//
// protected String getProjectName()
// {
// return projectConnector.getWrapper().getName();
// }
//
// protected String getPathToProjectDir()
// {
// return projectConnector.getWrapper().getPathToProjectDir();
// }
//
// }
//
// Path: src/main/java/octopus/server/importer/csv/ImportJob.java
// public class ImportJob
// {
// private final String nodeFilename;
// private final String edgeFilename;
// private final String projectName;
//
// public ImportJob(String nodeFilename, String edgeFilename, String projectName)
// {
// this.nodeFilename = nodeFilename;
// this.edgeFilename = edgeFilename;
// this.projectName = projectName;
// }
//
// public String getNodeFilename()
// {
// return nodeFilename;
// }
//
// public String getEdgeFilename()
// {
// return edgeFilename;
// }
//
// public String getProjectName()
// {
// return projectName;
// }
//
// }
| import java.nio.file.Paths;
import octopus.api.csvImporter.CSVImporter;
import octopus.api.plugin.types.OctopusProjectPlugin;
import octopus.server.importer.csv.ImportJob; | package octopus.plugins.csvimporter;
public class CSVImporterPlugin extends OctopusProjectPlugin {
@Override
public void execute() throws Exception {
String projectName = getProjectName();
String pathToProjecDir = getPathToProjectDir();
String nodeFilename = Paths.get(pathToProjecDir, "nodes.csv").toString();
String edgeFilename = Paths.get(pathToProjecDir, "edges.csv").toString();
| // Path: src/main/java/octopus/api/csvImporter/CSVImporter.java
// public class CSVImporter {
//
// public void importCSV(ImportJob job)
// {
// (new ImportCSVRunnable(job)).run();
// }
//
// }
//
// Path: src/main/java/octopus/api/plugin/types/OctopusProjectPlugin.java
// public abstract class OctopusProjectPlugin implements Plugin
// {
//
// private OctopusProjectConnector projectConnector;
//
// public OctopusProjectPlugin()
// {
// setProjectConnector(new OctopusProjectConnector());
// }
//
// @Override
// public void configure(JSONObject settings)
// {
// String projectName = settings.getString("projectName");
// getProjectConnector().connect(projectName);
// }
//
// protected void setProjectConnector(OctopusProjectConnector connector)
// {
// this.projectConnector = connector;
// }
//
// protected OctopusProjectConnector getProjectConnector()
// {
// return projectConnector;
// }
//
// protected String getProjectName()
// {
// return projectConnector.getWrapper().getName();
// }
//
// protected String getPathToProjectDir()
// {
// return projectConnector.getWrapper().getPathToProjectDir();
// }
//
// }
//
// Path: src/main/java/octopus/server/importer/csv/ImportJob.java
// public class ImportJob
// {
// private final String nodeFilename;
// private final String edgeFilename;
// private final String projectName;
//
// public ImportJob(String nodeFilename, String edgeFilename, String projectName)
// {
// this.nodeFilename = nodeFilename;
// this.edgeFilename = edgeFilename;
// this.projectName = projectName;
// }
//
// public String getNodeFilename()
// {
// return nodeFilename;
// }
//
// public String getEdgeFilename()
// {
// return edgeFilename;
// }
//
// public String getProjectName()
// {
// return projectName;
// }
//
// }
// Path: src/main/java/octopus/plugins/csvimporter/CSVImporterPlugin.java
import java.nio.file.Paths;
import octopus.api.csvImporter.CSVImporter;
import octopus.api.plugin.types.OctopusProjectPlugin;
import octopus.server.importer.csv.ImportJob;
package octopus.plugins.csvimporter;
public class CSVImporterPlugin extends OctopusProjectPlugin {
@Override
public void execute() throws Exception {
String projectName = getProjectName();
String pathToProjecDir = getPathToProjectDir();
String nodeFilename = Paths.get(pathToProjecDir, "nodes.csv").toString();
String edgeFilename = Paths.get(pathToProjecDir, "edges.csv").toString();
| ImportJob importJob = new ImportJob(nodeFilename, edgeFilename, projectName); |
octopus-platform/octopus | src/main/java/octopus/plugins/csvimporter/CSVImporterPlugin.java | // Path: src/main/java/octopus/api/csvImporter/CSVImporter.java
// public class CSVImporter {
//
// public void importCSV(ImportJob job)
// {
// (new ImportCSVRunnable(job)).run();
// }
//
// }
//
// Path: src/main/java/octopus/api/plugin/types/OctopusProjectPlugin.java
// public abstract class OctopusProjectPlugin implements Plugin
// {
//
// private OctopusProjectConnector projectConnector;
//
// public OctopusProjectPlugin()
// {
// setProjectConnector(new OctopusProjectConnector());
// }
//
// @Override
// public void configure(JSONObject settings)
// {
// String projectName = settings.getString("projectName");
// getProjectConnector().connect(projectName);
// }
//
// protected void setProjectConnector(OctopusProjectConnector connector)
// {
// this.projectConnector = connector;
// }
//
// protected OctopusProjectConnector getProjectConnector()
// {
// return projectConnector;
// }
//
// protected String getProjectName()
// {
// return projectConnector.getWrapper().getName();
// }
//
// protected String getPathToProjectDir()
// {
// return projectConnector.getWrapper().getPathToProjectDir();
// }
//
// }
//
// Path: src/main/java/octopus/server/importer/csv/ImportJob.java
// public class ImportJob
// {
// private final String nodeFilename;
// private final String edgeFilename;
// private final String projectName;
//
// public ImportJob(String nodeFilename, String edgeFilename, String projectName)
// {
// this.nodeFilename = nodeFilename;
// this.edgeFilename = edgeFilename;
// this.projectName = projectName;
// }
//
// public String getNodeFilename()
// {
// return nodeFilename;
// }
//
// public String getEdgeFilename()
// {
// return edgeFilename;
// }
//
// public String getProjectName()
// {
// return projectName;
// }
//
// }
| import java.nio.file.Paths;
import octopus.api.csvImporter.CSVImporter;
import octopus.api.plugin.types.OctopusProjectPlugin;
import octopus.server.importer.csv.ImportJob; | package octopus.plugins.csvimporter;
public class CSVImporterPlugin extends OctopusProjectPlugin {
@Override
public void execute() throws Exception {
String projectName = getProjectName();
String pathToProjecDir = getPathToProjectDir();
String nodeFilename = Paths.get(pathToProjecDir, "nodes.csv").toString();
String edgeFilename = Paths.get(pathToProjecDir, "edges.csv").toString();
ImportJob importJob = new ImportJob(nodeFilename, edgeFilename, projectName); | // Path: src/main/java/octopus/api/csvImporter/CSVImporter.java
// public class CSVImporter {
//
// public void importCSV(ImportJob job)
// {
// (new ImportCSVRunnable(job)).run();
// }
//
// }
//
// Path: src/main/java/octopus/api/plugin/types/OctopusProjectPlugin.java
// public abstract class OctopusProjectPlugin implements Plugin
// {
//
// private OctopusProjectConnector projectConnector;
//
// public OctopusProjectPlugin()
// {
// setProjectConnector(new OctopusProjectConnector());
// }
//
// @Override
// public void configure(JSONObject settings)
// {
// String projectName = settings.getString("projectName");
// getProjectConnector().connect(projectName);
// }
//
// protected void setProjectConnector(OctopusProjectConnector connector)
// {
// this.projectConnector = connector;
// }
//
// protected OctopusProjectConnector getProjectConnector()
// {
// return projectConnector;
// }
//
// protected String getProjectName()
// {
// return projectConnector.getWrapper().getName();
// }
//
// protected String getPathToProjectDir()
// {
// return projectConnector.getWrapper().getPathToProjectDir();
// }
//
// }
//
// Path: src/main/java/octopus/server/importer/csv/ImportJob.java
// public class ImportJob
// {
// private final String nodeFilename;
// private final String edgeFilename;
// private final String projectName;
//
// public ImportJob(String nodeFilename, String edgeFilename, String projectName)
// {
// this.nodeFilename = nodeFilename;
// this.edgeFilename = edgeFilename;
// this.projectName = projectName;
// }
//
// public String getNodeFilename()
// {
// return nodeFilename;
// }
//
// public String getEdgeFilename()
// {
// return edgeFilename;
// }
//
// public String getProjectName()
// {
// return projectName;
// }
//
// }
// Path: src/main/java/octopus/plugins/csvimporter/CSVImporterPlugin.java
import java.nio.file.Paths;
import octopus.api.csvImporter.CSVImporter;
import octopus.api.plugin.types.OctopusProjectPlugin;
import octopus.server.importer.csv.ImportJob;
package octopus.plugins.csvimporter;
public class CSVImporterPlugin extends OctopusProjectPlugin {
@Override
public void execute() throws Exception {
String projectName = getProjectName();
String pathToProjecDir = getPathToProjectDir();
String nodeFilename = Paths.get(pathToProjecDir, "nodes.csv").toString();
String edgeFilename = Paths.get(pathToProjecDir, "edges.csv").toString();
ImportJob importJob = new ImportJob(nodeFilename, edgeFilename, projectName); | (new CSVImporter()).importCSV(importJob); |
octopus-platform/octopus | src/main/java/octopus/server/restServer/handlers/CreateShellHandler.java | // Path: src/main/java/octopus/api/shell/ShellManager.java
// public class ShellManager {
//
// public List<OctopusGremlinShell> getActiveShells()
// {
// return OctopusShellManager.getActiveShells();
// }
//
// public int createNewShellThread(String projectName, String shellName) throws IOException
// {
// int port = OctopusShellManager.createNewShell(projectName, shellName);
// OctopusGremlinShell shell = OctopusShellManager.getShellForPort(port);
// startShellThread(shell);
// return port;
// }
//
// private void startShellThread(OctopusGremlinShell shell) throws IOException
// {
// ShellRunnable runnable = new ShellRunnable(shell);
// Thread thread = new Thread(runnable);
// thread.start();
// }
//
// }
//
// Path: src/main/java/octopus/server/restServer/OctopusRestHandler.java
// public interface OctopusRestHandler {
//
// public Object handle(Request req, Response resp);
//
// }
| import java.io.IOException;
import octopus.api.shell.ShellManager;
import octopus.server.restServer.OctopusRestHandler;
import spark.Request;
import spark.Response; | package octopus.server.restServer.handlers;
public class CreateShellHandler implements OctopusRestHandler {
String projectName;
String shellName;
@Override
public Object handle(Request req, Response resp) {
extractParameters(req);
int port = createNewShell();
return String.format("%d\n", port);
}
private void extractParameters(Request req)
{
projectName = req.params(":projectName");
shellName = req.params(":shellname");
}
private int createNewShell()
{
int port;
try { | // Path: src/main/java/octopus/api/shell/ShellManager.java
// public class ShellManager {
//
// public List<OctopusGremlinShell> getActiveShells()
// {
// return OctopusShellManager.getActiveShells();
// }
//
// public int createNewShellThread(String projectName, String shellName) throws IOException
// {
// int port = OctopusShellManager.createNewShell(projectName, shellName);
// OctopusGremlinShell shell = OctopusShellManager.getShellForPort(port);
// startShellThread(shell);
// return port;
// }
//
// private void startShellThread(OctopusGremlinShell shell) throws IOException
// {
// ShellRunnable runnable = new ShellRunnable(shell);
// Thread thread = new Thread(runnable);
// thread.start();
// }
//
// }
//
// Path: src/main/java/octopus/server/restServer/OctopusRestHandler.java
// public interface OctopusRestHandler {
//
// public Object handle(Request req, Response resp);
//
// }
// Path: src/main/java/octopus/server/restServer/handlers/CreateShellHandler.java
import java.io.IOException;
import octopus.api.shell.ShellManager;
import octopus.server.restServer.OctopusRestHandler;
import spark.Request;
import spark.Response;
package octopus.server.restServer.handlers;
public class CreateShellHandler implements OctopusRestHandler {
String projectName;
String shellName;
@Override
public Object handle(Request req, Response resp) {
extractParameters(req);
int port = createNewShell();
return String.format("%d\n", port);
}
private void extractParameters(Request req)
{
projectName = req.params(":projectName");
shellName = req.params(":shellname");
}
private int createNewShell()
{
int port;
try { | port = (new ShellManager()).createNewShellThread(projectName, shellName); |
octopus-platform/octopus | src/main/java/octopus/api/GraphOperations.java | // Path: src/main/java/octopus/api/structures/OctopusNode.java
// public abstract class OctopusNode implements Vertex
// {
//
// public OctopusNode(Vertex vertex)
// {
// if (vertex == null)
// {
// throw new IllegalArgumentException("vertex must not be null.");
// }
// }
//
// public OctopusNode(Vertex vertex, String nodeType)
// {
// this(vertex);
//
// if (!vertex.value(OctopusNodeProperties.TYPE).equals(nodeType))
// {
// throw new IllegalArgumentException("Invalid node. Expected a node of type " + nodeType + " was " + vertex
// .value(OctopusNodeProperties.TYPE));
// }
// }
//
//
// }
| import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import octopus.api.structures.OctopusNode; | package octopus.api;
public class GraphOperations
{
/**
* Add an edge from the node src to the node dst if it does
* not already exist.
*
* @param src the source of the edge
* @param dst the destination of the edge
*/ | // Path: src/main/java/octopus/api/structures/OctopusNode.java
// public abstract class OctopusNode implements Vertex
// {
//
// public OctopusNode(Vertex vertex)
// {
// if (vertex == null)
// {
// throw new IllegalArgumentException("vertex must not be null.");
// }
// }
//
// public OctopusNode(Vertex vertex, String nodeType)
// {
// this(vertex);
//
// if (!vertex.value(OctopusNodeProperties.TYPE).equals(nodeType))
// {
// throw new IllegalArgumentException("Invalid node. Expected a node of type " + nodeType + " was " + vertex
// .value(OctopusNodeProperties.TYPE));
// }
// }
//
//
// }
// Path: src/main/java/octopus/api/GraphOperations.java
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import octopus.api.structures.OctopusNode;
package octopus.api;
public class GraphOperations
{
/**
* Add an edge from the node src to the node dst if it does
* not already exist.
*
* @param src the source of the edge
* @param dst the destination of the edge
*/ | public static void addEdge(Graph graph, OctopusNode src, OctopusNode dst, String edgeType) |
octopus-platform/octopus | src/main/java/octopus/OctopusMain.java | // Path: src/main/java/octopus/server/ftpserver/OctopusFTPServer.java
// public class OctopusFTPServer {
//
// private static final Logger logger = LoggerFactory
// .getLogger(OctopusFTPServer.class);
//
// private static final String FTP_SERVER_HOST = "localhost";
// private static final int FTP_SERVER_PORT = 23231;
//
// FtpServer server;
// FtpServerFactory serverFactory = new FtpServerFactory();
// ListenerFactory factory = new ListenerFactory();
// ConnectionConfigFactory connectionConfigFactory = new ConnectionConfigFactory();
//
// public void start() throws FtpException
// {
// factory.setPort(FTP_SERVER_PORT);
// factory.setServerAddress(FTP_SERVER_HOST);
//
// configureAnonymousLogin();
//
// serverFactory.addListener("default", factory.createListener());
//
// server = serverFactory.createServer();
// server.start();
// }
//
// private void configureAnonymousLogin() throws FtpException
// {
// connectionConfigFactory.setAnonymousLoginEnabled(true);
// serverFactory.setConnectionConfig(connectionConfigFactory.createConnectionConfig());
//
// BaseUser user = configureAnonymousUser();
// String projectDirStr = OctopusEnvironment.PROJECTS_DIR.toString();
// user.setHomeDirectory(projectDirStr);
//
// serverFactory.getUserManager().save(user);
// }
//
// private BaseUser configureAnonymousUser()
// {
// BaseUser user = new BaseUser();
// user.setName("anonymous");
// List<Authority> auths = new ArrayList<Authority>();
// Authority auth = new WritePermission();
// auths.add(auth);
// user.setAuthorities(auths);
// return user;
// }
//
// }
//
// Path: src/main/java/octopus/server/restServer/OctopusRestServer.java
// public class OctopusRestServer {
//
// private static final int REST_PORT = 2480;
//
// public static void start()
// {
// port(REST_PORT);
//
// /*
// * This is a complete list of all REST commands. If you want to
// * add a command, please stick to the following RULES:
// *
// * - If you need optional parameters, create multiple routes
// * but do NOT use slack. This will ensure that all ways of
// * executing commands remain visible in this file.
// *
// * - Try to place your command into one of the existing
// * groups first. Only if none exists that matches, create
// * your own group.
// *
// * - Choose a group name that describes functionality, not
// * code origin.
// **/
//
// post("executeplugin/", (req, res) -> {
// return new ExecutePluginHandler().handle(req, res); });
//
// get("manageprojects/create/:projectName", (req, res) -> {
// return new CreateProjectHandler().handle(req, res);
// });
//
// get("manageprojects/delete/:projectName", (req, res) -> {
// return new DeleteProjectHandler().handle(req, res);
// });
//
// get("manageprojects/list", (req, res) -> {
// return new ListProjectsHandler().handle(req, res);
// });
//
// get("database/importcsv/:projectName", (req, res) -> {
// return new ImportCSVHandler().handle(req, res);
// });
//
// get("database/importcsv/:projectName/:nodeFilename/:edgeFilename", (req, res) -> {
// return new ImportCSVHandler().handle(req, res);
// });
//
// get("database/reset/:projectName", (req, res) -> {
// return new ResetDatabaseHandler().handle(req, res);
// });
//
// get("manageshells/list", (req, res) -> {
// return new ListShellsHandler().handle(req, res);
// });
//
// get("manageshells/create/:projectName/:shellName", (req, res) -> {
// return new CreateShellHandler().handle(req,res);
// });
//
// exception(RuntimeException.class, (e, req, res) -> {
// res.status(400);
// res.body("Runtime Exception: " + e.getMessage());
// });
//
// }
//
// }
| import org.apache.ftpserver.FtpServerConfigurationException;
import org.apache.ftpserver.ftplet.FtpException;
import octopus.server.ftpserver.OctopusFTPServer;
import octopus.server.restServer.OctopusRestServer; | package octopus;
public class OctopusMain {
static OctopusMain main;
| // Path: src/main/java/octopus/server/ftpserver/OctopusFTPServer.java
// public class OctopusFTPServer {
//
// private static final Logger logger = LoggerFactory
// .getLogger(OctopusFTPServer.class);
//
// private static final String FTP_SERVER_HOST = "localhost";
// private static final int FTP_SERVER_PORT = 23231;
//
// FtpServer server;
// FtpServerFactory serverFactory = new FtpServerFactory();
// ListenerFactory factory = new ListenerFactory();
// ConnectionConfigFactory connectionConfigFactory = new ConnectionConfigFactory();
//
// public void start() throws FtpException
// {
// factory.setPort(FTP_SERVER_PORT);
// factory.setServerAddress(FTP_SERVER_HOST);
//
// configureAnonymousLogin();
//
// serverFactory.addListener("default", factory.createListener());
//
// server = serverFactory.createServer();
// server.start();
// }
//
// private void configureAnonymousLogin() throws FtpException
// {
// connectionConfigFactory.setAnonymousLoginEnabled(true);
// serverFactory.setConnectionConfig(connectionConfigFactory.createConnectionConfig());
//
// BaseUser user = configureAnonymousUser();
// String projectDirStr = OctopusEnvironment.PROJECTS_DIR.toString();
// user.setHomeDirectory(projectDirStr);
//
// serverFactory.getUserManager().save(user);
// }
//
// private BaseUser configureAnonymousUser()
// {
// BaseUser user = new BaseUser();
// user.setName("anonymous");
// List<Authority> auths = new ArrayList<Authority>();
// Authority auth = new WritePermission();
// auths.add(auth);
// user.setAuthorities(auths);
// return user;
// }
//
// }
//
// Path: src/main/java/octopus/server/restServer/OctopusRestServer.java
// public class OctopusRestServer {
//
// private static final int REST_PORT = 2480;
//
// public static void start()
// {
// port(REST_PORT);
//
// /*
// * This is a complete list of all REST commands. If you want to
// * add a command, please stick to the following RULES:
// *
// * - If you need optional parameters, create multiple routes
// * but do NOT use slack. This will ensure that all ways of
// * executing commands remain visible in this file.
// *
// * - Try to place your command into one of the existing
// * groups first. Only if none exists that matches, create
// * your own group.
// *
// * - Choose a group name that describes functionality, not
// * code origin.
// **/
//
// post("executeplugin/", (req, res) -> {
// return new ExecutePluginHandler().handle(req, res); });
//
// get("manageprojects/create/:projectName", (req, res) -> {
// return new CreateProjectHandler().handle(req, res);
// });
//
// get("manageprojects/delete/:projectName", (req, res) -> {
// return new DeleteProjectHandler().handle(req, res);
// });
//
// get("manageprojects/list", (req, res) -> {
// return new ListProjectsHandler().handle(req, res);
// });
//
// get("database/importcsv/:projectName", (req, res) -> {
// return new ImportCSVHandler().handle(req, res);
// });
//
// get("database/importcsv/:projectName/:nodeFilename/:edgeFilename", (req, res) -> {
// return new ImportCSVHandler().handle(req, res);
// });
//
// get("database/reset/:projectName", (req, res) -> {
// return new ResetDatabaseHandler().handle(req, res);
// });
//
// get("manageshells/list", (req, res) -> {
// return new ListShellsHandler().handle(req, res);
// });
//
// get("manageshells/create/:projectName/:shellName", (req, res) -> {
// return new CreateShellHandler().handle(req,res);
// });
//
// exception(RuntimeException.class, (e, req, res) -> {
// res.status(400);
// res.body("Runtime Exception: " + e.getMessage());
// });
//
// }
//
// }
// Path: src/main/java/octopus/OctopusMain.java
import org.apache.ftpserver.FtpServerConfigurationException;
import org.apache.ftpserver.ftplet.FtpException;
import octopus.server.ftpserver.OctopusFTPServer;
import octopus.server.restServer.OctopusRestServer;
package octopus;
public class OctopusMain {
static OctopusMain main;
| OctopusFTPServer ftpServer; |
octopus-platform/octopus | src/main/java/octopus/OctopusMain.java | // Path: src/main/java/octopus/server/ftpserver/OctopusFTPServer.java
// public class OctopusFTPServer {
//
// private static final Logger logger = LoggerFactory
// .getLogger(OctopusFTPServer.class);
//
// private static final String FTP_SERVER_HOST = "localhost";
// private static final int FTP_SERVER_PORT = 23231;
//
// FtpServer server;
// FtpServerFactory serverFactory = new FtpServerFactory();
// ListenerFactory factory = new ListenerFactory();
// ConnectionConfigFactory connectionConfigFactory = new ConnectionConfigFactory();
//
// public void start() throws FtpException
// {
// factory.setPort(FTP_SERVER_PORT);
// factory.setServerAddress(FTP_SERVER_HOST);
//
// configureAnonymousLogin();
//
// serverFactory.addListener("default", factory.createListener());
//
// server = serverFactory.createServer();
// server.start();
// }
//
// private void configureAnonymousLogin() throws FtpException
// {
// connectionConfigFactory.setAnonymousLoginEnabled(true);
// serverFactory.setConnectionConfig(connectionConfigFactory.createConnectionConfig());
//
// BaseUser user = configureAnonymousUser();
// String projectDirStr = OctopusEnvironment.PROJECTS_DIR.toString();
// user.setHomeDirectory(projectDirStr);
//
// serverFactory.getUserManager().save(user);
// }
//
// private BaseUser configureAnonymousUser()
// {
// BaseUser user = new BaseUser();
// user.setName("anonymous");
// List<Authority> auths = new ArrayList<Authority>();
// Authority auth = new WritePermission();
// auths.add(auth);
// user.setAuthorities(auths);
// return user;
// }
//
// }
//
// Path: src/main/java/octopus/server/restServer/OctopusRestServer.java
// public class OctopusRestServer {
//
// private static final int REST_PORT = 2480;
//
// public static void start()
// {
// port(REST_PORT);
//
// /*
// * This is a complete list of all REST commands. If you want to
// * add a command, please stick to the following RULES:
// *
// * - If you need optional parameters, create multiple routes
// * but do NOT use slack. This will ensure that all ways of
// * executing commands remain visible in this file.
// *
// * - Try to place your command into one of the existing
// * groups first. Only if none exists that matches, create
// * your own group.
// *
// * - Choose a group name that describes functionality, not
// * code origin.
// **/
//
// post("executeplugin/", (req, res) -> {
// return new ExecutePluginHandler().handle(req, res); });
//
// get("manageprojects/create/:projectName", (req, res) -> {
// return new CreateProjectHandler().handle(req, res);
// });
//
// get("manageprojects/delete/:projectName", (req, res) -> {
// return new DeleteProjectHandler().handle(req, res);
// });
//
// get("manageprojects/list", (req, res) -> {
// return new ListProjectsHandler().handle(req, res);
// });
//
// get("database/importcsv/:projectName", (req, res) -> {
// return new ImportCSVHandler().handle(req, res);
// });
//
// get("database/importcsv/:projectName/:nodeFilename/:edgeFilename", (req, res) -> {
// return new ImportCSVHandler().handle(req, res);
// });
//
// get("database/reset/:projectName", (req, res) -> {
// return new ResetDatabaseHandler().handle(req, res);
// });
//
// get("manageshells/list", (req, res) -> {
// return new ListShellsHandler().handle(req, res);
// });
//
// get("manageshells/create/:projectName/:shellName", (req, res) -> {
// return new CreateShellHandler().handle(req,res);
// });
//
// exception(RuntimeException.class, (e, req, res) -> {
// res.status(400);
// res.body("Runtime Exception: " + e.getMessage());
// });
//
// }
//
// }
| import org.apache.ftpserver.FtpServerConfigurationException;
import org.apache.ftpserver.ftplet.FtpException;
import octopus.server.ftpserver.OctopusFTPServer;
import octopus.server.restServer.OctopusRestServer; | package octopus;
public class OctopusMain {
static OctopusMain main;
OctopusFTPServer ftpServer;
public static void main(String[] args) throws java.lang.Exception
{
main = new OctopusMain();
main.startFTPServer();
main.startRestServer();
}
private void startFTPServer()
{
ftpServer = new OctopusFTPServer();
try {
ftpServer.start();
} catch (FtpException| FtpServerConfigurationException e) {
System.out.println("Error starting Octopus");
System.out.println(e.getMessage());
System.exit(-1);
}
}
private void startRestServer()
{ | // Path: src/main/java/octopus/server/ftpserver/OctopusFTPServer.java
// public class OctopusFTPServer {
//
// private static final Logger logger = LoggerFactory
// .getLogger(OctopusFTPServer.class);
//
// private static final String FTP_SERVER_HOST = "localhost";
// private static final int FTP_SERVER_PORT = 23231;
//
// FtpServer server;
// FtpServerFactory serverFactory = new FtpServerFactory();
// ListenerFactory factory = new ListenerFactory();
// ConnectionConfigFactory connectionConfigFactory = new ConnectionConfigFactory();
//
// public void start() throws FtpException
// {
// factory.setPort(FTP_SERVER_PORT);
// factory.setServerAddress(FTP_SERVER_HOST);
//
// configureAnonymousLogin();
//
// serverFactory.addListener("default", factory.createListener());
//
// server = serverFactory.createServer();
// server.start();
// }
//
// private void configureAnonymousLogin() throws FtpException
// {
// connectionConfigFactory.setAnonymousLoginEnabled(true);
// serverFactory.setConnectionConfig(connectionConfigFactory.createConnectionConfig());
//
// BaseUser user = configureAnonymousUser();
// String projectDirStr = OctopusEnvironment.PROJECTS_DIR.toString();
// user.setHomeDirectory(projectDirStr);
//
// serverFactory.getUserManager().save(user);
// }
//
// private BaseUser configureAnonymousUser()
// {
// BaseUser user = new BaseUser();
// user.setName("anonymous");
// List<Authority> auths = new ArrayList<Authority>();
// Authority auth = new WritePermission();
// auths.add(auth);
// user.setAuthorities(auths);
// return user;
// }
//
// }
//
// Path: src/main/java/octopus/server/restServer/OctopusRestServer.java
// public class OctopusRestServer {
//
// private static final int REST_PORT = 2480;
//
// public static void start()
// {
// port(REST_PORT);
//
// /*
// * This is a complete list of all REST commands. If you want to
// * add a command, please stick to the following RULES:
// *
// * - If you need optional parameters, create multiple routes
// * but do NOT use slack. This will ensure that all ways of
// * executing commands remain visible in this file.
// *
// * - Try to place your command into one of the existing
// * groups first. Only if none exists that matches, create
// * your own group.
// *
// * - Choose a group name that describes functionality, not
// * code origin.
// **/
//
// post("executeplugin/", (req, res) -> {
// return new ExecutePluginHandler().handle(req, res); });
//
// get("manageprojects/create/:projectName", (req, res) -> {
// return new CreateProjectHandler().handle(req, res);
// });
//
// get("manageprojects/delete/:projectName", (req, res) -> {
// return new DeleteProjectHandler().handle(req, res);
// });
//
// get("manageprojects/list", (req, res) -> {
// return new ListProjectsHandler().handle(req, res);
// });
//
// get("database/importcsv/:projectName", (req, res) -> {
// return new ImportCSVHandler().handle(req, res);
// });
//
// get("database/importcsv/:projectName/:nodeFilename/:edgeFilename", (req, res) -> {
// return new ImportCSVHandler().handle(req, res);
// });
//
// get("database/reset/:projectName", (req, res) -> {
// return new ResetDatabaseHandler().handle(req, res);
// });
//
// get("manageshells/list", (req, res) -> {
// return new ListShellsHandler().handle(req, res);
// });
//
// get("manageshells/create/:projectName/:shellName", (req, res) -> {
// return new CreateShellHandler().handle(req,res);
// });
//
// exception(RuntimeException.class, (e, req, res) -> {
// res.status(400);
// res.body("Runtime Exception: " + e.getMessage());
// });
//
// }
//
// }
// Path: src/main/java/octopus/OctopusMain.java
import org.apache.ftpserver.FtpServerConfigurationException;
import org.apache.ftpserver.ftplet.FtpException;
import octopus.server.ftpserver.OctopusFTPServer;
import octopus.server.restServer.OctopusRestServer;
package octopus;
public class OctopusMain {
static OctopusMain main;
OctopusFTPServer ftpServer;
public static void main(String[] args) throws java.lang.Exception
{
main = new OctopusMain();
main.startFTPServer();
main.startRestServer();
}
private void startFTPServer()
{
ftpServer = new OctopusFTPServer();
try {
ftpServer.start();
} catch (FtpException| FtpServerConfigurationException e) {
System.out.println("Error starting Octopus");
System.out.println(e.getMessage());
System.exit(-1);
}
}
private void startRestServer()
{ | OctopusRestServer.start(); |
octopus-platform/octopus | src/main/java/octopus/server/shellmanager/OctopusShellManager.java | // Path: src/main/java/octopus/server/gremlinShell/OctopusGremlinShell.java
// public class OctopusGremlinShell
// {
//
// private GroovyShell shell;
// private int port;
// Database database;
// private String name;
// private boolean occupied = false;
// private Graph graph;
// private String projectName;
// private GraphTraversalSource g;
//
// static
// {
//
// }
//
// public OctopusGremlinShell(String projectName)
// {
// this.projectName = projectName;
// }
//
// private void octopusSugarLoad()
// {
// String cmd = "GremlinLoader.load();";
// execute(cmd);
//
// // This is the code responsible for the execution of session steps
// cmd = "DefaultGraphTraversal.metaClass.methodMissing = { final String name, final def args -> def closure = getStep(name); if (closure != null) { closure.delegate = delegate; return closure(args); } else { throw new MissingMethodException(name, this.class, args) } }";
// execute(cmd);
// }
//
// public void initShell()
// {
// this.shell = new GroovyShell(new OctopusCompilerConfiguration());
// openDatabaseConnection(projectName);
// octopusSugarLoad();
// loadStandardQueryLibrary();
// }
//
// private void openDatabaseConnection(String projectName)
// {
// OctopusProject project = new ProjectManager().getProjectByName(projectName);
// database = project.getNewDatabaseInstance();
// this.projectName = projectName;
//
// graph = database.getGraph();
// g = graph.traversal();
// this.shell.setVariable("graph", graph);
// this.shell.setVariable("g", g);
// this.shell.setVariable("sessionSteps", new HashMap<String, Closure>());
// }
//
// private void loadStandardQueryLibrary()
// {
// try
// {
// Path languagesDir = OctopusEnvironment.LANGUAGES_DIR;
// loadRecursively(languagesDir.toString());
// } catch (IOException e)
// {
// e.printStackTrace();
// }
// }
//
// private void loadRecursively(String languagesDir) throws IOException
// {
// SourceFileWalker walker = new OrderedWalker();
// GroovyFileLoader listener = new GroovyFileLoader();
// listener.setGroovyShell(this.getShell());
//
// walker.setFilenameFilter("*.groovy");
// walker.addListener(listener);
// walker.walk(new String[]{languagesDir});
// }
//
// public Object execute(String code)
// {
//
// try
// {
// return shell.evaluate(code);
// } catch (Exception ex)
// {
// return String.format("[%s] %s\n", ex.getClass().getSimpleName(), ex.getMessage());
// }
// }
//
// public int getPort()
// {
// return port;
// }
//
// public void setPort(int port)
// {
// this.port = port;
// }
//
// public GroovyShell getShell()
// {
// return shell;
// }
//
// public void setName(String name)
// {
// this.name = name;
// }
//
// public String getName()
// {
// return this.name;
// }
//
// public void markAsOccupied()
// {
// occupied = true;
// }
//
// public void markAsFree()
// {
// occupied = false;
// }
//
// public boolean isOccupied()
// {
// return occupied;
// }
//
// public void shutdownDBInstance()
// {
// database.closeInstance();
// }
//
// public String getProjectName()
// {
// return projectName;
// }
//
// public Graph getGraph()
// {
// return graph;
// }
//
// }
| import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import octopus.server.gremlinShell.OctopusGremlinShell; | package octopus.server.shellmanager;
public class OctopusShellManager
{
private static final Logger logger = LoggerFactory
.getLogger(OctopusShellManager.class);
private static final int MAX_SHELLS = 1024;
private static final int FIRST_PORT = 6000;
| // Path: src/main/java/octopus/server/gremlinShell/OctopusGremlinShell.java
// public class OctopusGremlinShell
// {
//
// private GroovyShell shell;
// private int port;
// Database database;
// private String name;
// private boolean occupied = false;
// private Graph graph;
// private String projectName;
// private GraphTraversalSource g;
//
// static
// {
//
// }
//
// public OctopusGremlinShell(String projectName)
// {
// this.projectName = projectName;
// }
//
// private void octopusSugarLoad()
// {
// String cmd = "GremlinLoader.load();";
// execute(cmd);
//
// // This is the code responsible for the execution of session steps
// cmd = "DefaultGraphTraversal.metaClass.methodMissing = { final String name, final def args -> def closure = getStep(name); if (closure != null) { closure.delegate = delegate; return closure(args); } else { throw new MissingMethodException(name, this.class, args) } }";
// execute(cmd);
// }
//
// public void initShell()
// {
// this.shell = new GroovyShell(new OctopusCompilerConfiguration());
// openDatabaseConnection(projectName);
// octopusSugarLoad();
// loadStandardQueryLibrary();
// }
//
// private void openDatabaseConnection(String projectName)
// {
// OctopusProject project = new ProjectManager().getProjectByName(projectName);
// database = project.getNewDatabaseInstance();
// this.projectName = projectName;
//
// graph = database.getGraph();
// g = graph.traversal();
// this.shell.setVariable("graph", graph);
// this.shell.setVariable("g", g);
// this.shell.setVariable("sessionSteps", new HashMap<String, Closure>());
// }
//
// private void loadStandardQueryLibrary()
// {
// try
// {
// Path languagesDir = OctopusEnvironment.LANGUAGES_DIR;
// loadRecursively(languagesDir.toString());
// } catch (IOException e)
// {
// e.printStackTrace();
// }
// }
//
// private void loadRecursively(String languagesDir) throws IOException
// {
// SourceFileWalker walker = new OrderedWalker();
// GroovyFileLoader listener = new GroovyFileLoader();
// listener.setGroovyShell(this.getShell());
//
// walker.setFilenameFilter("*.groovy");
// walker.addListener(listener);
// walker.walk(new String[]{languagesDir});
// }
//
// public Object execute(String code)
// {
//
// try
// {
// return shell.evaluate(code);
// } catch (Exception ex)
// {
// return String.format("[%s] %s\n", ex.getClass().getSimpleName(), ex.getMessage());
// }
// }
//
// public int getPort()
// {
// return port;
// }
//
// public void setPort(int port)
// {
// this.port = port;
// }
//
// public GroovyShell getShell()
// {
// return shell;
// }
//
// public void setName(String name)
// {
// this.name = name;
// }
//
// public String getName()
// {
// return this.name;
// }
//
// public void markAsOccupied()
// {
// occupied = true;
// }
//
// public void markAsFree()
// {
// occupied = false;
// }
//
// public boolean isOccupied()
// {
// return occupied;
// }
//
// public void shutdownDBInstance()
// {
// database.closeInstance();
// }
//
// public String getProjectName()
// {
// return projectName;
// }
//
// public Graph getGraph()
// {
// return graph;
// }
//
// }
// Path: src/main/java/octopus/server/shellmanager/OctopusShellManager.java
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import octopus.server.gremlinShell.OctopusGremlinShell;
package octopus.server.shellmanager;
public class OctopusShellManager
{
private static final Logger logger = LoggerFactory
.getLogger(OctopusShellManager.class);
private static final int MAX_SHELLS = 1024;
private static final int FIRST_PORT = 6000;
| static OctopusGremlinShell[] shells; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.