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 |
|---|---|---|---|---|---|---|
UweTrottmann/thetvdb-java | src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbUser.java | // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserFavoritesResponse.java
// public class UserFavoritesResponse {
// public UserFavorites data;
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRatingsQueryParamsRepsonse.java
// public class UserRatingsQueryParamsRepsonse {
// public List<String> data;
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRatingsResponse.java
// public class UserRatingsResponse {
// public List<UserRating> data;
// public Links links;
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserResponse.java
// public class UserResponse {
// public User data;
// }
| import com.uwetrottmann.thetvdb.entities.UserFavoritesResponse;
import com.uwetrottmann.thetvdb.entities.UserRatingsQueryParamsRepsonse;
import com.uwetrottmann.thetvdb.entities.UserRatingsResponse;
import com.uwetrottmann.thetvdb.entities.UserResponse;
import retrofit2.Call;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query; | package com.uwetrottmann.thetvdb.services;
public interface TheTvdbUser {
/**
* Returns basic information about the currently authenticated user.
*/
@GET("/user")
Call<UserResponse> user();
/**
* Returns an array of favorite series for a given user, will be a blank array if no favorites exist.
*/
@GET("/user/favorites")
Call<UserFavoritesResponse> favorites();
/**
* Deletes the given series ID from the user’s favorite’s list and returns the updated list.
*/
@DELETE("/user/favorites/{id}")
Call<UserFavoritesResponse> deleteFavorite(
@Path("id") long id
);
/**
* Adds the supplied series ID to the user’s favorite’s list and returns the updated list.
*/
@PUT("/user/favorites/{id}")
Call<UserFavoritesResponse> addFavorite(
@Path("id") long id
);
/**
* Returns an array of ratings for the given user.
*/
@GET("/user/ratings")
Call<UserRatingsResponse> ratings();
/**
* Returns an array of ratings for a given user that match the query.
*/
@GET("/user/ratings/query")
Call<UserRatingsResponse> ratingsQuery(
@Query("itemType") String itemType
);
/**
* Returns a list of query params for use in the /user/ratings/query route.
*/
@GET("/user/ratings/query/params") | // Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserFavoritesResponse.java
// public class UserFavoritesResponse {
// public UserFavorites data;
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRatingsQueryParamsRepsonse.java
// public class UserRatingsQueryParamsRepsonse {
// public List<String> data;
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserRatingsResponse.java
// public class UserRatingsResponse {
// public List<UserRating> data;
// public Links links;
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/UserResponse.java
// public class UserResponse {
// public User data;
// }
// Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbUser.java
import com.uwetrottmann.thetvdb.entities.UserFavoritesResponse;
import com.uwetrottmann.thetvdb.entities.UserRatingsQueryParamsRepsonse;
import com.uwetrottmann.thetvdb.entities.UserRatingsResponse;
import com.uwetrottmann.thetvdb.entities.UserResponse;
import retrofit2.Call;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;
package com.uwetrottmann.thetvdb.services;
public interface TheTvdbUser {
/**
* Returns basic information about the currently authenticated user.
*/
@GET("/user")
Call<UserResponse> user();
/**
* Returns an array of favorite series for a given user, will be a blank array if no favorites exist.
*/
@GET("/user/favorites")
Call<UserFavoritesResponse> favorites();
/**
* Deletes the given series ID from the user’s favorite’s list and returns the updated list.
*/
@DELETE("/user/favorites/{id}")
Call<UserFavoritesResponse> deleteFavorite(
@Path("id") long id
);
/**
* Adds the supplied series ID to the user’s favorite’s list and returns the updated list.
*/
@PUT("/user/favorites/{id}")
Call<UserFavoritesResponse> addFavorite(
@Path("id") long id
);
/**
* Returns an array of ratings for the given user.
*/
@GET("/user/ratings")
Call<UserRatingsResponse> ratings();
/**
* Returns an array of ratings for a given user that match the query.
*/
@GET("/user/ratings/query")
Call<UserRatingsResponse> ratingsQuery(
@Query("itemType") String itemType
);
/**
* Returns a list of query params for use in the /user/ratings/query route.
*/
@GET("/user/ratings/query/params") | Call<UserRatingsQueryParamsRepsonse> ratingsQueryParams(); |
UweTrottmann/thetvdb-java | src/main/java/com/uwetrottmann/thetvdb/TheTvdbAuthenticator.java | // Path: src/main/java/com/uwetrottmann/thetvdb/entities/LoginData.java
// public class LoginData {
//
// public String apikey;
// public String username;
// public String userkey;
//
// public LoginData(String apikey) {
// this.apikey = apikey;
// }
//
// public LoginData user(String username, String userkey) {
// this.username = username;
// this.userkey = userkey;
// return this;
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Token.java
// public class Token {
//
// public String token;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbAuthentication.java
// public interface TheTvdbAuthentication {
//
// String PATH_LOGIN = "login";
//
// /**
// * Returns a session token to be included in the rest of the requests. Note that API key authentication is required
// * for all subsequent requests and user auth is required for routes in the User section.
// */
// @POST(PATH_LOGIN)
// Call<Token> login(@Body LoginData loginData);
//
// /**
// * Refreshes your current, valid JWT token and returns a new token. Hit this route so that you do not have to post
// * to /login with your API key and credentials once you have already been authenticated.
// */
// @GET("refresh_token")
// Call<Token> refreshToken();
//
// }
| import com.uwetrottmann.thetvdb.entities.LoginData;
import com.uwetrottmann.thetvdb.entities.Token;
import com.uwetrottmann.thetvdb.services.TheTvdbAuthentication;
import okhttp3.Authenticator;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.Route;
import retrofit2.Call;
import javax.annotation.Nullable;
import java.io.IOException; | package com.uwetrottmann.thetvdb;
public class TheTvdbAuthenticator implements Authenticator {
public static final String PATH_LOGIN = "/" + TheTvdbAuthentication.PATH_LOGIN;
private TheTvdb theTvdb;
public TheTvdbAuthenticator(TheTvdb theTvdb) {
this.theTvdb = theTvdb;
}
@Override
@Nullable
public Request authenticate(@Nullable Route route, Response response) throws IOException {
return handleRequest(response, theTvdb);
}
/**
* If not doing a login request tries to call the login endpoint to get a new JSON web token. Does <b>not</b> check
* if the host is {@link TheTvdb#API_HOST}.
*
* @param response The response passed to {@link #authenticate(Route, Response)}.
* @param theTvdb The {@link TheTvdb} instance to use API key from and to set the updated JSON web token on.
* @return A request with updated authorization header or null if no auth is possible.
*/
@Nullable
public static Request handleRequest(Response response, TheTvdb theTvdb) throws IOException {
String path = response.request().url().encodedPath();
if (PATH_LOGIN.equals(path)) {
return null; // request was a login call and failed, give up.
}
if (responseCount(response) >= 2) {
return null; // failed 2 times, give up.
}
// get a new json web token with the API key | // Path: src/main/java/com/uwetrottmann/thetvdb/entities/LoginData.java
// public class LoginData {
//
// public String apikey;
// public String username;
// public String userkey;
//
// public LoginData(String apikey) {
// this.apikey = apikey;
// }
//
// public LoginData user(String username, String userkey) {
// this.username = username;
// this.userkey = userkey;
// return this;
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Token.java
// public class Token {
//
// public String token;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbAuthentication.java
// public interface TheTvdbAuthentication {
//
// String PATH_LOGIN = "login";
//
// /**
// * Returns a session token to be included in the rest of the requests. Note that API key authentication is required
// * for all subsequent requests and user auth is required for routes in the User section.
// */
// @POST(PATH_LOGIN)
// Call<Token> login(@Body LoginData loginData);
//
// /**
// * Refreshes your current, valid JWT token and returns a new token. Hit this route so that you do not have to post
// * to /login with your API key and credentials once you have already been authenticated.
// */
// @GET("refresh_token")
// Call<Token> refreshToken();
//
// }
// Path: src/main/java/com/uwetrottmann/thetvdb/TheTvdbAuthenticator.java
import com.uwetrottmann.thetvdb.entities.LoginData;
import com.uwetrottmann.thetvdb.entities.Token;
import com.uwetrottmann.thetvdb.services.TheTvdbAuthentication;
import okhttp3.Authenticator;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.Route;
import retrofit2.Call;
import javax.annotation.Nullable;
import java.io.IOException;
package com.uwetrottmann.thetvdb;
public class TheTvdbAuthenticator implements Authenticator {
public static final String PATH_LOGIN = "/" + TheTvdbAuthentication.PATH_LOGIN;
private TheTvdb theTvdb;
public TheTvdbAuthenticator(TheTvdb theTvdb) {
this.theTvdb = theTvdb;
}
@Override
@Nullable
public Request authenticate(@Nullable Route route, Response response) throws IOException {
return handleRequest(response, theTvdb);
}
/**
* If not doing a login request tries to call the login endpoint to get a new JSON web token. Does <b>not</b> check
* if the host is {@link TheTvdb#API_HOST}.
*
* @param response The response passed to {@link #authenticate(Route, Response)}.
* @param theTvdb The {@link TheTvdb} instance to use API key from and to set the updated JSON web token on.
* @return A request with updated authorization header or null if no auth is possible.
*/
@Nullable
public static Request handleRequest(Response response, TheTvdb theTvdb) throws IOException {
String path = response.request().url().encodedPath();
if (PATH_LOGIN.equals(path)) {
return null; // request was a login call and failed, give up.
}
if (responseCount(response) >= 2) {
return null; // failed 2 times, give up.
}
// get a new json web token with the API key | Call<Token> loginCall = theTvdb.authentication().login(new LoginData(theTvdb.apiKey())); |
UweTrottmann/thetvdb-java | src/main/java/com/uwetrottmann/thetvdb/TheTvdbAuthenticator.java | // Path: src/main/java/com/uwetrottmann/thetvdb/entities/LoginData.java
// public class LoginData {
//
// public String apikey;
// public String username;
// public String userkey;
//
// public LoginData(String apikey) {
// this.apikey = apikey;
// }
//
// public LoginData user(String username, String userkey) {
// this.username = username;
// this.userkey = userkey;
// return this;
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Token.java
// public class Token {
//
// public String token;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbAuthentication.java
// public interface TheTvdbAuthentication {
//
// String PATH_LOGIN = "login";
//
// /**
// * Returns a session token to be included in the rest of the requests. Note that API key authentication is required
// * for all subsequent requests and user auth is required for routes in the User section.
// */
// @POST(PATH_LOGIN)
// Call<Token> login(@Body LoginData loginData);
//
// /**
// * Refreshes your current, valid JWT token and returns a new token. Hit this route so that you do not have to post
// * to /login with your API key and credentials once you have already been authenticated.
// */
// @GET("refresh_token")
// Call<Token> refreshToken();
//
// }
| import com.uwetrottmann.thetvdb.entities.LoginData;
import com.uwetrottmann.thetvdb.entities.Token;
import com.uwetrottmann.thetvdb.services.TheTvdbAuthentication;
import okhttp3.Authenticator;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.Route;
import retrofit2.Call;
import javax.annotation.Nullable;
import java.io.IOException; | package com.uwetrottmann.thetvdb;
public class TheTvdbAuthenticator implements Authenticator {
public static final String PATH_LOGIN = "/" + TheTvdbAuthentication.PATH_LOGIN;
private TheTvdb theTvdb;
public TheTvdbAuthenticator(TheTvdb theTvdb) {
this.theTvdb = theTvdb;
}
@Override
@Nullable
public Request authenticate(@Nullable Route route, Response response) throws IOException {
return handleRequest(response, theTvdb);
}
/**
* If not doing a login request tries to call the login endpoint to get a new JSON web token. Does <b>not</b> check
* if the host is {@link TheTvdb#API_HOST}.
*
* @param response The response passed to {@link #authenticate(Route, Response)}.
* @param theTvdb The {@link TheTvdb} instance to use API key from and to set the updated JSON web token on.
* @return A request with updated authorization header or null if no auth is possible.
*/
@Nullable
public static Request handleRequest(Response response, TheTvdb theTvdb) throws IOException {
String path = response.request().url().encodedPath();
if (PATH_LOGIN.equals(path)) {
return null; // request was a login call and failed, give up.
}
if (responseCount(response) >= 2) {
return null; // failed 2 times, give up.
}
// get a new json web token with the API key | // Path: src/main/java/com/uwetrottmann/thetvdb/entities/LoginData.java
// public class LoginData {
//
// public String apikey;
// public String username;
// public String userkey;
//
// public LoginData(String apikey) {
// this.apikey = apikey;
// }
//
// public LoginData user(String username, String userkey) {
// this.username = username;
// this.userkey = userkey;
// return this;
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Token.java
// public class Token {
//
// public String token;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbAuthentication.java
// public interface TheTvdbAuthentication {
//
// String PATH_LOGIN = "login";
//
// /**
// * Returns a session token to be included in the rest of the requests. Note that API key authentication is required
// * for all subsequent requests and user auth is required for routes in the User section.
// */
// @POST(PATH_LOGIN)
// Call<Token> login(@Body LoginData loginData);
//
// /**
// * Refreshes your current, valid JWT token and returns a new token. Hit this route so that you do not have to post
// * to /login with your API key and credentials once you have already been authenticated.
// */
// @GET("refresh_token")
// Call<Token> refreshToken();
//
// }
// Path: src/main/java/com/uwetrottmann/thetvdb/TheTvdbAuthenticator.java
import com.uwetrottmann.thetvdb.entities.LoginData;
import com.uwetrottmann.thetvdb.entities.Token;
import com.uwetrottmann.thetvdb.services.TheTvdbAuthentication;
import okhttp3.Authenticator;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.Route;
import retrofit2.Call;
import javax.annotation.Nullable;
import java.io.IOException;
package com.uwetrottmann.thetvdb;
public class TheTvdbAuthenticator implements Authenticator {
public static final String PATH_LOGIN = "/" + TheTvdbAuthentication.PATH_LOGIN;
private TheTvdb theTvdb;
public TheTvdbAuthenticator(TheTvdb theTvdb) {
this.theTvdb = theTvdb;
}
@Override
@Nullable
public Request authenticate(@Nullable Route route, Response response) throws IOException {
return handleRequest(response, theTvdb);
}
/**
* If not doing a login request tries to call the login endpoint to get a new JSON web token. Does <b>not</b> check
* if the host is {@link TheTvdb#API_HOST}.
*
* @param response The response passed to {@link #authenticate(Route, Response)}.
* @param theTvdb The {@link TheTvdb} instance to use API key from and to set the updated JSON web token on.
* @return A request with updated authorization header or null if no auth is possible.
*/
@Nullable
public static Request handleRequest(Response response, TheTvdb theTvdb) throws IOException {
String path = response.request().url().encodedPath();
if (PATH_LOGIN.equals(path)) {
return null; // request was a login call and failed, give up.
}
if (responseCount(response) >= 2) {
return null; // failed 2 times, give up.
}
// get a new json web token with the API key | Call<Token> loginCall = theTvdb.authentication().login(new LoginData(theTvdb.apiKey())); |
UweTrottmann/thetvdb-java | src/test/java/com/uwetrottmann/thetvdb/services/TheTvdbAuthenticationTest.java | // Path: src/test/java/com/uwetrottmann/thetvdb/BaseTestCase.java
// public abstract class BaseTestCase {
//
// /** <b>WARNING:</b> do not use this in your code. This is for testing purposes only. */
// protected static final String API_KEY = "0B0BB36928753CD8";
//
// private static final boolean DEBUG = true;
//
// private static final TestTheTvdb theTvdb = new TestTheTvdb(API_KEY);
//
// static class TestTheTvdb extends TheTvdb {
//
// public TestTheTvdb(String apiKey) {
// super(apiKey);
// }
//
// @Override
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// super.setOkHttpClientDefaults(builder);
// if (DEBUG) {
// // add logging, standard output is easier to read
// HttpLoggingInterceptor logging = new HttpLoggingInterceptor(System.out::println);
// logging.setLevel(HttpLoggingInterceptor.Level.BODY);
// builder.addNetworkInterceptor(logging);
// }
// }
// }
//
// @BeforeClass
// public static void setUpOnce() {
// //noinspection ConstantConditions
// if (API_KEY.length() == 0) {
// throw new IllegalArgumentException("Set a valid value for API_KEY.");
// }
// }
//
// protected final TheTvdb getTheTvdb() {
// return theTvdb;
// }
//
// /**
// * Execute call with non-Void response body.
// */
// protected <T> T executeCall(Call<T> call) throws IOException {
// Response<T> response = call.execute();
// if (!response.isSuccessful()) {
// handleFailedResponse(response);
// }
// T body = response.body();
// if (body != null) {
// return body;
// } else {
// throw new IllegalStateException("Body should not be null for successful response");
// }
// }
//
// /**
// * Execute call with Void response body.
// */
// protected <T> Response<T> executeVoidCall(Call<T> call) throws IOException {
// Response<T> response = call.execute();
// if (!response.isSuccessful()) {
// handleFailedResponse(response); // will throw error
// }
// return response;
// }
//
// /**
// * Execute call with expected failure
// */
// protected <T> Response<T> executeExpectedErrorCall(Call<T> call, int expectedErrorCode) throws IOException {
// Response<T> response = call.execute();
// if (response.code() != expectedErrorCode) {
// fail(String.format("Expected error code %d but instead got %d %s", expectedErrorCode, response.code(), response.message()));
// }
//
// return response;
// }
//
// private static void handleFailedResponse(Response response) {
// if (response.code() == 401) {
// fail(String.format("Authorization required: %d %s", response.code(), response.message()));
// } else {
// fail(String.format("Request failed: %d %s", response.code(), response.message()));
// }
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/LoginData.java
// public class LoginData {
//
// public String apikey;
// public String username;
// public String userkey;
//
// public LoginData(String apikey) {
// this.apikey = apikey;
// }
//
// public LoginData user(String username, String userkey) {
// this.username = username;
// this.userkey = userkey;
// return this;
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Token.java
// public class Token {
//
// public String token;
//
// }
| import static com.google.common.truth.Truth.assertThat;
import com.uwetrottmann.thetvdb.BaseTestCase;
import com.uwetrottmann.thetvdb.entities.LoginData;
import com.uwetrottmann.thetvdb.entities.Token;
import java.io.IOException;
import org.junit.Ignore;
import org.junit.Test;
import retrofit2.Call; | package com.uwetrottmann.thetvdb.services;
public class TheTvdbAuthenticationTest extends BaseTestCase {
@Test
public void test_login() throws IOException {
//noinspection ConstantConditions
if (API_KEY.length() == 0) {
throw new IllegalArgumentException("Set your TheTVDB API key to test /login.");
}
// remove existing auth
getTheTvdb().jsonWebToken(null);
| // Path: src/test/java/com/uwetrottmann/thetvdb/BaseTestCase.java
// public abstract class BaseTestCase {
//
// /** <b>WARNING:</b> do not use this in your code. This is for testing purposes only. */
// protected static final String API_KEY = "0B0BB36928753CD8";
//
// private static final boolean DEBUG = true;
//
// private static final TestTheTvdb theTvdb = new TestTheTvdb(API_KEY);
//
// static class TestTheTvdb extends TheTvdb {
//
// public TestTheTvdb(String apiKey) {
// super(apiKey);
// }
//
// @Override
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// super.setOkHttpClientDefaults(builder);
// if (DEBUG) {
// // add logging, standard output is easier to read
// HttpLoggingInterceptor logging = new HttpLoggingInterceptor(System.out::println);
// logging.setLevel(HttpLoggingInterceptor.Level.BODY);
// builder.addNetworkInterceptor(logging);
// }
// }
// }
//
// @BeforeClass
// public static void setUpOnce() {
// //noinspection ConstantConditions
// if (API_KEY.length() == 0) {
// throw new IllegalArgumentException("Set a valid value for API_KEY.");
// }
// }
//
// protected final TheTvdb getTheTvdb() {
// return theTvdb;
// }
//
// /**
// * Execute call with non-Void response body.
// */
// protected <T> T executeCall(Call<T> call) throws IOException {
// Response<T> response = call.execute();
// if (!response.isSuccessful()) {
// handleFailedResponse(response);
// }
// T body = response.body();
// if (body != null) {
// return body;
// } else {
// throw new IllegalStateException("Body should not be null for successful response");
// }
// }
//
// /**
// * Execute call with Void response body.
// */
// protected <T> Response<T> executeVoidCall(Call<T> call) throws IOException {
// Response<T> response = call.execute();
// if (!response.isSuccessful()) {
// handleFailedResponse(response); // will throw error
// }
// return response;
// }
//
// /**
// * Execute call with expected failure
// */
// protected <T> Response<T> executeExpectedErrorCall(Call<T> call, int expectedErrorCode) throws IOException {
// Response<T> response = call.execute();
// if (response.code() != expectedErrorCode) {
// fail(String.format("Expected error code %d but instead got %d %s", expectedErrorCode, response.code(), response.message()));
// }
//
// return response;
// }
//
// private static void handleFailedResponse(Response response) {
// if (response.code() == 401) {
// fail(String.format("Authorization required: %d %s", response.code(), response.message()));
// } else {
// fail(String.format("Request failed: %d %s", response.code(), response.message()));
// }
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/LoginData.java
// public class LoginData {
//
// public String apikey;
// public String username;
// public String userkey;
//
// public LoginData(String apikey) {
// this.apikey = apikey;
// }
//
// public LoginData user(String username, String userkey) {
// this.username = username;
// this.userkey = userkey;
// return this;
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Token.java
// public class Token {
//
// public String token;
//
// }
// Path: src/test/java/com/uwetrottmann/thetvdb/services/TheTvdbAuthenticationTest.java
import static com.google.common.truth.Truth.assertThat;
import com.uwetrottmann.thetvdb.BaseTestCase;
import com.uwetrottmann.thetvdb.entities.LoginData;
import com.uwetrottmann.thetvdb.entities.Token;
import java.io.IOException;
import org.junit.Ignore;
import org.junit.Test;
import retrofit2.Call;
package com.uwetrottmann.thetvdb.services;
public class TheTvdbAuthenticationTest extends BaseTestCase {
@Test
public void test_login() throws IOException {
//noinspection ConstantConditions
if (API_KEY.length() == 0) {
throw new IllegalArgumentException("Set your TheTVDB API key to test /login.");
}
// remove existing auth
getTheTvdb().jsonWebToken(null);
| Call<Token> call = getTheTvdb().authentication().login(new LoginData(API_KEY)); |
UweTrottmann/thetvdb-java | src/test/java/com/uwetrottmann/thetvdb/services/TheTvdbAuthenticationTest.java | // Path: src/test/java/com/uwetrottmann/thetvdb/BaseTestCase.java
// public abstract class BaseTestCase {
//
// /** <b>WARNING:</b> do not use this in your code. This is for testing purposes only. */
// protected static final String API_KEY = "0B0BB36928753CD8";
//
// private static final boolean DEBUG = true;
//
// private static final TestTheTvdb theTvdb = new TestTheTvdb(API_KEY);
//
// static class TestTheTvdb extends TheTvdb {
//
// public TestTheTvdb(String apiKey) {
// super(apiKey);
// }
//
// @Override
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// super.setOkHttpClientDefaults(builder);
// if (DEBUG) {
// // add logging, standard output is easier to read
// HttpLoggingInterceptor logging = new HttpLoggingInterceptor(System.out::println);
// logging.setLevel(HttpLoggingInterceptor.Level.BODY);
// builder.addNetworkInterceptor(logging);
// }
// }
// }
//
// @BeforeClass
// public static void setUpOnce() {
// //noinspection ConstantConditions
// if (API_KEY.length() == 0) {
// throw new IllegalArgumentException("Set a valid value for API_KEY.");
// }
// }
//
// protected final TheTvdb getTheTvdb() {
// return theTvdb;
// }
//
// /**
// * Execute call with non-Void response body.
// */
// protected <T> T executeCall(Call<T> call) throws IOException {
// Response<T> response = call.execute();
// if (!response.isSuccessful()) {
// handleFailedResponse(response);
// }
// T body = response.body();
// if (body != null) {
// return body;
// } else {
// throw new IllegalStateException("Body should not be null for successful response");
// }
// }
//
// /**
// * Execute call with Void response body.
// */
// protected <T> Response<T> executeVoidCall(Call<T> call) throws IOException {
// Response<T> response = call.execute();
// if (!response.isSuccessful()) {
// handleFailedResponse(response); // will throw error
// }
// return response;
// }
//
// /**
// * Execute call with expected failure
// */
// protected <T> Response<T> executeExpectedErrorCall(Call<T> call, int expectedErrorCode) throws IOException {
// Response<T> response = call.execute();
// if (response.code() != expectedErrorCode) {
// fail(String.format("Expected error code %d but instead got %d %s", expectedErrorCode, response.code(), response.message()));
// }
//
// return response;
// }
//
// private static void handleFailedResponse(Response response) {
// if (response.code() == 401) {
// fail(String.format("Authorization required: %d %s", response.code(), response.message()));
// } else {
// fail(String.format("Request failed: %d %s", response.code(), response.message()));
// }
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/LoginData.java
// public class LoginData {
//
// public String apikey;
// public String username;
// public String userkey;
//
// public LoginData(String apikey) {
// this.apikey = apikey;
// }
//
// public LoginData user(String username, String userkey) {
// this.username = username;
// this.userkey = userkey;
// return this;
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Token.java
// public class Token {
//
// public String token;
//
// }
| import static com.google.common.truth.Truth.assertThat;
import com.uwetrottmann.thetvdb.BaseTestCase;
import com.uwetrottmann.thetvdb.entities.LoginData;
import com.uwetrottmann.thetvdb.entities.Token;
import java.io.IOException;
import org.junit.Ignore;
import org.junit.Test;
import retrofit2.Call; | package com.uwetrottmann.thetvdb.services;
public class TheTvdbAuthenticationTest extends BaseTestCase {
@Test
public void test_login() throws IOException {
//noinspection ConstantConditions
if (API_KEY.length() == 0) {
throw new IllegalArgumentException("Set your TheTVDB API key to test /login.");
}
// remove existing auth
getTheTvdb().jsonWebToken(null);
| // Path: src/test/java/com/uwetrottmann/thetvdb/BaseTestCase.java
// public abstract class BaseTestCase {
//
// /** <b>WARNING:</b> do not use this in your code. This is for testing purposes only. */
// protected static final String API_KEY = "0B0BB36928753CD8";
//
// private static final boolean DEBUG = true;
//
// private static final TestTheTvdb theTvdb = new TestTheTvdb(API_KEY);
//
// static class TestTheTvdb extends TheTvdb {
//
// public TestTheTvdb(String apiKey) {
// super(apiKey);
// }
//
// @Override
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// super.setOkHttpClientDefaults(builder);
// if (DEBUG) {
// // add logging, standard output is easier to read
// HttpLoggingInterceptor logging = new HttpLoggingInterceptor(System.out::println);
// logging.setLevel(HttpLoggingInterceptor.Level.BODY);
// builder.addNetworkInterceptor(logging);
// }
// }
// }
//
// @BeforeClass
// public static void setUpOnce() {
// //noinspection ConstantConditions
// if (API_KEY.length() == 0) {
// throw new IllegalArgumentException("Set a valid value for API_KEY.");
// }
// }
//
// protected final TheTvdb getTheTvdb() {
// return theTvdb;
// }
//
// /**
// * Execute call with non-Void response body.
// */
// protected <T> T executeCall(Call<T> call) throws IOException {
// Response<T> response = call.execute();
// if (!response.isSuccessful()) {
// handleFailedResponse(response);
// }
// T body = response.body();
// if (body != null) {
// return body;
// } else {
// throw new IllegalStateException("Body should not be null for successful response");
// }
// }
//
// /**
// * Execute call with Void response body.
// */
// protected <T> Response<T> executeVoidCall(Call<T> call) throws IOException {
// Response<T> response = call.execute();
// if (!response.isSuccessful()) {
// handleFailedResponse(response); // will throw error
// }
// return response;
// }
//
// /**
// * Execute call with expected failure
// */
// protected <T> Response<T> executeExpectedErrorCall(Call<T> call, int expectedErrorCode) throws IOException {
// Response<T> response = call.execute();
// if (response.code() != expectedErrorCode) {
// fail(String.format("Expected error code %d but instead got %d %s", expectedErrorCode, response.code(), response.message()));
// }
//
// return response;
// }
//
// private static void handleFailedResponse(Response response) {
// if (response.code() == 401) {
// fail(String.format("Authorization required: %d %s", response.code(), response.message()));
// } else {
// fail(String.format("Request failed: %d %s", response.code(), response.message()));
// }
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/LoginData.java
// public class LoginData {
//
// public String apikey;
// public String username;
// public String userkey;
//
// public LoginData(String apikey) {
// this.apikey = apikey;
// }
//
// public LoginData user(String username, String userkey) {
// this.username = username;
// this.userkey = userkey;
// return this;
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Token.java
// public class Token {
//
// public String token;
//
// }
// Path: src/test/java/com/uwetrottmann/thetvdb/services/TheTvdbAuthenticationTest.java
import static com.google.common.truth.Truth.assertThat;
import com.uwetrottmann.thetvdb.BaseTestCase;
import com.uwetrottmann.thetvdb.entities.LoginData;
import com.uwetrottmann.thetvdb.entities.Token;
import java.io.IOException;
import org.junit.Ignore;
import org.junit.Test;
import retrofit2.Call;
package com.uwetrottmann.thetvdb.services;
public class TheTvdbAuthenticationTest extends BaseTestCase {
@Test
public void test_login() throws IOException {
//noinspection ConstantConditions
if (API_KEY.length() == 0) {
throw new IllegalArgumentException("Set your TheTVDB API key to test /login.");
}
// remove existing auth
getTheTvdb().jsonWebToken(null);
| Call<Token> call = getTheTvdb().authentication().login(new LoginData(API_KEY)); |
UweTrottmann/thetvdb-java | src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbAuthentication.java | // Path: src/main/java/com/uwetrottmann/thetvdb/entities/LoginData.java
// public class LoginData {
//
// public String apikey;
// public String username;
// public String userkey;
//
// public LoginData(String apikey) {
// this.apikey = apikey;
// }
//
// public LoginData user(String username, String userkey) {
// this.username = username;
// this.userkey = userkey;
// return this;
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Token.java
// public class Token {
//
// public String token;
//
// }
| import com.uwetrottmann.thetvdb.entities.LoginData;
import com.uwetrottmann.thetvdb.entities.Token;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST; | package com.uwetrottmann.thetvdb.services;
public interface TheTvdbAuthentication {
String PATH_LOGIN = "login";
/**
* Returns a session token to be included in the rest of the requests. Note that API key authentication is required
* for all subsequent requests and user auth is required for routes in the User section.
*/
@POST(PATH_LOGIN) | // Path: src/main/java/com/uwetrottmann/thetvdb/entities/LoginData.java
// public class LoginData {
//
// public String apikey;
// public String username;
// public String userkey;
//
// public LoginData(String apikey) {
// this.apikey = apikey;
// }
//
// public LoginData user(String username, String userkey) {
// this.username = username;
// this.userkey = userkey;
// return this;
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Token.java
// public class Token {
//
// public String token;
//
// }
// Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbAuthentication.java
import com.uwetrottmann.thetvdb.entities.LoginData;
import com.uwetrottmann.thetvdb.entities.Token;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
package com.uwetrottmann.thetvdb.services;
public interface TheTvdbAuthentication {
String PATH_LOGIN = "login";
/**
* Returns a session token to be included in the rest of the requests. Note that API key authentication is required
* for all subsequent requests and user auth is required for routes in the User section.
*/
@POST(PATH_LOGIN) | Call<Token> login(@Body LoginData loginData); |
UweTrottmann/thetvdb-java | src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbAuthentication.java | // Path: src/main/java/com/uwetrottmann/thetvdb/entities/LoginData.java
// public class LoginData {
//
// public String apikey;
// public String username;
// public String userkey;
//
// public LoginData(String apikey) {
// this.apikey = apikey;
// }
//
// public LoginData user(String username, String userkey) {
// this.username = username;
// this.userkey = userkey;
// return this;
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Token.java
// public class Token {
//
// public String token;
//
// }
| import com.uwetrottmann.thetvdb.entities.LoginData;
import com.uwetrottmann.thetvdb.entities.Token;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST; | package com.uwetrottmann.thetvdb.services;
public interface TheTvdbAuthentication {
String PATH_LOGIN = "login";
/**
* Returns a session token to be included in the rest of the requests. Note that API key authentication is required
* for all subsequent requests and user auth is required for routes in the User section.
*/
@POST(PATH_LOGIN) | // Path: src/main/java/com/uwetrottmann/thetvdb/entities/LoginData.java
// public class LoginData {
//
// public String apikey;
// public String username;
// public String userkey;
//
// public LoginData(String apikey) {
// this.apikey = apikey;
// }
//
// public LoginData user(String username, String userkey) {
// this.username = username;
// this.userkey = userkey;
// return this;
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/Token.java
// public class Token {
//
// public String token;
//
// }
// Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbAuthentication.java
import com.uwetrottmann.thetvdb.entities.LoginData;
import com.uwetrottmann.thetvdb.entities.Token;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
package com.uwetrottmann.thetvdb.services;
public interface TheTvdbAuthentication {
String PATH_LOGIN = "login";
/**
* Returns a session token to be included in the rest of the requests. Note that API key authentication is required
* for all subsequent requests and user auth is required for routes in the User section.
*/
@POST(PATH_LOGIN) | Call<Token> login(@Body LoginData loginData); |
UweTrottmann/thetvdb-java | src/test/java/com/uwetrottmann/thetvdb/services/TheTvdbUpdatedTest.java | // Path: src/test/java/com/uwetrottmann/thetvdb/BaseTestCase.java
// public abstract class BaseTestCase {
//
// /** <b>WARNING:</b> do not use this in your code. This is for testing purposes only. */
// protected static final String API_KEY = "0B0BB36928753CD8";
//
// private static final boolean DEBUG = true;
//
// private static final TestTheTvdb theTvdb = new TestTheTvdb(API_KEY);
//
// static class TestTheTvdb extends TheTvdb {
//
// public TestTheTvdb(String apiKey) {
// super(apiKey);
// }
//
// @Override
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// super.setOkHttpClientDefaults(builder);
// if (DEBUG) {
// // add logging, standard output is easier to read
// HttpLoggingInterceptor logging = new HttpLoggingInterceptor(System.out::println);
// logging.setLevel(HttpLoggingInterceptor.Level.BODY);
// builder.addNetworkInterceptor(logging);
// }
// }
// }
//
// @BeforeClass
// public static void setUpOnce() {
// //noinspection ConstantConditions
// if (API_KEY.length() == 0) {
// throw new IllegalArgumentException("Set a valid value for API_KEY.");
// }
// }
//
// protected final TheTvdb getTheTvdb() {
// return theTvdb;
// }
//
// /**
// * Execute call with non-Void response body.
// */
// protected <T> T executeCall(Call<T> call) throws IOException {
// Response<T> response = call.execute();
// if (!response.isSuccessful()) {
// handleFailedResponse(response);
// }
// T body = response.body();
// if (body != null) {
// return body;
// } else {
// throw new IllegalStateException("Body should not be null for successful response");
// }
// }
//
// /**
// * Execute call with Void response body.
// */
// protected <T> Response<T> executeVoidCall(Call<T> call) throws IOException {
// Response<T> response = call.execute();
// if (!response.isSuccessful()) {
// handleFailedResponse(response); // will throw error
// }
// return response;
// }
//
// /**
// * Execute call with expected failure
// */
// protected <T> Response<T> executeExpectedErrorCall(Call<T> call, int expectedErrorCode) throws IOException {
// Response<T> response = call.execute();
// if (response.code() != expectedErrorCode) {
// fail(String.format("Expected error code %d but instead got %d %s", expectedErrorCode, response.code(), response.message()));
// }
//
// return response;
// }
//
// private static void handleFailedResponse(Response response) {
// if (response.code() == 401) {
// fail(String.format("Authorization required: %d %s", response.code(), response.message()));
// } else {
// fail(String.format("Request failed: %d %s", response.code(), response.message()));
// }
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SeriesUpdate.java
// public class SeriesUpdate {
//
// public long id;
// public long lastUpdated;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SeriesUpdatesResponse.java
// public class SeriesUpdatesResponse extends ErrorResponse {
//
// public List<SeriesUpdate> data;
//
// }
| import static com.google.common.truth.Truth.assertThat;
import com.uwetrottmann.thetvdb.BaseTestCase;
import com.uwetrottmann.thetvdb.entities.SeriesUpdate;
import com.uwetrottmann.thetvdb.entities.SeriesUpdatesResponse;
import java.io.IOException;
import java.util.Calendar;
import org.junit.Test; | package com.uwetrottmann.thetvdb.services;
public class TheTvdbUpdatedTest extends BaseTestCase {
@Test
public void test_seriesUpdates() throws IOException {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, -7);
long timeWeekAgoSeconds = cal.getTimeInMillis() / 1000;
| // Path: src/test/java/com/uwetrottmann/thetvdb/BaseTestCase.java
// public abstract class BaseTestCase {
//
// /** <b>WARNING:</b> do not use this in your code. This is for testing purposes only. */
// protected static final String API_KEY = "0B0BB36928753CD8";
//
// private static final boolean DEBUG = true;
//
// private static final TestTheTvdb theTvdb = new TestTheTvdb(API_KEY);
//
// static class TestTheTvdb extends TheTvdb {
//
// public TestTheTvdb(String apiKey) {
// super(apiKey);
// }
//
// @Override
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// super.setOkHttpClientDefaults(builder);
// if (DEBUG) {
// // add logging, standard output is easier to read
// HttpLoggingInterceptor logging = new HttpLoggingInterceptor(System.out::println);
// logging.setLevel(HttpLoggingInterceptor.Level.BODY);
// builder.addNetworkInterceptor(logging);
// }
// }
// }
//
// @BeforeClass
// public static void setUpOnce() {
// //noinspection ConstantConditions
// if (API_KEY.length() == 0) {
// throw new IllegalArgumentException("Set a valid value for API_KEY.");
// }
// }
//
// protected final TheTvdb getTheTvdb() {
// return theTvdb;
// }
//
// /**
// * Execute call with non-Void response body.
// */
// protected <T> T executeCall(Call<T> call) throws IOException {
// Response<T> response = call.execute();
// if (!response.isSuccessful()) {
// handleFailedResponse(response);
// }
// T body = response.body();
// if (body != null) {
// return body;
// } else {
// throw new IllegalStateException("Body should not be null for successful response");
// }
// }
//
// /**
// * Execute call with Void response body.
// */
// protected <T> Response<T> executeVoidCall(Call<T> call) throws IOException {
// Response<T> response = call.execute();
// if (!response.isSuccessful()) {
// handleFailedResponse(response); // will throw error
// }
// return response;
// }
//
// /**
// * Execute call with expected failure
// */
// protected <T> Response<T> executeExpectedErrorCall(Call<T> call, int expectedErrorCode) throws IOException {
// Response<T> response = call.execute();
// if (response.code() != expectedErrorCode) {
// fail(String.format("Expected error code %d but instead got %d %s", expectedErrorCode, response.code(), response.message()));
// }
//
// return response;
// }
//
// private static void handleFailedResponse(Response response) {
// if (response.code() == 401) {
// fail(String.format("Authorization required: %d %s", response.code(), response.message()));
// } else {
// fail(String.format("Request failed: %d %s", response.code(), response.message()));
// }
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SeriesUpdate.java
// public class SeriesUpdate {
//
// public long id;
// public long lastUpdated;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SeriesUpdatesResponse.java
// public class SeriesUpdatesResponse extends ErrorResponse {
//
// public List<SeriesUpdate> data;
//
// }
// Path: src/test/java/com/uwetrottmann/thetvdb/services/TheTvdbUpdatedTest.java
import static com.google.common.truth.Truth.assertThat;
import com.uwetrottmann.thetvdb.BaseTestCase;
import com.uwetrottmann.thetvdb.entities.SeriesUpdate;
import com.uwetrottmann.thetvdb.entities.SeriesUpdatesResponse;
import java.io.IOException;
import java.util.Calendar;
import org.junit.Test;
package com.uwetrottmann.thetvdb.services;
public class TheTvdbUpdatedTest extends BaseTestCase {
@Test
public void test_seriesUpdates() throws IOException {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, -7);
long timeWeekAgoSeconds = cal.getTimeInMillis() / 1000;
| SeriesUpdatesResponse response = executeCall(getTheTvdb().updated().seriesUpdates(timeWeekAgoSeconds, null)); |
UweTrottmann/thetvdb-java | src/test/java/com/uwetrottmann/thetvdb/services/TheTvdbUpdatedTest.java | // Path: src/test/java/com/uwetrottmann/thetvdb/BaseTestCase.java
// public abstract class BaseTestCase {
//
// /** <b>WARNING:</b> do not use this in your code. This is for testing purposes only. */
// protected static final String API_KEY = "0B0BB36928753CD8";
//
// private static final boolean DEBUG = true;
//
// private static final TestTheTvdb theTvdb = new TestTheTvdb(API_KEY);
//
// static class TestTheTvdb extends TheTvdb {
//
// public TestTheTvdb(String apiKey) {
// super(apiKey);
// }
//
// @Override
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// super.setOkHttpClientDefaults(builder);
// if (DEBUG) {
// // add logging, standard output is easier to read
// HttpLoggingInterceptor logging = new HttpLoggingInterceptor(System.out::println);
// logging.setLevel(HttpLoggingInterceptor.Level.BODY);
// builder.addNetworkInterceptor(logging);
// }
// }
// }
//
// @BeforeClass
// public static void setUpOnce() {
// //noinspection ConstantConditions
// if (API_KEY.length() == 0) {
// throw new IllegalArgumentException("Set a valid value for API_KEY.");
// }
// }
//
// protected final TheTvdb getTheTvdb() {
// return theTvdb;
// }
//
// /**
// * Execute call with non-Void response body.
// */
// protected <T> T executeCall(Call<T> call) throws IOException {
// Response<T> response = call.execute();
// if (!response.isSuccessful()) {
// handleFailedResponse(response);
// }
// T body = response.body();
// if (body != null) {
// return body;
// } else {
// throw new IllegalStateException("Body should not be null for successful response");
// }
// }
//
// /**
// * Execute call with Void response body.
// */
// protected <T> Response<T> executeVoidCall(Call<T> call) throws IOException {
// Response<T> response = call.execute();
// if (!response.isSuccessful()) {
// handleFailedResponse(response); // will throw error
// }
// return response;
// }
//
// /**
// * Execute call with expected failure
// */
// protected <T> Response<T> executeExpectedErrorCall(Call<T> call, int expectedErrorCode) throws IOException {
// Response<T> response = call.execute();
// if (response.code() != expectedErrorCode) {
// fail(String.format("Expected error code %d but instead got %d %s", expectedErrorCode, response.code(), response.message()));
// }
//
// return response;
// }
//
// private static void handleFailedResponse(Response response) {
// if (response.code() == 401) {
// fail(String.format("Authorization required: %d %s", response.code(), response.message()));
// } else {
// fail(String.format("Request failed: %d %s", response.code(), response.message()));
// }
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SeriesUpdate.java
// public class SeriesUpdate {
//
// public long id;
// public long lastUpdated;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SeriesUpdatesResponse.java
// public class SeriesUpdatesResponse extends ErrorResponse {
//
// public List<SeriesUpdate> data;
//
// }
| import static com.google.common.truth.Truth.assertThat;
import com.uwetrottmann.thetvdb.BaseTestCase;
import com.uwetrottmann.thetvdb.entities.SeriesUpdate;
import com.uwetrottmann.thetvdb.entities.SeriesUpdatesResponse;
import java.io.IOException;
import java.util.Calendar;
import org.junit.Test; | package com.uwetrottmann.thetvdb.services;
public class TheTvdbUpdatedTest extends BaseTestCase {
@Test
public void test_seriesUpdates() throws IOException {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, -7);
long timeWeekAgoSeconds = cal.getTimeInMillis() / 1000;
SeriesUpdatesResponse response = executeCall(getTheTvdb().updated().seriesUpdates(timeWeekAgoSeconds, null));
assertThat(response.data).isNotNull();
assertThat(response.data).isNotEmpty(); // there have to be some updates over the last 7 days | // Path: src/test/java/com/uwetrottmann/thetvdb/BaseTestCase.java
// public abstract class BaseTestCase {
//
// /** <b>WARNING:</b> do not use this in your code. This is for testing purposes only. */
// protected static final String API_KEY = "0B0BB36928753CD8";
//
// private static final boolean DEBUG = true;
//
// private static final TestTheTvdb theTvdb = new TestTheTvdb(API_KEY);
//
// static class TestTheTvdb extends TheTvdb {
//
// public TestTheTvdb(String apiKey) {
// super(apiKey);
// }
//
// @Override
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// super.setOkHttpClientDefaults(builder);
// if (DEBUG) {
// // add logging, standard output is easier to read
// HttpLoggingInterceptor logging = new HttpLoggingInterceptor(System.out::println);
// logging.setLevel(HttpLoggingInterceptor.Level.BODY);
// builder.addNetworkInterceptor(logging);
// }
// }
// }
//
// @BeforeClass
// public static void setUpOnce() {
// //noinspection ConstantConditions
// if (API_KEY.length() == 0) {
// throw new IllegalArgumentException("Set a valid value for API_KEY.");
// }
// }
//
// protected final TheTvdb getTheTvdb() {
// return theTvdb;
// }
//
// /**
// * Execute call with non-Void response body.
// */
// protected <T> T executeCall(Call<T> call) throws IOException {
// Response<T> response = call.execute();
// if (!response.isSuccessful()) {
// handleFailedResponse(response);
// }
// T body = response.body();
// if (body != null) {
// return body;
// } else {
// throw new IllegalStateException("Body should not be null for successful response");
// }
// }
//
// /**
// * Execute call with Void response body.
// */
// protected <T> Response<T> executeVoidCall(Call<T> call) throws IOException {
// Response<T> response = call.execute();
// if (!response.isSuccessful()) {
// handleFailedResponse(response); // will throw error
// }
// return response;
// }
//
// /**
// * Execute call with expected failure
// */
// protected <T> Response<T> executeExpectedErrorCall(Call<T> call, int expectedErrorCode) throws IOException {
// Response<T> response = call.execute();
// if (response.code() != expectedErrorCode) {
// fail(String.format("Expected error code %d but instead got %d %s", expectedErrorCode, response.code(), response.message()));
// }
//
// return response;
// }
//
// private static void handleFailedResponse(Response response) {
// if (response.code() == 401) {
// fail(String.format("Authorization required: %d %s", response.code(), response.message()));
// } else {
// fail(String.format("Request failed: %d %s", response.code(), response.message()));
// }
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SeriesUpdate.java
// public class SeriesUpdate {
//
// public long id;
// public long lastUpdated;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SeriesUpdatesResponse.java
// public class SeriesUpdatesResponse extends ErrorResponse {
//
// public List<SeriesUpdate> data;
//
// }
// Path: src/test/java/com/uwetrottmann/thetvdb/services/TheTvdbUpdatedTest.java
import static com.google.common.truth.Truth.assertThat;
import com.uwetrottmann.thetvdb.BaseTestCase;
import com.uwetrottmann.thetvdb.entities.SeriesUpdate;
import com.uwetrottmann.thetvdb.entities.SeriesUpdatesResponse;
import java.io.IOException;
import java.util.Calendar;
import org.junit.Test;
package com.uwetrottmann.thetvdb.services;
public class TheTvdbUpdatedTest extends BaseTestCase {
@Test
public void test_seriesUpdates() throws IOException {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, -7);
long timeWeekAgoSeconds = cal.getTimeInMillis() / 1000;
SeriesUpdatesResponse response = executeCall(getTheTvdb().updated().seriesUpdates(timeWeekAgoSeconds, null));
assertThat(response.data).isNotNull();
assertThat(response.data).isNotEmpty(); // there have to be some updates over the last 7 days | for (SeriesUpdate update : response.data) { |
UweTrottmann/thetvdb-java | src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbLanguages.java | // Path: src/main/java/com/uwetrottmann/thetvdb/entities/LanguagesResponse.java
// public class LanguagesResponse {
//
// public List<Language> data;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/LanguageResponse.java
// public class LanguageResponse {
//
// public Language data;
//
// }
| import com.uwetrottmann.thetvdb.entities.LanguagesResponse;
import com.uwetrottmann.thetvdb.entities.LanguageResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path; | package com.uwetrottmann.thetvdb.services;
public interface TheTvdbLanguages {
/**
* All available languages. These language abbreviations can be used in the Accept-Language header for routes that
* return translation records.
*/
@GET("languages") | // Path: src/main/java/com/uwetrottmann/thetvdb/entities/LanguagesResponse.java
// public class LanguagesResponse {
//
// public List<Language> data;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/LanguageResponse.java
// public class LanguageResponse {
//
// public Language data;
//
// }
// Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbLanguages.java
import com.uwetrottmann.thetvdb.entities.LanguagesResponse;
import com.uwetrottmann.thetvdb.entities.LanguageResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
package com.uwetrottmann.thetvdb.services;
public interface TheTvdbLanguages {
/**
* All available languages. These language abbreviations can be used in the Accept-Language header for routes that
* return translation records.
*/
@GET("languages") | Call<LanguagesResponse> allAvailable(); |
UweTrottmann/thetvdb-java | src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbLanguages.java | // Path: src/main/java/com/uwetrottmann/thetvdb/entities/LanguagesResponse.java
// public class LanguagesResponse {
//
// public List<Language> data;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/LanguageResponse.java
// public class LanguageResponse {
//
// public Language data;
//
// }
| import com.uwetrottmann.thetvdb.entities.LanguagesResponse;
import com.uwetrottmann.thetvdb.entities.LanguageResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path; | package com.uwetrottmann.thetvdb.services;
public interface TheTvdbLanguages {
/**
* All available languages. These language abbreviations can be used in the Accept-Language header for routes that
* return translation records.
*/
@GET("languages")
Call<LanguagesResponse> allAvailable();
/**
* Information about a particular language, given the language ID.
*/
@GET("languages/{id}") | // Path: src/main/java/com/uwetrottmann/thetvdb/entities/LanguagesResponse.java
// public class LanguagesResponse {
//
// public List<Language> data;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/LanguageResponse.java
// public class LanguageResponse {
//
// public Language data;
//
// }
// Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbLanguages.java
import com.uwetrottmann.thetvdb.entities.LanguagesResponse;
import com.uwetrottmann.thetvdb.entities.LanguageResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
package com.uwetrottmann.thetvdb.services;
public interface TheTvdbLanguages {
/**
* All available languages. These language abbreviations can be used in the Accept-Language header for routes that
* return translation records.
*/
@GET("languages")
Call<LanguagesResponse> allAvailable();
/**
* Information about a particular language, given the language ID.
*/
@GET("languages/{id}") | Call<LanguageResponse> languageDetails(@Path("id") int id); |
UweTrottmann/thetvdb-java | src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbSearch.java | // Path: src/main/java/com/uwetrottmann/thetvdb/TheTvdb.java
// @SuppressWarnings("WeakerAccess")
// public class TheTvdb {
//
// public static final String API_HOST = "api.thetvdb.com";
// public static final String API_URL = "https://" + API_HOST + "/";
//
// public static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language";
// public static final String HEADER_AUTHORIZATION = "Authorization";
//
// @Nullable private OkHttpClient okHttpClient;
// @Nullable private Retrofit retrofit;
//
// private String apiKey;
// @Nullable private String currentJsonWebToken;
//
// /**
// * Create a new manager instance.
// */
// public TheTvdb(String apiKey) {
// this.apiKey = apiKey;
// }
//
// public String apiKey() {
// return apiKey;
// }
//
// public void apiKey(String apiKey) {
// this.apiKey = apiKey;
// }
//
// @Nullable
// public String jsonWebToken() {
// return currentJsonWebToken;
// }
//
// public void jsonWebToken(@Nullable String value) {
// this.currentJsonWebToken = value;
// }
//
// /**
// * Creates a {@link Retrofit.Builder} that sets the base URL, adds a Gson converter and sets {@link
// * #okHttpClient()} as its client.
// *
// * @see #okHttpClient()
// */
// protected Retrofit.Builder retrofitBuilder() {
// return new Retrofit.Builder()
// .baseUrl(API_URL)
// .addConverterFactory(GsonConverterFactory.create())
// .client(okHttpClient());
// }
//
// /**
// * Returns the default OkHttp client instance. It is strongly recommended to override this and use your app
// * instance.
// *
// * @see #setOkHttpClientDefaults(OkHttpClient.Builder)
// */
// protected synchronized OkHttpClient okHttpClient() {
// if (okHttpClient == null) {
// OkHttpClient.Builder builder = new OkHttpClient.Builder();
// setOkHttpClientDefaults(builder);
// okHttpClient = builder.build();
// }
// return okHttpClient;
// }
//
// /**
// * Adds a network interceptor to add version and auth headers and
// * an authenticator to automatically login using the API key.
// */
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// builder.addNetworkInterceptor(new TheTvdbInterceptor(this))
// .authenticator(new TheTvdbAuthenticator(this));
// }
//
// /**
// * Return the {@link Retrofit} instance. If called for the first time builds the instance.
// */
// protected Retrofit getRetrofit() {
// if (retrofit == null) {
// retrofit = retrofitBuilder().build();
// }
// return retrofit;
// }
//
// /**
// * Obtaining and refreshing your JWT token.
// */
// public TheTvdbAuthentication authentication() {
// return getRetrofit().create(TheTvdbAuthentication.class);
// }
//
// /**
// * Information about a specific episode.
// */
// public TheTvdbEpisodes episodes() {
// return getRetrofit().create(TheTvdbEpisodes.class);
// }
//
// /**
// * Available languages and information.
// */
// public TheTvdbLanguages languages() {
// return getRetrofit().create(TheTvdbLanguages.class);
// }
//
// /**
// * Information about a specific series.
// */
// public TheTvdbSeries series() {
// return getRetrofit().create(TheTvdbSeries.class);
// }
//
// /**
// * Search for a particular series.
// */
// public TheTvdbSearch search() {
// return getRetrofit().create(TheTvdbSearch.class);
// }
//
// /**
// * Retrieve series which were recently updated.
// */
// public TheTvdbUpdated updated() {
// return getRetrofit().create(TheTvdbUpdated.class);
// }
//
// /**
// * Routes for handling user data.
// */
// public TheTvdbUser user() {
// return getRetrofit().create(TheTvdbUser.class);
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SearchParamsResponse.java
// public class SearchParamsResponse {
//
// public SearchParams data;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SeriesResultsResponse.java
// public class SeriesResultsResponse {
//
// public List<Series> data;
//
// }
| import com.uwetrottmann.thetvdb.TheTvdb;
import com.uwetrottmann.thetvdb.entities.SearchParamsResponse;
import com.uwetrottmann.thetvdb.entities.SeriesResultsResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Query; | package com.uwetrottmann.thetvdb.services;
public interface TheTvdbSearch {
/**
* Allows the user to search for a series based on the following parameters.
*
* @param name Name of the series to search for.
*/
@GET("search/series") | // Path: src/main/java/com/uwetrottmann/thetvdb/TheTvdb.java
// @SuppressWarnings("WeakerAccess")
// public class TheTvdb {
//
// public static final String API_HOST = "api.thetvdb.com";
// public static final String API_URL = "https://" + API_HOST + "/";
//
// public static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language";
// public static final String HEADER_AUTHORIZATION = "Authorization";
//
// @Nullable private OkHttpClient okHttpClient;
// @Nullable private Retrofit retrofit;
//
// private String apiKey;
// @Nullable private String currentJsonWebToken;
//
// /**
// * Create a new manager instance.
// */
// public TheTvdb(String apiKey) {
// this.apiKey = apiKey;
// }
//
// public String apiKey() {
// return apiKey;
// }
//
// public void apiKey(String apiKey) {
// this.apiKey = apiKey;
// }
//
// @Nullable
// public String jsonWebToken() {
// return currentJsonWebToken;
// }
//
// public void jsonWebToken(@Nullable String value) {
// this.currentJsonWebToken = value;
// }
//
// /**
// * Creates a {@link Retrofit.Builder} that sets the base URL, adds a Gson converter and sets {@link
// * #okHttpClient()} as its client.
// *
// * @see #okHttpClient()
// */
// protected Retrofit.Builder retrofitBuilder() {
// return new Retrofit.Builder()
// .baseUrl(API_URL)
// .addConverterFactory(GsonConverterFactory.create())
// .client(okHttpClient());
// }
//
// /**
// * Returns the default OkHttp client instance. It is strongly recommended to override this and use your app
// * instance.
// *
// * @see #setOkHttpClientDefaults(OkHttpClient.Builder)
// */
// protected synchronized OkHttpClient okHttpClient() {
// if (okHttpClient == null) {
// OkHttpClient.Builder builder = new OkHttpClient.Builder();
// setOkHttpClientDefaults(builder);
// okHttpClient = builder.build();
// }
// return okHttpClient;
// }
//
// /**
// * Adds a network interceptor to add version and auth headers and
// * an authenticator to automatically login using the API key.
// */
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// builder.addNetworkInterceptor(new TheTvdbInterceptor(this))
// .authenticator(new TheTvdbAuthenticator(this));
// }
//
// /**
// * Return the {@link Retrofit} instance. If called for the first time builds the instance.
// */
// protected Retrofit getRetrofit() {
// if (retrofit == null) {
// retrofit = retrofitBuilder().build();
// }
// return retrofit;
// }
//
// /**
// * Obtaining and refreshing your JWT token.
// */
// public TheTvdbAuthentication authentication() {
// return getRetrofit().create(TheTvdbAuthentication.class);
// }
//
// /**
// * Information about a specific episode.
// */
// public TheTvdbEpisodes episodes() {
// return getRetrofit().create(TheTvdbEpisodes.class);
// }
//
// /**
// * Available languages and information.
// */
// public TheTvdbLanguages languages() {
// return getRetrofit().create(TheTvdbLanguages.class);
// }
//
// /**
// * Information about a specific series.
// */
// public TheTvdbSeries series() {
// return getRetrofit().create(TheTvdbSeries.class);
// }
//
// /**
// * Search for a particular series.
// */
// public TheTvdbSearch search() {
// return getRetrofit().create(TheTvdbSearch.class);
// }
//
// /**
// * Retrieve series which were recently updated.
// */
// public TheTvdbUpdated updated() {
// return getRetrofit().create(TheTvdbUpdated.class);
// }
//
// /**
// * Routes for handling user data.
// */
// public TheTvdbUser user() {
// return getRetrofit().create(TheTvdbUser.class);
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SearchParamsResponse.java
// public class SearchParamsResponse {
//
// public SearchParams data;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SeriesResultsResponse.java
// public class SeriesResultsResponse {
//
// public List<Series> data;
//
// }
// Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbSearch.java
import com.uwetrottmann.thetvdb.TheTvdb;
import com.uwetrottmann.thetvdb.entities.SearchParamsResponse;
import com.uwetrottmann.thetvdb.entities.SeriesResultsResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Query;
package com.uwetrottmann.thetvdb.services;
public interface TheTvdbSearch {
/**
* Allows the user to search for a series based on the following parameters.
*
* @param name Name of the series to search for.
*/
@GET("search/series") | Call<SeriesResultsResponse> series( |
UweTrottmann/thetvdb-java | src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbSearch.java | // Path: src/main/java/com/uwetrottmann/thetvdb/TheTvdb.java
// @SuppressWarnings("WeakerAccess")
// public class TheTvdb {
//
// public static final String API_HOST = "api.thetvdb.com";
// public static final String API_URL = "https://" + API_HOST + "/";
//
// public static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language";
// public static final String HEADER_AUTHORIZATION = "Authorization";
//
// @Nullable private OkHttpClient okHttpClient;
// @Nullable private Retrofit retrofit;
//
// private String apiKey;
// @Nullable private String currentJsonWebToken;
//
// /**
// * Create a new manager instance.
// */
// public TheTvdb(String apiKey) {
// this.apiKey = apiKey;
// }
//
// public String apiKey() {
// return apiKey;
// }
//
// public void apiKey(String apiKey) {
// this.apiKey = apiKey;
// }
//
// @Nullable
// public String jsonWebToken() {
// return currentJsonWebToken;
// }
//
// public void jsonWebToken(@Nullable String value) {
// this.currentJsonWebToken = value;
// }
//
// /**
// * Creates a {@link Retrofit.Builder} that sets the base URL, adds a Gson converter and sets {@link
// * #okHttpClient()} as its client.
// *
// * @see #okHttpClient()
// */
// protected Retrofit.Builder retrofitBuilder() {
// return new Retrofit.Builder()
// .baseUrl(API_URL)
// .addConverterFactory(GsonConverterFactory.create())
// .client(okHttpClient());
// }
//
// /**
// * Returns the default OkHttp client instance. It is strongly recommended to override this and use your app
// * instance.
// *
// * @see #setOkHttpClientDefaults(OkHttpClient.Builder)
// */
// protected synchronized OkHttpClient okHttpClient() {
// if (okHttpClient == null) {
// OkHttpClient.Builder builder = new OkHttpClient.Builder();
// setOkHttpClientDefaults(builder);
// okHttpClient = builder.build();
// }
// return okHttpClient;
// }
//
// /**
// * Adds a network interceptor to add version and auth headers and
// * an authenticator to automatically login using the API key.
// */
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// builder.addNetworkInterceptor(new TheTvdbInterceptor(this))
// .authenticator(new TheTvdbAuthenticator(this));
// }
//
// /**
// * Return the {@link Retrofit} instance. If called for the first time builds the instance.
// */
// protected Retrofit getRetrofit() {
// if (retrofit == null) {
// retrofit = retrofitBuilder().build();
// }
// return retrofit;
// }
//
// /**
// * Obtaining and refreshing your JWT token.
// */
// public TheTvdbAuthentication authentication() {
// return getRetrofit().create(TheTvdbAuthentication.class);
// }
//
// /**
// * Information about a specific episode.
// */
// public TheTvdbEpisodes episodes() {
// return getRetrofit().create(TheTvdbEpisodes.class);
// }
//
// /**
// * Available languages and information.
// */
// public TheTvdbLanguages languages() {
// return getRetrofit().create(TheTvdbLanguages.class);
// }
//
// /**
// * Information about a specific series.
// */
// public TheTvdbSeries series() {
// return getRetrofit().create(TheTvdbSeries.class);
// }
//
// /**
// * Search for a particular series.
// */
// public TheTvdbSearch search() {
// return getRetrofit().create(TheTvdbSearch.class);
// }
//
// /**
// * Retrieve series which were recently updated.
// */
// public TheTvdbUpdated updated() {
// return getRetrofit().create(TheTvdbUpdated.class);
// }
//
// /**
// * Routes for handling user data.
// */
// public TheTvdbUser user() {
// return getRetrofit().create(TheTvdbUser.class);
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SearchParamsResponse.java
// public class SearchParamsResponse {
//
// public SearchParams data;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SeriesResultsResponse.java
// public class SeriesResultsResponse {
//
// public List<Series> data;
//
// }
| import com.uwetrottmann.thetvdb.TheTvdb;
import com.uwetrottmann.thetvdb.entities.SearchParamsResponse;
import com.uwetrottmann.thetvdb.entities.SeriesResultsResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Query; | package com.uwetrottmann.thetvdb.services;
public interface TheTvdbSearch {
/**
* Allows the user to search for a series based on the following parameters.
*
* @param name Name of the series to search for.
*/
@GET("search/series")
Call<SeriesResultsResponse> series(
@Query("name") String name,
@Query("imdbId") String imdbId,
@Query("zap2itId") String zap2itId,
@Query("slug") String slug, | // Path: src/main/java/com/uwetrottmann/thetvdb/TheTvdb.java
// @SuppressWarnings("WeakerAccess")
// public class TheTvdb {
//
// public static final String API_HOST = "api.thetvdb.com";
// public static final String API_URL = "https://" + API_HOST + "/";
//
// public static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language";
// public static final String HEADER_AUTHORIZATION = "Authorization";
//
// @Nullable private OkHttpClient okHttpClient;
// @Nullable private Retrofit retrofit;
//
// private String apiKey;
// @Nullable private String currentJsonWebToken;
//
// /**
// * Create a new manager instance.
// */
// public TheTvdb(String apiKey) {
// this.apiKey = apiKey;
// }
//
// public String apiKey() {
// return apiKey;
// }
//
// public void apiKey(String apiKey) {
// this.apiKey = apiKey;
// }
//
// @Nullable
// public String jsonWebToken() {
// return currentJsonWebToken;
// }
//
// public void jsonWebToken(@Nullable String value) {
// this.currentJsonWebToken = value;
// }
//
// /**
// * Creates a {@link Retrofit.Builder} that sets the base URL, adds a Gson converter and sets {@link
// * #okHttpClient()} as its client.
// *
// * @see #okHttpClient()
// */
// protected Retrofit.Builder retrofitBuilder() {
// return new Retrofit.Builder()
// .baseUrl(API_URL)
// .addConverterFactory(GsonConverterFactory.create())
// .client(okHttpClient());
// }
//
// /**
// * Returns the default OkHttp client instance. It is strongly recommended to override this and use your app
// * instance.
// *
// * @see #setOkHttpClientDefaults(OkHttpClient.Builder)
// */
// protected synchronized OkHttpClient okHttpClient() {
// if (okHttpClient == null) {
// OkHttpClient.Builder builder = new OkHttpClient.Builder();
// setOkHttpClientDefaults(builder);
// okHttpClient = builder.build();
// }
// return okHttpClient;
// }
//
// /**
// * Adds a network interceptor to add version and auth headers and
// * an authenticator to automatically login using the API key.
// */
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// builder.addNetworkInterceptor(new TheTvdbInterceptor(this))
// .authenticator(new TheTvdbAuthenticator(this));
// }
//
// /**
// * Return the {@link Retrofit} instance. If called for the first time builds the instance.
// */
// protected Retrofit getRetrofit() {
// if (retrofit == null) {
// retrofit = retrofitBuilder().build();
// }
// return retrofit;
// }
//
// /**
// * Obtaining and refreshing your JWT token.
// */
// public TheTvdbAuthentication authentication() {
// return getRetrofit().create(TheTvdbAuthentication.class);
// }
//
// /**
// * Information about a specific episode.
// */
// public TheTvdbEpisodes episodes() {
// return getRetrofit().create(TheTvdbEpisodes.class);
// }
//
// /**
// * Available languages and information.
// */
// public TheTvdbLanguages languages() {
// return getRetrofit().create(TheTvdbLanguages.class);
// }
//
// /**
// * Information about a specific series.
// */
// public TheTvdbSeries series() {
// return getRetrofit().create(TheTvdbSeries.class);
// }
//
// /**
// * Search for a particular series.
// */
// public TheTvdbSearch search() {
// return getRetrofit().create(TheTvdbSearch.class);
// }
//
// /**
// * Retrieve series which were recently updated.
// */
// public TheTvdbUpdated updated() {
// return getRetrofit().create(TheTvdbUpdated.class);
// }
//
// /**
// * Routes for handling user data.
// */
// public TheTvdbUser user() {
// return getRetrofit().create(TheTvdbUser.class);
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SearchParamsResponse.java
// public class SearchParamsResponse {
//
// public SearchParams data;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SeriesResultsResponse.java
// public class SeriesResultsResponse {
//
// public List<Series> data;
//
// }
// Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbSearch.java
import com.uwetrottmann.thetvdb.TheTvdb;
import com.uwetrottmann.thetvdb.entities.SearchParamsResponse;
import com.uwetrottmann.thetvdb.entities.SeriesResultsResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Query;
package com.uwetrottmann.thetvdb.services;
public interface TheTvdbSearch {
/**
* Allows the user to search for a series based on the following parameters.
*
* @param name Name of the series to search for.
*/
@GET("search/series")
Call<SeriesResultsResponse> series(
@Query("name") String name,
@Query("imdbId") String imdbId,
@Query("zap2itId") String zap2itId,
@Query("slug") String slug, | @Header(TheTvdb.HEADER_ACCEPT_LANGUAGE) String languages |
UweTrottmann/thetvdb-java | src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbSearch.java | // Path: src/main/java/com/uwetrottmann/thetvdb/TheTvdb.java
// @SuppressWarnings("WeakerAccess")
// public class TheTvdb {
//
// public static final String API_HOST = "api.thetvdb.com";
// public static final String API_URL = "https://" + API_HOST + "/";
//
// public static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language";
// public static final String HEADER_AUTHORIZATION = "Authorization";
//
// @Nullable private OkHttpClient okHttpClient;
// @Nullable private Retrofit retrofit;
//
// private String apiKey;
// @Nullable private String currentJsonWebToken;
//
// /**
// * Create a new manager instance.
// */
// public TheTvdb(String apiKey) {
// this.apiKey = apiKey;
// }
//
// public String apiKey() {
// return apiKey;
// }
//
// public void apiKey(String apiKey) {
// this.apiKey = apiKey;
// }
//
// @Nullable
// public String jsonWebToken() {
// return currentJsonWebToken;
// }
//
// public void jsonWebToken(@Nullable String value) {
// this.currentJsonWebToken = value;
// }
//
// /**
// * Creates a {@link Retrofit.Builder} that sets the base URL, adds a Gson converter and sets {@link
// * #okHttpClient()} as its client.
// *
// * @see #okHttpClient()
// */
// protected Retrofit.Builder retrofitBuilder() {
// return new Retrofit.Builder()
// .baseUrl(API_URL)
// .addConverterFactory(GsonConverterFactory.create())
// .client(okHttpClient());
// }
//
// /**
// * Returns the default OkHttp client instance. It is strongly recommended to override this and use your app
// * instance.
// *
// * @see #setOkHttpClientDefaults(OkHttpClient.Builder)
// */
// protected synchronized OkHttpClient okHttpClient() {
// if (okHttpClient == null) {
// OkHttpClient.Builder builder = new OkHttpClient.Builder();
// setOkHttpClientDefaults(builder);
// okHttpClient = builder.build();
// }
// return okHttpClient;
// }
//
// /**
// * Adds a network interceptor to add version and auth headers and
// * an authenticator to automatically login using the API key.
// */
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// builder.addNetworkInterceptor(new TheTvdbInterceptor(this))
// .authenticator(new TheTvdbAuthenticator(this));
// }
//
// /**
// * Return the {@link Retrofit} instance. If called for the first time builds the instance.
// */
// protected Retrofit getRetrofit() {
// if (retrofit == null) {
// retrofit = retrofitBuilder().build();
// }
// return retrofit;
// }
//
// /**
// * Obtaining and refreshing your JWT token.
// */
// public TheTvdbAuthentication authentication() {
// return getRetrofit().create(TheTvdbAuthentication.class);
// }
//
// /**
// * Information about a specific episode.
// */
// public TheTvdbEpisodes episodes() {
// return getRetrofit().create(TheTvdbEpisodes.class);
// }
//
// /**
// * Available languages and information.
// */
// public TheTvdbLanguages languages() {
// return getRetrofit().create(TheTvdbLanguages.class);
// }
//
// /**
// * Information about a specific series.
// */
// public TheTvdbSeries series() {
// return getRetrofit().create(TheTvdbSeries.class);
// }
//
// /**
// * Search for a particular series.
// */
// public TheTvdbSearch search() {
// return getRetrofit().create(TheTvdbSearch.class);
// }
//
// /**
// * Retrieve series which were recently updated.
// */
// public TheTvdbUpdated updated() {
// return getRetrofit().create(TheTvdbUpdated.class);
// }
//
// /**
// * Routes for handling user data.
// */
// public TheTvdbUser user() {
// return getRetrofit().create(TheTvdbUser.class);
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SearchParamsResponse.java
// public class SearchParamsResponse {
//
// public SearchParams data;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SeriesResultsResponse.java
// public class SeriesResultsResponse {
//
// public List<Series> data;
//
// }
| import com.uwetrottmann.thetvdb.TheTvdb;
import com.uwetrottmann.thetvdb.entities.SearchParamsResponse;
import com.uwetrottmann.thetvdb.entities.SeriesResultsResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Query; | package com.uwetrottmann.thetvdb.services;
public interface TheTvdbSearch {
/**
* Allows the user to search for a series based on the following parameters.
*
* @param name Name of the series to search for.
*/
@GET("search/series")
Call<SeriesResultsResponse> series(
@Query("name") String name,
@Query("imdbId") String imdbId,
@Query("zap2itId") String zap2itId,
@Query("slug") String slug,
@Header(TheTvdb.HEADER_ACCEPT_LANGUAGE) String languages
);
@GET("search/series/params") | // Path: src/main/java/com/uwetrottmann/thetvdb/TheTvdb.java
// @SuppressWarnings("WeakerAccess")
// public class TheTvdb {
//
// public static final String API_HOST = "api.thetvdb.com";
// public static final String API_URL = "https://" + API_HOST + "/";
//
// public static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language";
// public static final String HEADER_AUTHORIZATION = "Authorization";
//
// @Nullable private OkHttpClient okHttpClient;
// @Nullable private Retrofit retrofit;
//
// private String apiKey;
// @Nullable private String currentJsonWebToken;
//
// /**
// * Create a new manager instance.
// */
// public TheTvdb(String apiKey) {
// this.apiKey = apiKey;
// }
//
// public String apiKey() {
// return apiKey;
// }
//
// public void apiKey(String apiKey) {
// this.apiKey = apiKey;
// }
//
// @Nullable
// public String jsonWebToken() {
// return currentJsonWebToken;
// }
//
// public void jsonWebToken(@Nullable String value) {
// this.currentJsonWebToken = value;
// }
//
// /**
// * Creates a {@link Retrofit.Builder} that sets the base URL, adds a Gson converter and sets {@link
// * #okHttpClient()} as its client.
// *
// * @see #okHttpClient()
// */
// protected Retrofit.Builder retrofitBuilder() {
// return new Retrofit.Builder()
// .baseUrl(API_URL)
// .addConverterFactory(GsonConverterFactory.create())
// .client(okHttpClient());
// }
//
// /**
// * Returns the default OkHttp client instance. It is strongly recommended to override this and use your app
// * instance.
// *
// * @see #setOkHttpClientDefaults(OkHttpClient.Builder)
// */
// protected synchronized OkHttpClient okHttpClient() {
// if (okHttpClient == null) {
// OkHttpClient.Builder builder = new OkHttpClient.Builder();
// setOkHttpClientDefaults(builder);
// okHttpClient = builder.build();
// }
// return okHttpClient;
// }
//
// /**
// * Adds a network interceptor to add version and auth headers and
// * an authenticator to automatically login using the API key.
// */
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// builder.addNetworkInterceptor(new TheTvdbInterceptor(this))
// .authenticator(new TheTvdbAuthenticator(this));
// }
//
// /**
// * Return the {@link Retrofit} instance. If called for the first time builds the instance.
// */
// protected Retrofit getRetrofit() {
// if (retrofit == null) {
// retrofit = retrofitBuilder().build();
// }
// return retrofit;
// }
//
// /**
// * Obtaining and refreshing your JWT token.
// */
// public TheTvdbAuthentication authentication() {
// return getRetrofit().create(TheTvdbAuthentication.class);
// }
//
// /**
// * Information about a specific episode.
// */
// public TheTvdbEpisodes episodes() {
// return getRetrofit().create(TheTvdbEpisodes.class);
// }
//
// /**
// * Available languages and information.
// */
// public TheTvdbLanguages languages() {
// return getRetrofit().create(TheTvdbLanguages.class);
// }
//
// /**
// * Information about a specific series.
// */
// public TheTvdbSeries series() {
// return getRetrofit().create(TheTvdbSeries.class);
// }
//
// /**
// * Search for a particular series.
// */
// public TheTvdbSearch search() {
// return getRetrofit().create(TheTvdbSearch.class);
// }
//
// /**
// * Retrieve series which were recently updated.
// */
// public TheTvdbUpdated updated() {
// return getRetrofit().create(TheTvdbUpdated.class);
// }
//
// /**
// * Routes for handling user data.
// */
// public TheTvdbUser user() {
// return getRetrofit().create(TheTvdbUser.class);
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SearchParamsResponse.java
// public class SearchParamsResponse {
//
// public SearchParams data;
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/SeriesResultsResponse.java
// public class SeriesResultsResponse {
//
// public List<Series> data;
//
// }
// Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbSearch.java
import com.uwetrottmann.thetvdb.TheTvdb;
import com.uwetrottmann.thetvdb.entities.SearchParamsResponse;
import com.uwetrottmann.thetvdb.entities.SeriesResultsResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Query;
package com.uwetrottmann.thetvdb.services;
public interface TheTvdbSearch {
/**
* Allows the user to search for a series based on the following parameters.
*
* @param name Name of the series to search for.
*/
@GET("search/series")
Call<SeriesResultsResponse> series(
@Query("name") String name,
@Query("imdbId") String imdbId,
@Query("zap2itId") String zap2itId,
@Query("slug") String slug,
@Header(TheTvdb.HEADER_ACCEPT_LANGUAGE) String languages
);
@GET("search/series/params") | Call<SearchParamsResponse> params(); |
UweTrottmann/thetvdb-java | src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbEpisodes.java | // Path: src/main/java/com/uwetrottmann/thetvdb/TheTvdb.java
// @SuppressWarnings("WeakerAccess")
// public class TheTvdb {
//
// public static final String API_HOST = "api.thetvdb.com";
// public static final String API_URL = "https://" + API_HOST + "/";
//
// public static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language";
// public static final String HEADER_AUTHORIZATION = "Authorization";
//
// @Nullable private OkHttpClient okHttpClient;
// @Nullable private Retrofit retrofit;
//
// private String apiKey;
// @Nullable private String currentJsonWebToken;
//
// /**
// * Create a new manager instance.
// */
// public TheTvdb(String apiKey) {
// this.apiKey = apiKey;
// }
//
// public String apiKey() {
// return apiKey;
// }
//
// public void apiKey(String apiKey) {
// this.apiKey = apiKey;
// }
//
// @Nullable
// public String jsonWebToken() {
// return currentJsonWebToken;
// }
//
// public void jsonWebToken(@Nullable String value) {
// this.currentJsonWebToken = value;
// }
//
// /**
// * Creates a {@link Retrofit.Builder} that sets the base URL, adds a Gson converter and sets {@link
// * #okHttpClient()} as its client.
// *
// * @see #okHttpClient()
// */
// protected Retrofit.Builder retrofitBuilder() {
// return new Retrofit.Builder()
// .baseUrl(API_URL)
// .addConverterFactory(GsonConverterFactory.create())
// .client(okHttpClient());
// }
//
// /**
// * Returns the default OkHttp client instance. It is strongly recommended to override this and use your app
// * instance.
// *
// * @see #setOkHttpClientDefaults(OkHttpClient.Builder)
// */
// protected synchronized OkHttpClient okHttpClient() {
// if (okHttpClient == null) {
// OkHttpClient.Builder builder = new OkHttpClient.Builder();
// setOkHttpClientDefaults(builder);
// okHttpClient = builder.build();
// }
// return okHttpClient;
// }
//
// /**
// * Adds a network interceptor to add version and auth headers and
// * an authenticator to automatically login using the API key.
// */
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// builder.addNetworkInterceptor(new TheTvdbInterceptor(this))
// .authenticator(new TheTvdbAuthenticator(this));
// }
//
// /**
// * Return the {@link Retrofit} instance. If called for the first time builds the instance.
// */
// protected Retrofit getRetrofit() {
// if (retrofit == null) {
// retrofit = retrofitBuilder().build();
// }
// return retrofit;
// }
//
// /**
// * Obtaining and refreshing your JWT token.
// */
// public TheTvdbAuthentication authentication() {
// return getRetrofit().create(TheTvdbAuthentication.class);
// }
//
// /**
// * Information about a specific episode.
// */
// public TheTvdbEpisodes episodes() {
// return getRetrofit().create(TheTvdbEpisodes.class);
// }
//
// /**
// * Available languages and information.
// */
// public TheTvdbLanguages languages() {
// return getRetrofit().create(TheTvdbLanguages.class);
// }
//
// /**
// * Information about a specific series.
// */
// public TheTvdbSeries series() {
// return getRetrofit().create(TheTvdbSeries.class);
// }
//
// /**
// * Search for a particular series.
// */
// public TheTvdbSearch search() {
// return getRetrofit().create(TheTvdbSearch.class);
// }
//
// /**
// * Retrieve series which were recently updated.
// */
// public TheTvdbUpdated updated() {
// return getRetrofit().create(TheTvdbUpdated.class);
// }
//
// /**
// * Routes for handling user data.
// */
// public TheTvdbUser user() {
// return getRetrofit().create(TheTvdbUser.class);
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/EpisodeResponse.java
// public class EpisodeResponse extends ErrorResponse {
//
// public Episode data;
//
// }
| import com.uwetrottmann.thetvdb.TheTvdb;
import com.uwetrottmann.thetvdb.entities.EpisodeResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path; | package com.uwetrottmann.thetvdb.services;
public interface TheTvdbEpisodes {
@GET("episodes/{id}") | // Path: src/main/java/com/uwetrottmann/thetvdb/TheTvdb.java
// @SuppressWarnings("WeakerAccess")
// public class TheTvdb {
//
// public static final String API_HOST = "api.thetvdb.com";
// public static final String API_URL = "https://" + API_HOST + "/";
//
// public static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language";
// public static final String HEADER_AUTHORIZATION = "Authorization";
//
// @Nullable private OkHttpClient okHttpClient;
// @Nullable private Retrofit retrofit;
//
// private String apiKey;
// @Nullable private String currentJsonWebToken;
//
// /**
// * Create a new manager instance.
// */
// public TheTvdb(String apiKey) {
// this.apiKey = apiKey;
// }
//
// public String apiKey() {
// return apiKey;
// }
//
// public void apiKey(String apiKey) {
// this.apiKey = apiKey;
// }
//
// @Nullable
// public String jsonWebToken() {
// return currentJsonWebToken;
// }
//
// public void jsonWebToken(@Nullable String value) {
// this.currentJsonWebToken = value;
// }
//
// /**
// * Creates a {@link Retrofit.Builder} that sets the base URL, adds a Gson converter and sets {@link
// * #okHttpClient()} as its client.
// *
// * @see #okHttpClient()
// */
// protected Retrofit.Builder retrofitBuilder() {
// return new Retrofit.Builder()
// .baseUrl(API_URL)
// .addConverterFactory(GsonConverterFactory.create())
// .client(okHttpClient());
// }
//
// /**
// * Returns the default OkHttp client instance. It is strongly recommended to override this and use your app
// * instance.
// *
// * @see #setOkHttpClientDefaults(OkHttpClient.Builder)
// */
// protected synchronized OkHttpClient okHttpClient() {
// if (okHttpClient == null) {
// OkHttpClient.Builder builder = new OkHttpClient.Builder();
// setOkHttpClientDefaults(builder);
// okHttpClient = builder.build();
// }
// return okHttpClient;
// }
//
// /**
// * Adds a network interceptor to add version and auth headers and
// * an authenticator to automatically login using the API key.
// */
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// builder.addNetworkInterceptor(new TheTvdbInterceptor(this))
// .authenticator(new TheTvdbAuthenticator(this));
// }
//
// /**
// * Return the {@link Retrofit} instance. If called for the first time builds the instance.
// */
// protected Retrofit getRetrofit() {
// if (retrofit == null) {
// retrofit = retrofitBuilder().build();
// }
// return retrofit;
// }
//
// /**
// * Obtaining and refreshing your JWT token.
// */
// public TheTvdbAuthentication authentication() {
// return getRetrofit().create(TheTvdbAuthentication.class);
// }
//
// /**
// * Information about a specific episode.
// */
// public TheTvdbEpisodes episodes() {
// return getRetrofit().create(TheTvdbEpisodes.class);
// }
//
// /**
// * Available languages and information.
// */
// public TheTvdbLanguages languages() {
// return getRetrofit().create(TheTvdbLanguages.class);
// }
//
// /**
// * Information about a specific series.
// */
// public TheTvdbSeries series() {
// return getRetrofit().create(TheTvdbSeries.class);
// }
//
// /**
// * Search for a particular series.
// */
// public TheTvdbSearch search() {
// return getRetrofit().create(TheTvdbSearch.class);
// }
//
// /**
// * Retrieve series which were recently updated.
// */
// public TheTvdbUpdated updated() {
// return getRetrofit().create(TheTvdbUpdated.class);
// }
//
// /**
// * Routes for handling user data.
// */
// public TheTvdbUser user() {
// return getRetrofit().create(TheTvdbUser.class);
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/EpisodeResponse.java
// public class EpisodeResponse extends ErrorResponse {
//
// public Episode data;
//
// }
// Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbEpisodes.java
import com.uwetrottmann.thetvdb.TheTvdb;
import com.uwetrottmann.thetvdb.entities.EpisodeResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
package com.uwetrottmann.thetvdb.services;
public interface TheTvdbEpisodes {
@GET("episodes/{id}") | Call<EpisodeResponse> get( |
UweTrottmann/thetvdb-java | src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbEpisodes.java | // Path: src/main/java/com/uwetrottmann/thetvdb/TheTvdb.java
// @SuppressWarnings("WeakerAccess")
// public class TheTvdb {
//
// public static final String API_HOST = "api.thetvdb.com";
// public static final String API_URL = "https://" + API_HOST + "/";
//
// public static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language";
// public static final String HEADER_AUTHORIZATION = "Authorization";
//
// @Nullable private OkHttpClient okHttpClient;
// @Nullable private Retrofit retrofit;
//
// private String apiKey;
// @Nullable private String currentJsonWebToken;
//
// /**
// * Create a new manager instance.
// */
// public TheTvdb(String apiKey) {
// this.apiKey = apiKey;
// }
//
// public String apiKey() {
// return apiKey;
// }
//
// public void apiKey(String apiKey) {
// this.apiKey = apiKey;
// }
//
// @Nullable
// public String jsonWebToken() {
// return currentJsonWebToken;
// }
//
// public void jsonWebToken(@Nullable String value) {
// this.currentJsonWebToken = value;
// }
//
// /**
// * Creates a {@link Retrofit.Builder} that sets the base URL, adds a Gson converter and sets {@link
// * #okHttpClient()} as its client.
// *
// * @see #okHttpClient()
// */
// protected Retrofit.Builder retrofitBuilder() {
// return new Retrofit.Builder()
// .baseUrl(API_URL)
// .addConverterFactory(GsonConverterFactory.create())
// .client(okHttpClient());
// }
//
// /**
// * Returns the default OkHttp client instance. It is strongly recommended to override this and use your app
// * instance.
// *
// * @see #setOkHttpClientDefaults(OkHttpClient.Builder)
// */
// protected synchronized OkHttpClient okHttpClient() {
// if (okHttpClient == null) {
// OkHttpClient.Builder builder = new OkHttpClient.Builder();
// setOkHttpClientDefaults(builder);
// okHttpClient = builder.build();
// }
// return okHttpClient;
// }
//
// /**
// * Adds a network interceptor to add version and auth headers and
// * an authenticator to automatically login using the API key.
// */
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// builder.addNetworkInterceptor(new TheTvdbInterceptor(this))
// .authenticator(new TheTvdbAuthenticator(this));
// }
//
// /**
// * Return the {@link Retrofit} instance. If called for the first time builds the instance.
// */
// protected Retrofit getRetrofit() {
// if (retrofit == null) {
// retrofit = retrofitBuilder().build();
// }
// return retrofit;
// }
//
// /**
// * Obtaining and refreshing your JWT token.
// */
// public TheTvdbAuthentication authentication() {
// return getRetrofit().create(TheTvdbAuthentication.class);
// }
//
// /**
// * Information about a specific episode.
// */
// public TheTvdbEpisodes episodes() {
// return getRetrofit().create(TheTvdbEpisodes.class);
// }
//
// /**
// * Available languages and information.
// */
// public TheTvdbLanguages languages() {
// return getRetrofit().create(TheTvdbLanguages.class);
// }
//
// /**
// * Information about a specific series.
// */
// public TheTvdbSeries series() {
// return getRetrofit().create(TheTvdbSeries.class);
// }
//
// /**
// * Search for a particular series.
// */
// public TheTvdbSearch search() {
// return getRetrofit().create(TheTvdbSearch.class);
// }
//
// /**
// * Retrieve series which were recently updated.
// */
// public TheTvdbUpdated updated() {
// return getRetrofit().create(TheTvdbUpdated.class);
// }
//
// /**
// * Routes for handling user data.
// */
// public TheTvdbUser user() {
// return getRetrofit().create(TheTvdbUser.class);
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/EpisodeResponse.java
// public class EpisodeResponse extends ErrorResponse {
//
// public Episode data;
//
// }
| import com.uwetrottmann.thetvdb.TheTvdb;
import com.uwetrottmann.thetvdb.entities.EpisodeResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path; | package com.uwetrottmann.thetvdb.services;
public interface TheTvdbEpisodes {
@GET("episodes/{id}")
Call<EpisodeResponse> get(
@Path("id") int id, | // Path: src/main/java/com/uwetrottmann/thetvdb/TheTvdb.java
// @SuppressWarnings("WeakerAccess")
// public class TheTvdb {
//
// public static final String API_HOST = "api.thetvdb.com";
// public static final String API_URL = "https://" + API_HOST + "/";
//
// public static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language";
// public static final String HEADER_AUTHORIZATION = "Authorization";
//
// @Nullable private OkHttpClient okHttpClient;
// @Nullable private Retrofit retrofit;
//
// private String apiKey;
// @Nullable private String currentJsonWebToken;
//
// /**
// * Create a new manager instance.
// */
// public TheTvdb(String apiKey) {
// this.apiKey = apiKey;
// }
//
// public String apiKey() {
// return apiKey;
// }
//
// public void apiKey(String apiKey) {
// this.apiKey = apiKey;
// }
//
// @Nullable
// public String jsonWebToken() {
// return currentJsonWebToken;
// }
//
// public void jsonWebToken(@Nullable String value) {
// this.currentJsonWebToken = value;
// }
//
// /**
// * Creates a {@link Retrofit.Builder} that sets the base URL, adds a Gson converter and sets {@link
// * #okHttpClient()} as its client.
// *
// * @see #okHttpClient()
// */
// protected Retrofit.Builder retrofitBuilder() {
// return new Retrofit.Builder()
// .baseUrl(API_URL)
// .addConverterFactory(GsonConverterFactory.create())
// .client(okHttpClient());
// }
//
// /**
// * Returns the default OkHttp client instance. It is strongly recommended to override this and use your app
// * instance.
// *
// * @see #setOkHttpClientDefaults(OkHttpClient.Builder)
// */
// protected synchronized OkHttpClient okHttpClient() {
// if (okHttpClient == null) {
// OkHttpClient.Builder builder = new OkHttpClient.Builder();
// setOkHttpClientDefaults(builder);
// okHttpClient = builder.build();
// }
// return okHttpClient;
// }
//
// /**
// * Adds a network interceptor to add version and auth headers and
// * an authenticator to automatically login using the API key.
// */
// protected void setOkHttpClientDefaults(OkHttpClient.Builder builder) {
// builder.addNetworkInterceptor(new TheTvdbInterceptor(this))
// .authenticator(new TheTvdbAuthenticator(this));
// }
//
// /**
// * Return the {@link Retrofit} instance. If called for the first time builds the instance.
// */
// protected Retrofit getRetrofit() {
// if (retrofit == null) {
// retrofit = retrofitBuilder().build();
// }
// return retrofit;
// }
//
// /**
// * Obtaining and refreshing your JWT token.
// */
// public TheTvdbAuthentication authentication() {
// return getRetrofit().create(TheTvdbAuthentication.class);
// }
//
// /**
// * Information about a specific episode.
// */
// public TheTvdbEpisodes episodes() {
// return getRetrofit().create(TheTvdbEpisodes.class);
// }
//
// /**
// * Available languages and information.
// */
// public TheTvdbLanguages languages() {
// return getRetrofit().create(TheTvdbLanguages.class);
// }
//
// /**
// * Information about a specific series.
// */
// public TheTvdbSeries series() {
// return getRetrofit().create(TheTvdbSeries.class);
// }
//
// /**
// * Search for a particular series.
// */
// public TheTvdbSearch search() {
// return getRetrofit().create(TheTvdbSearch.class);
// }
//
// /**
// * Retrieve series which were recently updated.
// */
// public TheTvdbUpdated updated() {
// return getRetrofit().create(TheTvdbUpdated.class);
// }
//
// /**
// * Routes for handling user data.
// */
// public TheTvdbUser user() {
// return getRetrofit().create(TheTvdbUser.class);
// }
//
// }
//
// Path: src/main/java/com/uwetrottmann/thetvdb/entities/EpisodeResponse.java
// public class EpisodeResponse extends ErrorResponse {
//
// public Episode data;
//
// }
// Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbEpisodes.java
import com.uwetrottmann.thetvdb.TheTvdb;
import com.uwetrottmann.thetvdb.entities.EpisodeResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
package com.uwetrottmann.thetvdb.services;
public interface TheTvdbEpisodes {
@GET("episodes/{id}")
Call<EpisodeResponse> get(
@Path("id") int id, | @Header(TheTvdb.HEADER_ACCEPT_LANGUAGE) String language |
UweTrottmann/thetvdb-java | src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbUpdated.java | // Path: src/main/java/com/uwetrottmann/thetvdb/entities/SeriesUpdatesResponse.java
// public class SeriesUpdatesResponse extends ErrorResponse {
//
// public List<SeriesUpdate> data;
//
// }
| import com.uwetrottmann.thetvdb.entities.SeriesUpdatesResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query; | package com.uwetrottmann.thetvdb.services;
public interface TheTvdbUpdated {
/**
* Returns an array of series that have changed in a maximum of one week blocks since the provided fromTime.
* The user may specify a toTime to grab results for less than a week. Any timespan larger than a week will
* be reduced down to one week automatically.
*
* @param fromTime Epoch time to start your date range.
* @param toTime Epoch time to end your date range. Must be one week from fromTime
*/
@GET("updated/query") | // Path: src/main/java/com/uwetrottmann/thetvdb/entities/SeriesUpdatesResponse.java
// public class SeriesUpdatesResponse extends ErrorResponse {
//
// public List<SeriesUpdate> data;
//
// }
// Path: src/main/java/com/uwetrottmann/thetvdb/services/TheTvdbUpdated.java
import com.uwetrottmann.thetvdb.entities.SeriesUpdatesResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;
package com.uwetrottmann.thetvdb.services;
public interface TheTvdbUpdated {
/**
* Returns an array of series that have changed in a maximum of one week blocks since the provided fromTime.
* The user may specify a toTime to grab results for less than a week. Any timespan larger than a week will
* be reduced down to one week automatically.
*
* @param fromTime Epoch time to start your date range.
* @param toTime Epoch time to end your date range. Must be one week from fromTime
*/
@GET("updated/query") | Call<SeriesUpdatesResponse> seriesUpdates(@Query("fromTime") Long fromTime, @Query("toTime") Long toTime); |
OrangeTeam/FamilyLink | app/src/org/orange/familylink/data/Contact.java | // Path: app/src/org/orange/familylink/util/Objects.java
// public abstract class Objects {
// /**
// * 判断两对象是否相等,根据o1的<code>equals</code>方法判断。
// * <p><em>当o1为null时:若o2也为null,返回true;若o2不是null,返回false</em></p>
// * @param o1 待比较对象1
// * @param o2 待比较对象2
// * @return 若o1 == o2,返回true;若o1 != o2,返回false
// */
// public static boolean compare(Object o1, Object o2) {
// return o1 == null ? o2 == null : o1.equals(o2);
// }
// }
| import org.orange.familylink.util.Objects;
import android.graphics.Bitmap; | }
/**
* 获取照片
* @return
*/
public Bitmap getPhoto(){
return mPhoto;
}
/**
* 设置照片
* @param photo
* @return
*/
public Contact setPhoto(Bitmap photo){
mPhoto = photo;
return this;
}
/**
* 用来判断提供的类是否与本来相同
*/
public boolean equals(Object o) {
if(o == null)
return false;
else if(!isSameClass(o))
return false;
else {
Contact other = (Contact) o; | // Path: app/src/org/orange/familylink/util/Objects.java
// public abstract class Objects {
// /**
// * 判断两对象是否相等,根据o1的<code>equals</code>方法判断。
// * <p><em>当o1为null时:若o2也为null,返回true;若o2不是null,返回false</em></p>
// * @param o1 待比较对象1
// * @param o2 待比较对象2
// * @return 若o1 == o2,返回true;若o1 != o2,返回false
// */
// public static boolean compare(Object o1, Object o2) {
// return o1 == null ? o2 == null : o1.equals(o2);
// }
// }
// Path: app/src/org/orange/familylink/data/Contact.java
import org.orange.familylink.util.Objects;
import android.graphics.Bitmap;
}
/**
* 获取照片
* @return
*/
public Bitmap getPhoto(){
return mPhoto;
}
/**
* 设置照片
* @param photo
* @return
*/
public Contact setPhoto(Bitmap photo){
mPhoto = photo;
return this;
}
/**
* 用来判断提供的类是否与本来相同
*/
public boolean equals(Object o) {
if(o == null)
return false;
else if(!isSameClass(o))
return false;
else {
Contact other = (Contact) o; | return Objects.compare(mId, other.mId) |
OrangeTeam/FamilyLink | app/tests/src/org/orange/familylink/data/MessageLogRecordTest.java | // Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Direction {
// /** 发送 */
// SEND,
// /** 接收 */
// RECEIVE
// }
//
// Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Status {
// /** 未读 */
// UNREAD(Direction.RECEIVE),
// /** 已读 */
// HAVE_READ(Direction.RECEIVE),
// /** 发送中 */
// SENDING(Direction.SEND),
// /** 已发送 */
// SENT(Direction.SEND),
// /** 已送达 */
// DELIVERED(Direction.SEND),
// /** 发送失败 */
// FAILED_TO_SEND(Direction.SEND);
//
// private final Direction mDirection;
// private Status(Direction direction) {
// this.mDirection = direction;
// }
// /**
// * @return 消息方向。如{@link Direction#SEND}
// */
// public Direction getDirection() {
// return mDirection;
// }
// }
//
// Path: app/tests/src/org/orange/familylink/data/MessageTest.java
// public static class MockMessage extends Message {
// @Override
// public void send(Context context, Uri messageUri, String dest,
// String password) {
// throw new UnsupportedOperationException();
// }
// @Override
// public void receive(String receivedMessage, String password) {
// throw new UnsupportedOperationException();
// }
// }
//
// Path: app/src/org/orange/familylink/sms/SmsMessage.java
// public class SmsMessage extends Message {
//
// @Override
// public void send(Context context, Uri messageUri, String dest,
// String password) {
// // 加密body
// String body = getBody();
// if(body != null)
// setBody(Crypto.encrypt(body, password));
// String json = toJson();
// // 通过SMS发送消息
// json = encode(json);
// SmsSender.sendMessage(context, messageUri, json, dest);
// // 恢复body
// setBody(body);
// }
// @Override
// public void receive(String receivedMessage, String password) {
// receivedMessage = decode(receivedMessage);
// fromJson(receivedMessage);
// String body = getBody();
// if(body != null)
// setBody(Crypto.decrypt(body, password));
// }
// protected static String encode(String origin) {
// origin = origin.replace('{', '(');
// origin = origin.replace('}', ')');
// origin = origin.replace('[', '<');
// origin = origin.replace(']', '>');
// return origin;
// }
// protected static String decode(String encoded) {
// encoded = encoded.replace('(', '{');
// encoded = encoded.replace(')', '}');
// encoded = encoded.replace('<', '[');
// encoded = encoded.replace('>', ']');
// return encoded;
// }
//
// }
| import java.util.Date;
import junit.framework.TestCase;
import org.orange.familylink.data.MessageLogRecord.Direction;
import org.orange.familylink.data.MessageLogRecord.Status;
import org.orange.familylink.data.MessageTest.MockMessage;
import org.orange.familylink.sms.SmsMessage;
import android.content.Context;
import android.net.Uri; | } catch(Exception e) {
// Optionally make sure you get the correct Exception, too
assertTrue(e instanceof IllegalStateException);
System.out.println(e.getMessage());
}
try {
defaultValue.setAddress(null);
fail( "Missing exception" );
} catch(Exception e) {
// Optionally make sure you get the correct Exception, too
assertTrue(e instanceof IllegalStateException);
System.out.println(e.getMessage());
}
try {
defaultValue.setDate(null);
fail( "Missing exception" );
} catch(Exception e) {
// Optionally make sure you get the correct Exception, too
assertTrue(e instanceof IllegalStateException);
System.out.println(e.getMessage());
}
try {
defaultValue.setStatus(null);
fail( "Missing exception" );
} catch(Exception e) {
// Optionally make sure you get the correct Exception, too
assertTrue(e instanceof IllegalStateException);
System.out.println(e.getMessage());
}
try { | // Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Direction {
// /** 发送 */
// SEND,
// /** 接收 */
// RECEIVE
// }
//
// Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Status {
// /** 未读 */
// UNREAD(Direction.RECEIVE),
// /** 已读 */
// HAVE_READ(Direction.RECEIVE),
// /** 发送中 */
// SENDING(Direction.SEND),
// /** 已发送 */
// SENT(Direction.SEND),
// /** 已送达 */
// DELIVERED(Direction.SEND),
// /** 发送失败 */
// FAILED_TO_SEND(Direction.SEND);
//
// private final Direction mDirection;
// private Status(Direction direction) {
// this.mDirection = direction;
// }
// /**
// * @return 消息方向。如{@link Direction#SEND}
// */
// public Direction getDirection() {
// return mDirection;
// }
// }
//
// Path: app/tests/src/org/orange/familylink/data/MessageTest.java
// public static class MockMessage extends Message {
// @Override
// public void send(Context context, Uri messageUri, String dest,
// String password) {
// throw new UnsupportedOperationException();
// }
// @Override
// public void receive(String receivedMessage, String password) {
// throw new UnsupportedOperationException();
// }
// }
//
// Path: app/src/org/orange/familylink/sms/SmsMessage.java
// public class SmsMessage extends Message {
//
// @Override
// public void send(Context context, Uri messageUri, String dest,
// String password) {
// // 加密body
// String body = getBody();
// if(body != null)
// setBody(Crypto.encrypt(body, password));
// String json = toJson();
// // 通过SMS发送消息
// json = encode(json);
// SmsSender.sendMessage(context, messageUri, json, dest);
// // 恢复body
// setBody(body);
// }
// @Override
// public void receive(String receivedMessage, String password) {
// receivedMessage = decode(receivedMessage);
// fromJson(receivedMessage);
// String body = getBody();
// if(body != null)
// setBody(Crypto.decrypt(body, password));
// }
// protected static String encode(String origin) {
// origin = origin.replace('{', '(');
// origin = origin.replace('}', ')');
// origin = origin.replace('[', '<');
// origin = origin.replace(']', '>');
// return origin;
// }
// protected static String decode(String encoded) {
// encoded = encoded.replace('(', '{');
// encoded = encoded.replace(')', '}');
// encoded = encoded.replace('<', '[');
// encoded = encoded.replace('>', ']');
// return encoded;
// }
//
// }
// Path: app/tests/src/org/orange/familylink/data/MessageLogRecordTest.java
import java.util.Date;
import junit.framework.TestCase;
import org.orange.familylink.data.MessageLogRecord.Direction;
import org.orange.familylink.data.MessageLogRecord.Status;
import org.orange.familylink.data.MessageTest.MockMessage;
import org.orange.familylink.sms.SmsMessage;
import android.content.Context;
import android.net.Uri;
} catch(Exception e) {
// Optionally make sure you get the correct Exception, too
assertTrue(e instanceof IllegalStateException);
System.out.println(e.getMessage());
}
try {
defaultValue.setAddress(null);
fail( "Missing exception" );
} catch(Exception e) {
// Optionally make sure you get the correct Exception, too
assertTrue(e instanceof IllegalStateException);
System.out.println(e.getMessage());
}
try {
defaultValue.setDate(null);
fail( "Missing exception" );
} catch(Exception e) {
// Optionally make sure you get the correct Exception, too
assertTrue(e instanceof IllegalStateException);
System.out.println(e.getMessage());
}
try {
defaultValue.setStatus(null);
fail( "Missing exception" );
} catch(Exception e) {
// Optionally make sure you get the correct Exception, too
assertTrue(e instanceof IllegalStateException);
System.out.println(e.getMessage());
}
try { | defaultValue.setMessage(new SmsMessage()); |
OrangeTeam/FamilyLink | app/tests/src/org/orange/familylink/data/MessageLogRecordTest.java | // Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Direction {
// /** 发送 */
// SEND,
// /** 接收 */
// RECEIVE
// }
//
// Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Status {
// /** 未读 */
// UNREAD(Direction.RECEIVE),
// /** 已读 */
// HAVE_READ(Direction.RECEIVE),
// /** 发送中 */
// SENDING(Direction.SEND),
// /** 已发送 */
// SENT(Direction.SEND),
// /** 已送达 */
// DELIVERED(Direction.SEND),
// /** 发送失败 */
// FAILED_TO_SEND(Direction.SEND);
//
// private final Direction mDirection;
// private Status(Direction direction) {
// this.mDirection = direction;
// }
// /**
// * @return 消息方向。如{@link Direction#SEND}
// */
// public Direction getDirection() {
// return mDirection;
// }
// }
//
// Path: app/tests/src/org/orange/familylink/data/MessageTest.java
// public static class MockMessage extends Message {
// @Override
// public void send(Context context, Uri messageUri, String dest,
// String password) {
// throw new UnsupportedOperationException();
// }
// @Override
// public void receive(String receivedMessage, String password) {
// throw new UnsupportedOperationException();
// }
// }
//
// Path: app/src/org/orange/familylink/sms/SmsMessage.java
// public class SmsMessage extends Message {
//
// @Override
// public void send(Context context, Uri messageUri, String dest,
// String password) {
// // 加密body
// String body = getBody();
// if(body != null)
// setBody(Crypto.encrypt(body, password));
// String json = toJson();
// // 通过SMS发送消息
// json = encode(json);
// SmsSender.sendMessage(context, messageUri, json, dest);
// // 恢复body
// setBody(body);
// }
// @Override
// public void receive(String receivedMessage, String password) {
// receivedMessage = decode(receivedMessage);
// fromJson(receivedMessage);
// String body = getBody();
// if(body != null)
// setBody(Crypto.decrypt(body, password));
// }
// protected static String encode(String origin) {
// origin = origin.replace('{', '(');
// origin = origin.replace('}', ')');
// origin = origin.replace('[', '<');
// origin = origin.replace(']', '>');
// return origin;
// }
// protected static String decode(String encoded) {
// encoded = encoded.replace('(', '{');
// encoded = encoded.replace(')', '}');
// encoded = encoded.replace('<', '[');
// encoded = encoded.replace('>', ']');
// return encoded;
// }
//
// }
| import java.util.Date;
import junit.framework.TestCase;
import org.orange.familylink.data.MessageLogRecord.Direction;
import org.orange.familylink.data.MessageLogRecord.Status;
import org.orange.familylink.data.MessageTest.MockMessage;
import org.orange.familylink.sms.SmsMessage;
import android.content.Context;
import android.net.Uri; | assertEquals(address, mMessageLogRecord.getAddress());
address = "15620906177";
mMessageLogRecord.setAddress(address);
assertEquals(address, mMessageLogRecord.getAddress());
address = "";
mMessageLogRecord.setAddress(address);
assertEquals(address, mMessageLogRecord.getAddress());
mMessageLogRecord.setAddress(null);
assertNull(mMessageLogRecord.getAddress());
}
public void testDate() {
Date date = new Date();
mMessageLogRecord.setDate(date);
assertEquals(date, mMessageLogRecord.getDate());
date = new Date(Long.MIN_VALUE);
mMessageLogRecord.setDate(date);
assertEquals(date, mMessageLogRecord.getDate());
date = new Date(0);
mMessageLogRecord.setDate(date);
assertEquals(date, mMessageLogRecord.getDate());
mMessageLogRecord.setDate(null);
assertNull(mMessageLogRecord.getDate());
}
public void testStatus() { | // Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Direction {
// /** 发送 */
// SEND,
// /** 接收 */
// RECEIVE
// }
//
// Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Status {
// /** 未读 */
// UNREAD(Direction.RECEIVE),
// /** 已读 */
// HAVE_READ(Direction.RECEIVE),
// /** 发送中 */
// SENDING(Direction.SEND),
// /** 已发送 */
// SENT(Direction.SEND),
// /** 已送达 */
// DELIVERED(Direction.SEND),
// /** 发送失败 */
// FAILED_TO_SEND(Direction.SEND);
//
// private final Direction mDirection;
// private Status(Direction direction) {
// this.mDirection = direction;
// }
// /**
// * @return 消息方向。如{@link Direction#SEND}
// */
// public Direction getDirection() {
// return mDirection;
// }
// }
//
// Path: app/tests/src/org/orange/familylink/data/MessageTest.java
// public static class MockMessage extends Message {
// @Override
// public void send(Context context, Uri messageUri, String dest,
// String password) {
// throw new UnsupportedOperationException();
// }
// @Override
// public void receive(String receivedMessage, String password) {
// throw new UnsupportedOperationException();
// }
// }
//
// Path: app/src/org/orange/familylink/sms/SmsMessage.java
// public class SmsMessage extends Message {
//
// @Override
// public void send(Context context, Uri messageUri, String dest,
// String password) {
// // 加密body
// String body = getBody();
// if(body != null)
// setBody(Crypto.encrypt(body, password));
// String json = toJson();
// // 通过SMS发送消息
// json = encode(json);
// SmsSender.sendMessage(context, messageUri, json, dest);
// // 恢复body
// setBody(body);
// }
// @Override
// public void receive(String receivedMessage, String password) {
// receivedMessage = decode(receivedMessage);
// fromJson(receivedMessage);
// String body = getBody();
// if(body != null)
// setBody(Crypto.decrypt(body, password));
// }
// protected static String encode(String origin) {
// origin = origin.replace('{', '(');
// origin = origin.replace('}', ')');
// origin = origin.replace('[', '<');
// origin = origin.replace(']', '>');
// return origin;
// }
// protected static String decode(String encoded) {
// encoded = encoded.replace('(', '{');
// encoded = encoded.replace(')', '}');
// encoded = encoded.replace('<', '[');
// encoded = encoded.replace('>', ']');
// return encoded;
// }
//
// }
// Path: app/tests/src/org/orange/familylink/data/MessageLogRecordTest.java
import java.util.Date;
import junit.framework.TestCase;
import org.orange.familylink.data.MessageLogRecord.Direction;
import org.orange.familylink.data.MessageLogRecord.Status;
import org.orange.familylink.data.MessageTest.MockMessage;
import org.orange.familylink.sms.SmsMessage;
import android.content.Context;
import android.net.Uri;
assertEquals(address, mMessageLogRecord.getAddress());
address = "15620906177";
mMessageLogRecord.setAddress(address);
assertEquals(address, mMessageLogRecord.getAddress());
address = "";
mMessageLogRecord.setAddress(address);
assertEquals(address, mMessageLogRecord.getAddress());
mMessageLogRecord.setAddress(null);
assertNull(mMessageLogRecord.getAddress());
}
public void testDate() {
Date date = new Date();
mMessageLogRecord.setDate(date);
assertEquals(date, mMessageLogRecord.getDate());
date = new Date(Long.MIN_VALUE);
mMessageLogRecord.setDate(date);
assertEquals(date, mMessageLogRecord.getDate());
date = new Date(0);
mMessageLogRecord.setDate(date);
assertEquals(date, mMessageLogRecord.getDate());
mMessageLogRecord.setDate(null);
assertNull(mMessageLogRecord.getDate());
}
public void testStatus() { | Status s; |
OrangeTeam/FamilyLink | app/tests/src/org/orange/familylink/data/MessageLogRecordTest.java | // Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Direction {
// /** 发送 */
// SEND,
// /** 接收 */
// RECEIVE
// }
//
// Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Status {
// /** 未读 */
// UNREAD(Direction.RECEIVE),
// /** 已读 */
// HAVE_READ(Direction.RECEIVE),
// /** 发送中 */
// SENDING(Direction.SEND),
// /** 已发送 */
// SENT(Direction.SEND),
// /** 已送达 */
// DELIVERED(Direction.SEND),
// /** 发送失败 */
// FAILED_TO_SEND(Direction.SEND);
//
// private final Direction mDirection;
// private Status(Direction direction) {
// this.mDirection = direction;
// }
// /**
// * @return 消息方向。如{@link Direction#SEND}
// */
// public Direction getDirection() {
// return mDirection;
// }
// }
//
// Path: app/tests/src/org/orange/familylink/data/MessageTest.java
// public static class MockMessage extends Message {
// @Override
// public void send(Context context, Uri messageUri, String dest,
// String password) {
// throw new UnsupportedOperationException();
// }
// @Override
// public void receive(String receivedMessage, String password) {
// throw new UnsupportedOperationException();
// }
// }
//
// Path: app/src/org/orange/familylink/sms/SmsMessage.java
// public class SmsMessage extends Message {
//
// @Override
// public void send(Context context, Uri messageUri, String dest,
// String password) {
// // 加密body
// String body = getBody();
// if(body != null)
// setBody(Crypto.encrypt(body, password));
// String json = toJson();
// // 通过SMS发送消息
// json = encode(json);
// SmsSender.sendMessage(context, messageUri, json, dest);
// // 恢复body
// setBody(body);
// }
// @Override
// public void receive(String receivedMessage, String password) {
// receivedMessage = decode(receivedMessage);
// fromJson(receivedMessage);
// String body = getBody();
// if(body != null)
// setBody(Crypto.decrypt(body, password));
// }
// protected static String encode(String origin) {
// origin = origin.replace('{', '(');
// origin = origin.replace('}', ')');
// origin = origin.replace('[', '<');
// origin = origin.replace(']', '>');
// return origin;
// }
// protected static String decode(String encoded) {
// encoded = encoded.replace('(', '{');
// encoded = encoded.replace(')', '}');
// encoded = encoded.replace('<', '[');
// encoded = encoded.replace('>', ']');
// return encoded;
// }
//
// }
| import java.util.Date;
import junit.framework.TestCase;
import org.orange.familylink.data.MessageLogRecord.Direction;
import org.orange.familylink.data.MessageLogRecord.Status;
import org.orange.familylink.data.MessageTest.MockMessage;
import org.orange.familylink.sms.SmsMessage;
import android.content.Context;
import android.net.Uri; | assertEquals(address, mMessageLogRecord.getAddress());
address = "";
mMessageLogRecord.setAddress(address);
assertEquals(address, mMessageLogRecord.getAddress());
mMessageLogRecord.setAddress(null);
assertNull(mMessageLogRecord.getAddress());
}
public void testDate() {
Date date = new Date();
mMessageLogRecord.setDate(date);
assertEquals(date, mMessageLogRecord.getDate());
date = new Date(Long.MIN_VALUE);
mMessageLogRecord.setDate(date);
assertEquals(date, mMessageLogRecord.getDate());
date = new Date(0);
mMessageLogRecord.setDate(date);
assertEquals(date, mMessageLogRecord.getDate());
mMessageLogRecord.setDate(null);
assertNull(mMessageLogRecord.getDate());
}
public void testStatus() {
Status s;
s = Status.UNREAD;
mMessageLogRecord.setStatus(s);
assertEquals(s, mMessageLogRecord.getStatus()); | // Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Direction {
// /** 发送 */
// SEND,
// /** 接收 */
// RECEIVE
// }
//
// Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Status {
// /** 未读 */
// UNREAD(Direction.RECEIVE),
// /** 已读 */
// HAVE_READ(Direction.RECEIVE),
// /** 发送中 */
// SENDING(Direction.SEND),
// /** 已发送 */
// SENT(Direction.SEND),
// /** 已送达 */
// DELIVERED(Direction.SEND),
// /** 发送失败 */
// FAILED_TO_SEND(Direction.SEND);
//
// private final Direction mDirection;
// private Status(Direction direction) {
// this.mDirection = direction;
// }
// /**
// * @return 消息方向。如{@link Direction#SEND}
// */
// public Direction getDirection() {
// return mDirection;
// }
// }
//
// Path: app/tests/src/org/orange/familylink/data/MessageTest.java
// public static class MockMessage extends Message {
// @Override
// public void send(Context context, Uri messageUri, String dest,
// String password) {
// throw new UnsupportedOperationException();
// }
// @Override
// public void receive(String receivedMessage, String password) {
// throw new UnsupportedOperationException();
// }
// }
//
// Path: app/src/org/orange/familylink/sms/SmsMessage.java
// public class SmsMessage extends Message {
//
// @Override
// public void send(Context context, Uri messageUri, String dest,
// String password) {
// // 加密body
// String body = getBody();
// if(body != null)
// setBody(Crypto.encrypt(body, password));
// String json = toJson();
// // 通过SMS发送消息
// json = encode(json);
// SmsSender.sendMessage(context, messageUri, json, dest);
// // 恢复body
// setBody(body);
// }
// @Override
// public void receive(String receivedMessage, String password) {
// receivedMessage = decode(receivedMessage);
// fromJson(receivedMessage);
// String body = getBody();
// if(body != null)
// setBody(Crypto.decrypt(body, password));
// }
// protected static String encode(String origin) {
// origin = origin.replace('{', '(');
// origin = origin.replace('}', ')');
// origin = origin.replace('[', '<');
// origin = origin.replace(']', '>');
// return origin;
// }
// protected static String decode(String encoded) {
// encoded = encoded.replace('(', '{');
// encoded = encoded.replace(')', '}');
// encoded = encoded.replace('<', '[');
// encoded = encoded.replace('>', ']');
// return encoded;
// }
//
// }
// Path: app/tests/src/org/orange/familylink/data/MessageLogRecordTest.java
import java.util.Date;
import junit.framework.TestCase;
import org.orange.familylink.data.MessageLogRecord.Direction;
import org.orange.familylink.data.MessageLogRecord.Status;
import org.orange.familylink.data.MessageTest.MockMessage;
import org.orange.familylink.sms.SmsMessage;
import android.content.Context;
import android.net.Uri;
assertEquals(address, mMessageLogRecord.getAddress());
address = "";
mMessageLogRecord.setAddress(address);
assertEquals(address, mMessageLogRecord.getAddress());
mMessageLogRecord.setAddress(null);
assertNull(mMessageLogRecord.getAddress());
}
public void testDate() {
Date date = new Date();
mMessageLogRecord.setDate(date);
assertEquals(date, mMessageLogRecord.getDate());
date = new Date(Long.MIN_VALUE);
mMessageLogRecord.setDate(date);
assertEquals(date, mMessageLogRecord.getDate());
date = new Date(0);
mMessageLogRecord.setDate(date);
assertEquals(date, mMessageLogRecord.getDate());
mMessageLogRecord.setDate(null);
assertNull(mMessageLogRecord.getDate());
}
public void testStatus() {
Status s;
s = Status.UNREAD;
mMessageLogRecord.setStatus(s);
assertEquals(s, mMessageLogRecord.getStatus()); | assertEquals(Direction.RECEIVE, mMessageLogRecord.getStatus().getDirection()); |
OrangeTeam/FamilyLink | app/tests/src/org/orange/familylink/data/MessageLogRecordTest.java | // Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Direction {
// /** 发送 */
// SEND,
// /** 接收 */
// RECEIVE
// }
//
// Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Status {
// /** 未读 */
// UNREAD(Direction.RECEIVE),
// /** 已读 */
// HAVE_READ(Direction.RECEIVE),
// /** 发送中 */
// SENDING(Direction.SEND),
// /** 已发送 */
// SENT(Direction.SEND),
// /** 已送达 */
// DELIVERED(Direction.SEND),
// /** 发送失败 */
// FAILED_TO_SEND(Direction.SEND);
//
// private final Direction mDirection;
// private Status(Direction direction) {
// this.mDirection = direction;
// }
// /**
// * @return 消息方向。如{@link Direction#SEND}
// */
// public Direction getDirection() {
// return mDirection;
// }
// }
//
// Path: app/tests/src/org/orange/familylink/data/MessageTest.java
// public static class MockMessage extends Message {
// @Override
// public void send(Context context, Uri messageUri, String dest,
// String password) {
// throw new UnsupportedOperationException();
// }
// @Override
// public void receive(String receivedMessage, String password) {
// throw new UnsupportedOperationException();
// }
// }
//
// Path: app/src/org/orange/familylink/sms/SmsMessage.java
// public class SmsMessage extends Message {
//
// @Override
// public void send(Context context, Uri messageUri, String dest,
// String password) {
// // 加密body
// String body = getBody();
// if(body != null)
// setBody(Crypto.encrypt(body, password));
// String json = toJson();
// // 通过SMS发送消息
// json = encode(json);
// SmsSender.sendMessage(context, messageUri, json, dest);
// // 恢复body
// setBody(body);
// }
// @Override
// public void receive(String receivedMessage, String password) {
// receivedMessage = decode(receivedMessage);
// fromJson(receivedMessage);
// String body = getBody();
// if(body != null)
// setBody(Crypto.decrypt(body, password));
// }
// protected static String encode(String origin) {
// origin = origin.replace('{', '(');
// origin = origin.replace('}', ')');
// origin = origin.replace('[', '<');
// origin = origin.replace(']', '>');
// return origin;
// }
// protected static String decode(String encoded) {
// encoded = encoded.replace('(', '{');
// encoded = encoded.replace(')', '}');
// encoded = encoded.replace('<', '[');
// encoded = encoded.replace('>', ']');
// return encoded;
// }
//
// }
| import java.util.Date;
import junit.framework.TestCase;
import org.orange.familylink.data.MessageLogRecord.Direction;
import org.orange.familylink.data.MessageLogRecord.Status;
import org.orange.familylink.data.MessageTest.MockMessage;
import org.orange.familylink.sms.SmsMessage;
import android.content.Context;
import android.net.Uri; | assertEquals(Direction.SEND, mMessageLogRecord.getStatus().getDirection());
s = Status.DELIVERED;
mMessageLogRecord.setStatus(s);
assertEquals(s, mMessageLogRecord.getStatus());
assertEquals(Direction.SEND, mMessageLogRecord.getStatus().getDirection());
s = Status.FAILED_TO_SEND;
mMessageLogRecord.setStatus(s);
assertEquals(s, mMessageLogRecord.getStatus());
assertEquals(Direction.SEND, mMessageLogRecord.getStatus().getDirection());
mMessageLogRecord.setStatus(null);
assertNull(mMessageLogRecord.getStatus());
}
public void testMessage() {
Message m = new Message() {
@Override
public void send(Context context, Uri messageUri, String dest,
String password) {}
@Override
public void receive(String receivedMessage, String password) {}
};
mMessageLogRecord.setMessage(m);
assertEquals(m, mMessageLogRecord.getMessage());
// 验证 可以设置并取回null
mMessageLogRecord.setMessage(null);
assertNull(mMessageLogRecord.getMessage());
| // Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Direction {
// /** 发送 */
// SEND,
// /** 接收 */
// RECEIVE
// }
//
// Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Status {
// /** 未读 */
// UNREAD(Direction.RECEIVE),
// /** 已读 */
// HAVE_READ(Direction.RECEIVE),
// /** 发送中 */
// SENDING(Direction.SEND),
// /** 已发送 */
// SENT(Direction.SEND),
// /** 已送达 */
// DELIVERED(Direction.SEND),
// /** 发送失败 */
// FAILED_TO_SEND(Direction.SEND);
//
// private final Direction mDirection;
// private Status(Direction direction) {
// this.mDirection = direction;
// }
// /**
// * @return 消息方向。如{@link Direction#SEND}
// */
// public Direction getDirection() {
// return mDirection;
// }
// }
//
// Path: app/tests/src/org/orange/familylink/data/MessageTest.java
// public static class MockMessage extends Message {
// @Override
// public void send(Context context, Uri messageUri, String dest,
// String password) {
// throw new UnsupportedOperationException();
// }
// @Override
// public void receive(String receivedMessage, String password) {
// throw new UnsupportedOperationException();
// }
// }
//
// Path: app/src/org/orange/familylink/sms/SmsMessage.java
// public class SmsMessage extends Message {
//
// @Override
// public void send(Context context, Uri messageUri, String dest,
// String password) {
// // 加密body
// String body = getBody();
// if(body != null)
// setBody(Crypto.encrypt(body, password));
// String json = toJson();
// // 通过SMS发送消息
// json = encode(json);
// SmsSender.sendMessage(context, messageUri, json, dest);
// // 恢复body
// setBody(body);
// }
// @Override
// public void receive(String receivedMessage, String password) {
// receivedMessage = decode(receivedMessage);
// fromJson(receivedMessage);
// String body = getBody();
// if(body != null)
// setBody(Crypto.decrypt(body, password));
// }
// protected static String encode(String origin) {
// origin = origin.replace('{', '(');
// origin = origin.replace('}', ')');
// origin = origin.replace('[', '<');
// origin = origin.replace(']', '>');
// return origin;
// }
// protected static String decode(String encoded) {
// encoded = encoded.replace('(', '{');
// encoded = encoded.replace(')', '}');
// encoded = encoded.replace('<', '[');
// encoded = encoded.replace('>', ']');
// return encoded;
// }
//
// }
// Path: app/tests/src/org/orange/familylink/data/MessageLogRecordTest.java
import java.util.Date;
import junit.framework.TestCase;
import org.orange.familylink.data.MessageLogRecord.Direction;
import org.orange.familylink.data.MessageLogRecord.Status;
import org.orange.familylink.data.MessageTest.MockMessage;
import org.orange.familylink.sms.SmsMessage;
import android.content.Context;
import android.net.Uri;
assertEquals(Direction.SEND, mMessageLogRecord.getStatus().getDirection());
s = Status.DELIVERED;
mMessageLogRecord.setStatus(s);
assertEquals(s, mMessageLogRecord.getStatus());
assertEquals(Direction.SEND, mMessageLogRecord.getStatus().getDirection());
s = Status.FAILED_TO_SEND;
mMessageLogRecord.setStatus(s);
assertEquals(s, mMessageLogRecord.getStatus());
assertEquals(Direction.SEND, mMessageLogRecord.getStatus().getDirection());
mMessageLogRecord.setStatus(null);
assertNull(mMessageLogRecord.getStatus());
}
public void testMessage() {
Message m = new Message() {
@Override
public void send(Context context, Uri messageUri, String dest,
String password) {}
@Override
public void receive(String receivedMessage, String password) {}
};
mMessageLogRecord.setMessage(m);
assertEquals(m, mMessageLogRecord.getMessage());
// 验证 可以设置并取回null
mMessageLogRecord.setMessage(null);
assertNull(mMessageLogRecord.getMessage());
| m = new MockMessage(); |
OrangeTeam/FamilyLink | app/src/org/orange/familylink/data/MessageLogRecord.java | // Path: app/src/org/orange/familylink/util/Objects.java
// public abstract class Objects {
// /**
// * 判断两对象是否相等,根据o1的<code>equals</code>方法判断。
// * <p><em>当o1为null时:若o2也为null,返回true;若o2不是null,返回false</em></p>
// * @param o1 待比较对象1
// * @param o2 待比较对象2
// * @return 若o1 == o2,返回true;若o1 != o2,返回false
// */
// public static boolean compare(Object o1, Object o2) {
// return o1 == null ? o2 == null : o1.equals(o2);
// }
// }
| import java.util.Date;
import org.orange.familylink.util.Objects; | * @return 消息内容
*/
public Message getMessageToSet() {
return mMessage;
}
/**
* 设置{@link Message}(设置为null,来取消之前的设置)。本对象会保留参数的<strong>{@link Message#clone() clone}</strong>。
* @param message 消息内容
* @return this(用于链式调用)
*/
public MessageLogRecord setMessage(Message message) {
this.mMessage = message != null ? message.clone() : null;
return this;
}
/**
* 判断指定对象是否与本对象内容相同。
* <p><em>会调用{@link #isSameClass(Object)}判断是否是本类的实例,
* 调用{@link Objects#compare(Object, Object)}比较各对象字段</em></p>
* @param o 待比较对象
* @return 如果内容与本对象相同,返回true;不同,返回false
*/
@Override
public boolean equals(Object o) {
if(o == null)
return false;
else if(!isSameClass(o))
return false;
else {
MessageLogRecord other = (MessageLogRecord) o; | // Path: app/src/org/orange/familylink/util/Objects.java
// public abstract class Objects {
// /**
// * 判断两对象是否相等,根据o1的<code>equals</code>方法判断。
// * <p><em>当o1为null时:若o2也为null,返回true;若o2不是null,返回false</em></p>
// * @param o1 待比较对象1
// * @param o2 待比较对象2
// * @return 若o1 == o2,返回true;若o1 != o2,返回false
// */
// public static boolean compare(Object o1, Object o2) {
// return o1 == null ? o2 == null : o1.equals(o2);
// }
// }
// Path: app/src/org/orange/familylink/data/MessageLogRecord.java
import java.util.Date;
import org.orange.familylink.util.Objects;
* @return 消息内容
*/
public Message getMessageToSet() {
return mMessage;
}
/**
* 设置{@link Message}(设置为null,来取消之前的设置)。本对象会保留参数的<strong>{@link Message#clone() clone}</strong>。
* @param message 消息内容
* @return this(用于链式调用)
*/
public MessageLogRecord setMessage(Message message) {
this.mMessage = message != null ? message.clone() : null;
return this;
}
/**
* 判断指定对象是否与本对象内容相同。
* <p><em>会调用{@link #isSameClass(Object)}判断是否是本类的实例,
* 调用{@link Objects#compare(Object, Object)}比较各对象字段</em></p>
* @param o 待比较对象
* @return 如果内容与本对象相同,返回true;不同,返回false
*/
@Override
public boolean equals(Object o) {
if(o == null)
return false;
else if(!isSameClass(o))
return false;
else {
MessageLogRecord other = (MessageLogRecord) o; | return Objects.compare(mId, other.mId) |
OrangeTeam/FamilyLink | app/src/org/orange/familylink/database/Contract.java | // Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Direction {
// /** 发送 */
// SEND,
// /** 接收 */
// RECEIVE
// }
//
// Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Status {
// /** 未读 */
// UNREAD(Direction.RECEIVE),
// /** 已读 */
// HAVE_READ(Direction.RECEIVE),
// /** 发送中 */
// SENDING(Direction.SEND),
// /** 已发送 */
// SENT(Direction.SEND),
// /** 已送达 */
// DELIVERED(Direction.SEND),
// /** 发送失败 */
// FAILED_TO_SEND(Direction.SEND);
//
// private final Direction mDirection;
// private Status(Direction direction) {
// this.mDirection = direction;
// }
// /**
// * @return 消息方向。如{@link Direction#SEND}
// */
// public Direction getDirection() {
// return mDirection;
// }
// }
| import org.orange.familylink.data.MessageLogRecord.Direction;
import org.orange.familylink.data.MessageLogRecord.Status;
import android.net.Uri;
import android.provider.BaseColumns; | * 信息表中的状态存储信息是‘正在发送’、‘已发送’、‘已送达’、‘发送失败’等情况 String
*/
public static final String COLUMN_NAME_STATUS = "status";
/**
* 信息表中的信息所发送的内容就是短信内容 String
*/
public static final String COLUMN_NAME_BODY = "body";
/**
* 信息表中的代表短信级别的码 int
*/
public static final String COLUMN_NAME_CODE = "CODE";
//这个常量字符串是创建messages表的sql语句
public static final String MESSAGES_TABLE_CREATE = "create table " + DATABASE_MESSAGES_TABLE + " (" +
_ID + " integer primary key," + COLUMN_NAME_CONTACT_ID + " integer references contacts(_id)," +
COLUMN_NAME_ADDRESS + " varchar(20)," + COLUMN_NAME_TIME + " integer," + COLUMN_NAME_STATUS + " varchar(30),"
+ COLUMN_NAME_BODY + " text," + COLUMN_NAME_CODE + " integer"
+ ");";
public static final String MESSAGES_DEFAULT_SORT_ORDER = COLUMN_NAME_TIME + " DESC";
//为messages表中的time字段创建索引
public static final String INDEX_CREATE = "create index messages_time_index on " +
DATABASE_MESSAGES_TABLE + "(" + COLUMN_NAME_TIME + ");";
/**
* 取得与指定条件对应的SQL where子句(不包括“WHERE”自身)
* @param status 筛选条件:消息状态
* @return SQL where子句,满足此子句的消息的状态都为status
*/ | // Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Direction {
// /** 发送 */
// SEND,
// /** 接收 */
// RECEIVE
// }
//
// Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Status {
// /** 未读 */
// UNREAD(Direction.RECEIVE),
// /** 已读 */
// HAVE_READ(Direction.RECEIVE),
// /** 发送中 */
// SENDING(Direction.SEND),
// /** 已发送 */
// SENT(Direction.SEND),
// /** 已送达 */
// DELIVERED(Direction.SEND),
// /** 发送失败 */
// FAILED_TO_SEND(Direction.SEND);
//
// private final Direction mDirection;
// private Status(Direction direction) {
// this.mDirection = direction;
// }
// /**
// * @return 消息方向。如{@link Direction#SEND}
// */
// public Direction getDirection() {
// return mDirection;
// }
// }
// Path: app/src/org/orange/familylink/database/Contract.java
import org.orange.familylink.data.MessageLogRecord.Direction;
import org.orange.familylink.data.MessageLogRecord.Status;
import android.net.Uri;
import android.provider.BaseColumns;
* 信息表中的状态存储信息是‘正在发送’、‘已发送’、‘已送达’、‘发送失败’等情况 String
*/
public static final String COLUMN_NAME_STATUS = "status";
/**
* 信息表中的信息所发送的内容就是短信内容 String
*/
public static final String COLUMN_NAME_BODY = "body";
/**
* 信息表中的代表短信级别的码 int
*/
public static final String COLUMN_NAME_CODE = "CODE";
//这个常量字符串是创建messages表的sql语句
public static final String MESSAGES_TABLE_CREATE = "create table " + DATABASE_MESSAGES_TABLE + " (" +
_ID + " integer primary key," + COLUMN_NAME_CONTACT_ID + " integer references contacts(_id)," +
COLUMN_NAME_ADDRESS + " varchar(20)," + COLUMN_NAME_TIME + " integer," + COLUMN_NAME_STATUS + " varchar(30),"
+ COLUMN_NAME_BODY + " text," + COLUMN_NAME_CODE + " integer"
+ ");";
public static final String MESSAGES_DEFAULT_SORT_ORDER = COLUMN_NAME_TIME + " DESC";
//为messages表中的time字段创建索引
public static final String INDEX_CREATE = "create index messages_time_index on " +
DATABASE_MESSAGES_TABLE + "(" + COLUMN_NAME_TIME + ");";
/**
* 取得与指定条件对应的SQL where子句(不包括“WHERE”自身)
* @param status 筛选条件:消息状态
* @return SQL where子句,满足此子句的消息的状态都为status
*/ | public static String getWhereClause(Status status) { |
OrangeTeam/FamilyLink | app/src/org/orange/familylink/database/Contract.java | // Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Direction {
// /** 发送 */
// SEND,
// /** 接收 */
// RECEIVE
// }
//
// Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Status {
// /** 未读 */
// UNREAD(Direction.RECEIVE),
// /** 已读 */
// HAVE_READ(Direction.RECEIVE),
// /** 发送中 */
// SENDING(Direction.SEND),
// /** 已发送 */
// SENT(Direction.SEND),
// /** 已送达 */
// DELIVERED(Direction.SEND),
// /** 发送失败 */
// FAILED_TO_SEND(Direction.SEND);
//
// private final Direction mDirection;
// private Status(Direction direction) {
// this.mDirection = direction;
// }
// /**
// * @return 消息方向。如{@link Direction#SEND}
// */
// public Direction getDirection() {
// return mDirection;
// }
// }
| import org.orange.familylink.data.MessageLogRecord.Direction;
import org.orange.familylink.data.MessageLogRecord.Status;
import android.net.Uri;
import android.provider.BaseColumns; | * 信息表中的代表短信级别的码 int
*/
public static final String COLUMN_NAME_CODE = "CODE";
//这个常量字符串是创建messages表的sql语句
public static final String MESSAGES_TABLE_CREATE = "create table " + DATABASE_MESSAGES_TABLE + " (" +
_ID + " integer primary key," + COLUMN_NAME_CONTACT_ID + " integer references contacts(_id)," +
COLUMN_NAME_ADDRESS + " varchar(20)," + COLUMN_NAME_TIME + " integer," + COLUMN_NAME_STATUS + " varchar(30),"
+ COLUMN_NAME_BODY + " text," + COLUMN_NAME_CODE + " integer"
+ ");";
public static final String MESSAGES_DEFAULT_SORT_ORDER = COLUMN_NAME_TIME + " DESC";
//为messages表中的time字段创建索引
public static final String INDEX_CREATE = "create index messages_time_index on " +
DATABASE_MESSAGES_TABLE + "(" + COLUMN_NAME_TIME + ");";
/**
* 取得与指定条件对应的SQL where子句(不包括“WHERE”自身)
* @param status 筛选条件:消息状态
* @return SQL where子句,满足此子句的消息的状态都为status
*/
public static String getWhereClause(Status status) {
return COLUMN_NAME_STATUS + " = '" + status.name() + "'";
}
/**
* 取得与指定条件对应的SQL where子句(不包括“WHERE”自身)
* @param direction 筛选条件:消息方向
* @return SQL where子句,满足此子句的消息的{@link Direction}都为direction
*/ | // Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Direction {
// /** 发送 */
// SEND,
// /** 接收 */
// RECEIVE
// }
//
// Path: app/src/org/orange/familylink/data/MessageLogRecord.java
// public enum Status {
// /** 未读 */
// UNREAD(Direction.RECEIVE),
// /** 已读 */
// HAVE_READ(Direction.RECEIVE),
// /** 发送中 */
// SENDING(Direction.SEND),
// /** 已发送 */
// SENT(Direction.SEND),
// /** 已送达 */
// DELIVERED(Direction.SEND),
// /** 发送失败 */
// FAILED_TO_SEND(Direction.SEND);
//
// private final Direction mDirection;
// private Status(Direction direction) {
// this.mDirection = direction;
// }
// /**
// * @return 消息方向。如{@link Direction#SEND}
// */
// public Direction getDirection() {
// return mDirection;
// }
// }
// Path: app/src/org/orange/familylink/database/Contract.java
import org.orange.familylink.data.MessageLogRecord.Direction;
import org.orange.familylink.data.MessageLogRecord.Status;
import android.net.Uri;
import android.provider.BaseColumns;
* 信息表中的代表短信级别的码 int
*/
public static final String COLUMN_NAME_CODE = "CODE";
//这个常量字符串是创建messages表的sql语句
public static final String MESSAGES_TABLE_CREATE = "create table " + DATABASE_MESSAGES_TABLE + " (" +
_ID + " integer primary key," + COLUMN_NAME_CONTACT_ID + " integer references contacts(_id)," +
COLUMN_NAME_ADDRESS + " varchar(20)," + COLUMN_NAME_TIME + " integer," + COLUMN_NAME_STATUS + " varchar(30),"
+ COLUMN_NAME_BODY + " text," + COLUMN_NAME_CODE + " integer"
+ ");";
public static final String MESSAGES_DEFAULT_SORT_ORDER = COLUMN_NAME_TIME + " DESC";
//为messages表中的time字段创建索引
public static final String INDEX_CREATE = "create index messages_time_index on " +
DATABASE_MESSAGES_TABLE + "(" + COLUMN_NAME_TIME + ");";
/**
* 取得与指定条件对应的SQL where子句(不包括“WHERE”自身)
* @param status 筛选条件:消息状态
* @return SQL where子句,满足此子句的消息的状态都为status
*/
public static String getWhereClause(Status status) {
return COLUMN_NAME_STATUS + " = '" + status.name() + "'";
}
/**
* 取得与指定条件对应的SQL where子句(不包括“WHERE”自身)
* @param direction 筛选条件:消息方向
* @return SQL where子句,满足此子句的消息的{@link Direction}都为direction
*/ | public static String getWhereClause(Direction direction) { |
fmoghaddam/Hi-Rec | src/main/java/controller/similarity/LowLevelGenreSimilarityRepository.java | // Path: src/main/java/util/ArrayUtil.java
// public class ArrayUtil {
//
// /**
// * Concatenate two arrays into one array
// * @param first
// * @param rest
// * @return
// */
// public static
// double[] concatAll(
// double[] first, double[] ... rest)
// {
// int totalLength = first.length;
// for (double[] array : rest) {
// totalLength += array.length;
// }
// final double[] result = Arrays.copyOf(first, totalLength);
// int offset = first.length;
// for (double[] array : rest) {
// System.arraycopy(array, 0, result, offset, array.length);
// offset += array.length;
// }
// return result;
// }
// }
| import org.apache.commons.math3.stat.correlation.PearsonsCorrelation;
import org.apache.log4j.Logger;
import interfaces.SimilarityInterface;
import model.DataModel;
import model.Globals;
import util.ArrayUtil; | public
Float getItemSimilairty(
int itemId1, int itemId2)
{
switch (Globals.SIMILAIRTY_FUNCTION) {
case COSINE:
return calculateItemCosineSimilarity(itemId1, itemId2);
case PEARSON:
return calculateItemPearsonSimilarity(itemId1, itemId2);
default:
return calculateItemCosineSimilarity(itemId1, itemId2);
}
}
/**
* Calculate Pearson correlation between two items
*
* @param itemId1
* @param itemId2
* @return Pearson correlation of two items if they exist in train dataset,
* O.W. NaN
*/
private
Float calculateItemPearsonSimilarity(
int itemId1, int itemId2)
{
if (this.dataModel.getItem(itemId1) != null
&& this.dataModel.getItem(itemId2) != null)
{
| // Path: src/main/java/util/ArrayUtil.java
// public class ArrayUtil {
//
// /**
// * Concatenate two arrays into one array
// * @param first
// * @param rest
// * @return
// */
// public static
// double[] concatAll(
// double[] first, double[] ... rest)
// {
// int totalLength = first.length;
// for (double[] array : rest) {
// totalLength += array.length;
// }
// final double[] result = Arrays.copyOf(first, totalLength);
// int offset = first.length;
// for (double[] array : rest) {
// System.arraycopy(array, 0, result, offset, array.length);
// offset += array.length;
// }
// return result;
// }
// }
// Path: src/main/java/controller/similarity/LowLevelGenreSimilarityRepository.java
import org.apache.commons.math3.stat.correlation.PearsonsCorrelation;
import org.apache.log4j.Logger;
import interfaces.SimilarityInterface;
import model.DataModel;
import model.Globals;
import util.ArrayUtil;
public
Float getItemSimilairty(
int itemId1, int itemId2)
{
switch (Globals.SIMILAIRTY_FUNCTION) {
case COSINE:
return calculateItemCosineSimilarity(itemId1, itemId2);
case PEARSON:
return calculateItemPearsonSimilarity(itemId1, itemId2);
default:
return calculateItemCosineSimilarity(itemId1, itemId2);
}
}
/**
* Calculate Pearson correlation between two items
*
* @param itemId1
* @param itemId2
* @return Pearson correlation of two items if they exist in train dataset,
* O.W. NaN
*/
private
Float calculateItemPearsonSimilarity(
int itemId1, int itemId2)
{
if (this.dataModel.getItem(itemId1) != null
&& this.dataModel.getItem(itemId2) != null)
{
| final double item1Array[] = ArrayUtil.concatAll(dataModel.getItem(itemId1) |
fmoghaddam/Hi-Rec | src/test/java/metrics/PopularityOnHitTest.java | // Path: src/main/java/model/User.java
// public final class User {
//
// /**
// * User id
// */
// private final int id;
// /**
// * all the items which this user rated and the related rating value
// */
// private Int2FloatLinkedOpenHashMap itemRating;
// /**
// * Mean of rating for this user
// */
// private float meanOfRatings;
//
// public User(
// final int id)
// {
// this.id = id;
// itemRating = new Int2FloatLinkedOpenHashMap();
// }
//
// public User(
// final User user)
// {
// if (user == null) {
// throw new IllegalArgumentException("User is null");
// }
// this.id = user.id;
// this.itemRating = new Int2FloatLinkedOpenHashMap(user.itemRating);
// this.meanOfRatings = user.meanOfRatings;
// }
//
// public
// float getMeanOfRatings() {
// calculateMeanOfRatings();
// return meanOfRatings;
// }
//
// public
// void calculateMeanOfRatings() {
// final DescriptiveStatistics values = new DescriptiveStatistics();
// for (Float rating: itemRating.values()) {
// values.addValue(rating);
// }
// this.meanOfRatings = (float)values.getMean();
// }
//
// public
// int getId() {
// return id;
// }
//
// public
// Int2FloatLinkedOpenHashMap getItemRating() {
// return itemRating;
// }
//
// public
// void addItemRating(
// final int itemId, final float rating)
// {
// if (itemId <= 0 || rating > Globals.MAX_RATING
// || rating < Globals.MIN_RATING)
// {
// throw new IllegalArgumentException(
// "Itemid is not OK or rating value is not OK");
// }
//
// this.itemRating.put(itemId, rating);
// }
//
// public
// double[] getRatingsInFullSizeArray() {
// final double[] ratings = new double[(int)Globals.MAX_ID_OF_ITEMS];
// for (int i: itemRating.keySet()) {
// ratings[(int)(i - 1)] = itemRating.get(i);
// }
// return ratings;
// }
//
// /*
// * @see java.lang.Object#toString()
// */
// @Override
// public
// String toString() {
// return "User [id=" + id + ", itemRating=" + itemRating
// + ", meanOfRatings=" + meanOfRatings + "]";
// }
//
// }
| import model.DataModel;
import model.User;
import static org.junit.Assert.*;
import org.junit.Test; | /**
*
*/
package metrics;
/**
* Test class for {@link PopularityOnHit}
* @author FBM
*
*/
final public class PopularityOnHitTest {
@Test
public
void test() { | // Path: src/main/java/model/User.java
// public final class User {
//
// /**
// * User id
// */
// private final int id;
// /**
// * all the items which this user rated and the related rating value
// */
// private Int2FloatLinkedOpenHashMap itemRating;
// /**
// * Mean of rating for this user
// */
// private float meanOfRatings;
//
// public User(
// final int id)
// {
// this.id = id;
// itemRating = new Int2FloatLinkedOpenHashMap();
// }
//
// public User(
// final User user)
// {
// if (user == null) {
// throw new IllegalArgumentException("User is null");
// }
// this.id = user.id;
// this.itemRating = new Int2FloatLinkedOpenHashMap(user.itemRating);
// this.meanOfRatings = user.meanOfRatings;
// }
//
// public
// float getMeanOfRatings() {
// calculateMeanOfRatings();
// return meanOfRatings;
// }
//
// public
// void calculateMeanOfRatings() {
// final DescriptiveStatistics values = new DescriptiveStatistics();
// for (Float rating: itemRating.values()) {
// values.addValue(rating);
// }
// this.meanOfRatings = (float)values.getMean();
// }
//
// public
// int getId() {
// return id;
// }
//
// public
// Int2FloatLinkedOpenHashMap getItemRating() {
// return itemRating;
// }
//
// public
// void addItemRating(
// final int itemId, final float rating)
// {
// if (itemId <= 0 || rating > Globals.MAX_RATING
// || rating < Globals.MIN_RATING)
// {
// throw new IllegalArgumentException(
// "Itemid is not OK or rating value is not OK");
// }
//
// this.itemRating.put(itemId, rating);
// }
//
// public
// double[] getRatingsInFullSizeArray() {
// final double[] ratings = new double[(int)Globals.MAX_ID_OF_ITEMS];
// for (int i: itemRating.keySet()) {
// ratings[(int)(i - 1)] = itemRating.get(i);
// }
// return ratings;
// }
//
// /*
// * @see java.lang.Object#toString()
// */
// @Override
// public
// String toString() {
// return "User [id=" + id + ", itemRating=" + itemRating
// + ", meanOfRatings=" + meanOfRatings + "]";
// }
//
// }
// Path: src/test/java/metrics/PopularityOnHitTest.java
import model.DataModel;
import model.User;
import static org.junit.Assert.*;
import org.junit.Test;
/**
*
*/
package metrics;
/**
* Test class for {@link PopularityOnHit}
* @author FBM
*
*/
final public class PopularityOnHitTest {
@Test
public
void test() { | final User user = TestDataGenerator.getUser1(); |
fmoghaddam/Hi-Rec | src/test/java/metrics/NoveltyOnHitTest.java | // Path: src/main/java/model/User.java
// public final class User {
//
// /**
// * User id
// */
// private final int id;
// /**
// * all the items which this user rated and the related rating value
// */
// private Int2FloatLinkedOpenHashMap itemRating;
// /**
// * Mean of rating for this user
// */
// private float meanOfRatings;
//
// public User(
// final int id)
// {
// this.id = id;
// itemRating = new Int2FloatLinkedOpenHashMap();
// }
//
// public User(
// final User user)
// {
// if (user == null) {
// throw new IllegalArgumentException("User is null");
// }
// this.id = user.id;
// this.itemRating = new Int2FloatLinkedOpenHashMap(user.itemRating);
// this.meanOfRatings = user.meanOfRatings;
// }
//
// public
// float getMeanOfRatings() {
// calculateMeanOfRatings();
// return meanOfRatings;
// }
//
// public
// void calculateMeanOfRatings() {
// final DescriptiveStatistics values = new DescriptiveStatistics();
// for (Float rating: itemRating.values()) {
// values.addValue(rating);
// }
// this.meanOfRatings = (float)values.getMean();
// }
//
// public
// int getId() {
// return id;
// }
//
// public
// Int2FloatLinkedOpenHashMap getItemRating() {
// return itemRating;
// }
//
// public
// void addItemRating(
// final int itemId, final float rating)
// {
// if (itemId <= 0 || rating > Globals.MAX_RATING
// || rating < Globals.MIN_RATING)
// {
// throw new IllegalArgumentException(
// "Itemid is not OK or rating value is not OK");
// }
//
// this.itemRating.put(itemId, rating);
// }
//
// public
// double[] getRatingsInFullSizeArray() {
// final double[] ratings = new double[(int)Globals.MAX_ID_OF_ITEMS];
// for (int i: itemRating.keySet()) {
// ratings[(int)(i - 1)] = itemRating.get(i);
// }
// return ratings;
// }
//
// /*
// * @see java.lang.Object#toString()
// */
// @Override
// public
// String toString() {
// return "User [id=" + id + ", itemRating=" + itemRating
// + ", meanOfRatings=" + meanOfRatings + "]";
// }
//
// }
| import static org.junit.Assert.*;
import org.junit.Test;
import model.DataModel;
import model.User; | package metrics;
/**
* Test class for {@link NoveltyOnHit}
*
* @author FBM
*
*/
public final class NoveltyOnHitTest {
@Test
public
void test() { | // Path: src/main/java/model/User.java
// public final class User {
//
// /**
// * User id
// */
// private final int id;
// /**
// * all the items which this user rated and the related rating value
// */
// private Int2FloatLinkedOpenHashMap itemRating;
// /**
// * Mean of rating for this user
// */
// private float meanOfRatings;
//
// public User(
// final int id)
// {
// this.id = id;
// itemRating = new Int2FloatLinkedOpenHashMap();
// }
//
// public User(
// final User user)
// {
// if (user == null) {
// throw new IllegalArgumentException("User is null");
// }
// this.id = user.id;
// this.itemRating = new Int2FloatLinkedOpenHashMap(user.itemRating);
// this.meanOfRatings = user.meanOfRatings;
// }
//
// public
// float getMeanOfRatings() {
// calculateMeanOfRatings();
// return meanOfRatings;
// }
//
// public
// void calculateMeanOfRatings() {
// final DescriptiveStatistics values = new DescriptiveStatistics();
// for (Float rating: itemRating.values()) {
// values.addValue(rating);
// }
// this.meanOfRatings = (float)values.getMean();
// }
//
// public
// int getId() {
// return id;
// }
//
// public
// Int2FloatLinkedOpenHashMap getItemRating() {
// return itemRating;
// }
//
// public
// void addItemRating(
// final int itemId, final float rating)
// {
// if (itemId <= 0 || rating > Globals.MAX_RATING
// || rating < Globals.MIN_RATING)
// {
// throw new IllegalArgumentException(
// "Itemid is not OK or rating value is not OK");
// }
//
// this.itemRating.put(itemId, rating);
// }
//
// public
// double[] getRatingsInFullSizeArray() {
// final double[] ratings = new double[(int)Globals.MAX_ID_OF_ITEMS];
// for (int i: itemRating.keySet()) {
// ratings[(int)(i - 1)] = itemRating.get(i);
// }
// return ratings;
// }
//
// /*
// * @see java.lang.Object#toString()
// */
// @Override
// public
// String toString() {
// return "User [id=" + id + ", itemRating=" + itemRating
// + ", meanOfRatings=" + meanOfRatings + "]";
// }
//
// }
// Path: src/test/java/metrics/NoveltyOnHitTest.java
import static org.junit.Assert.*;
import org.junit.Test;
import model.DataModel;
import model.User;
package metrics;
/**
* Test class for {@link NoveltyOnHit}
*
* @author FBM
*
*/
public final class NoveltyOnHitTest {
@Test
public
void test() { | final User user = TestDataGenerator.getUser1(); |
fmoghaddam/Hi-Rec | src/main/java/metrics/MAP.java | // Path: src/main/java/interfaces/ListEvaluation.java
// public interface ListEvaluation extends Metric {
// /**
// * Adds generated list for a specific user for internal calculation
// *
// * @param user
// * A target {@link User} which normally comes from test data
// * @param list
// * Generate item list with related predicted rating for a given
// * {@link User}
// */
// void addRecommendations(User user, Map<Integer, Float> list);
//
// /**
// * Returns the calculated result
// *
// * @return The calculated result
// */
// float getEvaluationResult();
//
// /**
// * Set train data. Train data neede for some metrics such as popularity
// * @param trainData
// */
// void setTrainData(DataModel trainData);
// }
//
// Path: src/main/java/model/User.java
// public final class User {
//
// /**
// * User id
// */
// private final int id;
// /**
// * all the items which this user rated and the related rating value
// */
// private Int2FloatLinkedOpenHashMap itemRating;
// /**
// * Mean of rating for this user
// */
// private float meanOfRatings;
//
// public User(
// final int id)
// {
// this.id = id;
// itemRating = new Int2FloatLinkedOpenHashMap();
// }
//
// public User(
// final User user)
// {
// if (user == null) {
// throw new IllegalArgumentException("User is null");
// }
// this.id = user.id;
// this.itemRating = new Int2FloatLinkedOpenHashMap(user.itemRating);
// this.meanOfRatings = user.meanOfRatings;
// }
//
// public
// float getMeanOfRatings() {
// calculateMeanOfRatings();
// return meanOfRatings;
// }
//
// public
// void calculateMeanOfRatings() {
// final DescriptiveStatistics values = new DescriptiveStatistics();
// for (Float rating: itemRating.values()) {
// values.addValue(rating);
// }
// this.meanOfRatings = (float)values.getMean();
// }
//
// public
// int getId() {
// return id;
// }
//
// public
// Int2FloatLinkedOpenHashMap getItemRating() {
// return itemRating;
// }
//
// public
// void addItemRating(
// final int itemId, final float rating)
// {
// if (itemId <= 0 || rating > Globals.MAX_RATING
// || rating < Globals.MIN_RATING)
// {
// throw new IllegalArgumentException(
// "Itemid is not OK or rating value is not OK");
// }
//
// this.itemRating.put(itemId, rating);
// }
//
// public
// double[] getRatingsInFullSizeArray() {
// final double[] ratings = new double[(int)Globals.MAX_ID_OF_ITEMS];
// for (int i: itemRating.keySet()) {
// ratings[(int)(i - 1)] = itemRating.get(i);
// }
// return ratings;
// }
//
// /*
// * @see java.lang.Object#toString()
// */
// @Override
// public
// String toString() {
// return "User [id=" + id + ", itemRating=" + itemRating
// + ", meanOfRatings=" + meanOfRatings + "]";
// }
//
// }
| import java.util.Map;
import java.util.Map.Entry;
import interfaces.ListEvaluation;
import model.DataModel;
import model.Globals;
import model.User; | /**
*
*/
package metrics;
/**
* @author Admin
*
*/
public class MAP
implements ListEvaluation
{
private float n = 0;
private float sumOfAPs = 0;
/* (non-Javadoc)
* @see interfaces.ListEvaluation#addRecommendations(model.User, java.util.Map)
*/
@Override
public
void addRecommendations( | // Path: src/main/java/interfaces/ListEvaluation.java
// public interface ListEvaluation extends Metric {
// /**
// * Adds generated list for a specific user for internal calculation
// *
// * @param user
// * A target {@link User} which normally comes from test data
// * @param list
// * Generate item list with related predicted rating for a given
// * {@link User}
// */
// void addRecommendations(User user, Map<Integer, Float> list);
//
// /**
// * Returns the calculated result
// *
// * @return The calculated result
// */
// float getEvaluationResult();
//
// /**
// * Set train data. Train data neede for some metrics such as popularity
// * @param trainData
// */
// void setTrainData(DataModel trainData);
// }
//
// Path: src/main/java/model/User.java
// public final class User {
//
// /**
// * User id
// */
// private final int id;
// /**
// * all the items which this user rated and the related rating value
// */
// private Int2FloatLinkedOpenHashMap itemRating;
// /**
// * Mean of rating for this user
// */
// private float meanOfRatings;
//
// public User(
// final int id)
// {
// this.id = id;
// itemRating = new Int2FloatLinkedOpenHashMap();
// }
//
// public User(
// final User user)
// {
// if (user == null) {
// throw new IllegalArgumentException("User is null");
// }
// this.id = user.id;
// this.itemRating = new Int2FloatLinkedOpenHashMap(user.itemRating);
// this.meanOfRatings = user.meanOfRatings;
// }
//
// public
// float getMeanOfRatings() {
// calculateMeanOfRatings();
// return meanOfRatings;
// }
//
// public
// void calculateMeanOfRatings() {
// final DescriptiveStatistics values = new DescriptiveStatistics();
// for (Float rating: itemRating.values()) {
// values.addValue(rating);
// }
// this.meanOfRatings = (float)values.getMean();
// }
//
// public
// int getId() {
// return id;
// }
//
// public
// Int2FloatLinkedOpenHashMap getItemRating() {
// return itemRating;
// }
//
// public
// void addItemRating(
// final int itemId, final float rating)
// {
// if (itemId <= 0 || rating > Globals.MAX_RATING
// || rating < Globals.MIN_RATING)
// {
// throw new IllegalArgumentException(
// "Itemid is not OK or rating value is not OK");
// }
//
// this.itemRating.put(itemId, rating);
// }
//
// public
// double[] getRatingsInFullSizeArray() {
// final double[] ratings = new double[(int)Globals.MAX_ID_OF_ITEMS];
// for (int i: itemRating.keySet()) {
// ratings[(int)(i - 1)] = itemRating.get(i);
// }
// return ratings;
// }
//
// /*
// * @see java.lang.Object#toString()
// */
// @Override
// public
// String toString() {
// return "User [id=" + id + ", itemRating=" + itemRating
// + ", meanOfRatings=" + meanOfRatings + "]";
// }
//
// }
// Path: src/main/java/metrics/MAP.java
import java.util.Map;
import java.util.Map.Entry;
import interfaces.ListEvaluation;
import model.DataModel;
import model.Globals;
import model.User;
/**
*
*/
package metrics;
/**
* @author Admin
*
*/
public class MAP
implements ListEvaluation
{
private float n = 0;
private float sumOfAPs = 0;
/* (non-Javadoc)
* @see interfaces.ListEvaluation#addRecommendations(model.User, java.util.Map)
*/
@Override
public
void addRecommendations( | User user, Map<Integer, Float> list) |
fmoghaddam/Hi-Rec | src/main/java/gui/pages/GeneralFeatureWizard.java | // Path: src/main/java/gui/model/ErrorMessage.java
// public class ErrorMessage extends Label {
//
// public ErrorMessage() {
// this.setTextFill(Color.web("#FF0000"));
// this.setFont(new Font("Arial", 16));
// }
// }
| import gui.WizardPage;
import gui.model.ConfigData;
import gui.model.ErrorMessage;
import gui.model.Metrics;
import gui.model.SimilarityFunctions;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox; | package gui.pages;
/**
* @author FBM
*
*/
public class GeneralFeatureWizard extends WizardPage {
private ComboBox<SimilarityFunctions> similairtyFunction;
private Label similairtyFunctionLable;
private TextField topN;
private Label topNLabel;
private TextField minimumRatingForPositiveRatingTextField;
private Label minimumRatingForPositiveRatingLabel;
private TextField atN;
private Label atNLabel;
private ListView<Metrics> metrics;
private Label metricsLabel;
private CheckBox calculateTTest;
private CheckBox dropMostPopularItemsCheckBox;
private TextField dropMostPopularItemsTextField;
| // Path: src/main/java/gui/model/ErrorMessage.java
// public class ErrorMessage extends Label {
//
// public ErrorMessage() {
// this.setTextFill(Color.web("#FF0000"));
// this.setFont(new Font("Arial", 16));
// }
// }
// Path: src/main/java/gui/pages/GeneralFeatureWizard.java
import gui.WizardPage;
import gui.model.ConfigData;
import gui.model.ErrorMessage;
import gui.model.Metrics;
import gui.model.SimilarityFunctions;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
package gui.pages;
/**
* @author FBM
*
*/
public class GeneralFeatureWizard extends WizardPage {
private ComboBox<SimilarityFunctions> similairtyFunction;
private Label similairtyFunctionLable;
private TextField topN;
private Label topNLabel;
private TextField minimumRatingForPositiveRatingTextField;
private Label minimumRatingForPositiveRatingLabel;
private TextField atN;
private Label atNLabel;
private ListView<Metrics> metrics;
private Label metricsLabel;
private CheckBox calculateTTest;
private CheckBox dropMostPopularItemsCheckBox;
private TextField dropMostPopularItemsTextField;
| private ErrorMessage errorMessage; |
fmoghaddam/Hi-Rec | src/main/java/metrics/Recall.java | // Path: src/main/java/interfaces/ListEvaluation.java
// public interface ListEvaluation extends Metric {
// /**
// * Adds generated list for a specific user for internal calculation
// *
// * @param user
// * A target {@link User} which normally comes from test data
// * @param list
// * Generate item list with related predicted rating for a given
// * {@link User}
// */
// void addRecommendations(User user, Map<Integer, Float> list);
//
// /**
// * Returns the calculated result
// *
// * @return The calculated result
// */
// float getEvaluationResult();
//
// /**
// * Set train data. Train data neede for some metrics such as popularity
// * @param trainData
// */
// void setTrainData(DataModel trainData);
// }
//
// Path: src/main/java/model/User.java
// public final class User {
//
// /**
// * User id
// */
// private final int id;
// /**
// * all the items which this user rated and the related rating value
// */
// private Int2FloatLinkedOpenHashMap itemRating;
// /**
// * Mean of rating for this user
// */
// private float meanOfRatings;
//
// public User(
// final int id)
// {
// this.id = id;
// itemRating = new Int2FloatLinkedOpenHashMap();
// }
//
// public User(
// final User user)
// {
// if (user == null) {
// throw new IllegalArgumentException("User is null");
// }
// this.id = user.id;
// this.itemRating = new Int2FloatLinkedOpenHashMap(user.itemRating);
// this.meanOfRatings = user.meanOfRatings;
// }
//
// public
// float getMeanOfRatings() {
// calculateMeanOfRatings();
// return meanOfRatings;
// }
//
// public
// void calculateMeanOfRatings() {
// final DescriptiveStatistics values = new DescriptiveStatistics();
// for (Float rating: itemRating.values()) {
// values.addValue(rating);
// }
// this.meanOfRatings = (float)values.getMean();
// }
//
// public
// int getId() {
// return id;
// }
//
// public
// Int2FloatLinkedOpenHashMap getItemRating() {
// return itemRating;
// }
//
// public
// void addItemRating(
// final int itemId, final float rating)
// {
// if (itemId <= 0 || rating > Globals.MAX_RATING
// || rating < Globals.MIN_RATING)
// {
// throw new IllegalArgumentException(
// "Itemid is not OK or rating value is not OK");
// }
//
// this.itemRating.put(itemId, rating);
// }
//
// public
// double[] getRatingsInFullSizeArray() {
// final double[] ratings = new double[(int)Globals.MAX_ID_OF_ITEMS];
// for (int i: itemRating.keySet()) {
// ratings[(int)(i - 1)] = itemRating.get(i);
// }
// return ratings;
// }
//
// /*
// * @see java.lang.Object#toString()
// */
// @Override
// public
// String toString() {
// return "User [id=" + id + ", itemRating=" + itemRating
// + ", meanOfRatings=" + meanOfRatings + "]";
// }
//
// }
| import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import interfaces.ListEvaluation;
import model.DataModel;
import model.Globals;
import model.User; | package metrics;
/**
* Recall
*
* @author FBM
*
*/
public final class Recall
implements ListEvaluation
{
float recall = 0;
long counter = 0;
/*
* @see interfaces.ListEvaluation#addRecommendations(model.User,
* java.util.Map)
*/
@Override
public
void addRecommendations( | // Path: src/main/java/interfaces/ListEvaluation.java
// public interface ListEvaluation extends Metric {
// /**
// * Adds generated list for a specific user for internal calculation
// *
// * @param user
// * A target {@link User} which normally comes from test data
// * @param list
// * Generate item list with related predicted rating for a given
// * {@link User}
// */
// void addRecommendations(User user, Map<Integer, Float> list);
//
// /**
// * Returns the calculated result
// *
// * @return The calculated result
// */
// float getEvaluationResult();
//
// /**
// * Set train data. Train data neede for some metrics such as popularity
// * @param trainData
// */
// void setTrainData(DataModel trainData);
// }
//
// Path: src/main/java/model/User.java
// public final class User {
//
// /**
// * User id
// */
// private final int id;
// /**
// * all the items which this user rated and the related rating value
// */
// private Int2FloatLinkedOpenHashMap itemRating;
// /**
// * Mean of rating for this user
// */
// private float meanOfRatings;
//
// public User(
// final int id)
// {
// this.id = id;
// itemRating = new Int2FloatLinkedOpenHashMap();
// }
//
// public User(
// final User user)
// {
// if (user == null) {
// throw new IllegalArgumentException("User is null");
// }
// this.id = user.id;
// this.itemRating = new Int2FloatLinkedOpenHashMap(user.itemRating);
// this.meanOfRatings = user.meanOfRatings;
// }
//
// public
// float getMeanOfRatings() {
// calculateMeanOfRatings();
// return meanOfRatings;
// }
//
// public
// void calculateMeanOfRatings() {
// final DescriptiveStatistics values = new DescriptiveStatistics();
// for (Float rating: itemRating.values()) {
// values.addValue(rating);
// }
// this.meanOfRatings = (float)values.getMean();
// }
//
// public
// int getId() {
// return id;
// }
//
// public
// Int2FloatLinkedOpenHashMap getItemRating() {
// return itemRating;
// }
//
// public
// void addItemRating(
// final int itemId, final float rating)
// {
// if (itemId <= 0 || rating > Globals.MAX_RATING
// || rating < Globals.MIN_RATING)
// {
// throw new IllegalArgumentException(
// "Itemid is not OK or rating value is not OK");
// }
//
// this.itemRating.put(itemId, rating);
// }
//
// public
// double[] getRatingsInFullSizeArray() {
// final double[] ratings = new double[(int)Globals.MAX_ID_OF_ITEMS];
// for (int i: itemRating.keySet()) {
// ratings[(int)(i - 1)] = itemRating.get(i);
// }
// return ratings;
// }
//
// /*
// * @see java.lang.Object#toString()
// */
// @Override
// public
// String toString() {
// return "User [id=" + id + ", itemRating=" + itemRating
// + ", meanOfRatings=" + meanOfRatings + "]";
// }
//
// }
// Path: src/main/java/metrics/Recall.java
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import interfaces.ListEvaluation;
import model.DataModel;
import model.Globals;
import model.User;
package metrics;
/**
* Recall
*
* @author FBM
*
*/
public final class Recall
implements ListEvaluation
{
float recall = 0;
long counter = 0;
/*
* @see interfaces.ListEvaluation#addRecommendations(model.User,
* java.util.Map)
*/
@Override
public
void addRecommendations( | final User user, final Map<Integer, Float> list) |
fmoghaddam/Hi-Rec | src/main/java/gui/pages/AlgorithmWizard.java | // Path: src/main/java/gui/model/ErrorMessage.java
// public class ErrorMessage extends Label {
//
// public ErrorMessage() {
// this.setTextFill(Color.web("#FF0000"));
// this.setFont(new Font("Arial", 16));
// }
// }
| import java.util.ArrayList;
import java.util.List;
import gui.WizardPage;
import gui.model.ConfigData;
import gui.model.ErrorMessage;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ChangeListener;
import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.Slider;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font; | package gui.pages;
/**
* @author FBM
*
*/
public class AlgorithmWizard extends WizardPage {
private ScrollPane scrollPane;
private Label numberOfConfiguration;
private Label numberOfConfigurationValue;
private Slider slider;
private GridPane gridpane;
private GridPane algorithmGridpane;
| // Path: src/main/java/gui/model/ErrorMessage.java
// public class ErrorMessage extends Label {
//
// public ErrorMessage() {
// this.setTextFill(Color.web("#FF0000"));
// this.setFont(new Font("Arial", 16));
// }
// }
// Path: src/main/java/gui/pages/AlgorithmWizard.java
import java.util.ArrayList;
import java.util.List;
import gui.WizardPage;
import gui.model.ConfigData;
import gui.model.ErrorMessage;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ChangeListener;
import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.Slider;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
package gui.pages;
/**
* @author FBM
*
*/
public class AlgorithmWizard extends WizardPage {
private ScrollPane scrollPane;
private Label numberOfConfiguration;
private Label numberOfConfigurationValue;
private Slider slider;
private GridPane gridpane;
private GridPane algorithmGridpane;
| private ErrorMessage errorMessage; |
fmoghaddam/Hi-Rec | src/test/java/metrics/DiversityLowLevelTest.java | // Path: src/main/java/model/User.java
// public final class User {
//
// /**
// * User id
// */
// private final int id;
// /**
// * all the items which this user rated and the related rating value
// */
// private Int2FloatLinkedOpenHashMap itemRating;
// /**
// * Mean of rating for this user
// */
// private float meanOfRatings;
//
// public User(
// final int id)
// {
// this.id = id;
// itemRating = new Int2FloatLinkedOpenHashMap();
// }
//
// public User(
// final User user)
// {
// if (user == null) {
// throw new IllegalArgumentException("User is null");
// }
// this.id = user.id;
// this.itemRating = new Int2FloatLinkedOpenHashMap(user.itemRating);
// this.meanOfRatings = user.meanOfRatings;
// }
//
// public
// float getMeanOfRatings() {
// calculateMeanOfRatings();
// return meanOfRatings;
// }
//
// public
// void calculateMeanOfRatings() {
// final DescriptiveStatistics values = new DescriptiveStatistics();
// for (Float rating: itemRating.values()) {
// values.addValue(rating);
// }
// this.meanOfRatings = (float)values.getMean();
// }
//
// public
// int getId() {
// return id;
// }
//
// public
// Int2FloatLinkedOpenHashMap getItemRating() {
// return itemRating;
// }
//
// public
// void addItemRating(
// final int itemId, final float rating)
// {
// if (itemId <= 0 || rating > Globals.MAX_RATING
// || rating < Globals.MIN_RATING)
// {
// throw new IllegalArgumentException(
// "Itemid is not OK or rating value is not OK");
// }
//
// this.itemRating.put(itemId, rating);
// }
//
// public
// double[] getRatingsInFullSizeArray() {
// final double[] ratings = new double[(int)Globals.MAX_ID_OF_ITEMS];
// for (int i: itemRating.keySet()) {
// ratings[(int)(i - 1)] = itemRating.get(i);
// }
// return ratings;
// }
//
// /*
// * @see java.lang.Object#toString()
// */
// @Override
// public
// String toString() {
// return "User [id=" + id + ", itemRating=" + itemRating
// + ", meanOfRatings=" + meanOfRatings + "]";
// }
//
// }
| import static org.junit.Assert.*;
import org.junit.Test;
import model.DataModel;
import model.User; | package metrics;
/**
* Test class for {@link DiversityLowLevel}
* @author FBM
*
*/
public class DiversityLowLevelTest {
@Test
public
void test() { | // Path: src/main/java/model/User.java
// public final class User {
//
// /**
// * User id
// */
// private final int id;
// /**
// * all the items which this user rated and the related rating value
// */
// private Int2FloatLinkedOpenHashMap itemRating;
// /**
// * Mean of rating for this user
// */
// private float meanOfRatings;
//
// public User(
// final int id)
// {
// this.id = id;
// itemRating = new Int2FloatLinkedOpenHashMap();
// }
//
// public User(
// final User user)
// {
// if (user == null) {
// throw new IllegalArgumentException("User is null");
// }
// this.id = user.id;
// this.itemRating = new Int2FloatLinkedOpenHashMap(user.itemRating);
// this.meanOfRatings = user.meanOfRatings;
// }
//
// public
// float getMeanOfRatings() {
// calculateMeanOfRatings();
// return meanOfRatings;
// }
//
// public
// void calculateMeanOfRatings() {
// final DescriptiveStatistics values = new DescriptiveStatistics();
// for (Float rating: itemRating.values()) {
// values.addValue(rating);
// }
// this.meanOfRatings = (float)values.getMean();
// }
//
// public
// int getId() {
// return id;
// }
//
// public
// Int2FloatLinkedOpenHashMap getItemRating() {
// return itemRating;
// }
//
// public
// void addItemRating(
// final int itemId, final float rating)
// {
// if (itemId <= 0 || rating > Globals.MAX_RATING
// || rating < Globals.MIN_RATING)
// {
// throw new IllegalArgumentException(
// "Itemid is not OK or rating value is not OK");
// }
//
// this.itemRating.put(itemId, rating);
// }
//
// public
// double[] getRatingsInFullSizeArray() {
// final double[] ratings = new double[(int)Globals.MAX_ID_OF_ITEMS];
// for (int i: itemRating.keySet()) {
// ratings[(int)(i - 1)] = itemRating.get(i);
// }
// return ratings;
// }
//
// /*
// * @see java.lang.Object#toString()
// */
// @Override
// public
// String toString() {
// return "User [id=" + id + ", itemRating=" + itemRating
// + ", meanOfRatings=" + meanOfRatings + "]";
// }
//
// }
// Path: src/test/java/metrics/DiversityLowLevelTest.java
import static org.junit.Assert.*;
import org.junit.Test;
import model.DataModel;
import model.User;
package metrics;
/**
* Test class for {@link DiversityLowLevel}
* @author FBM
*
*/
public class DiversityLowLevelTest {
@Test
public
void test() { | final User user = TestDataGenerator.getUser1(); |
fmoghaddam/Hi-Rec | src/main/java/util/TopPopularItemsUtil.java | // Path: src/main/java/model/Item.java
// public class Item {
//
// /**
// * Item id
// */
// private final int id;
// /**
// * All the used who rated this item with the rating value
// */
// private Int2FloatLinkedOpenHashMap userRated;
// /**
// * List of low level features
// */
// private FloatArrayList lowLevelFeature;
// /**
// * List of Genre
// */
// private FloatArrayList genres;
// /**
// * List of tags
// */
// private ObjectSet<String> tags;
// /**
// * Global mean for this item
// */
// private Float mean = null;
//
// public Item(
// final int id)
// {
// this.id = id;
// this.userRated = new Int2FloatLinkedOpenHashMap();
// this.lowLevelFeature = new FloatArrayList();
// this.genres = new FloatArrayList();
// this.tags = new ObjectOpenHashSet<>();
// }
//
// public Item(
// final Item item)
// {
// this.id = item.id;
// this.userRated = new Int2FloatLinkedOpenHashMap(item.userRated);
// this.lowLevelFeature = new FloatArrayList(item.lowLevelFeature);
// this.genres = new FloatArrayList(item.genres);
// this.tags = new ObjectOpenHashSet<>(item.tags);
// }
//
// public
// int getId() {
// return id;
// }
//
// public
// Int2FloatLinkedOpenHashMap getUserRated() {
// return userRated;
// }
//
// public
// double[] getUserRatedAsArray() {
// final double[] array = new double[(int)Globals.MAX_ID_OF_UESRS];
// for (Entry<Integer, Float> entry: userRated.entrySet()) {
// array[entry.getKey() - 1] = entry.getValue();
// }
// return array;
// }
//
// public
// void addUserRating(
// final int userId, final float rating)
// {
// if (userId <= 0 || rating < Globals.MIN_RATING
// || rating > Globals.MAX_RATING)
// {
// throw new IllegalArgumentException(
// "User id is not OK or rating value is not OK");
// }
// userRated.put(userId, rating);
// }
//
// /**
// * Convert low level feature list to array
// *
// * @return
// */
// public
// double[] getLowLevelFeatureAsArray() {
// final double[] array = new double[lowLevelFeature.size()];
// for (int i = 0; i < lowLevelFeature.size(); i++) {
// array[i] = (double)lowLevelFeature.getFloat(i);
// }
// return array;
// }
//
// /**
// * Returns global mean
// *
// * @return
// */
// public
// float getMean() {
// if (mean != null) {
// return mean;
// } else {
// float sum = 0;
// for (float rating: userRated.values()) {
// sum += rating;
// }
// mean = sum / userRated.size();
// }
// return mean;
//
// }
//
// /**
// * @return the tags
// */
// public final
// ObjectSet<String> getTags() {
// return tags;
// }
//
// /**
// * @param tags
// * the tags to set
// */
// public final
// void setTags(
// ObjectSet<String> tags)
// {
// this.tags = new ObjectOpenHashSet<>(tags);
// }
//
// /**
// * @return the genres
// */
// public final
// FloatArrayList getGenres() {
// return genres;
// }
//
// /**
// * @return the lowLevelFeature
// */
// public final
// FloatArrayList getLowLevelFeature() {
// return lowLevelFeature;
// }
//
// /**
// * @param lowLevelFeature
// * the lowLevelFeature to set
// */
// public final
// void setLowLevelFeature(
// FloatArrayList lowLevelFeature)
// {
// this.lowLevelFeature = new FloatArrayList(lowLevelFeature);
// }
//
// /**
// * @param userRated
// * the userRated to set
// */
// public final
// void setUserRated(
// final Int2FloatLinkedOpenHashMap userRated)
// {
// this.userRated = userRated;
// }
//
// /**
// * @param genres
// * the genres to set
// */
// public final
// void setGenres(
// final FloatArrayList genres)
// {
// this.genres = new FloatArrayList(genres);
// }
//
// /**
// * Convert genre list to array
// *
// * @return
// */
// public
// double[] getGenresAsArray() {
// final double[] array = new double[genres.size()];
// for (int i = 0; i < genres.size(); i++) {
// array[i] = genres.getFloat(i);
// }
// return array;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#toString()
// */
// @Override
// public
// String toString() {
// return "Item [id=" + id + ", userRated=" + userRated
// + ", lowLevelFeature=" + lowLevelFeature + ", genres="
// + genres + ", tags=" + tags + ", mean=" + mean + "]";
// }
//
// }
| import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import controller.DataLoader;
import controller.DataLoaderException;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import model.DataModel;
import model.Item; | /**
*
*/
package util;
/**
* This class generates Id of top popular items This ids could be used somewhere
* else (e.g. DataLoader to remove popular items)
*
* @author FBM
*/
public class TopPopularItemsUtil {
/**
* How many items should be reported?
*/
private static final int SIZE = 800;
/**
* @param args
* @throws DataLoaderException
*/
public static
void main(
String[] args) throws DataLoaderException
{
final DataLoader loader = new DataLoader();
final DataModel dataModel = loader.readData();
dataModel.printStatistic();
final Map<Integer, Integer> itemPopularityMap = new LinkedHashMap<>(); | // Path: src/main/java/model/Item.java
// public class Item {
//
// /**
// * Item id
// */
// private final int id;
// /**
// * All the used who rated this item with the rating value
// */
// private Int2FloatLinkedOpenHashMap userRated;
// /**
// * List of low level features
// */
// private FloatArrayList lowLevelFeature;
// /**
// * List of Genre
// */
// private FloatArrayList genres;
// /**
// * List of tags
// */
// private ObjectSet<String> tags;
// /**
// * Global mean for this item
// */
// private Float mean = null;
//
// public Item(
// final int id)
// {
// this.id = id;
// this.userRated = new Int2FloatLinkedOpenHashMap();
// this.lowLevelFeature = new FloatArrayList();
// this.genres = new FloatArrayList();
// this.tags = new ObjectOpenHashSet<>();
// }
//
// public Item(
// final Item item)
// {
// this.id = item.id;
// this.userRated = new Int2FloatLinkedOpenHashMap(item.userRated);
// this.lowLevelFeature = new FloatArrayList(item.lowLevelFeature);
// this.genres = new FloatArrayList(item.genres);
// this.tags = new ObjectOpenHashSet<>(item.tags);
// }
//
// public
// int getId() {
// return id;
// }
//
// public
// Int2FloatLinkedOpenHashMap getUserRated() {
// return userRated;
// }
//
// public
// double[] getUserRatedAsArray() {
// final double[] array = new double[(int)Globals.MAX_ID_OF_UESRS];
// for (Entry<Integer, Float> entry: userRated.entrySet()) {
// array[entry.getKey() - 1] = entry.getValue();
// }
// return array;
// }
//
// public
// void addUserRating(
// final int userId, final float rating)
// {
// if (userId <= 0 || rating < Globals.MIN_RATING
// || rating > Globals.MAX_RATING)
// {
// throw new IllegalArgumentException(
// "User id is not OK or rating value is not OK");
// }
// userRated.put(userId, rating);
// }
//
// /**
// * Convert low level feature list to array
// *
// * @return
// */
// public
// double[] getLowLevelFeatureAsArray() {
// final double[] array = new double[lowLevelFeature.size()];
// for (int i = 0; i < lowLevelFeature.size(); i++) {
// array[i] = (double)lowLevelFeature.getFloat(i);
// }
// return array;
// }
//
// /**
// * Returns global mean
// *
// * @return
// */
// public
// float getMean() {
// if (mean != null) {
// return mean;
// } else {
// float sum = 0;
// for (float rating: userRated.values()) {
// sum += rating;
// }
// mean = sum / userRated.size();
// }
// return mean;
//
// }
//
// /**
// * @return the tags
// */
// public final
// ObjectSet<String> getTags() {
// return tags;
// }
//
// /**
// * @param tags
// * the tags to set
// */
// public final
// void setTags(
// ObjectSet<String> tags)
// {
// this.tags = new ObjectOpenHashSet<>(tags);
// }
//
// /**
// * @return the genres
// */
// public final
// FloatArrayList getGenres() {
// return genres;
// }
//
// /**
// * @return the lowLevelFeature
// */
// public final
// FloatArrayList getLowLevelFeature() {
// return lowLevelFeature;
// }
//
// /**
// * @param lowLevelFeature
// * the lowLevelFeature to set
// */
// public final
// void setLowLevelFeature(
// FloatArrayList lowLevelFeature)
// {
// this.lowLevelFeature = new FloatArrayList(lowLevelFeature);
// }
//
// /**
// * @param userRated
// * the userRated to set
// */
// public final
// void setUserRated(
// final Int2FloatLinkedOpenHashMap userRated)
// {
// this.userRated = userRated;
// }
//
// /**
// * @param genres
// * the genres to set
// */
// public final
// void setGenres(
// final FloatArrayList genres)
// {
// this.genres = new FloatArrayList(genres);
// }
//
// /**
// * Convert genre list to array
// *
// * @return
// */
// public
// double[] getGenresAsArray() {
// final double[] array = new double[genres.size()];
// for (int i = 0; i < genres.size(); i++) {
// array[i] = genres.getFloat(i);
// }
// return array;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#toString()
// */
// @Override
// public
// String toString() {
// return "Item [id=" + id + ", userRated=" + userRated
// + ", lowLevelFeature=" + lowLevelFeature + ", genres="
// + genres + ", tags=" + tags + ", mean=" + mean + "]";
// }
//
// }
// Path: src/main/java/util/TopPopularItemsUtil.java
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import controller.DataLoader;
import controller.DataLoaderException;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import model.DataModel;
import model.Item;
/**
*
*/
package util;
/**
* This class generates Id of top popular items This ids could be used somewhere
* else (e.g. DataLoader to remove popular items)
*
* @author FBM
*/
public class TopPopularItemsUtil {
/**
* How many items should be reported?
*/
private static final int SIZE = 800;
/**
* @param args
* @throws DataLoaderException
*/
public static
void main(
String[] args) throws DataLoaderException
{
final DataLoader loader = new DataLoader();
final DataModel dataModel = loader.readData();
dataModel.printStatistic();
final Map<Integer, Integer> itemPopularityMap = new LinkedHashMap<>(); | for (Entry<Integer, Item> entry: dataModel.getItems().entrySet()) { |
fmoghaddam/Hi-Rec | src/main/java/gui/pages/AlgorithmVisualComponent.java | // Path: src/main/java/gui/messages/FoldLevelUpdateMessage.java
// public class FoldLevelUpdateMessage {
// private final int algorithmId;
// private final int foldId;
// private final FoldStatus status;
// /**
// * @param algorithmId
// * @param foldId
// * @param status
// */
// public FoldLevelUpdateMessage(int algorithmId, int foldId, FoldStatus status) {
// super();
// this.algorithmId = algorithmId;
// this.foldId = foldId;
// this.status = status;
// }
// /**
// * @return the algorithmId
// */
// public final int getAlgorithmId() {
// return algorithmId;
// }
// /**
// * @return the foldId
// */
// public final int getFoldId() {
// return foldId;
// }
// /**
// * @return the status
// */
// public final FoldStatus getStatus() {
// return status;
// }
//
// }
| import java.util.HashMap;
import java.util.Map;
import com.google.common.eventbus.Subscribe;
import gui.messages.FoldLevelUpdateMessage;
import javafx.application.Platform;
import javafx.scene.Parent;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import util.MessageBus; | package gui.pages;
/**
* @author FBM
*
*/
public class AlgorithmVisualComponent {
private int algorithmId;
private Label algorithmName;
private Map<Integer,CircleComponent> circleMap;
/**
* @param id
* @param algorithmName
* @param numberOfFold
*/
public AlgorithmVisualComponent(int id, String algorithmName, int numberOfFold) {
this.algorithmId = id;
this.algorithmName = new Label(algorithmName);
this.circleMap = new HashMap<>();
for(int i=1;i<=numberOfFold;i++){
circleMap.put(i,new CircleComponent("Fold "+i));
}
MessageBus.getInstance().register(this);
}
public Parent getLayout(){
final VBox circles = new VBox(5.0);
for(CircleComponent c:circleMap.values()){
circles.getChildren().add(c.getLayout());
};
final VBox main = new VBox(5.0, algorithmName, circles);
main.setMinWidth(320);
main.setStyle("-fx-padding: 10;" + "-fx-border-style: solid inside;" + "-fx-border-width: 2;"
+ "-fx-border-insets: 5;" + "-fx-border-radius: 5;" + "-fx-border-color: gray;");
return main;
}
@Subscribe | // Path: src/main/java/gui/messages/FoldLevelUpdateMessage.java
// public class FoldLevelUpdateMessage {
// private final int algorithmId;
// private final int foldId;
// private final FoldStatus status;
// /**
// * @param algorithmId
// * @param foldId
// * @param status
// */
// public FoldLevelUpdateMessage(int algorithmId, int foldId, FoldStatus status) {
// super();
// this.algorithmId = algorithmId;
// this.foldId = foldId;
// this.status = status;
// }
// /**
// * @return the algorithmId
// */
// public final int getAlgorithmId() {
// return algorithmId;
// }
// /**
// * @return the foldId
// */
// public final int getFoldId() {
// return foldId;
// }
// /**
// * @return the status
// */
// public final FoldStatus getStatus() {
// return status;
// }
//
// }
// Path: src/main/java/gui/pages/AlgorithmVisualComponent.java
import java.util.HashMap;
import java.util.Map;
import com.google.common.eventbus.Subscribe;
import gui.messages.FoldLevelUpdateMessage;
import javafx.application.Platform;
import javafx.scene.Parent;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import util.MessageBus;
package gui.pages;
/**
* @author FBM
*
*/
public class AlgorithmVisualComponent {
private int algorithmId;
private Label algorithmName;
private Map<Integer,CircleComponent> circleMap;
/**
* @param id
* @param algorithmName
* @param numberOfFold
*/
public AlgorithmVisualComponent(int id, String algorithmName, int numberOfFold) {
this.algorithmId = id;
this.algorithmName = new Label(algorithmName);
this.circleMap = new HashMap<>();
for(int i=1;i<=numberOfFold;i++){
circleMap.put(i,new CircleComponent("Fold "+i));
}
MessageBus.getInstance().register(this);
}
public Parent getLayout(){
final VBox circles = new VBox(5.0);
for(CircleComponent c:circleMap.values()){
circles.getChildren().add(c.getLayout());
};
final VBox main = new VBox(5.0, algorithmName, circles);
main.setMinWidth(320);
main.setStyle("-fx-padding: 10;" + "-fx-border-style: solid inside;" + "-fx-border-width: 2;"
+ "-fx-border-insets: 5;" + "-fx-border-radius: 5;" + "-fx-border-color: gray;");
return main;
}
@Subscribe | public void update(final FoldLevelUpdateMessage message) { |
fmoghaddam/Hi-Rec | src/main/java/gui/pages/RunPage.java | // Path: src/main/java/gui/messages/AlgorithmLevelUpdateMessage.java
// public class AlgorithmLevelUpdateMessage {
// private final int id;
// private final String algorithmName;
// private final int numberOfFold;
// /**
// * @param id
// * @param algorithmName
// * @param nuberOfFold
// */
// public AlgorithmLevelUpdateMessage(int id, String algorithmName, int nuberOfFold) {
// super();
// this.id = id;
// this.algorithmName = algorithmName;
// this.numberOfFold = nuberOfFold;
// }
// /**
// * @return the id
// */
// public final int getId() {
// return id;
// }
// /**
// * @return the algorithmName
// */
// public final String getAlgorithmName() {
// return algorithmName;
// }
// /**
// * @return the nuberOfFold
// */
// public final int getNumberOfFold() {
// return numberOfFold;
// }
// }
//
// Path: src/main/java/gui/messages/CalculationDoneMessage.java
// public class CalculationDoneMessage {
//
// }
//
// Path: src/main/java/gui/messages/StopAllRequestMessage.java
// public class StopAllRequestMessage {
//
// }
| import java.util.Arrays;
import java.util.List;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
import com.google.common.eventbus.Subscribe;
import gui.WizardPage;
import gui.messages.AlgorithmLevelUpdateMessage;
import gui.messages.CalculationDoneMessage;
import gui.messages.EnableStopButtonMessage;
import gui.messages.StopAllRequestMessage;
import javafx.application.Platform;
import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextArea;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import run.HiRec;
import util.MessageBus; | package gui.pages;
/**
* @author FBM
*
*/
public class RunPage extends WizardPage{
private StatusMessageAppender outputTextArea;
private ScrollPane algorithmsScrollPane;
private GridPane algorithmsGrid;
private static Button stopBtn;
private static Button goToFirstPage;
/**
* @param title
*/
public RunPage() {
super("Run",createExtraButtons());
MessageBus.getInstance().register(this);
Logger.getRootLogger().addAppender(outputTextArea);
//This line should be inside createExtraButtons
//Just for simplicity I added it here
goToFirstPage.setOnAction(event->{
navTo(0);
});
}
private static List<Button> createExtraButtons() {
stopBtn = new Button("Stop");
stopBtn.setOnAction(event -> { | // Path: src/main/java/gui/messages/AlgorithmLevelUpdateMessage.java
// public class AlgorithmLevelUpdateMessage {
// private final int id;
// private final String algorithmName;
// private final int numberOfFold;
// /**
// * @param id
// * @param algorithmName
// * @param nuberOfFold
// */
// public AlgorithmLevelUpdateMessage(int id, String algorithmName, int nuberOfFold) {
// super();
// this.id = id;
// this.algorithmName = algorithmName;
// this.numberOfFold = nuberOfFold;
// }
// /**
// * @return the id
// */
// public final int getId() {
// return id;
// }
// /**
// * @return the algorithmName
// */
// public final String getAlgorithmName() {
// return algorithmName;
// }
// /**
// * @return the nuberOfFold
// */
// public final int getNumberOfFold() {
// return numberOfFold;
// }
// }
//
// Path: src/main/java/gui/messages/CalculationDoneMessage.java
// public class CalculationDoneMessage {
//
// }
//
// Path: src/main/java/gui/messages/StopAllRequestMessage.java
// public class StopAllRequestMessage {
//
// }
// Path: src/main/java/gui/pages/RunPage.java
import java.util.Arrays;
import java.util.List;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
import com.google.common.eventbus.Subscribe;
import gui.WizardPage;
import gui.messages.AlgorithmLevelUpdateMessage;
import gui.messages.CalculationDoneMessage;
import gui.messages.EnableStopButtonMessage;
import gui.messages.StopAllRequestMessage;
import javafx.application.Platform;
import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextArea;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import run.HiRec;
import util.MessageBus;
package gui.pages;
/**
* @author FBM
*
*/
public class RunPage extends WizardPage{
private StatusMessageAppender outputTextArea;
private ScrollPane algorithmsScrollPane;
private GridPane algorithmsGrid;
private static Button stopBtn;
private static Button goToFirstPage;
/**
* @param title
*/
public RunPage() {
super("Run",createExtraButtons());
MessageBus.getInstance().register(this);
Logger.getRootLogger().addAppender(outputTextArea);
//This line should be inside createExtraButtons
//Just for simplicity I added it here
goToFirstPage.setOnAction(event->{
navTo(0);
});
}
private static List<Button> createExtraButtons() {
stopBtn = new Button("Stop");
stopBtn.setOnAction(event -> { | MessageBus.getInstance().getBus().post(new StopAllRequestMessage()); |
fmoghaddam/Hi-Rec | src/main/java/gui/pages/RunPage.java | // Path: src/main/java/gui/messages/AlgorithmLevelUpdateMessage.java
// public class AlgorithmLevelUpdateMessage {
// private final int id;
// private final String algorithmName;
// private final int numberOfFold;
// /**
// * @param id
// * @param algorithmName
// * @param nuberOfFold
// */
// public AlgorithmLevelUpdateMessage(int id, String algorithmName, int nuberOfFold) {
// super();
// this.id = id;
// this.algorithmName = algorithmName;
// this.numberOfFold = nuberOfFold;
// }
// /**
// * @return the id
// */
// public final int getId() {
// return id;
// }
// /**
// * @return the algorithmName
// */
// public final String getAlgorithmName() {
// return algorithmName;
// }
// /**
// * @return the nuberOfFold
// */
// public final int getNumberOfFold() {
// return numberOfFold;
// }
// }
//
// Path: src/main/java/gui/messages/CalculationDoneMessage.java
// public class CalculationDoneMessage {
//
// }
//
// Path: src/main/java/gui/messages/StopAllRequestMessage.java
// public class StopAllRequestMessage {
//
// }
| import java.util.Arrays;
import java.util.List;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
import com.google.common.eventbus.Subscribe;
import gui.WizardPage;
import gui.messages.AlgorithmLevelUpdateMessage;
import gui.messages.CalculationDoneMessage;
import gui.messages.EnableStopButtonMessage;
import gui.messages.StopAllRequestMessage;
import javafx.application.Platform;
import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextArea;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import run.HiRec;
import util.MessageBus; | package gui.pages;
/**
* @author FBM
*
*/
public class RunPage extends WizardPage{
private StatusMessageAppender outputTextArea;
private ScrollPane algorithmsScrollPane;
private GridPane algorithmsGrid;
private static Button stopBtn;
private static Button goToFirstPage;
/**
* @param title
*/
public RunPage() {
super("Run",createExtraButtons());
MessageBus.getInstance().register(this);
Logger.getRootLogger().addAppender(outputTextArea);
//This line should be inside createExtraButtons
//Just for simplicity I added it here
goToFirstPage.setOnAction(event->{
navTo(0);
});
}
private static List<Button> createExtraButtons() {
stopBtn = new Button("Stop");
stopBtn.setOnAction(event -> {
MessageBus.getInstance().getBus().post(new StopAllRequestMessage());
});
stopBtn.setDisable(true);
goToFirstPage = new Button("Go to first page");
goToFirstPage.setDisable(true);
return Arrays.asList(goToFirstPage,stopBtn) ;
}
@Subscribe | // Path: src/main/java/gui/messages/AlgorithmLevelUpdateMessage.java
// public class AlgorithmLevelUpdateMessage {
// private final int id;
// private final String algorithmName;
// private final int numberOfFold;
// /**
// * @param id
// * @param algorithmName
// * @param nuberOfFold
// */
// public AlgorithmLevelUpdateMessage(int id, String algorithmName, int nuberOfFold) {
// super();
// this.id = id;
// this.algorithmName = algorithmName;
// this.numberOfFold = nuberOfFold;
// }
// /**
// * @return the id
// */
// public final int getId() {
// return id;
// }
// /**
// * @return the algorithmName
// */
// public final String getAlgorithmName() {
// return algorithmName;
// }
// /**
// * @return the nuberOfFold
// */
// public final int getNumberOfFold() {
// return numberOfFold;
// }
// }
//
// Path: src/main/java/gui/messages/CalculationDoneMessage.java
// public class CalculationDoneMessage {
//
// }
//
// Path: src/main/java/gui/messages/StopAllRequestMessage.java
// public class StopAllRequestMessage {
//
// }
// Path: src/main/java/gui/pages/RunPage.java
import java.util.Arrays;
import java.util.List;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
import com.google.common.eventbus.Subscribe;
import gui.WizardPage;
import gui.messages.AlgorithmLevelUpdateMessage;
import gui.messages.CalculationDoneMessage;
import gui.messages.EnableStopButtonMessage;
import gui.messages.StopAllRequestMessage;
import javafx.application.Platform;
import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextArea;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import run.HiRec;
import util.MessageBus;
package gui.pages;
/**
* @author FBM
*
*/
public class RunPage extends WizardPage{
private StatusMessageAppender outputTextArea;
private ScrollPane algorithmsScrollPane;
private GridPane algorithmsGrid;
private static Button stopBtn;
private static Button goToFirstPage;
/**
* @param title
*/
public RunPage() {
super("Run",createExtraButtons());
MessageBus.getInstance().register(this);
Logger.getRootLogger().addAppender(outputTextArea);
//This line should be inside createExtraButtons
//Just for simplicity I added it here
goToFirstPage.setOnAction(event->{
navTo(0);
});
}
private static List<Button> createExtraButtons() {
stopBtn = new Button("Stop");
stopBtn.setOnAction(event -> {
MessageBus.getInstance().getBus().post(new StopAllRequestMessage());
});
stopBtn.setDisable(true);
goToFirstPage = new Button("Go to first page");
goToFirstPage.setDisable(true);
return Arrays.asList(goToFirstPage,stopBtn) ;
}
@Subscribe | private void enableGoToFirstPgaeButton(final CalculationDoneMessage message){ |
fmoghaddam/Hi-Rec | src/main/java/gui/pages/RunPage.java | // Path: src/main/java/gui/messages/AlgorithmLevelUpdateMessage.java
// public class AlgorithmLevelUpdateMessage {
// private final int id;
// private final String algorithmName;
// private final int numberOfFold;
// /**
// * @param id
// * @param algorithmName
// * @param nuberOfFold
// */
// public AlgorithmLevelUpdateMessage(int id, String algorithmName, int nuberOfFold) {
// super();
// this.id = id;
// this.algorithmName = algorithmName;
// this.numberOfFold = nuberOfFold;
// }
// /**
// * @return the id
// */
// public final int getId() {
// return id;
// }
// /**
// * @return the algorithmName
// */
// public final String getAlgorithmName() {
// return algorithmName;
// }
// /**
// * @return the nuberOfFold
// */
// public final int getNumberOfFold() {
// return numberOfFold;
// }
// }
//
// Path: src/main/java/gui/messages/CalculationDoneMessage.java
// public class CalculationDoneMessage {
//
// }
//
// Path: src/main/java/gui/messages/StopAllRequestMessage.java
// public class StopAllRequestMessage {
//
// }
| import java.util.Arrays;
import java.util.List;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
import com.google.common.eventbus.Subscribe;
import gui.WizardPage;
import gui.messages.AlgorithmLevelUpdateMessage;
import gui.messages.CalculationDoneMessage;
import gui.messages.EnableStopButtonMessage;
import gui.messages.StopAllRequestMessage;
import javafx.application.Platform;
import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextArea;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import run.HiRec;
import util.MessageBus; | //Just for simplicity I added it here
goToFirstPage.setOnAction(event->{
navTo(0);
});
}
private static List<Button> createExtraButtons() {
stopBtn = new Button("Stop");
stopBtn.setOnAction(event -> {
MessageBus.getInstance().getBus().post(new StopAllRequestMessage());
});
stopBtn.setDisable(true);
goToFirstPage = new Button("Go to first page");
goToFirstPage.setDisable(true);
return Arrays.asList(goToFirstPage,stopBtn) ;
}
@Subscribe
private void enableGoToFirstPgaeButton(final CalculationDoneMessage message){
goToFirstPage.setDisable(false);
}
@Subscribe
private void enableStopButton(final EnableStopButtonMessage message){
stopBtn.setDisable(false);
}
@Subscribe | // Path: src/main/java/gui/messages/AlgorithmLevelUpdateMessage.java
// public class AlgorithmLevelUpdateMessage {
// private final int id;
// private final String algorithmName;
// private final int numberOfFold;
// /**
// * @param id
// * @param algorithmName
// * @param nuberOfFold
// */
// public AlgorithmLevelUpdateMessage(int id, String algorithmName, int nuberOfFold) {
// super();
// this.id = id;
// this.algorithmName = algorithmName;
// this.numberOfFold = nuberOfFold;
// }
// /**
// * @return the id
// */
// public final int getId() {
// return id;
// }
// /**
// * @return the algorithmName
// */
// public final String getAlgorithmName() {
// return algorithmName;
// }
// /**
// * @return the nuberOfFold
// */
// public final int getNumberOfFold() {
// return numberOfFold;
// }
// }
//
// Path: src/main/java/gui/messages/CalculationDoneMessage.java
// public class CalculationDoneMessage {
//
// }
//
// Path: src/main/java/gui/messages/StopAllRequestMessage.java
// public class StopAllRequestMessage {
//
// }
// Path: src/main/java/gui/pages/RunPage.java
import java.util.Arrays;
import java.util.List;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
import com.google.common.eventbus.Subscribe;
import gui.WizardPage;
import gui.messages.AlgorithmLevelUpdateMessage;
import gui.messages.CalculationDoneMessage;
import gui.messages.EnableStopButtonMessage;
import gui.messages.StopAllRequestMessage;
import javafx.application.Platform;
import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextArea;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import run.HiRec;
import util.MessageBus;
//Just for simplicity I added it here
goToFirstPage.setOnAction(event->{
navTo(0);
});
}
private static List<Button> createExtraButtons() {
stopBtn = new Button("Stop");
stopBtn.setOnAction(event -> {
MessageBus.getInstance().getBus().post(new StopAllRequestMessage());
});
stopBtn.setDisable(true);
goToFirstPage = new Button("Go to first page");
goToFirstPage.setDisable(true);
return Arrays.asList(goToFirstPage,stopBtn) ;
}
@Subscribe
private void enableGoToFirstPgaeButton(final CalculationDoneMessage message){
goToFirstPage.setDisable(false);
}
@Subscribe
private void enableStopButton(final EnableStopButtonMessage message){
stopBtn.setDisable(false);
}
@Subscribe | private void addAlgorithmComponent(final AlgorithmLevelUpdateMessage message) { |
fmoghaddam/Hi-Rec | src/main/java/gui/pages/AlgorithmComponent.java | // Path: src/main/java/gui/model/Algorithms.java
// public enum Algorithms {
// ItemBasedNN("ItemBasedNN"), FactorizationMachine("FactorizationMachine"), AveragePopularity(
// "AveragePopularity"), FunkSVD("FunkSVD"), HybridTagLowLevel("HybridTagLowLevel");
//
// private StringProperty text;
//
// private Algorithms(String text) {
// this.text = new SimpleStringProperty(text);
// }
//
// public StringProperty getText() {
// return text;
// }
// }
//
// Path: src/main/java/interfaces/AbstractRecommender.java
// public class AbstractRecommender implements Recommender,Serializable {
//
// private static final long serialVersionUID = -7339073808310101731L;
// protected DataModel trainDataModel;
// /**
// * A map which contains information about the fields name in the class
// * and the related key in config file.
// * Key = filed name
// * Value = Map<config file key,pretty name>
// * pretty name used in GUI
// */
// protected final Map<String,Map<String,String>> configurableParametersMap = new HashMap<>();
// /**
// * Repository used for calculating similarities
// */
// protected SimilarityInterface similarityRepository;
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#predictRating(model.User, model.Item)
// */
// @Override
// public Float predictRating(User user, Item item) {
// return null;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#recommendItems(model.User)
// */
// @Override
// public Map<Integer, Float> recommendItems(User user) {
// return null;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#train(model.DataModel)
// */
// @Override
// public void train(DataModel trainData) {
// this.trainDataModel = trainData;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#setSimilarityRepository(interfaces.SimilarityInterface)
// */
// @Override
// public void setSimilarityRepository(SimilarityInterface similarityRepository) {
// if (similarityRepository == null) {
// throw new IllegalArgumentException("SimilarityRepository is null");
// }
// this.similarityRepository = similarityRepository;
// }
//
// /*
// * (non-Javadoc)
// * @see interfaces.Recommender#getSimilarityRepository()
// */
// @Override
// public SimilarityInterface getSimilarityRepository() {
// return similarityRepository;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#isSimilairtyNeeded()
// */
// @Override
// public boolean isSimilairtyNeeded() {
// return true;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#getConfigurabaleParameters()
// */
// @Override
// public Map<String,Map<String,String>> getConfigurabaleParameters() {
// return this.configurableParametersMap;
// }
//
// }
| import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import gui.model.Algorithms;
import gui.model.ConfigData;
import interfaces.AbstractRecommender;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.scene.Parent;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.Toggle;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import util.ClassInstantiator; | package gui.pages;
/**
* @author FBM
*
*/
public class AlgorithmComponent {
private int id;
private Label algorithmName; | // Path: src/main/java/gui/model/Algorithms.java
// public enum Algorithms {
// ItemBasedNN("ItemBasedNN"), FactorizationMachine("FactorizationMachine"), AveragePopularity(
// "AveragePopularity"), FunkSVD("FunkSVD"), HybridTagLowLevel("HybridTagLowLevel");
//
// private StringProperty text;
//
// private Algorithms(String text) {
// this.text = new SimpleStringProperty(text);
// }
//
// public StringProperty getText() {
// return text;
// }
// }
//
// Path: src/main/java/interfaces/AbstractRecommender.java
// public class AbstractRecommender implements Recommender,Serializable {
//
// private static final long serialVersionUID = -7339073808310101731L;
// protected DataModel trainDataModel;
// /**
// * A map which contains information about the fields name in the class
// * and the related key in config file.
// * Key = filed name
// * Value = Map<config file key,pretty name>
// * pretty name used in GUI
// */
// protected final Map<String,Map<String,String>> configurableParametersMap = new HashMap<>();
// /**
// * Repository used for calculating similarities
// */
// protected SimilarityInterface similarityRepository;
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#predictRating(model.User, model.Item)
// */
// @Override
// public Float predictRating(User user, Item item) {
// return null;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#recommendItems(model.User)
// */
// @Override
// public Map<Integer, Float> recommendItems(User user) {
// return null;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#train(model.DataModel)
// */
// @Override
// public void train(DataModel trainData) {
// this.trainDataModel = trainData;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#setSimilarityRepository(interfaces.SimilarityInterface)
// */
// @Override
// public void setSimilarityRepository(SimilarityInterface similarityRepository) {
// if (similarityRepository == null) {
// throw new IllegalArgumentException("SimilarityRepository is null");
// }
// this.similarityRepository = similarityRepository;
// }
//
// /*
// * (non-Javadoc)
// * @see interfaces.Recommender#getSimilarityRepository()
// */
// @Override
// public SimilarityInterface getSimilarityRepository() {
// return similarityRepository;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#isSimilairtyNeeded()
// */
// @Override
// public boolean isSimilairtyNeeded() {
// return true;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#getConfigurabaleParameters()
// */
// @Override
// public Map<String,Map<String,String>> getConfigurabaleParameters() {
// return this.configurableParametersMap;
// }
//
// }
// Path: src/main/java/gui/pages/AlgorithmComponent.java
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import gui.model.Algorithms;
import gui.model.ConfigData;
import interfaces.AbstractRecommender;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.scene.Parent;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.Toggle;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import util.ClassInstantiator;
package gui.pages;
/**
* @author FBM
*
*/
public class AlgorithmComponent {
private int id;
private Label algorithmName; | private ComboBox<Algorithms> algorithmCombobox; |
fmoghaddam/Hi-Rec | src/main/java/gui/pages/AlgorithmComponent.java | // Path: src/main/java/gui/model/Algorithms.java
// public enum Algorithms {
// ItemBasedNN("ItemBasedNN"), FactorizationMachine("FactorizationMachine"), AveragePopularity(
// "AveragePopularity"), FunkSVD("FunkSVD"), HybridTagLowLevel("HybridTagLowLevel");
//
// private StringProperty text;
//
// private Algorithms(String text) {
// this.text = new SimpleStringProperty(text);
// }
//
// public StringProperty getText() {
// return text;
// }
// }
//
// Path: src/main/java/interfaces/AbstractRecommender.java
// public class AbstractRecommender implements Recommender,Serializable {
//
// private static final long serialVersionUID = -7339073808310101731L;
// protected DataModel trainDataModel;
// /**
// * A map which contains information about the fields name in the class
// * and the related key in config file.
// * Key = filed name
// * Value = Map<config file key,pretty name>
// * pretty name used in GUI
// */
// protected final Map<String,Map<String,String>> configurableParametersMap = new HashMap<>();
// /**
// * Repository used for calculating similarities
// */
// protected SimilarityInterface similarityRepository;
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#predictRating(model.User, model.Item)
// */
// @Override
// public Float predictRating(User user, Item item) {
// return null;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#recommendItems(model.User)
// */
// @Override
// public Map<Integer, Float> recommendItems(User user) {
// return null;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#train(model.DataModel)
// */
// @Override
// public void train(DataModel trainData) {
// this.trainDataModel = trainData;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#setSimilarityRepository(interfaces.SimilarityInterface)
// */
// @Override
// public void setSimilarityRepository(SimilarityInterface similarityRepository) {
// if (similarityRepository == null) {
// throw new IllegalArgumentException("SimilarityRepository is null");
// }
// this.similarityRepository = similarityRepository;
// }
//
// /*
// * (non-Javadoc)
// * @see interfaces.Recommender#getSimilarityRepository()
// */
// @Override
// public SimilarityInterface getSimilarityRepository() {
// return similarityRepository;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#isSimilairtyNeeded()
// */
// @Override
// public boolean isSimilairtyNeeded() {
// return true;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#getConfigurabaleParameters()
// */
// @Override
// public Map<String,Map<String,String>> getConfigurabaleParameters() {
// return this.configurableParametersMap;
// }
//
// }
| import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import gui.model.Algorithms;
import gui.model.ConfigData;
import interfaces.AbstractRecommender;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.scene.Parent;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.Toggle;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import util.ClassInstantiator; |
final String key3 = "ALGORITHM_" + id + "_USE_GENRE";
ConfigData.instance.ALGORITHM_PARAMETERS.put(key3, new SimpleStringProperty(""));
ConfigData.instance.ALGORITHM_PARAMETERS.get(key3)
.bind(new SimpleStringProperty(String.valueOf(useGenre.selectedProperty().get())));
final String key4 = "ALGORITHM_" + id + "_USE_TAG";
ConfigData.instance.ALGORITHM_PARAMETERS.put(key4, new SimpleStringProperty(""));
ConfigData.instance.ALGORITHM_PARAMETERS.get(key4)
.bind(new SimpleStringProperty(String.valueOf(useTag.selectedProperty().get())));
final String key5 = "ALGORITHM_" + id + "_USE_RATING";
ConfigData.instance.ALGORITHM_PARAMETERS.put(key5, new SimpleStringProperty(""));
ConfigData.instance.ALGORITHM_PARAMETERS.get(key5)
.bind(new SimpleStringProperty(String.valueOf(useRating.selectedProperty().get())));
options.selectedToggleProperty().addListener((ChangeListener<Toggle>) (observable, oldValue, newValue) -> {
if (options.getSelectedToggle() != null) {
ConfigData.instance.ALGORITHM_PARAMETERS.get(key2)
.bind(new SimpleStringProperty(String.valueOf(useLowLevel.selectedProperty().get())));
ConfigData.instance.ALGORITHM_PARAMETERS.get(key3)
.bind(new SimpleStringProperty(String.valueOf(useGenre.selectedProperty().get())));
ConfigData.instance.ALGORITHM_PARAMETERS.get(key4)
.bind(new SimpleStringProperty(String.valueOf(useTag.selectedProperty().get())));
ConfigData.instance.ALGORITHM_PARAMETERS.get(key5)
.bind(new SimpleStringProperty(String.valueOf(useRating.selectedProperty().get())));
}
});
final String selectedAlgorithmName = "algorithms." + algorithmCombobox.getValue().getText().get(); | // Path: src/main/java/gui/model/Algorithms.java
// public enum Algorithms {
// ItemBasedNN("ItemBasedNN"), FactorizationMachine("FactorizationMachine"), AveragePopularity(
// "AveragePopularity"), FunkSVD("FunkSVD"), HybridTagLowLevel("HybridTagLowLevel");
//
// private StringProperty text;
//
// private Algorithms(String text) {
// this.text = new SimpleStringProperty(text);
// }
//
// public StringProperty getText() {
// return text;
// }
// }
//
// Path: src/main/java/interfaces/AbstractRecommender.java
// public class AbstractRecommender implements Recommender,Serializable {
//
// private static final long serialVersionUID = -7339073808310101731L;
// protected DataModel trainDataModel;
// /**
// * A map which contains information about the fields name in the class
// * and the related key in config file.
// * Key = filed name
// * Value = Map<config file key,pretty name>
// * pretty name used in GUI
// */
// protected final Map<String,Map<String,String>> configurableParametersMap = new HashMap<>();
// /**
// * Repository used for calculating similarities
// */
// protected SimilarityInterface similarityRepository;
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#predictRating(model.User, model.Item)
// */
// @Override
// public Float predictRating(User user, Item item) {
// return null;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#recommendItems(model.User)
// */
// @Override
// public Map<Integer, Float> recommendItems(User user) {
// return null;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#train(model.DataModel)
// */
// @Override
// public void train(DataModel trainData) {
// this.trainDataModel = trainData;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#setSimilarityRepository(interfaces.SimilarityInterface)
// */
// @Override
// public void setSimilarityRepository(SimilarityInterface similarityRepository) {
// if (similarityRepository == null) {
// throw new IllegalArgumentException("SimilarityRepository is null");
// }
// this.similarityRepository = similarityRepository;
// }
//
// /*
// * (non-Javadoc)
// * @see interfaces.Recommender#getSimilarityRepository()
// */
// @Override
// public SimilarityInterface getSimilarityRepository() {
// return similarityRepository;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#isSimilairtyNeeded()
// */
// @Override
// public boolean isSimilairtyNeeded() {
// return true;
// }
//
// /* (non-Javadoc)
// * @see interfaces.Recommender#getConfigurabaleParameters()
// */
// @Override
// public Map<String,Map<String,String>> getConfigurabaleParameters() {
// return this.configurableParametersMap;
// }
//
// }
// Path: src/main/java/gui/pages/AlgorithmComponent.java
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import gui.model.Algorithms;
import gui.model.ConfigData;
import interfaces.AbstractRecommender;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.scene.Parent;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.Toggle;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import util.ClassInstantiator;
final String key3 = "ALGORITHM_" + id + "_USE_GENRE";
ConfigData.instance.ALGORITHM_PARAMETERS.put(key3, new SimpleStringProperty(""));
ConfigData.instance.ALGORITHM_PARAMETERS.get(key3)
.bind(new SimpleStringProperty(String.valueOf(useGenre.selectedProperty().get())));
final String key4 = "ALGORITHM_" + id + "_USE_TAG";
ConfigData.instance.ALGORITHM_PARAMETERS.put(key4, new SimpleStringProperty(""));
ConfigData.instance.ALGORITHM_PARAMETERS.get(key4)
.bind(new SimpleStringProperty(String.valueOf(useTag.selectedProperty().get())));
final String key5 = "ALGORITHM_" + id + "_USE_RATING";
ConfigData.instance.ALGORITHM_PARAMETERS.put(key5, new SimpleStringProperty(""));
ConfigData.instance.ALGORITHM_PARAMETERS.get(key5)
.bind(new SimpleStringProperty(String.valueOf(useRating.selectedProperty().get())));
options.selectedToggleProperty().addListener((ChangeListener<Toggle>) (observable, oldValue, newValue) -> {
if (options.getSelectedToggle() != null) {
ConfigData.instance.ALGORITHM_PARAMETERS.get(key2)
.bind(new SimpleStringProperty(String.valueOf(useLowLevel.selectedProperty().get())));
ConfigData.instance.ALGORITHM_PARAMETERS.get(key3)
.bind(new SimpleStringProperty(String.valueOf(useGenre.selectedProperty().get())));
ConfigData.instance.ALGORITHM_PARAMETERS.get(key4)
.bind(new SimpleStringProperty(String.valueOf(useTag.selectedProperty().get())));
ConfigData.instance.ALGORITHM_PARAMETERS.get(key5)
.bind(new SimpleStringProperty(String.valueOf(useRating.selectedProperty().get())));
}
});
final String selectedAlgorithmName = "algorithms." + algorithmCombobox.getValue().getText().get(); | final AbstractRecommender instantiateClass = (AbstractRecommender) ClassInstantiator |
rghorbani/react-native-common | android/src/main/java/com/kajoo/reactnativecommon/wheelpicker/WheelPickerPackage.java | // Path: android/src/main/java/com/kajoo/reactnativecommon/wheelpicker/WheelPickerManager.java
// public class WheelPickerManager extends SimpleViewManager<WheelPicker> {
// public static final String REACT_CLASS = "WheelPicker";
//
// @Override
// public String getName() {
// return REACT_CLASS;
// }
//
// @Override
// public WheelPicker createViewInstance(ThemedReactContext context) {
// return new WheelPicker(context); //If your customview has more constructor parameters pass it from here.
// }
//
// @ReactProp(name = "data")
// public void setData(WheelPicker wheelPicker, @Nullable ReadableArray data) {
// NumberPicker numberPicker = (NumberPicker) wheelPicker;
// ArrayList dataList = data.toArrayList();
// final String[] arrayString= (String[]) dataList.toArray(new String[0]);
// numberPicker.setMinValue(0);
// numberPicker.setMaxValue(arrayString.length-1);
// numberPicker.setDisplayedValues( arrayString );
// }
//
// public Map getExportedCustomBubblingEventTypeConstants() {
// return MapBuilder.builder()
// .put(
// "topChange",
// MapBuilder.of(
// "phasedRegistrationNames",
// MapBuilder.of("bubbled", "onChange")))
// .build();
// }
// }
| import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.kajoo.reactnativecommon.wheelpicker.WheelPickerManager;
import java.util.Arrays;
import java.util.Collections;
import java.util.List; |
package com.kajoo.reactnativecommon.wheelpicker;
public class WheelPickerPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { | // Path: android/src/main/java/com/kajoo/reactnativecommon/wheelpicker/WheelPickerManager.java
// public class WheelPickerManager extends SimpleViewManager<WheelPicker> {
// public static final String REACT_CLASS = "WheelPicker";
//
// @Override
// public String getName() {
// return REACT_CLASS;
// }
//
// @Override
// public WheelPicker createViewInstance(ThemedReactContext context) {
// return new WheelPicker(context); //If your customview has more constructor parameters pass it from here.
// }
//
// @ReactProp(name = "data")
// public void setData(WheelPicker wheelPicker, @Nullable ReadableArray data) {
// NumberPicker numberPicker = (NumberPicker) wheelPicker;
// ArrayList dataList = data.toArrayList();
// final String[] arrayString= (String[]) dataList.toArray(new String[0]);
// numberPicker.setMinValue(0);
// numberPicker.setMaxValue(arrayString.length-1);
// numberPicker.setDisplayedValues( arrayString );
// }
//
// public Map getExportedCustomBubblingEventTypeConstants() {
// return MapBuilder.builder()
// .put(
// "topChange",
// MapBuilder.of(
// "phasedRegistrationNames",
// MapBuilder.of("bubbled", "onChange")))
// .build();
// }
// }
// Path: android/src/main/java/com/kajoo/reactnativecommon/wheelpicker/WheelPickerPackage.java
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.kajoo.reactnativecommon.wheelpicker.WheelPickerManager;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
package com.kajoo.reactnativecommon.wheelpicker;
public class WheelPickerPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { | return Arrays.<ViewManager>asList( new WheelPickerManager() ); |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/keystone/KeystoneIdentity.java | // Path: src/main/java/io/iron/ironmq/HttpClient.java
// public class HttpClient {
// private boolean forMq;
//
// private HttpClient() { }
//
// public HttpClient(boolean forMq) {
// this.forMq = forMq;
// }
//
// public static HttpClient create() {
// return new HttpClient(false);
// }
//
// public static HttpClient createForMq() {
// return new HttpClient(true);
// }
//
// static private class Error implements Serializable {
// String msg;
// }
//
// public Reader singleRequest(String method, URL url, String body, HashMap<String, String> headers) throws IOException {
// HttpURLConnection conn = (HttpURLConnection) url.openConnection();
//
// if (method.equals("DELETE") || method.equals("PATCH")) {
// conn.setRequestMethod("POST");
// conn.setRequestProperty("X-HTTP-Method-Override", method);
// } else {
// conn.setRequestMethod(method);
// }
//
// for (Map.Entry<String, String> entry : headers.entrySet()) {
// conn.setRequestProperty(entry.getKey(), entry.getValue());
// }
//
// if (body != null) {
// conn.setRequestProperty("Content-Type", "application/json");
// conn.setDoOutput(true);
// }
//
// conn.connect();
//
// if (body != null) {
// OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
// out.write(body);
// out.close();
// }
//
// int status = conn.getResponseCode();
// if (status != 200) {
// if (forMq) {
// String msg;
// if (conn.getContentLength() > 0 && conn.getContentType().equals("application/json")) {
// InputStreamReader reader = null;
// try {
// reader = new InputStreamReader(conn.getErrorStream());
// Gson gson = new Gson();
// Error error = gson.fromJson(reader, Error.class);
// msg = error.msg;
// } catch (JsonSyntaxException e) {
// msg = "IronMQ's response contained invalid JSON";
// } finally {
// if (reader != null)
// reader.close();
// }
// } else {
// msg = "Empty or non-JSON response";
// }
// throw new HTTPException(status, msg);
// } else {
// throw new HTTPException(status, conn.getResponseMessage());
// }
// }
//
// return new InputStreamReader(conn.getInputStream());
// }
//
// }
//
// Path: src/main/java/io/iron/ironmq/TokenContainer.java
// public interface TokenContainer {
// String getToken() throws IOException;
// }
| import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import io.iron.ironmq.HttpClient;
import io.iron.ironmq.TokenContainer;
import java.io.IOException;
import java.io.Reader;
import java.net.URL;
import java.util.HashMap; | public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getToken() throws IOException {
if (tokenInfo == null || tokenInfo.isExpired()) {
Gson gson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.S")
.create();
KeystoneGetTokenPayload payload = new KeystoneGetTokenPayload(
new Auth(
tenant,
new PasswordCredentials(username, password)
)
);
String body = gson.toJson(payload);
URL url = new URL(server + (server.endsWith("/") ? "" : "/") + "tokens");
String method = "POST";
| // Path: src/main/java/io/iron/ironmq/HttpClient.java
// public class HttpClient {
// private boolean forMq;
//
// private HttpClient() { }
//
// public HttpClient(boolean forMq) {
// this.forMq = forMq;
// }
//
// public static HttpClient create() {
// return new HttpClient(false);
// }
//
// public static HttpClient createForMq() {
// return new HttpClient(true);
// }
//
// static private class Error implements Serializable {
// String msg;
// }
//
// public Reader singleRequest(String method, URL url, String body, HashMap<String, String> headers) throws IOException {
// HttpURLConnection conn = (HttpURLConnection) url.openConnection();
//
// if (method.equals("DELETE") || method.equals("PATCH")) {
// conn.setRequestMethod("POST");
// conn.setRequestProperty("X-HTTP-Method-Override", method);
// } else {
// conn.setRequestMethod(method);
// }
//
// for (Map.Entry<String, String> entry : headers.entrySet()) {
// conn.setRequestProperty(entry.getKey(), entry.getValue());
// }
//
// if (body != null) {
// conn.setRequestProperty("Content-Type", "application/json");
// conn.setDoOutput(true);
// }
//
// conn.connect();
//
// if (body != null) {
// OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
// out.write(body);
// out.close();
// }
//
// int status = conn.getResponseCode();
// if (status != 200) {
// if (forMq) {
// String msg;
// if (conn.getContentLength() > 0 && conn.getContentType().equals("application/json")) {
// InputStreamReader reader = null;
// try {
// reader = new InputStreamReader(conn.getErrorStream());
// Gson gson = new Gson();
// Error error = gson.fromJson(reader, Error.class);
// msg = error.msg;
// } catch (JsonSyntaxException e) {
// msg = "IronMQ's response contained invalid JSON";
// } finally {
// if (reader != null)
// reader.close();
// }
// } else {
// msg = "Empty or non-JSON response";
// }
// throw new HTTPException(status, msg);
// } else {
// throw new HTTPException(status, conn.getResponseMessage());
// }
// }
//
// return new InputStreamReader(conn.getInputStream());
// }
//
// }
//
// Path: src/main/java/io/iron/ironmq/TokenContainer.java
// public interface TokenContainer {
// String getToken() throws IOException;
// }
// Path: src/main/java/io/iron/ironmq/keystone/KeystoneIdentity.java
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import io.iron.ironmq.HttpClient;
import io.iron.ironmq.TokenContainer;
import java.io.IOException;
import java.io.Reader;
import java.net.URL;
import java.util.HashMap;
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getToken() throws IOException {
if (tokenInfo == null || tokenInfo.isExpired()) {
Gson gson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.S")
.create();
KeystoneGetTokenPayload payload = new KeystoneGetTokenPayload(
new Auth(
tenant,
new PasswordCredentials(username, password)
)
);
String body = gson.toJson(payload);
URL url = new URL(server + (server.endsWith("/") ? "" : "/") + "tokens");
String method = "POST";
| HttpClient client = HttpClient.create(); |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Client.java | // Path: src/main/java/io/iron/ironmq/keystone/KeystoneIdentity.java
// public class KeystoneIdentity implements TokenContainer {
// String server;
// String tenant;
// String username;
// String password;
// Token tokenInfo;
//
// protected KeystoneIdentity() {
// }
//
// public KeystoneIdentity(String server, String tenant, String username, String password) {
// this.server = server;
// this.tenant = tenant;
// this.username = username;
// this.password = password;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getToken() throws IOException {
// if (tokenInfo == null || tokenInfo.isExpired()) {
// Gson gson = new GsonBuilder()
// .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.S")
// .create();
//
// KeystoneGetTokenPayload payload = new KeystoneGetTokenPayload(
// new Auth(
// tenant,
// new PasswordCredentials(username, password)
// )
// );
// String body = gson.toJson(payload);
//
// URL url = new URL(server + (server.endsWith("/") ? "" : "/") + "tokens");
//
// String method = "POST";
//
// HttpClient client = HttpClient.create();
// HashMap<String, String> headers = new HashMap<String, String>() {{
// put("Content-Type", "application/json");
// put("Accept", "application/json");
// }};
// Reader response = client.singleRequest(method, url, body, headers);
// KeystoneGetTokenResponse tokenResponse = gson.fromJson(response, KeystoneGetTokenResponse.class);
// response.close();
//
// tokenInfo = tokenResponse.getAccess().getToken();
// }
//
// return tokenInfo.getId();
// }
//
// public static String readFully(Reader reader) throws IOException {
// char[] arr = new char[8*1024]; // 8K at a time
// StringBuilder buf = new StringBuilder();
// int numChars;
//
// while ((numChars = reader.read(arr, 0, arr.length)) > 0) {
// buf.append(arr, 0, numChars);
// }
//
// return buf.toString();
// }
//
// public HashMap<String, Object> toHash() {
// return new HashMap<String, Object>() {{
// put("server", server);
// put("tenant", tenant);
// put("username", username);
// put("password", password);
// }};
// }
//
// public static KeystoneIdentity fromHash(HashMap<String, Object> hash) {
// return new KeystoneIdentity(
// (String) hash.get("server"),
// (String) hash.get("tenant"),
// (String) hash.get("username"),
// (String) hash.get("password"));
// }
// }
| import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Serializable;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import io.iron.ironmq.keystone.KeystoneIdentity;
import org.apache.commons.lang3.ArrayUtils;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.stream.JsonWriter;
import org.apache.commons.lang3.StringUtils; | */
public Client(String projectId, String token, Cloud cloud) {
this(projectId, token, cloud, null);
}
/**
* Constructs a new Client using the specified project ID and token.
* A null projectId, token, or cloud will be filled in using the
* filesystem and environment for configuration as described
* <a href="http://dev.iron.io/worker/reference/configuration/">here</a>.
* The network is not accessed during construction and this call
* succeeds even if the credentials are invalid.
*
* @param projectId A 24-character project ID.
* @param token An OAuth token.
* @param cloud The cloud to use.
* @param apiVersion Version of ironmq api to use, default is 3.
*/
public Client(String projectId, String token, Cloud cloud, Integer apiVersion) {
Map<String, Object> userOptions = new HashMap<String, Object>();
userOptions.put("project_id", projectId);
userOptions.put("token", token);
if (cloud != null) {
userOptions.put("cloud", cloud);
}
this.apiVersion = (apiVersion == null || apiVersion < 1) ? defaultApiVersion : apiVersion.toString();
loadConfiguration("iron", "mq", userOptions, new String[]{"project_id", "token", "cloud"});
}
| // Path: src/main/java/io/iron/ironmq/keystone/KeystoneIdentity.java
// public class KeystoneIdentity implements TokenContainer {
// String server;
// String tenant;
// String username;
// String password;
// Token tokenInfo;
//
// protected KeystoneIdentity() {
// }
//
// public KeystoneIdentity(String server, String tenant, String username, String password) {
// this.server = server;
// this.tenant = tenant;
// this.username = username;
// this.password = password;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getToken() throws IOException {
// if (tokenInfo == null || tokenInfo.isExpired()) {
// Gson gson = new GsonBuilder()
// .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.S")
// .create();
//
// KeystoneGetTokenPayload payload = new KeystoneGetTokenPayload(
// new Auth(
// tenant,
// new PasswordCredentials(username, password)
// )
// );
// String body = gson.toJson(payload);
//
// URL url = new URL(server + (server.endsWith("/") ? "" : "/") + "tokens");
//
// String method = "POST";
//
// HttpClient client = HttpClient.create();
// HashMap<String, String> headers = new HashMap<String, String>() {{
// put("Content-Type", "application/json");
// put("Accept", "application/json");
// }};
// Reader response = client.singleRequest(method, url, body, headers);
// KeystoneGetTokenResponse tokenResponse = gson.fromJson(response, KeystoneGetTokenResponse.class);
// response.close();
//
// tokenInfo = tokenResponse.getAccess().getToken();
// }
//
// return tokenInfo.getId();
// }
//
// public static String readFully(Reader reader) throws IOException {
// char[] arr = new char[8*1024]; // 8K at a time
// StringBuilder buf = new StringBuilder();
// int numChars;
//
// while ((numChars = reader.read(arr, 0, arr.length)) > 0) {
// buf.append(arr, 0, numChars);
// }
//
// return buf.toString();
// }
//
// public HashMap<String, Object> toHash() {
// return new HashMap<String, Object>() {{
// put("server", server);
// put("tenant", tenant);
// put("username", username);
// put("password", password);
// }};
// }
//
// public static KeystoneIdentity fromHash(HashMap<String, Object> hash) {
// return new KeystoneIdentity(
// (String) hash.get("server"),
// (String) hash.get("tenant"),
// (String) hash.get("username"),
// (String) hash.get("password"));
// }
// }
// Path: src/main/java/io/iron/ironmq/Client.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Serializable;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import io.iron.ironmq.keystone.KeystoneIdentity;
import org.apache.commons.lang3.ArrayUtils;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.stream.JsonWriter;
import org.apache.commons.lang3.StringUtils;
*/
public Client(String projectId, String token, Cloud cloud) {
this(projectId, token, cloud, null);
}
/**
* Constructs a new Client using the specified project ID and token.
* A null projectId, token, or cloud will be filled in using the
* filesystem and environment for configuration as described
* <a href="http://dev.iron.io/worker/reference/configuration/">here</a>.
* The network is not accessed during construction and this call
* succeeds even if the credentials are invalid.
*
* @param projectId A 24-character project ID.
* @param token An OAuth token.
* @param cloud The cloud to use.
* @param apiVersion Version of ironmq api to use, default is 3.
*/
public Client(String projectId, String token, Cloud cloud, Integer apiVersion) {
Map<String, Object> userOptions = new HashMap<String, Object>();
userOptions.put("project_id", projectId);
userOptions.put("token", token);
if (cloud != null) {
userOptions.put("cloud", cloud);
}
this.apiVersion = (apiVersion == null || apiVersion < 1) ? defaultApiVersion : apiVersion.toString();
loadConfiguration("iron", "mq", userOptions, new String[]{"project_id", "token", "cloud"});
}
| public Client(String projectId, KeystoneIdentity identity, Cloud cloud, Integer apiVersion) { |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/debug/PrintNode.java | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.debug;
/**
* A node which prints a string to standard out.
*/
@NodeInfo(name = "Print")
public class PrintNode extends AbstractNode
{
@Input | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/debug/PrintNode.java
import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.debug;
/**
* A node which prints a string to standard out.
*/
@NodeInfo(name = "Print")
public class PrintNode extends AbstractNode
{
@Input | private final Provider<?> msg; |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/debug/PrintNode.java | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.debug;
/**
* A node which prints a string to standard out.
*/
@NodeInfo(name = "Print")
public class PrintNode extends AbstractNode
{
@Input
private final Provider<?> msg;
/**
* Creates a new {@link PrintNode}.
*
* @param msg The message to print
*/
public PrintNode(Provider<?> msg)
{
this.msg = msg;
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/debug/PrintNode.java
import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.debug;
/**
* A node which prints a string to standard out.
*/
@NodeInfo(name = "Print")
public class PrintNode extends AbstractNode
{
@Input
private final Provider<?> msg;
/**
* Creates a new {@link PrintNode}.
*
* @param msg The message to print
*/
public PrintNode(Provider<?> msg)
{
this.msg = msg;
}
/**
* {@inheritDoc}
*/
@Override | public void exec(RuntimeState state) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/variables/ParentedVariableScope.java | // Path: src/main/java/com/thevoxelbox/vsl/api/variables/VariableHolder.java
// public interface VariableHolder
// {
//
// /**
// * Sets whether the variable holder should use case sensitive keys for its
// * variable storage.
// *
// * @param cs Case sensitive keys
// */
// void setCaseSensitive(boolean cs);
//
// /**
// * Returns the variable with the given name, or null if there is no variable
// * with that name in this storage container.
// *
// * @param name the name of the object to fetch, cannot be null
// * @return the value or null if no value is found
// */
// Optional<Object> get(String name);
//
// /**
// * Returns the variable with the given name, or null if there is no variable
// * with that name in this storage container.
// *
// * @param name the name of the object to fetch, cannot be null
// * @param type The expected value type
// * @param <T> The type
// * @return the value or null if no value is found
// */
// <T> Optional<T> get(String name, Class<T> type);
//
// /**
// * Puts a named value into this storage container
// *
// * @param name the name of the value to add, cannot be null
// * @param value the value to add
// */
// void set(String name, Object value);
//
// /**
// * Checks if this storage container has a value with the given name.
// *
// * @param name the name to check
// * @return whether a value with this name exists
// */
// boolean hasValue(String name);
//
// /**
// * Gets a Set of all keys stored within this variable holder.
// *
// * @return The keyset
// */
// Set<String> keyset();
//
// /**
// * Clears the values from this variable holder.
// */
// void clear();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/api/variables/VariableScope.java
// public interface VariableScope extends VariableHolder
// {
//
// /**
// * Sets the parent {@link VariableScope}.
// *
// * @param scope the new parent, cannot be null
// */
// void setParent(VariableHolder scope);
//
// /**
// * Returns the parent of this VariableScope or null if this VariableScope
// * has no parent.
// *
// * @return the parent, may be null
// */
// Optional<VariableHolder> getParent();
//
// /**
// * Returns the highest parent VariableScope. That is the farthest parent
// * VariableScope by recursively calling {@link #getParent()} until a
// * VariableScope with no parent is reached. Returns null if this
// * VariableScope has no parent.
// *
// * @return the highest parent, may be null
// */
// Optional<VariableHolder> getHighestParent();
// }
| import com.thevoxelbox.vsl.api.variables.VariableHolder;
import com.thevoxelbox.vsl.api.variables.VariableScope;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import com.google.common.base.Optional;
import com.google.common.collect.Sets; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.variables;
/**
* A recursive variable holder.
*/
public class ParentedVariableScope implements VariableScope, Serializable
{
private static final long serialVersionUID = 9032180603411264823L;
/**
* The parent variable holder.
*/ | // Path: src/main/java/com/thevoxelbox/vsl/api/variables/VariableHolder.java
// public interface VariableHolder
// {
//
// /**
// * Sets whether the variable holder should use case sensitive keys for its
// * variable storage.
// *
// * @param cs Case sensitive keys
// */
// void setCaseSensitive(boolean cs);
//
// /**
// * Returns the variable with the given name, or null if there is no variable
// * with that name in this storage container.
// *
// * @param name the name of the object to fetch, cannot be null
// * @return the value or null if no value is found
// */
// Optional<Object> get(String name);
//
// /**
// * Returns the variable with the given name, or null if there is no variable
// * with that name in this storage container.
// *
// * @param name the name of the object to fetch, cannot be null
// * @param type The expected value type
// * @param <T> The type
// * @return the value or null if no value is found
// */
// <T> Optional<T> get(String name, Class<T> type);
//
// /**
// * Puts a named value into this storage container
// *
// * @param name the name of the value to add, cannot be null
// * @param value the value to add
// */
// void set(String name, Object value);
//
// /**
// * Checks if this storage container has a value with the given name.
// *
// * @param name the name to check
// * @return whether a value with this name exists
// */
// boolean hasValue(String name);
//
// /**
// * Gets a Set of all keys stored within this variable holder.
// *
// * @return The keyset
// */
// Set<String> keyset();
//
// /**
// * Clears the values from this variable holder.
// */
// void clear();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/api/variables/VariableScope.java
// public interface VariableScope extends VariableHolder
// {
//
// /**
// * Sets the parent {@link VariableScope}.
// *
// * @param scope the new parent, cannot be null
// */
// void setParent(VariableHolder scope);
//
// /**
// * Returns the parent of this VariableScope or null if this VariableScope
// * has no parent.
// *
// * @return the parent, may be null
// */
// Optional<VariableHolder> getParent();
//
// /**
// * Returns the highest parent VariableScope. That is the farthest parent
// * VariableScope by recursively calling {@link #getParent()} until a
// * VariableScope with no parent is reached. Returns null if this
// * VariableScope has no parent.
// *
// * @return the highest parent, may be null
// */
// Optional<VariableHolder> getHighestParent();
// }
// Path: src/main/java/com/thevoxelbox/vsl/variables/ParentedVariableScope.java
import com.thevoxelbox.vsl.api.variables.VariableHolder;
import com.thevoxelbox.vsl.api.variables.VariableScope;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import com.google.common.base.Optional;
import com.google.common.collect.Sets;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.variables;
/**
* A recursive variable holder.
*/
public class ParentedVariableScope implements VariableScope, Serializable
{
private static final long serialVersionUID = 9032180603411264823L;
/**
* The parent variable holder.
*/ | private transient VariableHolder parent = null; |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/ModuloNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Performs the modulo operator between two given numbers.
*/
@NodeInfo(name = "Modulo")
public class ModuloNode extends NumberOperatorNode
{
/**
* Creates a new {@link ModuloNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/ | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/ModuloNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Performs the modulo operator between two given numbers.
*/
@NodeInfo(name = "Modulo")
public class ModuloNode extends NumberOperatorNode
{
/**
* Creates a new {@link ModuloNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/ | public ModuloNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/ModuloNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Performs the modulo operator between two given numbers.
*/
@NodeInfo(name = "Modulo")
public class ModuloNode extends NumberOperatorNode
{
/**
* Creates a new {@link ModuloNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/
public ModuloNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/ModuloNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Performs the modulo operator between two given numbers.
*/
@NodeInfo(name = "Modulo")
public class ModuloNode extends NumberOperatorNode
{
/**
* Creates a new {@link ModuloNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/
public ModuloNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | public void exec(RuntimeState state) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/AbsNode.java | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Returns the absolute value of an integer or floating-point number.
*/
@NodeInfo(name = "Abs")
public class AbsNode extends AbstractNode
{
@Output | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/AbsNode.java
import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Returns the absolute value of an integer or floating-point number.
*/
@NodeInfo(name = "Abs")
public class AbsNode extends AbstractNode
{
@Output | private final Provider<Number> value; |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/AbsNode.java | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Returns the absolute value of an integer or floating-point number.
*/
@NodeInfo(name = "Abs")
public class AbsNode extends AbstractNode
{
@Output
private final Provider<Number> value;
@Input
private final Provider<? extends Number> a;
private final boolean floating;
/**
* Creates a new {@link AbsNode}.
*
* @param a The input value
* @param floating Whether to use floating point percision
*/
public AbsNode(Provider<? extends Number> a, boolean floating)
{
this.a = a;
this.value = new Provider<Number>(this);
this.floating = floating;
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/AbsNode.java
import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Returns the absolute value of an integer or floating-point number.
*/
@NodeInfo(name = "Abs")
public class AbsNode extends AbstractNode
{
@Output
private final Provider<Number> value;
@Input
private final Provider<? extends Number> a;
private final boolean floating;
/**
* Creates a new {@link AbsNode}.
*
* @param a The input value
* @param floating Whether to use floating point percision
*/
public AbsNode(Provider<? extends Number> a, boolean floating)
{
this.a = a;
this.value = new Provider<Number>(this);
this.floating = floating;
}
/**
* {@inheritDoc}
*/
@Override | public void exec(RuntimeState state) |
Deamon5550/VisualScripting | src/test/java/com/thevoxelbox/test/NodeTestUtilsTest.java | // Path: src/test/java/com/thevoxelbox/test/util/MockUtility.java
// public static <T> Provider<T> mock(T value)
// {
// return new Provider<T>(mockNode, value);
// }
//
// Path: src/test/java/com/thevoxelbox/test/util/CheckRunNode.java
// public class CheckRunNode extends AbstractNode
// {
//
// int expected;
//
// /**
// * Creates a new {@link CheckRunNode}.
// *
// * @param e The expected number of runs
// */
// public CheckRunNode(int e)
// {
// this.expected = e;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// this.expected--;
// if (this.expected < 0)
// {
// throw new UnsupportedOperationException("Check node ran too many times");
// }
// }
//
// /**
// * Validates that the node ran the expected number of times
// */
// public void end()
// {
// if (this.expected > 0)
// {
// throw new UnsupportedOperationException("Check node ran too few times");
// }
// }
//
// }
//
// Path: src/test/java/com/thevoxelbox/test/util/StringArrayCheckNode.java
// public class StringArrayCheckNode extends AbstractNode
// {
//
// final String[] check;
// int index = 0;
// Provider<String> prov;
//
// /**
// * Creates a new {@link StringArrayCheckNode}.
// *
// * @param prov The string provider
// * @param values The expected strings
// */
// public StringArrayCheckNode(Provider<String> prov, String... values)
// {
// this.check = values;
// this.prov = prov;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// if (this.index >= this.check.length)
// {
// throw new ArrayIndexOutOfBoundsException("More than the expected number of strings were passed into check node.");
// }
// if (!this.check[this.index++].equals(this.prov.get(state)))
// {
// throw new IllegalArgumentException("An unexpected string was passed into check node");
// }
// }
//
// /**
// * Validates the test.
// */
// public void end()
// {
// if (this.index < this.check.length)
// {
// throw new UnsupportedOperationException("Check was called too few times.");
// }
// }
//
// }
| import static com.thevoxelbox.test.util.MockUtility.mock;
import org.junit.Test;
import com.thevoxelbox.test.util.CheckRunNode;
import com.thevoxelbox.test.util.StringArrayCheckNode; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test;
/**
* Tests the testing utility nodes.
*/
public class NodeTestUtilsTest extends StandardTest
{
/**
*
*/
@Test
public void testStringCheckArrayNode()
{ | // Path: src/test/java/com/thevoxelbox/test/util/MockUtility.java
// public static <T> Provider<T> mock(T value)
// {
// return new Provider<T>(mockNode, value);
// }
//
// Path: src/test/java/com/thevoxelbox/test/util/CheckRunNode.java
// public class CheckRunNode extends AbstractNode
// {
//
// int expected;
//
// /**
// * Creates a new {@link CheckRunNode}.
// *
// * @param e The expected number of runs
// */
// public CheckRunNode(int e)
// {
// this.expected = e;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// this.expected--;
// if (this.expected < 0)
// {
// throw new UnsupportedOperationException("Check node ran too many times");
// }
// }
//
// /**
// * Validates that the node ran the expected number of times
// */
// public void end()
// {
// if (this.expected > 0)
// {
// throw new UnsupportedOperationException("Check node ran too few times");
// }
// }
//
// }
//
// Path: src/test/java/com/thevoxelbox/test/util/StringArrayCheckNode.java
// public class StringArrayCheckNode extends AbstractNode
// {
//
// final String[] check;
// int index = 0;
// Provider<String> prov;
//
// /**
// * Creates a new {@link StringArrayCheckNode}.
// *
// * @param prov The string provider
// * @param values The expected strings
// */
// public StringArrayCheckNode(Provider<String> prov, String... values)
// {
// this.check = values;
// this.prov = prov;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// if (this.index >= this.check.length)
// {
// throw new ArrayIndexOutOfBoundsException("More than the expected number of strings were passed into check node.");
// }
// if (!this.check[this.index++].equals(this.prov.get(state)))
// {
// throw new IllegalArgumentException("An unexpected string was passed into check node");
// }
// }
//
// /**
// * Validates the test.
// */
// public void end()
// {
// if (this.index < this.check.length)
// {
// throw new UnsupportedOperationException("Check was called too few times.");
// }
// }
//
// }
// Path: src/test/java/com/thevoxelbox/test/NodeTestUtilsTest.java
import static com.thevoxelbox.test.util.MockUtility.mock;
import org.junit.Test;
import com.thevoxelbox.test.util.CheckRunNode;
import com.thevoxelbox.test.util.StringArrayCheckNode;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test;
/**
* Tests the testing utility nodes.
*/
public class NodeTestUtilsTest extends StandardTest
{
/**
*
*/
@Test
public void testStringCheckArrayNode()
{ | StringArrayCheckNode check = new StringArrayCheckNode(mock("hello"), "hello"); |
Deamon5550/VisualScripting | src/test/java/com/thevoxelbox/test/NodeTestUtilsTest.java | // Path: src/test/java/com/thevoxelbox/test/util/MockUtility.java
// public static <T> Provider<T> mock(T value)
// {
// return new Provider<T>(mockNode, value);
// }
//
// Path: src/test/java/com/thevoxelbox/test/util/CheckRunNode.java
// public class CheckRunNode extends AbstractNode
// {
//
// int expected;
//
// /**
// * Creates a new {@link CheckRunNode}.
// *
// * @param e The expected number of runs
// */
// public CheckRunNode(int e)
// {
// this.expected = e;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// this.expected--;
// if (this.expected < 0)
// {
// throw new UnsupportedOperationException("Check node ran too many times");
// }
// }
//
// /**
// * Validates that the node ran the expected number of times
// */
// public void end()
// {
// if (this.expected > 0)
// {
// throw new UnsupportedOperationException("Check node ran too few times");
// }
// }
//
// }
//
// Path: src/test/java/com/thevoxelbox/test/util/StringArrayCheckNode.java
// public class StringArrayCheckNode extends AbstractNode
// {
//
// final String[] check;
// int index = 0;
// Provider<String> prov;
//
// /**
// * Creates a new {@link StringArrayCheckNode}.
// *
// * @param prov The string provider
// * @param values The expected strings
// */
// public StringArrayCheckNode(Provider<String> prov, String... values)
// {
// this.check = values;
// this.prov = prov;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// if (this.index >= this.check.length)
// {
// throw new ArrayIndexOutOfBoundsException("More than the expected number of strings were passed into check node.");
// }
// if (!this.check[this.index++].equals(this.prov.get(state)))
// {
// throw new IllegalArgumentException("An unexpected string was passed into check node");
// }
// }
//
// /**
// * Validates the test.
// */
// public void end()
// {
// if (this.index < this.check.length)
// {
// throw new UnsupportedOperationException("Check was called too few times.");
// }
// }
//
// }
| import static com.thevoxelbox.test.util.MockUtility.mock;
import org.junit.Test;
import com.thevoxelbox.test.util.CheckRunNode;
import com.thevoxelbox.test.util.StringArrayCheckNode; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test;
/**
* Tests the testing utility nodes.
*/
public class NodeTestUtilsTest extends StandardTest
{
/**
*
*/
@Test
public void testStringCheckArrayNode()
{ | // Path: src/test/java/com/thevoxelbox/test/util/MockUtility.java
// public static <T> Provider<T> mock(T value)
// {
// return new Provider<T>(mockNode, value);
// }
//
// Path: src/test/java/com/thevoxelbox/test/util/CheckRunNode.java
// public class CheckRunNode extends AbstractNode
// {
//
// int expected;
//
// /**
// * Creates a new {@link CheckRunNode}.
// *
// * @param e The expected number of runs
// */
// public CheckRunNode(int e)
// {
// this.expected = e;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// this.expected--;
// if (this.expected < 0)
// {
// throw new UnsupportedOperationException("Check node ran too many times");
// }
// }
//
// /**
// * Validates that the node ran the expected number of times
// */
// public void end()
// {
// if (this.expected > 0)
// {
// throw new UnsupportedOperationException("Check node ran too few times");
// }
// }
//
// }
//
// Path: src/test/java/com/thevoxelbox/test/util/StringArrayCheckNode.java
// public class StringArrayCheckNode extends AbstractNode
// {
//
// final String[] check;
// int index = 0;
// Provider<String> prov;
//
// /**
// * Creates a new {@link StringArrayCheckNode}.
// *
// * @param prov The string provider
// * @param values The expected strings
// */
// public StringArrayCheckNode(Provider<String> prov, String... values)
// {
// this.check = values;
// this.prov = prov;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// if (this.index >= this.check.length)
// {
// throw new ArrayIndexOutOfBoundsException("More than the expected number of strings were passed into check node.");
// }
// if (!this.check[this.index++].equals(this.prov.get(state)))
// {
// throw new IllegalArgumentException("An unexpected string was passed into check node");
// }
// }
//
// /**
// * Validates the test.
// */
// public void end()
// {
// if (this.index < this.check.length)
// {
// throw new UnsupportedOperationException("Check was called too few times.");
// }
// }
//
// }
// Path: src/test/java/com/thevoxelbox/test/NodeTestUtilsTest.java
import static com.thevoxelbox.test.util.MockUtility.mock;
import org.junit.Test;
import com.thevoxelbox.test.util.CheckRunNode;
import com.thevoxelbox.test.util.StringArrayCheckNode;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test;
/**
* Tests the testing utility nodes.
*/
public class NodeTestUtilsTest extends StandardTest
{
/**
*
*/
@Test
public void testStringCheckArrayNode()
{ | StringArrayCheckNode check = new StringArrayCheckNode(mock("hello"), "hello"); |
Deamon5550/VisualScripting | src/test/java/com/thevoxelbox/test/NodeTestUtilsTest.java | // Path: src/test/java/com/thevoxelbox/test/util/MockUtility.java
// public static <T> Provider<T> mock(T value)
// {
// return new Provider<T>(mockNode, value);
// }
//
// Path: src/test/java/com/thevoxelbox/test/util/CheckRunNode.java
// public class CheckRunNode extends AbstractNode
// {
//
// int expected;
//
// /**
// * Creates a new {@link CheckRunNode}.
// *
// * @param e The expected number of runs
// */
// public CheckRunNode(int e)
// {
// this.expected = e;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// this.expected--;
// if (this.expected < 0)
// {
// throw new UnsupportedOperationException("Check node ran too many times");
// }
// }
//
// /**
// * Validates that the node ran the expected number of times
// */
// public void end()
// {
// if (this.expected > 0)
// {
// throw new UnsupportedOperationException("Check node ran too few times");
// }
// }
//
// }
//
// Path: src/test/java/com/thevoxelbox/test/util/StringArrayCheckNode.java
// public class StringArrayCheckNode extends AbstractNode
// {
//
// final String[] check;
// int index = 0;
// Provider<String> prov;
//
// /**
// * Creates a new {@link StringArrayCheckNode}.
// *
// * @param prov The string provider
// * @param values The expected strings
// */
// public StringArrayCheckNode(Provider<String> prov, String... values)
// {
// this.check = values;
// this.prov = prov;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// if (this.index >= this.check.length)
// {
// throw new ArrayIndexOutOfBoundsException("More than the expected number of strings were passed into check node.");
// }
// if (!this.check[this.index++].equals(this.prov.get(state)))
// {
// throw new IllegalArgumentException("An unexpected string was passed into check node");
// }
// }
//
// /**
// * Validates the test.
// */
// public void end()
// {
// if (this.index < this.check.length)
// {
// throw new UnsupportedOperationException("Check was called too few times.");
// }
// }
//
// }
| import static com.thevoxelbox.test.util.MockUtility.mock;
import org.junit.Test;
import com.thevoxelbox.test.util.CheckRunNode;
import com.thevoxelbox.test.util.StringArrayCheckNode; | *
*/
@Test(expected = ArrayIndexOutOfBoundsException.class)
public void testStringCheckArrayNodeTooMany()
{
StringArrayCheckNode check = new StringArrayCheckNode(mock("hello"), "hello");
check.exec(this.state);
check.exec(this.state);
check.end();
}
/**
*
*/
@Test(expected = IllegalArgumentException.class)
public void testStringCheckArrayNodeInvalid()
{
StringArrayCheckNode check = new StringArrayCheckNode(mock("world"), "hello");
check.exec(this.state);
check.end();
}
/**
* Tests the expected behavior of a {@link CheckRunNode}.
*/
@Test
public void testCheckRunNode()
{ | // Path: src/test/java/com/thevoxelbox/test/util/MockUtility.java
// public static <T> Provider<T> mock(T value)
// {
// return new Provider<T>(mockNode, value);
// }
//
// Path: src/test/java/com/thevoxelbox/test/util/CheckRunNode.java
// public class CheckRunNode extends AbstractNode
// {
//
// int expected;
//
// /**
// * Creates a new {@link CheckRunNode}.
// *
// * @param e The expected number of runs
// */
// public CheckRunNode(int e)
// {
// this.expected = e;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// this.expected--;
// if (this.expected < 0)
// {
// throw new UnsupportedOperationException("Check node ran too many times");
// }
// }
//
// /**
// * Validates that the node ran the expected number of times
// */
// public void end()
// {
// if (this.expected > 0)
// {
// throw new UnsupportedOperationException("Check node ran too few times");
// }
// }
//
// }
//
// Path: src/test/java/com/thevoxelbox/test/util/StringArrayCheckNode.java
// public class StringArrayCheckNode extends AbstractNode
// {
//
// final String[] check;
// int index = 0;
// Provider<String> prov;
//
// /**
// * Creates a new {@link StringArrayCheckNode}.
// *
// * @param prov The string provider
// * @param values The expected strings
// */
// public StringArrayCheckNode(Provider<String> prov, String... values)
// {
// this.check = values;
// this.prov = prov;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// if (this.index >= this.check.length)
// {
// throw new ArrayIndexOutOfBoundsException("More than the expected number of strings were passed into check node.");
// }
// if (!this.check[this.index++].equals(this.prov.get(state)))
// {
// throw new IllegalArgumentException("An unexpected string was passed into check node");
// }
// }
//
// /**
// * Validates the test.
// */
// public void end()
// {
// if (this.index < this.check.length)
// {
// throw new UnsupportedOperationException("Check was called too few times.");
// }
// }
//
// }
// Path: src/test/java/com/thevoxelbox/test/NodeTestUtilsTest.java
import static com.thevoxelbox.test.util.MockUtility.mock;
import org.junit.Test;
import com.thevoxelbox.test.util.CheckRunNode;
import com.thevoxelbox.test.util.StringArrayCheckNode;
*
*/
@Test(expected = ArrayIndexOutOfBoundsException.class)
public void testStringCheckArrayNodeTooMany()
{
StringArrayCheckNode check = new StringArrayCheckNode(mock("hello"), "hello");
check.exec(this.state);
check.exec(this.state);
check.end();
}
/**
*
*/
@Test(expected = IllegalArgumentException.class)
public void testStringCheckArrayNodeInvalid()
{
StringArrayCheckNode check = new StringArrayCheckNode(mock("world"), "hello");
check.exec(this.state);
check.end();
}
/**
* Tests the expected behavior of a {@link CheckRunNode}.
*/
@Test
public void testCheckRunNode()
{ | CheckRunNode check = new CheckRunNode(3); |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/vars/ChainedOutputNode.java | // Path: src/main/java/com/thevoxelbox/vsl/node/RunnableNodeGraph.java
// public class RunnableNodeGraph extends AbstractNode implements NodeGraph
// {
//
// String name;
// RunnableNodeGraph nextgraph = null;
//
// /**
// * Creates a new {@link RunnableNodeGraph}
// *
// * @param name The name
// */
// public RunnableNodeGraph(String name)
// {
// this.name = name;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String getName()
// {
// return this.name;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void run(VariableHolder vars)
// {
// RuntimeState state = new RuntimeState(vars);
// exec(state);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// Node next = this.getStart();
// while (next != null)
// {
// next.exec(state);
// next = next.getNext();
// }
// if (this.nextgraph != null)
// {
// this.nextgraph.exec(state);
// }
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void chain(RunnableNodeGraph next)
// {
// this.nextgraph = next;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public RunnableNodeGraph getNextGraph()
// {
// return this.nextgraph;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getStart()
// {
// return this.getNext();
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setStart(Node node)
// {
// this.setNext(node);
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.node.RunnableNodeGraph;
import com.thevoxelbox.vsl.util.Provider; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.vars;
/**
* Outputs a value for a future chained {@link RunnableNodeGraph} to input.
*
* @param <T> The output type
*/
@NodeInfo(name = "ChainedOutput")
public class ChainedOutputNode<T> extends VariableSetNode<T>
{
/**
* Creates a new {@link ChainedOutputNode}.
*
* @param name The name of the output
* @param value The value to output
*/ | // Path: src/main/java/com/thevoxelbox/vsl/node/RunnableNodeGraph.java
// public class RunnableNodeGraph extends AbstractNode implements NodeGraph
// {
//
// String name;
// RunnableNodeGraph nextgraph = null;
//
// /**
// * Creates a new {@link RunnableNodeGraph}
// *
// * @param name The name
// */
// public RunnableNodeGraph(String name)
// {
// this.name = name;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String getName()
// {
// return this.name;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void run(VariableHolder vars)
// {
// RuntimeState state = new RuntimeState(vars);
// exec(state);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// Node next = this.getStart();
// while (next != null)
// {
// next.exec(state);
// next = next.getNext();
// }
// if (this.nextgraph != null)
// {
// this.nextgraph.exec(state);
// }
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void chain(RunnableNodeGraph next)
// {
// this.nextgraph = next;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public RunnableNodeGraph getNextGraph()
// {
// return this.nextgraph;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getStart()
// {
// return this.getNext();
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setStart(Node node)
// {
// this.setNext(node);
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/vars/ChainedOutputNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.node.RunnableNodeGraph;
import com.thevoxelbox.vsl.util.Provider;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.vars;
/**
* Outputs a value for a future chained {@link RunnableNodeGraph} to input.
*
* @param <T> The output type
*/
@NodeInfo(name = "ChainedOutput")
public class ChainedOutputNode<T> extends VariableSetNode<T>
{
/**
* Creates a new {@link ChainedOutputNode}.
*
* @param name The name of the output
* @param value The value to output
*/ | public ChainedOutputNode(String name, Provider<T> value) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberLessThanNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if a number is less than a second number.
*/
@NodeInfo(name = "LessThan")
public class NumberLessThanNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberEqualsNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/ | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberLessThanNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if a number is less than a second number.
*/
@NodeInfo(name = "LessThan")
public class NumberLessThanNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberEqualsNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/ | public NumberLessThanNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberLessThanNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if a number is less than a second number.
*/
@NodeInfo(name = "LessThan")
public class NumberLessThanNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberEqualsNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/
public NumberLessThanNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberLessThanNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if a number is less than a second number.
*/
@NodeInfo(name = "LessThan")
public class NumberLessThanNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberEqualsNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/
public NumberLessThanNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | public void exec(RuntimeState state) |
Deamon5550/VisualScripting | src/test/java/com/thevoxelbox/test/ProviderTest.java | // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
| import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.mockito.Mockito;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.util.Provider; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test;
/**
* A set of tests for the {@link Provider} utility.
*/
public class ProviderTest extends StandardTest
{
/**
*
*/
@Test
public void testOwner()
{ | // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
// Path: src/test/java/com/thevoxelbox/test/ProviderTest.java
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.mockito.Mockito;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.util.Provider;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test;
/**
* A set of tests for the {@link Provider} utility.
*/
public class ProviderTest extends StandardTest
{
/**
*
*/
@Test
public void testOwner()
{ | Node node = Mockito.mock(Node.class); |
Deamon5550/VisualScripting | src/test/java/com/thevoxelbox/test/ProviderTest.java | // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
| import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.mockito.Mockito;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.util.Provider; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test;
/**
* A set of tests for the {@link Provider} utility.
*/
public class ProviderTest extends StandardTest
{
/**
*
*/
@Test
public void testOwner()
{
Node node = Mockito.mock(Node.class); | // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
// Path: src/test/java/com/thevoxelbox/test/ProviderTest.java
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.mockito.Mockito;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.util.Provider;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test;
/**
* A set of tests for the {@link Provider} utility.
*/
public class ProviderTest extends StandardTest
{
/**
*
*/
@Test
public void testOwner()
{
Node node = Mockito.mock(Node.class); | Provider<Object> p = new Provider<Object>(node); |
Deamon5550/VisualScripting | src/test/java/com/thevoxelbox/test/util/MockUtility.java | // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
| import org.mockito.Mockito;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.util.Provider; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test.util;
/**
* A utility for easily mocking basic types.
*/
public class MockUtility
{
| // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
// Path: src/test/java/com/thevoxelbox/test/util/MockUtility.java
import org.mockito.Mockito;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.util.Provider;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test.util;
/**
* A utility for easily mocking basic types.
*/
public class MockUtility
{
| private static Node mockNode; |
Deamon5550/VisualScripting | src/test/java/com/thevoxelbox/test/util/MockUtility.java | // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
| import org.mockito.Mockito;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.util.Provider; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test.util;
/**
* A utility for easily mocking basic types.
*/
public class MockUtility
{
private static Node mockNode;
static
{
mockNode = Mockito.mock(Node.class);
}
/**
* Mocks a provider for the given type and initial value.
*
* @param value The value
* @return The provider
*/ | // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
// Path: src/test/java/com/thevoxelbox/test/util/MockUtility.java
import org.mockito.Mockito;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.util.Provider;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test.util;
/**
* A utility for easily mocking basic types.
*/
public class MockUtility
{
private static Node mockNode;
static
{
mockNode = Mockito.mock(Node.class);
}
/**
* Mocks a provider for the given type and initial value.
*
* @param value The value
* @return The provider
*/ | public static <T> Provider<T> mock(T value) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberEqualsNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if two numbers are equal.
*/
@NodeInfo(name = "Equals")
public class NumberEqualsNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberEqualsNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/ | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberEqualsNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if two numbers are equal.
*/
@NodeInfo(name = "Equals")
public class NumberEqualsNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberEqualsNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/ | public NumberEqualsNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberEqualsNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if two numbers are equal.
*/
@NodeInfo(name = "Equals")
public class NumberEqualsNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberEqualsNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/
public NumberEqualsNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberEqualsNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if two numbers are equal.
*/
@NodeInfo(name = "Equals")
public class NumberEqualsNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberEqualsNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/
public NumberEqualsNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | public void exec(RuntimeState state) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/AdditionNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Returns the sub of two integer or floating-point numbers.
*/
@NodeInfo(name = "Addition")
public class AdditionNode extends NumberOperatorNode
{
/**
* Creates a new {@link AdditionNode}.
*
* @param a The first input
* @param b The second input
* @param floating Whether to use floating point percision
*/ | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/AdditionNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Returns the sub of two integer or floating-point numbers.
*/
@NodeInfo(name = "Addition")
public class AdditionNode extends NumberOperatorNode
{
/**
* Creates a new {@link AdditionNode}.
*
* @param a The first input
* @param b The second input
* @param floating Whether to use floating point percision
*/ | public AdditionNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/AdditionNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Returns the sub of two integer or floating-point numbers.
*/
@NodeInfo(name = "Addition")
public class AdditionNode extends NumberOperatorNode
{
/**
* Creates a new {@link AdditionNode}.
*
* @param a The first input
* @param b The second input
* @param floating Whether to use floating point percision
*/
public AdditionNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/AdditionNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Returns the sub of two integer or floating-point numbers.
*/
@NodeInfo(name = "Addition")
public class AdditionNode extends NumberOperatorNode
{
/**
* Creates a new {@link AdditionNode}.
*
* @param a The first input
* @param b The second input
* @param floating Whether to use floating point percision
*/
public AdditionNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | public void exec(RuntimeState state) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberGreaterThanOrEqualsNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if a number is greater than or equal to a second number.
*/
@NodeInfo(name = "GreaterThanOrEquals")
public class NumberGreaterThanOrEqualsNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberEqualsNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/ | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberGreaterThanOrEqualsNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if a number is greater than or equal to a second number.
*/
@NodeInfo(name = "GreaterThanOrEquals")
public class NumberGreaterThanOrEqualsNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberEqualsNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/ | public NumberGreaterThanOrEqualsNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberGreaterThanOrEqualsNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if a number is greater than or equal to a second number.
*/
@NodeInfo(name = "GreaterThanOrEquals")
public class NumberGreaterThanOrEqualsNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberEqualsNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/
public NumberGreaterThanOrEqualsNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberGreaterThanOrEqualsNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if a number is greater than or equal to a second number.
*/
@NodeInfo(name = "GreaterThanOrEquals")
public class NumberGreaterThanOrEqualsNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberEqualsNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/
public NumberGreaterThanOrEqualsNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | public void exec(RuntimeState state) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/NumberOperatorNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.util.Provider; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* An abstract node for a numerical operator node.
*/
public abstract class NumberOperatorNode extends TwoNumberNode
{
@Output | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/NumberOperatorNode.java
import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.util.Provider;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* An abstract node for a numerical operator node.
*/
public abstract class NumberOperatorNode extends TwoNumberNode
{
@Output | protected final Provider<Number> value; |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberGreaterThanNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if a number is greater than a second number.
*/
@NodeInfo(name = "GreaterThan")
public class NumberGreaterThanNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberGreaterThanNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/ | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberGreaterThanNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if a number is greater than a second number.
*/
@NodeInfo(name = "GreaterThan")
public class NumberGreaterThanNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberGreaterThanNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/ | public NumberGreaterThanNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberGreaterThanNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if a number is greater than a second number.
*/
@NodeInfo(name = "GreaterThan")
public class NumberGreaterThanNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberGreaterThanNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/
public NumberGreaterThanNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberGreaterThanNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if a number is greater than a second number.
*/
@NodeInfo(name = "GreaterThan")
public class NumberGreaterThanNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberGreaterThanNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/
public NumberGreaterThanNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | public void exec(RuntimeState state) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/SqrtNode.java | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Performs the {@link Math#sqrt(double)} on the given number.
*/
@NodeInfo(name = "Sqrt")
public class SqrtNode extends AbstractNode
{
@Output | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/SqrtNode.java
import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Performs the {@link Math#sqrt(double)} on the given number.
*/
@NodeInfo(name = "Sqrt")
public class SqrtNode extends AbstractNode
{
@Output | private final Provider<Number> value; |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/SqrtNode.java | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Performs the {@link Math#sqrt(double)} on the given number.
*/
@NodeInfo(name = "Sqrt")
public class SqrtNode extends AbstractNode
{
@Output
private final Provider<Number> value;
@Input
private final Provider<? extends Number> a;
/**
* Creates a new {@link SqrtNode}.
*
* @param a The number to square root
*/
public SqrtNode(Provider<? extends Number> a)
{
this.a = a;
this.value = new Provider<Number>(this);
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/SqrtNode.java
import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Performs the {@link Math#sqrt(double)} on the given number.
*/
@NodeInfo(name = "Sqrt")
public class SqrtNode extends AbstractNode
{
@Output
private final Provider<Number> value;
@Input
private final Provider<? extends Number> a;
/**
* Creates a new {@link SqrtNode}.
*
* @param a The number to square root
*/
public SqrtNode(Provider<? extends Number> a)
{
this.a = a;
this.value = new Provider<Number>(this);
}
/**
* {@inheritDoc}
*/
@Override | public void exec(RuntimeState state) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java | // Path: src/main/java/com/thevoxelbox/vsl/api/variables/VariableHolder.java
// public interface VariableHolder
// {
//
// /**
// * Sets whether the variable holder should use case sensitive keys for its
// * variable storage.
// *
// * @param cs Case sensitive keys
// */
// void setCaseSensitive(boolean cs);
//
// /**
// * Returns the variable with the given name, or null if there is no variable
// * with that name in this storage container.
// *
// * @param name the name of the object to fetch, cannot be null
// * @return the value or null if no value is found
// */
// Optional<Object> get(String name);
//
// /**
// * Returns the variable with the given name, or null if there is no variable
// * with that name in this storage container.
// *
// * @param name the name of the object to fetch, cannot be null
// * @param type The expected value type
// * @param <T> The type
// * @return the value or null if no value is found
// */
// <T> Optional<T> get(String name, Class<T> type);
//
// /**
// * Puts a named value into this storage container
// *
// * @param name the name of the value to add, cannot be null
// * @param value the value to add
// */
// void set(String name, Object value);
//
// /**
// * Checks if this storage container has a value with the given name.
// *
// * @param name the name to check
// * @return whether a value with this name exists
// */
// boolean hasValue(String name);
//
// /**
// * Gets a Set of all keys stored within this variable holder.
// *
// * @return The keyset
// */
// Set<String> keyset();
//
// /**
// * Clears the values from this variable holder.
// */
// void clear();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/node/RunnableNodeGraph.java
// public class RunnableNodeGraph extends AbstractNode implements NodeGraph
// {
//
// String name;
// RunnableNodeGraph nextgraph = null;
//
// /**
// * Creates a new {@link RunnableNodeGraph}
// *
// * @param name The name
// */
// public RunnableNodeGraph(String name)
// {
// this.name = name;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String getName()
// {
// return this.name;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void run(VariableHolder vars)
// {
// RuntimeState state = new RuntimeState(vars);
// exec(state);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// Node next = this.getStart();
// while (next != null)
// {
// next.exec(state);
// next = next.getNext();
// }
// if (this.nextgraph != null)
// {
// this.nextgraph.exec(state);
// }
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void chain(RunnableNodeGraph next)
// {
// this.nextgraph = next;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public RunnableNodeGraph getNextGraph()
// {
// return this.nextgraph;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getStart()
// {
// return this.getNext();
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setStart(Node node)
// {
// this.setNext(node);
// }
//
// }
| import java.util.UUID;
import com.thevoxelbox.vsl.api.variables.VariableHolder;
import com.thevoxelbox.vsl.node.RunnableNodeGraph; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.util;
/**
* A container for the values associated with a single runtime instance of a
* {@link RunnableNodeGraph}.
*/
public class RuntimeState
{
private final UUID uuid; | // Path: src/main/java/com/thevoxelbox/vsl/api/variables/VariableHolder.java
// public interface VariableHolder
// {
//
// /**
// * Sets whether the variable holder should use case sensitive keys for its
// * variable storage.
// *
// * @param cs Case sensitive keys
// */
// void setCaseSensitive(boolean cs);
//
// /**
// * Returns the variable with the given name, or null if there is no variable
// * with that name in this storage container.
// *
// * @param name the name of the object to fetch, cannot be null
// * @return the value or null if no value is found
// */
// Optional<Object> get(String name);
//
// /**
// * Returns the variable with the given name, or null if there is no variable
// * with that name in this storage container.
// *
// * @param name the name of the object to fetch, cannot be null
// * @param type The expected value type
// * @param <T> The type
// * @return the value or null if no value is found
// */
// <T> Optional<T> get(String name, Class<T> type);
//
// /**
// * Puts a named value into this storage container
// *
// * @param name the name of the value to add, cannot be null
// * @param value the value to add
// */
// void set(String name, Object value);
//
// /**
// * Checks if this storage container has a value with the given name.
// *
// * @param name the name to check
// * @return whether a value with this name exists
// */
// boolean hasValue(String name);
//
// /**
// * Gets a Set of all keys stored within this variable holder.
// *
// * @return The keyset
// */
// Set<String> keyset();
//
// /**
// * Clears the values from this variable holder.
// */
// void clear();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/node/RunnableNodeGraph.java
// public class RunnableNodeGraph extends AbstractNode implements NodeGraph
// {
//
// String name;
// RunnableNodeGraph nextgraph = null;
//
// /**
// * Creates a new {@link RunnableNodeGraph}
// *
// * @param name The name
// */
// public RunnableNodeGraph(String name)
// {
// this.name = name;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String getName()
// {
// return this.name;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void run(VariableHolder vars)
// {
// RuntimeState state = new RuntimeState(vars);
// exec(state);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// Node next = this.getStart();
// while (next != null)
// {
// next.exec(state);
// next = next.getNext();
// }
// if (this.nextgraph != null)
// {
// this.nextgraph.exec(state);
// }
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void chain(RunnableNodeGraph next)
// {
// this.nextgraph = next;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public RunnableNodeGraph getNextGraph()
// {
// return this.nextgraph;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getStart()
// {
// return this.getNext();
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setStart(Node node)
// {
// this.setNext(node);
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
import java.util.UUID;
import com.thevoxelbox.vsl.api.variables.VariableHolder;
import com.thevoxelbox.vsl.node.RunnableNodeGraph;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.util;
/**
* A container for the values associated with a single runtime instance of a
* {@link RunnableNodeGraph}.
*/
public class RuntimeState
{
private final UUID uuid; | private final VariableHolder vars; |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/api/node/Node.java | // Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.api.node;
/**
* Represents a node with a set of inputs and outputs which executes a single
* discrete function.
*/
public interface Node
{
/**
* Executes this node's function based on the runtime state and its inputs.
*
* @param state The runtime state
*/ | // Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.api.node;
/**
* Represents a node with a set of inputs and outputs which executes a single
* discrete function.
*/
public interface Node
{
/**
* Executes this node's function based on the runtime state and its inputs.
*
* @param state The runtime state
*/ | void exec(RuntimeState state); |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/vars/VariableSetNode.java | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.vars;
/**
* Sets a variable within the runtime variables.
*
* @param <T> The value type
*/
@NodeInfo(name = "VariableSet")
public class VariableSetNode<T> extends AbstractNode
{
@Input | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/vars/VariableSetNode.java
import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.vars;
/**
* Sets a variable within the runtime variables.
*
* @param <T> The value type
*/
@NodeInfo(name = "VariableSet")
public class VariableSetNode<T> extends AbstractNode
{
@Input | private final Provider<String> varName; |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/util/Provider.java | // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
| import java.util.Map;
import java.util.UUID;
import com.google.common.collect.Maps;
import com.thevoxelbox.vsl.api.node.Node; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.util;
/**
* Tracks values for an input or output of a node and stores them with an
* associated UUID for a {@link RuntimeState}.
*
* @param <T> The value type
*/
public class Provider<T>
{
private final Map<UUID, T> values;
private final T value;
private final boolean isStatic; | // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
import java.util.Map;
import java.util.UUID;
import com.google.common.collect.Maps;
import com.thevoxelbox.vsl.api.node.Node;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.util;
/**
* Tracks values for an input or output of a node and stores them with an
* associated UUID for a {@link RuntimeState}.
*
* @param <T> The value type
*/
public class Provider<T>
{
private final Map<UUID, T> values;
private final T value;
private final boolean isStatic; | private Node callback; |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/StaticValueNode.java | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes;
/**
* A node for inserting a static value to a program.
*
* @param <T> The value type
*/
@NodeInfo(name = "StaticValue")
public class StaticValueNode<T> extends AbstractNode
{
@Output | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/StaticValueNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes;
/**
* A node for inserting a static value to a program.
*
* @param <T> The value type
*/
@NodeInfo(name = "StaticValue")
public class StaticValueNode<T> extends AbstractNode
{
@Output | private final Provider<T> value; |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/StaticValueNode.java | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes;
/**
* A node for inserting a static value to a program.
*
* @param <T> The value type
*/
@NodeInfo(name = "StaticValue")
public class StaticValueNode<T> extends AbstractNode
{
@Output
private final Provider<T> value;
/**
* Creates a new {@link StaticValueNode}.
*
* @param value The value
*/
public StaticValueNode(T value)
{
this.value = new Provider<T>(this, value);
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/StaticValueNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes;
/**
* A node for inserting a static value to a program.
*
* @param <T> The value type
*/
@NodeInfo(name = "StaticValue")
public class StaticValueNode<T> extends AbstractNode
{
@Output
private final Provider<T> value;
/**
* Creates a new {@link StaticValueNode}.
*
* @param value The value
*/
public StaticValueNode(T value)
{
this.value = new Provider<T>(this, value);
}
/**
* {@inheritDoc}
*/
@Override | public void exec(RuntimeState state) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/api/node/NodeGraph.java | // Path: src/main/java/com/thevoxelbox/vsl/api/variables/VariableHolder.java
// public interface VariableHolder
// {
//
// /**
// * Sets whether the variable holder should use case sensitive keys for its
// * variable storage.
// *
// * @param cs Case sensitive keys
// */
// void setCaseSensitive(boolean cs);
//
// /**
// * Returns the variable with the given name, or null if there is no variable
// * with that name in this storage container.
// *
// * @param name the name of the object to fetch, cannot be null
// * @return the value or null if no value is found
// */
// Optional<Object> get(String name);
//
// /**
// * Returns the variable with the given name, or null if there is no variable
// * with that name in this storage container.
// *
// * @param name the name of the object to fetch, cannot be null
// * @param type The expected value type
// * @param <T> The type
// * @return the value or null if no value is found
// */
// <T> Optional<T> get(String name, Class<T> type);
//
// /**
// * Puts a named value into this storage container
// *
// * @param name the name of the value to add, cannot be null
// * @param value the value to add
// */
// void set(String name, Object value);
//
// /**
// * Checks if this storage container has a value with the given name.
// *
// * @param name the name to check
// * @return whether a value with this name exists
// */
// boolean hasValue(String name);
//
// /**
// * Gets a Set of all keys stored within this variable holder.
// *
// * @return The keyset
// */
// Set<String> keyset();
//
// /**
// * Clears the values from this variable holder.
// */
// void clear();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/node/RunnableNodeGraph.java
// public class RunnableNodeGraph extends AbstractNode implements NodeGraph
// {
//
// String name;
// RunnableNodeGraph nextgraph = null;
//
// /**
// * Creates a new {@link RunnableNodeGraph}
// *
// * @param name The name
// */
// public RunnableNodeGraph(String name)
// {
// this.name = name;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String getName()
// {
// return this.name;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void run(VariableHolder vars)
// {
// RuntimeState state = new RuntimeState(vars);
// exec(state);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// Node next = this.getStart();
// while (next != null)
// {
// next.exec(state);
// next = next.getNext();
// }
// if (this.nextgraph != null)
// {
// this.nextgraph.exec(state);
// }
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void chain(RunnableNodeGraph next)
// {
// this.nextgraph = next;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public RunnableNodeGraph getNextGraph()
// {
// return this.nextgraph;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getStart()
// {
// return this.getNext();
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setStart(Node node)
// {
// this.setNext(node);
// }
//
// }
| import com.thevoxelbox.vsl.api.variables.VariableHolder;
import com.thevoxelbox.vsl.node.RunnableNodeGraph; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.api.node;
/**
* Represents a system on nodes which may be executed.
*/
public interface NodeGraph
{
/**
* Gets the graph name.
*
* @return The name
*/
String getName();
/**
* Runs this graph based on the given variables.
*
* @param vars The runtime variables
*/ | // Path: src/main/java/com/thevoxelbox/vsl/api/variables/VariableHolder.java
// public interface VariableHolder
// {
//
// /**
// * Sets whether the variable holder should use case sensitive keys for its
// * variable storage.
// *
// * @param cs Case sensitive keys
// */
// void setCaseSensitive(boolean cs);
//
// /**
// * Returns the variable with the given name, or null if there is no variable
// * with that name in this storage container.
// *
// * @param name the name of the object to fetch, cannot be null
// * @return the value or null if no value is found
// */
// Optional<Object> get(String name);
//
// /**
// * Returns the variable with the given name, or null if there is no variable
// * with that name in this storage container.
// *
// * @param name the name of the object to fetch, cannot be null
// * @param type The expected value type
// * @param <T> The type
// * @return the value or null if no value is found
// */
// <T> Optional<T> get(String name, Class<T> type);
//
// /**
// * Puts a named value into this storage container
// *
// * @param name the name of the value to add, cannot be null
// * @param value the value to add
// */
// void set(String name, Object value);
//
// /**
// * Checks if this storage container has a value with the given name.
// *
// * @param name the name to check
// * @return whether a value with this name exists
// */
// boolean hasValue(String name);
//
// /**
// * Gets a Set of all keys stored within this variable holder.
// *
// * @return The keyset
// */
// Set<String> keyset();
//
// /**
// * Clears the values from this variable holder.
// */
// void clear();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/node/RunnableNodeGraph.java
// public class RunnableNodeGraph extends AbstractNode implements NodeGraph
// {
//
// String name;
// RunnableNodeGraph nextgraph = null;
//
// /**
// * Creates a new {@link RunnableNodeGraph}
// *
// * @param name The name
// */
// public RunnableNodeGraph(String name)
// {
// this.name = name;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String getName()
// {
// return this.name;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void run(VariableHolder vars)
// {
// RuntimeState state = new RuntimeState(vars);
// exec(state);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// Node next = this.getStart();
// while (next != null)
// {
// next.exec(state);
// next = next.getNext();
// }
// if (this.nextgraph != null)
// {
// this.nextgraph.exec(state);
// }
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void chain(RunnableNodeGraph next)
// {
// this.nextgraph = next;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public RunnableNodeGraph getNextGraph()
// {
// return this.nextgraph;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getStart()
// {
// return this.getNext();
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setStart(Node node)
// {
// this.setNext(node);
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/api/node/NodeGraph.java
import com.thevoxelbox.vsl.api.variables.VariableHolder;
import com.thevoxelbox.vsl.node.RunnableNodeGraph;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.api.node;
/**
* Represents a system on nodes which may be executed.
*/
public interface NodeGraph
{
/**
* Gets the graph name.
*
* @return The name
*/
String getName();
/**
* Runs this graph based on the given variables.
*
* @param vars The runtime variables
*/ | void run(VariableHolder vars); |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/api/node/NodeGraph.java | // Path: src/main/java/com/thevoxelbox/vsl/api/variables/VariableHolder.java
// public interface VariableHolder
// {
//
// /**
// * Sets whether the variable holder should use case sensitive keys for its
// * variable storage.
// *
// * @param cs Case sensitive keys
// */
// void setCaseSensitive(boolean cs);
//
// /**
// * Returns the variable with the given name, or null if there is no variable
// * with that name in this storage container.
// *
// * @param name the name of the object to fetch, cannot be null
// * @return the value or null if no value is found
// */
// Optional<Object> get(String name);
//
// /**
// * Returns the variable with the given name, or null if there is no variable
// * with that name in this storage container.
// *
// * @param name the name of the object to fetch, cannot be null
// * @param type The expected value type
// * @param <T> The type
// * @return the value or null if no value is found
// */
// <T> Optional<T> get(String name, Class<T> type);
//
// /**
// * Puts a named value into this storage container
// *
// * @param name the name of the value to add, cannot be null
// * @param value the value to add
// */
// void set(String name, Object value);
//
// /**
// * Checks if this storage container has a value with the given name.
// *
// * @param name the name to check
// * @return whether a value with this name exists
// */
// boolean hasValue(String name);
//
// /**
// * Gets a Set of all keys stored within this variable holder.
// *
// * @return The keyset
// */
// Set<String> keyset();
//
// /**
// * Clears the values from this variable holder.
// */
// void clear();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/node/RunnableNodeGraph.java
// public class RunnableNodeGraph extends AbstractNode implements NodeGraph
// {
//
// String name;
// RunnableNodeGraph nextgraph = null;
//
// /**
// * Creates a new {@link RunnableNodeGraph}
// *
// * @param name The name
// */
// public RunnableNodeGraph(String name)
// {
// this.name = name;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String getName()
// {
// return this.name;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void run(VariableHolder vars)
// {
// RuntimeState state = new RuntimeState(vars);
// exec(state);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// Node next = this.getStart();
// while (next != null)
// {
// next.exec(state);
// next = next.getNext();
// }
// if (this.nextgraph != null)
// {
// this.nextgraph.exec(state);
// }
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void chain(RunnableNodeGraph next)
// {
// this.nextgraph = next;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public RunnableNodeGraph getNextGraph()
// {
// return this.nextgraph;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getStart()
// {
// return this.getNext();
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setStart(Node node)
// {
// this.setNext(node);
// }
//
// }
| import com.thevoxelbox.vsl.api.variables.VariableHolder;
import com.thevoxelbox.vsl.node.RunnableNodeGraph; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.api.node;
/**
* Represents a system on nodes which may be executed.
*/
public interface NodeGraph
{
/**
* Gets the graph name.
*
* @return The name
*/
String getName();
/**
* Runs this graph based on the given variables.
*
* @param vars The runtime variables
*/
void run(VariableHolder vars);
/**
* Chains this graph into another graph
*
* @param next The next graph
*/ | // Path: src/main/java/com/thevoxelbox/vsl/api/variables/VariableHolder.java
// public interface VariableHolder
// {
//
// /**
// * Sets whether the variable holder should use case sensitive keys for its
// * variable storage.
// *
// * @param cs Case sensitive keys
// */
// void setCaseSensitive(boolean cs);
//
// /**
// * Returns the variable with the given name, or null if there is no variable
// * with that name in this storage container.
// *
// * @param name the name of the object to fetch, cannot be null
// * @return the value or null if no value is found
// */
// Optional<Object> get(String name);
//
// /**
// * Returns the variable with the given name, or null if there is no variable
// * with that name in this storage container.
// *
// * @param name the name of the object to fetch, cannot be null
// * @param type The expected value type
// * @param <T> The type
// * @return the value or null if no value is found
// */
// <T> Optional<T> get(String name, Class<T> type);
//
// /**
// * Puts a named value into this storage container
// *
// * @param name the name of the value to add, cannot be null
// * @param value the value to add
// */
// void set(String name, Object value);
//
// /**
// * Checks if this storage container has a value with the given name.
// *
// * @param name the name to check
// * @return whether a value with this name exists
// */
// boolean hasValue(String name);
//
// /**
// * Gets a Set of all keys stored within this variable holder.
// *
// * @return The keyset
// */
// Set<String> keyset();
//
// /**
// * Clears the values from this variable holder.
// */
// void clear();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/node/RunnableNodeGraph.java
// public class RunnableNodeGraph extends AbstractNode implements NodeGraph
// {
//
// String name;
// RunnableNodeGraph nextgraph = null;
//
// /**
// * Creates a new {@link RunnableNodeGraph}
// *
// * @param name The name
// */
// public RunnableNodeGraph(String name)
// {
// this.name = name;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String getName()
// {
// return this.name;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void run(VariableHolder vars)
// {
// RuntimeState state = new RuntimeState(vars);
// exec(state);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void exec(RuntimeState state)
// {
// Node next = this.getStart();
// while (next != null)
// {
// next.exec(state);
// next = next.getNext();
// }
// if (this.nextgraph != null)
// {
// this.nextgraph.exec(state);
// }
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void chain(RunnableNodeGraph next)
// {
// this.nextgraph = next;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public RunnableNodeGraph getNextGraph()
// {
// return this.nextgraph;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getStart()
// {
// return this.getNext();
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setStart(Node node)
// {
// this.setNext(node);
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/api/node/NodeGraph.java
import com.thevoxelbox.vsl.api.variables.VariableHolder;
import com.thevoxelbox.vsl.node.RunnableNodeGraph;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.api.node;
/**
* Represents a system on nodes which may be executed.
*/
public interface NodeGraph
{
/**
* Gets the graph name.
*
* @return The name
*/
String getName();
/**
* Runs this graph based on the given variables.
*
* @param vars The runtime variables
*/
void run(VariableHolder vars);
/**
* Chains this graph into another graph
*
* @param next The next graph
*/ | void chain(RunnableNodeGraph next); |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/vars/VariableGetNode.java | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.vars;
/**
* Gets a variable from the runtime variables with the given name.
*
* @param <T> The value type
*/
@NodeInfo(name = "VariableGet")
public class VariableGetNode<T> extends AbstractNode
{
@Input | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/vars/VariableGetNode.java
import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.vars;
/**
* Gets a variable from the runtime variables with the given name.
*
* @param <T> The value type
*/
@NodeInfo(name = "VariableGet")
public class VariableGetNode<T> extends AbstractNode
{
@Input | private final Provider<String> varName; |
Deamon5550/VisualScripting | src/test/java/com/thevoxelbox/test/util/StringArrayCheckNode.java | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test.util;
/**
* A testing utility node for checking if an array of strings is correctly
* passed from a loop.
*/
public class StringArrayCheckNode extends AbstractNode
{
final String[] check;
int index = 0; | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/test/java/com/thevoxelbox/test/util/StringArrayCheckNode.java
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test.util;
/**
* A testing utility node for checking if an array of strings is correctly
* passed from a loop.
*/
public class StringArrayCheckNode extends AbstractNode
{
final String[] check;
int index = 0; | Provider<String> prov; |
Deamon5550/VisualScripting | src/test/java/com/thevoxelbox/test/util/StringArrayCheckNode.java | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test.util;
/**
* A testing utility node for checking if an array of strings is correctly
* passed from a loop.
*/
public class StringArrayCheckNode extends AbstractNode
{
final String[] check;
int index = 0;
Provider<String> prov;
/**
* Creates a new {@link StringArrayCheckNode}.
*
* @param prov The string provider
* @param values The expected strings
*/
public StringArrayCheckNode(Provider<String> prov, String... values)
{
this.check = values;
this.prov = prov;
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/test/java/com/thevoxelbox/test/util/StringArrayCheckNode.java
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test.util;
/**
* A testing utility node for checking if an array of strings is correctly
* passed from a loop.
*/
public class StringArrayCheckNode extends AbstractNode
{
final String[] check;
int index = 0;
Provider<String> prov;
/**
* Creates a new {@link StringArrayCheckNode}.
*
* @param prov The string provider
* @param values The expected strings
*/
public StringArrayCheckNode(Provider<String> prov, String... values)
{
this.check = values;
this.prov = prov;
}
/**
* {@inheritDoc}
*/
@Override | public void exec(RuntimeState state) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/control/ForLoop.java | // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.control;
/**
* Loops over a set of integers and executes a {@link Node} for each integer.
*/
@NodeInfo(name = "For")
public class ForLoop extends AbstractNode
{
| // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/control/ForLoop.java
import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.control;
/**
* Loops over a set of integers and executes a {@link Node} for each integer.
*/
@NodeInfo(name = "For")
public class ForLoop extends AbstractNode
{
| private Node body; |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/control/ForLoop.java | // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.control;
/**
* Loops over a set of integers and executes a {@link Node} for each integer.
*/
@NodeInfo(name = "For")
public class ForLoop extends AbstractNode
{
private Node body;
@Input | // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/control/ForLoop.java
import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.control;
/**
* Loops over a set of integers and executes a {@link Node} for each integer.
*/
@NodeInfo(name = "For")
public class ForLoop extends AbstractNode
{
private Node body;
@Input | private final Provider<Integer> init; |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/control/ForLoop.java | // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | *
* @param i The initial value
* @param t The target value
* @param n The increment
*/
public ForLoop(Provider<Integer> i, int t, int n)
{
this.init = i;
this.target = new Provider<Integer>(this, t);
this.increment = new Provider<Integer>(this, n);
}
/**
* Creates a new {@link ForLoop}.
*
* @param i The initial value
* @param t The target value
* @param n The increment
*/
public ForLoop(int i, Provider<Integer> t, int n)
{
this.init = new Provider<Integer>(this, i);
this.target = t;
this.increment = new Provider<Integer>(this, n);
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/control/ForLoop.java
import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
*
* @param i The initial value
* @param t The target value
* @param n The increment
*/
public ForLoop(Provider<Integer> i, int t, int n)
{
this.init = i;
this.target = new Provider<Integer>(this, t);
this.increment = new Provider<Integer>(this, n);
}
/**
* Creates a new {@link ForLoop}.
*
* @param i The initial value
* @param t The target value
* @param n The increment
*/
public ForLoop(int i, Provider<Integer> t, int n)
{
this.init = new Provider<Integer>(this, i);
this.target = t;
this.increment = new Provider<Integer>(this, n);
}
/**
* {@inheritDoc}
*/
@Override | public void exec(RuntimeState state) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/SubtractionNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Performs a numerical subtraction between two numbers.
*/
@NodeInfo(name = "Subtraction")
public class SubtractionNode extends NumberOperatorNode
{
/**
* Creates a new {@link SubtractionNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/ | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/SubtractionNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Performs a numerical subtraction between two numbers.
*/
@NodeInfo(name = "Subtraction")
public class SubtractionNode extends NumberOperatorNode
{
/**
* Creates a new {@link SubtractionNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/ | public SubtractionNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/SubtractionNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Performs a numerical subtraction between two numbers.
*/
@NodeInfo(name = "Subtraction")
public class SubtractionNode extends NumberOperatorNode
{
/**
* Creates a new {@link SubtractionNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/
public SubtractionNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/SubtractionNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Performs a numerical subtraction between two numbers.
*/
@NodeInfo(name = "Subtraction")
public class SubtractionNode extends NumberOperatorNode
{
/**
* Creates a new {@link SubtractionNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/
public SubtractionNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | public void exec(RuntimeState state) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/TwoNumberNode.java | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* An abstract node for a node receiving two numbers as input.
*/
public abstract class TwoNumberNode extends AbstractNode
{
@Input | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/TwoNumberNode.java
import com.thevoxelbox.vsl.annotation.Input;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* An abstract node for a node receiving two numbers as input.
*/
public abstract class TwoNumberNode extends AbstractNode
{
@Input | protected final Provider<? extends Number> a; |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberCompareNode.java | // Path: src/main/java/com/thevoxelbox/vsl/nodes/math/TwoNumberNode.java
// public abstract class TwoNumberNode extends AbstractNode
// {
//
// @Input
// protected final Provider<? extends Number> a;
// @Input
// protected final Provider<? extends Number> b;
// protected final boolean floating;
//
// /**
// * Sets up a {@link TwoNumberNode}.
// *
// * @param a The first number
// * @param b The second number
// * @param floating Whether to use floating point precision
// */
// public TwoNumberNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
// {
// this.a = a;
// this.b = b;
// this.floating = floating;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.nodes.math.TwoNumberNode;
import com.thevoxelbox.vsl.util.Provider; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* An abstract node for comparing numbers.
*/
public abstract class NumberCompareNode extends TwoNumberNode
{
@Output | // Path: src/main/java/com/thevoxelbox/vsl/nodes/math/TwoNumberNode.java
// public abstract class TwoNumberNode extends AbstractNode
// {
//
// @Input
// protected final Provider<? extends Number> a;
// @Input
// protected final Provider<? extends Number> b;
// protected final boolean floating;
//
// /**
// * Sets up a {@link TwoNumberNode}.
// *
// * @param a The first number
// * @param b The second number
// * @param floating Whether to use floating point precision
// */
// public TwoNumberNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
// {
// this.a = a;
// this.b = b;
// this.floating = floating;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberCompareNode.java
import com.thevoxelbox.vsl.annotation.Output;
import com.thevoxelbox.vsl.nodes.math.TwoNumberNode;
import com.thevoxelbox.vsl.util.Provider;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* An abstract node for comparing numbers.
*/
public abstract class NumberCompareNode extends TwoNumberNode
{
@Output | protected final Provider<Boolean> result; |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/MultiplicationNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Performs the multiplication operation between two numbers.
*/
@NodeInfo(name = "Multiplication")
public class MultiplicationNode extends NumberOperatorNode
{
/**
* Creates a new {@link MultiplicationNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/ | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/MultiplicationNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Performs the multiplication operation between two numbers.
*/
@NodeInfo(name = "Multiplication")
public class MultiplicationNode extends NumberOperatorNode
{
/**
* Creates a new {@link MultiplicationNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/ | public MultiplicationNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/MultiplicationNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Performs the multiplication operation between two numbers.
*/
@NodeInfo(name = "Multiplication")
public class MultiplicationNode extends NumberOperatorNode
{
/**
* Creates a new {@link MultiplicationNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/
public MultiplicationNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/MultiplicationNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Performs the multiplication operation between two numbers.
*/
@NodeInfo(name = "Multiplication")
public class MultiplicationNode extends NumberOperatorNode
{
/**
* Creates a new {@link MultiplicationNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/
public MultiplicationNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | public void exec(RuntimeState state) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberLessThanOrEqualsNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if a number is less than or equal to a second number.
*/
@NodeInfo(name = "LessThanOrEquals")
public class NumberLessThanOrEqualsNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberEqualsNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/ | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberLessThanOrEqualsNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if a number is less than or equal to a second number.
*/
@NodeInfo(name = "LessThanOrEquals")
public class NumberLessThanOrEqualsNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberEqualsNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/ | public NumberLessThanOrEqualsNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberLessThanOrEqualsNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if a number is less than or equal to a second number.
*/
@NodeInfo(name = "LessThanOrEquals")
public class NumberLessThanOrEqualsNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberEqualsNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/
public NumberLessThanOrEqualsNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/compare/NumberLessThanOrEqualsNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math.compare;
/**
* Tests if a number is less than or equal to a second number.
*/
@NodeInfo(name = "LessThanOrEquals")
public class NumberLessThanOrEqualsNode extends NumberCompareNode
{
/**
* Creates a new {@link NumberEqualsNode}.
*
* @param a The first number
* @param b The second number
* @param floating Whether to use floating point precision
*/
public NumberLessThanOrEqualsNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | public void exec(RuntimeState state) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/DivisionNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Returns the quotient of two integer or floating-point numbers.
*/
@NodeInfo(name = "Division")
public class DivisionNode extends NumberOperatorNode
{
/**
* Creates a new {@link DivisionNode}.
*
* @param a The first input
* @param b The second input
* @param floating Whether to use floating point precision
*/ | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/DivisionNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Returns the quotient of two integer or floating-point numbers.
*/
@NodeInfo(name = "Division")
public class DivisionNode extends NumberOperatorNode
{
/**
* Creates a new {@link DivisionNode}.
*
* @param a The first input
* @param b The second input
* @param floating Whether to use floating point precision
*/ | public DivisionNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/math/DivisionNode.java | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Returns the quotient of two integer or floating-point numbers.
*/
@NodeInfo(name = "Division")
public class DivisionNode extends NumberOperatorNode
{
/**
* Creates a new {@link DivisionNode}.
*
* @param a The first input
* @param b The second input
* @param floating Whether to use floating point precision
*/
public DivisionNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/math/DivisionNode.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.math;
/**
* Returns the quotient of two integer or floating-point numbers.
*/
@NodeInfo(name = "Division")
public class DivisionNode extends NumberOperatorNode
{
/**
* Creates a new {@link DivisionNode}.
*
* @param a The first input
* @param b The second input
* @param floating Whether to use floating point precision
*/
public DivisionNode(Provider<? extends Number> a, Provider<? extends Number> b, boolean floating)
{
super(a, b, floating);
}
/**
* {@inheritDoc}
*/
@Override | public void exec(RuntimeState state) |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/control/IfStatement.java | // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.control;
/**
* Executed a node if the given boolean is true. TODO: else support
*/
@NodeInfo(name = "If")
public class IfStatement extends AbstractNode
{
| // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/control/IfStatement.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.control;
/**
* Executed a node if the given boolean is true. TODO: else support
*/
@NodeInfo(name = "If")
public class IfStatement extends AbstractNode
{
| private final Provider<Boolean> statement; |
Deamon5550/VisualScripting | src/main/java/com/thevoxelbox/vsl/nodes/control/IfStatement.java | // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.control;
/**
* Executed a node if the given boolean is true. TODO: else support
*/
@NodeInfo(name = "If")
public class IfStatement extends AbstractNode
{
private final Provider<Boolean> statement; | // Path: src/main/java/com/thevoxelbox/vsl/api/node/Node.java
// public interface Node
// {
//
// /**
// * Executes this node's function based on the runtime state and its inputs.
// *
// * @param state The runtime state
// */
// void exec(RuntimeState state);
//
// /**
// * Sets the node to be executed after this node in the execution pathway.
// *
// * @param next The next node
// */
// void setNext(Node next);
//
// /**
// * Gets the next node in the execution pathway.
// *
// * @return The next node
// */
// Node getNext();
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/Provider.java
// public class Provider<T>
// {
//
// private final Map<UUID, T> values;
// private final T value;
// private final boolean isStatic;
// private Node callback;
//
// /**
// * Creates a new {@link Provider} which will perform a callback to the given
// * node if the value is not set and a call to {@link #get(RuntimeState)}
// * occurs.
// *
// * @param n The node to call back to
// */
// public Provider(Node n)
// {
// this.callback = n;
// this.values = Maps.newHashMap();
// this.isStatic = false;
// this.value = null;
// }
//
// /**
// * Creates a new {@link Provider} with the given static value.
// *
// * @param n The node as reference
// * @param value The static value
// */
// public Provider(Node n, T value)
// {
// this.callback = n;
// this.value = value;
// this.isStatic = true;
// this.values = null;
// }
//
// /**
// * Gets the value for the given {@link RuntimeState} from this provider. I
// * decided not to use optionals here in preference of the debugging utility
// * of null pointers over checking an optional value.
// *
// * @param state The runtime state
// * @return The value, or null
// */
// public T get(RuntimeState state)
// {
// if (this.isStatic)
// {
// return this.value;
// }
// if (!this.values.containsKey(state.getUUID()))
// {
// this.callback.exec(state);
// }
// return this.values.get(state.getUUID());
// }
//
// /**
// * Sets the value for the given {@link UUID}.
// *
// * @param newValue The new value
// * @param uuid The UUID
// */
// public void set(T newValue, UUID uuid)
// {
// this.values.put(uuid, newValue);
// }
//
// /**
// * Gets the owner of this provider.
// *
// * @return The owner
// */
// public Node getOwner()
// {
// return this.callback;
// }
//
// /**
// * Gets whether this provider has a static value, or receives its value from
// * its owner.
// *
// * @return Is static
// */
// public boolean isStatic()
// {
// return this.isStatic;
// }
//
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/main/java/com/thevoxelbox/vsl/nodes/control/IfStatement.java
import com.thevoxelbox.vsl.annotation.NodeInfo;
import com.thevoxelbox.vsl.api.node.Node;
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.Provider;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.vsl.nodes.control;
/**
* Executed a node if the given boolean is true. TODO: else support
*/
@NodeInfo(name = "If")
public class IfStatement extends AbstractNode
{
private final Provider<Boolean> statement; | private Node body; |
Deamon5550/VisualScripting | src/test/java/com/thevoxelbox/test/util/CheckRunNode.java | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
| import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.RuntimeState; | /*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test.util;
/**
* A testing utility node to check that a node is run a specified number of
* times.
*/
public class CheckRunNode extends AbstractNode
{
int expected;
/**
* Creates a new {@link CheckRunNode}.
*
* @param e The expected number of runs
*/
public CheckRunNode(int e)
{
this.expected = e;
}
/**
* {@inheritDoc}
*/
@Override | // Path: src/main/java/com/thevoxelbox/vsl/node/AbstractNode.java
// public abstract class AbstractNode implements Node
// {
//
// private Node next;
//
// /**
// * {@inheritDoc}
// */
// @Override
// public void setNext(Node n)
// {
// this.next = n;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Node getNext()
// {
// return this.next;
// }
// }
//
// Path: src/main/java/com/thevoxelbox/vsl/util/RuntimeState.java
// public class RuntimeState
// {
//
// private final UUID uuid;
// private final VariableHolder vars;
//
// /**
// * Creates a new {@link RuntimeState}.
// *
// * @param vars
// */
// public RuntimeState(VariableHolder vars)
// {
// this.vars = vars;
// this.uuid = UUID.randomUUID();
// }
//
// /**
// * Gets the {@link UUID} of this runtime instance.
// *
// * @return The UUID
// */
// public UUID getUUID()
// {
// return this.uuid;
// }
//
// /**
// * Gets the runtime variable holder for this runtime instance.
// *
// * @return The variables
// */
// public VariableHolder getVars()
// {
// return this.vars;
// }
//
// }
// Path: src/test/java/com/thevoxelbox/test/util/CheckRunNode.java
import com.thevoxelbox.vsl.node.AbstractNode;
import com.thevoxelbox.vsl.util.RuntimeState;
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 The VoxelBox
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 OR COPYRIGHT HOLDERS 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.
*/
package com.thevoxelbox.test.util;
/**
* A testing utility node to check that a node is run a specified number of
* times.
*/
public class CheckRunNode extends AbstractNode
{
int expected;
/**
* Creates a new {@link CheckRunNode}.
*
* @param e The expected number of runs
*/
public CheckRunNode(int e)
{
this.expected = e;
}
/**
* {@inheritDoc}
*/
@Override | public void exec(RuntimeState state) |
OfficeDev/Property-Inspection-Code-Sample | AndroidRepairApp/app/src/main/java/com/canviz/repairapp/data/RepairPhotoModel.java | // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/SPListItemWrapper.java
// public class SPListItemWrapper {
// private SimpleDateFormat mZuluFormat;
// private SPListItem mInner;
//
// public SPListItemWrapper(SPListItem inner) {
// mInner = inner;
// }
//
// public SPListItem getInner() {
// return mInner;
// }
//
// private DateFormat getZuluFormat() {
// if (mZuluFormat == null) {
// //Format used by SharePoint for encoding datetimes
// mZuluFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
// mZuluFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
// }
// return mZuluFormat;
// }
//
// public Date getDate(String fieldName) {
// try {
// Object data = mInner.getData(fieldName);
// if (data == null || !(data instanceof String)) {
// return null;
// }
// return getZuluFormat().parse((String) data);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setDate(String fieldName, Date value) {
// if (value == null) {
// mInner.setData(fieldName, null);
// }
// mInner.setData(fieldName, getZuluFormat().format(value));
// }
//
// public int getInt(String fieldName) {
// try {
// return (Integer) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return 0;
// }
// }
//
// public void setInt(String fieldName, int value) {
// mInner.setData(fieldName, value);
// }
//
// public String getString(String fieldName) {
// try {
// return (String) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setString(String fieldName, String value) {
// mInner.setData(fieldName, value);
// }
//
// public JSONObject getObject(String fieldName) {
// try {
// return (JSONObject) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setObject(String fieldName, JSONObject value) {
// mInner.setData(fieldName, value);
// }
// }
| import com.canviz.repairapp.utility.SPListItemWrapper;
import com.microsoft.services.sharepoint.SPListItem; | package com.canviz.repairapp.data;
public class RepairPhotoModel {
public static final String[] SELECT = {
"Id","sl_inspectionIDId","sl_incidentIDId","sl_roomIDId"
};
public static final String[] EXPAND = {
};
| // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/SPListItemWrapper.java
// public class SPListItemWrapper {
// private SimpleDateFormat mZuluFormat;
// private SPListItem mInner;
//
// public SPListItemWrapper(SPListItem inner) {
// mInner = inner;
// }
//
// public SPListItem getInner() {
// return mInner;
// }
//
// private DateFormat getZuluFormat() {
// if (mZuluFormat == null) {
// //Format used by SharePoint for encoding datetimes
// mZuluFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
// mZuluFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
// }
// return mZuluFormat;
// }
//
// public Date getDate(String fieldName) {
// try {
// Object data = mInner.getData(fieldName);
// if (data == null || !(data instanceof String)) {
// return null;
// }
// return getZuluFormat().parse((String) data);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setDate(String fieldName, Date value) {
// if (value == null) {
// mInner.setData(fieldName, null);
// }
// mInner.setData(fieldName, getZuluFormat().format(value));
// }
//
// public int getInt(String fieldName) {
// try {
// return (Integer) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return 0;
// }
// }
//
// public void setInt(String fieldName, int value) {
// mInner.setData(fieldName, value);
// }
//
// public String getString(String fieldName) {
// try {
// return (String) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setString(String fieldName, String value) {
// mInner.setData(fieldName, value);
// }
//
// public JSONObject getObject(String fieldName) {
// try {
// return (JSONObject) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setObject(String fieldName, JSONObject value) {
// mInner.setData(fieldName, value);
// }
// }
// Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/data/RepairPhotoModel.java
import com.canviz.repairapp.utility.SPListItemWrapper;
import com.microsoft.services.sharepoint.SPListItem;
package com.canviz.repairapp.data;
public class RepairPhotoModel {
public static final String[] SELECT = {
"Id","sl_inspectionIDId","sl_incidentIDId","sl_roomIDId"
};
public static final String[] EXPAND = {
};
| private final SPListItemWrapper mData; |
OfficeDev/Property-Inspection-Code-Sample | AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/GraphAuthenticationProvider.java | // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/Constants.java
// public final class Constants {;
//
// public static final String AAD_CLIENT_ID = "YOUR CLIENT ID";
// public static final String AAD_REDIRECT_URL = "http://PropertyManagementRepairApp";
// public static final String AAD_AUTHORITY = "https://login.microsoftonline.com/common";
//
// public static final String GRAPH_RESOURCE_ID = "https://graph.microsoft.com/";
// public static final String GRAPH_RESOURCE_URL = "https://graph.microsoft.com/v1.0/";
// public static final String GRAPH_BETA_RESOURCE_URL = "https://graph.microsoft.com/beta/";
//
// public static final String SHAREPOINT_URL = "https://TENANCY.sharepoint.com";
// public static final String SHAREPOINT_SITE_PATH = "/sites/SuiteLevelAppDemo";
// public static final String SHAREPOINT_RESOURCE_ID = SHAREPOINT_URL;
//
// public static final String OUTLOOK_RESOURCE_ID = "https://outlook.office365.com/";
// public static final String ONENOTE_RESOURCE_ID = "https://onenote.com/";
// public static final String ONENOTE_NAME = "Contoso Property Management";
// public static final String VIDEO_RESOURCE_URL = SHAREPOINT_URL + "/portals/hub";
// public static final String VIDEO_CHANNEL_NAME = "Incidents";
//
// public static final String DISPATCHEREMAIL = "katiej@TENANCY.onmicrosoft.com";
//
// public static final String LIST_NAME_INCIDENTS = "Incidents";
// public static final String LIST_NAME_INSPECTIONS = "Inspections";
// public static final String LIST_NAME_INCIDENTWORKFLOWTASKS = "Incident Workflow Tasks";
// public static final String LIST_NAME_PROPERTYPHOTOS = "Property Photos";
// public static final String LIST_NAME_ROOMINSPECTIONPHOTOS = "Room Inspection Photos";
// public static final String LIST_NAME_REPAIRPHOTOS = "Repair Photos";
// public static final String LOCALIMAGE_SAVEPATH="/mnt/sdcard/repair/images/";
//
// public static final int SUCCESS = 0x111;
// public static final int FAILED = 0x112;
// }
| import android.app.Application;
import com.canviz.repairapp.Constants;
import com.microsoft.graph.authentication.MSAAuthAndroidAdapter;
import com.microsoft.graph.http.IHttpRequest;
import com.microsoft.graph.logger.ILogger;
import com.microsoft.graph.options.HeaderOption; | package com.canviz.repairapp.utility;
/**
* Created by Luis Lu on 5/12/2016.
*/
public class GraphAuthenticationProvider extends MSAAuthAndroidAdapter{
/**
* The logger instance.
*/
private String mToken;
/**
* Create a new instance of the provider
*
* @param application the application instance
*/
public GraphAuthenticationProvider(Application application, String token) {
super(application);
mToken = token;
}
@Override
public String getClientId() { | // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/Constants.java
// public final class Constants {;
//
// public static final String AAD_CLIENT_ID = "YOUR CLIENT ID";
// public static final String AAD_REDIRECT_URL = "http://PropertyManagementRepairApp";
// public static final String AAD_AUTHORITY = "https://login.microsoftonline.com/common";
//
// public static final String GRAPH_RESOURCE_ID = "https://graph.microsoft.com/";
// public static final String GRAPH_RESOURCE_URL = "https://graph.microsoft.com/v1.0/";
// public static final String GRAPH_BETA_RESOURCE_URL = "https://graph.microsoft.com/beta/";
//
// public static final String SHAREPOINT_URL = "https://TENANCY.sharepoint.com";
// public static final String SHAREPOINT_SITE_PATH = "/sites/SuiteLevelAppDemo";
// public static final String SHAREPOINT_RESOURCE_ID = SHAREPOINT_URL;
//
// public static final String OUTLOOK_RESOURCE_ID = "https://outlook.office365.com/";
// public static final String ONENOTE_RESOURCE_ID = "https://onenote.com/";
// public static final String ONENOTE_NAME = "Contoso Property Management";
// public static final String VIDEO_RESOURCE_URL = SHAREPOINT_URL + "/portals/hub";
// public static final String VIDEO_CHANNEL_NAME = "Incidents";
//
// public static final String DISPATCHEREMAIL = "katiej@TENANCY.onmicrosoft.com";
//
// public static final String LIST_NAME_INCIDENTS = "Incidents";
// public static final String LIST_NAME_INSPECTIONS = "Inspections";
// public static final String LIST_NAME_INCIDENTWORKFLOWTASKS = "Incident Workflow Tasks";
// public static final String LIST_NAME_PROPERTYPHOTOS = "Property Photos";
// public static final String LIST_NAME_ROOMINSPECTIONPHOTOS = "Room Inspection Photos";
// public static final String LIST_NAME_REPAIRPHOTOS = "Repair Photos";
// public static final String LOCALIMAGE_SAVEPATH="/mnt/sdcard/repair/images/";
//
// public static final int SUCCESS = 0x111;
// public static final int FAILED = 0x112;
// }
// Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/GraphAuthenticationProvider.java
import android.app.Application;
import com.canviz.repairapp.Constants;
import com.microsoft.graph.authentication.MSAAuthAndroidAdapter;
import com.microsoft.graph.http.IHttpRequest;
import com.microsoft.graph.logger.ILogger;
import com.microsoft.graph.options.HeaderOption;
package com.canviz.repairapp.utility;
/**
* Created by Luis Lu on 5/12/2016.
*/
public class GraphAuthenticationProvider extends MSAAuthAndroidAdapter{
/**
* The logger instance.
*/
private String mToken;
/**
* Create a new instance of the provider
*
* @param application the application instance
*/
public GraphAuthenticationProvider(Application application, String token) {
super(application);
mToken = token;
}
@Override
public String getClientId() { | return Constants.AAD_CLIENT_ID; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.