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
dubrousky/CMaker
src/cmake/filetypes/CMakeFileType.java
// Path: src/cmake/icons/CMakeIcons.java // public class CMakeIcons { // public static final Icon FILE = IconLoader.getIcon("/icons/cmake.png"); // public static final Icon MACRO = IconLoader.getIcon("/icons/hashtag.png"); // public static final Icon FUN = IconLoader.getIcon("/icons/fun.jpg"); // public static final Icon LOOP = IconLoader.getIcon("/icons/loop.png"); // } // // Path: src/cmake/global/CMakeLanguage.java // public class CMakeLanguage extends Language { // public static final CMakeLanguage INSTANCE = new CMakeLanguage(); // // private CMakeLanguage() { // super("CMake"); // } // }
import cmake.icons.CMakeIcons; import cmake.global.CMakeLanguage; import com.intellij.openapi.fileTypes.LanguageFileType; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.encoding.EncodingRegistry; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.nio.charset.Charset;
package cmake.filetypes; /** * Defines the association between the file type, extension * and language. Registered by the CMakeFileTypeFactory. */ public class CMakeFileType extends LanguageFileType { public static final CMakeFileType INSTANCE = new CMakeFileType(); private static final String[] DEFAULT_EXTENSIONS = {"cmake","txt"}; protected CMakeFileType() {
// Path: src/cmake/icons/CMakeIcons.java // public class CMakeIcons { // public static final Icon FILE = IconLoader.getIcon("/icons/cmake.png"); // public static final Icon MACRO = IconLoader.getIcon("/icons/hashtag.png"); // public static final Icon FUN = IconLoader.getIcon("/icons/fun.jpg"); // public static final Icon LOOP = IconLoader.getIcon("/icons/loop.png"); // } // // Path: src/cmake/global/CMakeLanguage.java // public class CMakeLanguage extends Language { // public static final CMakeLanguage INSTANCE = new CMakeLanguage(); // // private CMakeLanguage() { // super("CMake"); // } // } // Path: src/cmake/filetypes/CMakeFileType.java import cmake.icons.CMakeIcons; import cmake.global.CMakeLanguage; import com.intellij.openapi.fileTypes.LanguageFileType; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.encoding.EncodingRegistry; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.nio.charset.Charset; package cmake.filetypes; /** * Defines the association between the file type, extension * and language. Registered by the CMakeFileTypeFactory. */ public class CMakeFileType extends LanguageFileType { public static final CMakeFileType INSTANCE = new CMakeFileType(); private static final String[] DEFAULT_EXTENSIONS = {"cmake","txt"}; protected CMakeFileType() {
super(CMakeLanguage.INSTANCE);
dubrousky/CMaker
src/cmake/filetypes/CMakeFileType.java
// Path: src/cmake/icons/CMakeIcons.java // public class CMakeIcons { // public static final Icon FILE = IconLoader.getIcon("/icons/cmake.png"); // public static final Icon MACRO = IconLoader.getIcon("/icons/hashtag.png"); // public static final Icon FUN = IconLoader.getIcon("/icons/fun.jpg"); // public static final Icon LOOP = IconLoader.getIcon("/icons/loop.png"); // } // // Path: src/cmake/global/CMakeLanguage.java // public class CMakeLanguage extends Language { // public static final CMakeLanguage INSTANCE = new CMakeLanguage(); // // private CMakeLanguage() { // super("CMake"); // } // }
import cmake.icons.CMakeIcons; import cmake.global.CMakeLanguage; import com.intellij.openapi.fileTypes.LanguageFileType; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.encoding.EncodingRegistry; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.nio.charset.Charset;
package cmake.filetypes; /** * Defines the association between the file type, extension * and language. Registered by the CMakeFileTypeFactory. */ public class CMakeFileType extends LanguageFileType { public static final CMakeFileType INSTANCE = new CMakeFileType(); private static final String[] DEFAULT_EXTENSIONS = {"cmake","txt"}; protected CMakeFileType() { super(CMakeLanguage.INSTANCE); } @NotNull @Override public String getName() { return "CMake"; } @NotNull @Override public String getDescription() { return "CMake build system file"; } @NotNull @Override public String getDefaultExtension() { return DEFAULT_EXTENSIONS[0]; } @Nullable @Override public Icon getIcon() {
// Path: src/cmake/icons/CMakeIcons.java // public class CMakeIcons { // public static final Icon FILE = IconLoader.getIcon("/icons/cmake.png"); // public static final Icon MACRO = IconLoader.getIcon("/icons/hashtag.png"); // public static final Icon FUN = IconLoader.getIcon("/icons/fun.jpg"); // public static final Icon LOOP = IconLoader.getIcon("/icons/loop.png"); // } // // Path: src/cmake/global/CMakeLanguage.java // public class CMakeLanguage extends Language { // public static final CMakeLanguage INSTANCE = new CMakeLanguage(); // // private CMakeLanguage() { // super("CMake"); // } // } // Path: src/cmake/filetypes/CMakeFileType.java import cmake.icons.CMakeIcons; import cmake.global.CMakeLanguage; import com.intellij.openapi.fileTypes.LanguageFileType; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.encoding.EncodingRegistry; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.nio.charset.Charset; package cmake.filetypes; /** * Defines the association between the file type, extension * and language. Registered by the CMakeFileTypeFactory. */ public class CMakeFileType extends LanguageFileType { public static final CMakeFileType INSTANCE = new CMakeFileType(); private static final String[] DEFAULT_EXTENSIONS = {"cmake","txt"}; protected CMakeFileType() { super(CMakeLanguage.INSTANCE); } @NotNull @Override public String getName() { return "CMake"; } @NotNull @Override public String getDescription() { return "CMake build system file"; } @NotNull @Override public String getDefaultExtension() { return DEFAULT_EXTENSIONS[0]; } @Nullable @Override public Icon getIcon() {
return CMakeIcons.FILE;
dubrousky/CMaker
src/cmake/format/CMakeFormattingBlock.java
// Path: src/cmake/global/CMakeLanguage.java // public class CMakeLanguage extends Language { // public static final CMakeLanguage INSTANCE = new CMakeLanguage(); // // private CMakeLanguage() { // super("CMake"); // } // }
import cmake.global.CMakeLanguage; import cmake.psi.*; import com.intellij.formatting.*; import com.intellij.lang.ASTNode; import com.intellij.lang.Language; import com.intellij.openapi.util.Ref; import com.intellij.psi.PsiElement; import com.intellij.psi.TokenType; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.formatter.WrappingUtil; import com.intellij.psi.formatter.common.AbstractBlock; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collections; import java.util.List;
@Nullable @Override public Spacing getSpacing(Block block, Block block1) { return mySpacingBuilder.getSpacing(this, block, block1); } @NotNull @Override public ChildAttributes getChildAttributes(int newChildIndex) { return new ChildAttributes(myIndent, Alignment.createChildAlignment(Alignment.createAlignment())); } @Override public Indent getIndent() { return myIndent; } @Override protected Indent getChildIndent() { return null;} @Override public boolean isLeaf() { return myNode.getFirstChildNode() == null; } @Nullable @Override public Language getLanguage() {
// Path: src/cmake/global/CMakeLanguage.java // public class CMakeLanguage extends Language { // public static final CMakeLanguage INSTANCE = new CMakeLanguage(); // // private CMakeLanguage() { // super("CMake"); // } // } // Path: src/cmake/format/CMakeFormattingBlock.java import cmake.global.CMakeLanguage; import cmake.psi.*; import com.intellij.formatting.*; import com.intellij.lang.ASTNode; import com.intellij.lang.Language; import com.intellij.openapi.util.Ref; import com.intellij.psi.PsiElement; import com.intellij.psi.TokenType; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.formatter.WrappingUtil; import com.intellij.psi.formatter.common.AbstractBlock; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collections; import java.util.List; @Nullable @Override public Spacing getSpacing(Block block, Block block1) { return mySpacingBuilder.getSpacing(this, block, block1); } @NotNull @Override public ChildAttributes getChildAttributes(int newChildIndex) { return new ChildAttributes(myIndent, Alignment.createChildAlignment(Alignment.createAlignment())); } @Override public Indent getIndent() { return myIndent; } @Override protected Indent getChildIndent() { return null;} @Override public boolean isLeaf() { return myNode.getFirstChildNode() == null; } @Nullable @Override public Language getLanguage() {
return CMakeLanguage.INSTANCE;
dubrousky/CMaker
src/cmake/run/CMakeRunConfigurationType.java
// Path: src/cmake/icons/CMakeIcons.java // public class CMakeIcons { // public static final Icon FILE = IconLoader.getIcon("/icons/cmake.png"); // public static final Icon MACRO = IconLoader.getIcon("/icons/hashtag.png"); // public static final Icon FUN = IconLoader.getIcon("/icons/fun.jpg"); // public static final Icon LOOP = IconLoader.getIcon("/icons/loop.png"); // }
import cmake.icons.CMakeIcons; import com.intellij.execution.configurations.ConfigurationFactory; import com.intellij.execution.configurations.ConfigurationType; import org.jetbrains.annotations.NotNull; import javax.swing.*;
package cmake.run; /** * Created by alex on 1/24/15. */ public class CMakeRunConfigurationType implements ConfigurationType { public static CMakeRunConfigurationType INSTANCE = new CMakeRunConfigurationType(); protected CMakeRunConfigurationType() {} @Override public String getDisplayName() { return "CMake"; } @Override public String getConfigurationTypeDescription() { return "Run CMake Tool"; } @Override public Icon getIcon() {
// Path: src/cmake/icons/CMakeIcons.java // public class CMakeIcons { // public static final Icon FILE = IconLoader.getIcon("/icons/cmake.png"); // public static final Icon MACRO = IconLoader.getIcon("/icons/hashtag.png"); // public static final Icon FUN = IconLoader.getIcon("/icons/fun.jpg"); // public static final Icon LOOP = IconLoader.getIcon("/icons/loop.png"); // } // Path: src/cmake/run/CMakeRunConfigurationType.java import cmake.icons.CMakeIcons; import com.intellij.execution.configurations.ConfigurationFactory; import com.intellij.execution.configurations.ConfigurationType; import org.jetbrains.annotations.NotNull; import javax.swing.*; package cmake.run; /** * Created by alex on 1/24/15. */ public class CMakeRunConfigurationType implements ConfigurationType { public static CMakeRunConfigurationType INSTANCE = new CMakeRunConfigurationType(); protected CMakeRunConfigurationType() {} @Override public String getDisplayName() { return "CMake"; } @Override public String getConfigurationTypeDescription() { return "Run CMake Tool"; } @Override public Icon getIcon() {
return CMakeIcons.FILE;
dubrousky/CMaker
src/cmake/format/CMakeFormattingModuleBuilder.java
// Path: src/cmake/global/CMakeLanguage.java // public class CMakeLanguage extends Language { // public static final CMakeLanguage INSTANCE = new CMakeLanguage(); // // private CMakeLanguage() { // super("CMake"); // } // }
import cmake.global.CMakeLanguage; import cmake.psi.CMakeTypes; import com.intellij.formatting.*; import com.intellij.lang.ASTNode; import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable;
package cmake.format; /** * Created by alex on 1/11/15. */ public class CMakeFormattingModuleBuilder implements FormattingModelBuilder { @NotNull @Override public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { CMakeCodeStyleSettings cmakeSettings = settings.getCustomSettings(CMakeCodeStyleSettings.class); SpacingBuilder spacingBuilder = createSpacingBuilder(settings, cmakeSettings); CMakeFormattingBlock block = new CMakeFormattingBlock(element.getNode(), Wrap.createWrap(WrapType.NONE,true), null, spacingBuilder); return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(), block, settings); } private static SpacingBuilder createSpacingBuilder(@NotNull CodeStyleSettings settings, CMakeCodeStyleSettings cmakeSettings) { //noinspection SuspiciousNameCombination
// Path: src/cmake/global/CMakeLanguage.java // public class CMakeLanguage extends Language { // public static final CMakeLanguage INSTANCE = new CMakeLanguage(); // // private CMakeLanguage() { // super("CMake"); // } // } // Path: src/cmake/format/CMakeFormattingModuleBuilder.java import cmake.global.CMakeLanguage; import cmake.psi.CMakeTypes; import com.intellij.formatting.*; import com.intellij.lang.ASTNode; import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; package cmake.format; /** * Created by alex on 1/11/15. */ public class CMakeFormattingModuleBuilder implements FormattingModelBuilder { @NotNull @Override public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { CMakeCodeStyleSettings cmakeSettings = settings.getCustomSettings(CMakeCodeStyleSettings.class); SpacingBuilder spacingBuilder = createSpacingBuilder(settings, cmakeSettings); CMakeFormattingBlock block = new CMakeFormattingBlock(element.getNode(), Wrap.createWrap(WrapType.NONE,true), null, spacingBuilder); return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(), block, settings); } private static SpacingBuilder createSpacingBuilder(@NotNull CodeStyleSettings settings, CMakeCodeStyleSettings cmakeSettings) { //noinspection SuspiciousNameCombination
return new SpacingBuilder(settings, CMakeLanguage.INSTANCE)
mikegehard/userManagementEvolution
applications/ums/src/main/java/com/example/ums/users/UsersController.java
// Path: components/users/src/main/java/com/example/users/CreateUser.java // public class CreateUser { // private final UaaClient uaaClient; // // public CreateUser(UaaClient uaaClient) { // this.uaaClient = uaaClient; // } // public Optional<User> run(String name, String password) { // return uaaClient.createUser(name, password); // } // } // // Path: components/users/src/main/java/com/example/users/UaaClient.java // public class UaaClient { // private final String clientId; // private final String clientSecret; // private final String uaaUrl; // private final RestTemplate restTemplate; // // public UaaClient(String clientId, String clientSecret, String uaaUrl) { // this.clientId = clientId; // this.clientSecret = clientSecret; // this.uaaUrl = uaaUrl; // this.restTemplate = new RestTemplate(); // } // // public Optional<User> createUser(String name, String password) { // String clientToken = getClientToken(clientId, clientSecret); // // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", "Bearer " + clientToken); // // ParameterizedTypeReference<Map<String, ?>> userReturnValue = new ParameterizedTypeReference<Map<String, ?>>() { // }; // // Map<String, Object> userData = createUserData(name, password); // // HttpEntity<Map<String, ?>> request = new HttpEntity<>(userData, headers); // ResponseEntity<Map<String, ?>> response = restTemplate.exchange( // uaaUrl + "/uaa/Users", // HttpMethod.POST, // request, // userReturnValue // ); // // return Optional.of(new User(name, (String) response.getBody().get("id"))); // } // // public Optional<Session> logIn(String name, String password) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "password"); // form.add("username", name); // form.add("password", password); // // ParameterizedTypeReference<Map<String, String>> returnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // request, // returnValue // ); // // return Optional.of(new Session(clientTokenResponse.getBody().get("access_token"))); // } // // private String getAuthorizationHeader(String clientId, String clientSecret) { // return "Basic " + new String(Base64.encodeBase64((clientId + ":" + clientSecret).getBytes(Charset.forName("US-ASCII")))); // } // // private Map<String, Object> createUserData(String userName, String password) { // Map<String, Object> data = new HashMap<>(); // // /* // { // "userName":"username", // "password": "user password", // "emails": [{ // "value": "foo@example.com" // }] // } // */ // // data.put("userName", userName); // data.put("password", password); // List<Map<String, String>> emails = new ArrayList<>(); // Map<String, String> email = new HashMap<>(); // emails.add(email); // email.put("value", "user-" + userName + "@example.com"); // data.put("emails", emails); // // return data; // } // // private String getClientToken(String clientId, String clientSecret) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "client_credentials"); // // ParameterizedTypeReference<Map<String, String>> clientTokenReturnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> clientTokenRequest = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // clientTokenRequest, // clientTokenReturnValue // ); // // return clientTokenResponse.getBody().get("access_token"); // } // } // // Path: components/users/src/main/java/com/example/users/User.java // public class User { // private final String userName; // private final String id; // // public User(String userName, String id) { // // this.userName = userName; // this.id = id; // } // // public String getUserName() { // return userName; // } // // public String getId() { // return id; // } // }
import com.example.users.CreateUser; import com.example.users.UaaClient; import com.example.users.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map; import java.util.Optional;
package com.example.ums.users; @RestController @RequestMapping("/users") public class UsersController { @Autowired
// Path: components/users/src/main/java/com/example/users/CreateUser.java // public class CreateUser { // private final UaaClient uaaClient; // // public CreateUser(UaaClient uaaClient) { // this.uaaClient = uaaClient; // } // public Optional<User> run(String name, String password) { // return uaaClient.createUser(name, password); // } // } // // Path: components/users/src/main/java/com/example/users/UaaClient.java // public class UaaClient { // private final String clientId; // private final String clientSecret; // private final String uaaUrl; // private final RestTemplate restTemplate; // // public UaaClient(String clientId, String clientSecret, String uaaUrl) { // this.clientId = clientId; // this.clientSecret = clientSecret; // this.uaaUrl = uaaUrl; // this.restTemplate = new RestTemplate(); // } // // public Optional<User> createUser(String name, String password) { // String clientToken = getClientToken(clientId, clientSecret); // // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", "Bearer " + clientToken); // // ParameterizedTypeReference<Map<String, ?>> userReturnValue = new ParameterizedTypeReference<Map<String, ?>>() { // }; // // Map<String, Object> userData = createUserData(name, password); // // HttpEntity<Map<String, ?>> request = new HttpEntity<>(userData, headers); // ResponseEntity<Map<String, ?>> response = restTemplate.exchange( // uaaUrl + "/uaa/Users", // HttpMethod.POST, // request, // userReturnValue // ); // // return Optional.of(new User(name, (String) response.getBody().get("id"))); // } // // public Optional<Session> logIn(String name, String password) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "password"); // form.add("username", name); // form.add("password", password); // // ParameterizedTypeReference<Map<String, String>> returnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // request, // returnValue // ); // // return Optional.of(new Session(clientTokenResponse.getBody().get("access_token"))); // } // // private String getAuthorizationHeader(String clientId, String clientSecret) { // return "Basic " + new String(Base64.encodeBase64((clientId + ":" + clientSecret).getBytes(Charset.forName("US-ASCII")))); // } // // private Map<String, Object> createUserData(String userName, String password) { // Map<String, Object> data = new HashMap<>(); // // /* // { // "userName":"username", // "password": "user password", // "emails": [{ // "value": "foo@example.com" // }] // } // */ // // data.put("userName", userName); // data.put("password", password); // List<Map<String, String>> emails = new ArrayList<>(); // Map<String, String> email = new HashMap<>(); // emails.add(email); // email.put("value", "user-" + userName + "@example.com"); // data.put("emails", emails); // // return data; // } // // private String getClientToken(String clientId, String clientSecret) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "client_credentials"); // // ParameterizedTypeReference<Map<String, String>> clientTokenReturnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> clientTokenRequest = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // clientTokenRequest, // clientTokenReturnValue // ); // // return clientTokenResponse.getBody().get("access_token"); // } // } // // Path: components/users/src/main/java/com/example/users/User.java // public class User { // private final String userName; // private final String id; // // public User(String userName, String id) { // // this.userName = userName; // this.id = id; // } // // public String getUserName() { // return userName; // } // // public String getId() { // return id; // } // } // Path: applications/ums/src/main/java/com/example/ums/users/UsersController.java import com.example.users.CreateUser; import com.example.users.UaaClient; import com.example.users.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map; import java.util.Optional; package com.example.ums.users; @RestController @RequestMapping("/users") public class UsersController { @Autowired
private UaaClient createUserUaaClient;
mikegehard/userManagementEvolution
applications/ums/src/main/java/com/example/ums/users/UsersController.java
// Path: components/users/src/main/java/com/example/users/CreateUser.java // public class CreateUser { // private final UaaClient uaaClient; // // public CreateUser(UaaClient uaaClient) { // this.uaaClient = uaaClient; // } // public Optional<User> run(String name, String password) { // return uaaClient.createUser(name, password); // } // } // // Path: components/users/src/main/java/com/example/users/UaaClient.java // public class UaaClient { // private final String clientId; // private final String clientSecret; // private final String uaaUrl; // private final RestTemplate restTemplate; // // public UaaClient(String clientId, String clientSecret, String uaaUrl) { // this.clientId = clientId; // this.clientSecret = clientSecret; // this.uaaUrl = uaaUrl; // this.restTemplate = new RestTemplate(); // } // // public Optional<User> createUser(String name, String password) { // String clientToken = getClientToken(clientId, clientSecret); // // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", "Bearer " + clientToken); // // ParameterizedTypeReference<Map<String, ?>> userReturnValue = new ParameterizedTypeReference<Map<String, ?>>() { // }; // // Map<String, Object> userData = createUserData(name, password); // // HttpEntity<Map<String, ?>> request = new HttpEntity<>(userData, headers); // ResponseEntity<Map<String, ?>> response = restTemplate.exchange( // uaaUrl + "/uaa/Users", // HttpMethod.POST, // request, // userReturnValue // ); // // return Optional.of(new User(name, (String) response.getBody().get("id"))); // } // // public Optional<Session> logIn(String name, String password) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "password"); // form.add("username", name); // form.add("password", password); // // ParameterizedTypeReference<Map<String, String>> returnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // request, // returnValue // ); // // return Optional.of(new Session(clientTokenResponse.getBody().get("access_token"))); // } // // private String getAuthorizationHeader(String clientId, String clientSecret) { // return "Basic " + new String(Base64.encodeBase64((clientId + ":" + clientSecret).getBytes(Charset.forName("US-ASCII")))); // } // // private Map<String, Object> createUserData(String userName, String password) { // Map<String, Object> data = new HashMap<>(); // // /* // { // "userName":"username", // "password": "user password", // "emails": [{ // "value": "foo@example.com" // }] // } // */ // // data.put("userName", userName); // data.put("password", password); // List<Map<String, String>> emails = new ArrayList<>(); // Map<String, String> email = new HashMap<>(); // emails.add(email); // email.put("value", "user-" + userName + "@example.com"); // data.put("emails", emails); // // return data; // } // // private String getClientToken(String clientId, String clientSecret) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "client_credentials"); // // ParameterizedTypeReference<Map<String, String>> clientTokenReturnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> clientTokenRequest = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // clientTokenRequest, // clientTokenReturnValue // ); // // return clientTokenResponse.getBody().get("access_token"); // } // } // // Path: components/users/src/main/java/com/example/users/User.java // public class User { // private final String userName; // private final String id; // // public User(String userName, String id) { // // this.userName = userName; // this.id = id; // } // // public String getUserName() { // return userName; // } // // public String getId() { // return id; // } // }
import com.example.users.CreateUser; import com.example.users.UaaClient; import com.example.users.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map; import java.util.Optional;
package com.example.ums.users; @RestController @RequestMapping("/users") public class UsersController { @Autowired private UaaClient createUserUaaClient; @RequestMapping(method = RequestMethod.POST)
// Path: components/users/src/main/java/com/example/users/CreateUser.java // public class CreateUser { // private final UaaClient uaaClient; // // public CreateUser(UaaClient uaaClient) { // this.uaaClient = uaaClient; // } // public Optional<User> run(String name, String password) { // return uaaClient.createUser(name, password); // } // } // // Path: components/users/src/main/java/com/example/users/UaaClient.java // public class UaaClient { // private final String clientId; // private final String clientSecret; // private final String uaaUrl; // private final RestTemplate restTemplate; // // public UaaClient(String clientId, String clientSecret, String uaaUrl) { // this.clientId = clientId; // this.clientSecret = clientSecret; // this.uaaUrl = uaaUrl; // this.restTemplate = new RestTemplate(); // } // // public Optional<User> createUser(String name, String password) { // String clientToken = getClientToken(clientId, clientSecret); // // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", "Bearer " + clientToken); // // ParameterizedTypeReference<Map<String, ?>> userReturnValue = new ParameterizedTypeReference<Map<String, ?>>() { // }; // // Map<String, Object> userData = createUserData(name, password); // // HttpEntity<Map<String, ?>> request = new HttpEntity<>(userData, headers); // ResponseEntity<Map<String, ?>> response = restTemplate.exchange( // uaaUrl + "/uaa/Users", // HttpMethod.POST, // request, // userReturnValue // ); // // return Optional.of(new User(name, (String) response.getBody().get("id"))); // } // // public Optional<Session> logIn(String name, String password) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "password"); // form.add("username", name); // form.add("password", password); // // ParameterizedTypeReference<Map<String, String>> returnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // request, // returnValue // ); // // return Optional.of(new Session(clientTokenResponse.getBody().get("access_token"))); // } // // private String getAuthorizationHeader(String clientId, String clientSecret) { // return "Basic " + new String(Base64.encodeBase64((clientId + ":" + clientSecret).getBytes(Charset.forName("US-ASCII")))); // } // // private Map<String, Object> createUserData(String userName, String password) { // Map<String, Object> data = new HashMap<>(); // // /* // { // "userName":"username", // "password": "user password", // "emails": [{ // "value": "foo@example.com" // }] // } // */ // // data.put("userName", userName); // data.put("password", password); // List<Map<String, String>> emails = new ArrayList<>(); // Map<String, String> email = new HashMap<>(); // emails.add(email); // email.put("value", "user-" + userName + "@example.com"); // data.put("emails", emails); // // return data; // } // // private String getClientToken(String clientId, String clientSecret) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "client_credentials"); // // ParameterizedTypeReference<Map<String, String>> clientTokenReturnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> clientTokenRequest = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // clientTokenRequest, // clientTokenReturnValue // ); // // return clientTokenResponse.getBody().get("access_token"); // } // } // // Path: components/users/src/main/java/com/example/users/User.java // public class User { // private final String userName; // private final String id; // // public User(String userName, String id) { // // this.userName = userName; // this.id = id; // } // // public String getUserName() { // return userName; // } // // public String getId() { // return id; // } // } // Path: applications/ums/src/main/java/com/example/ums/users/UsersController.java import com.example.users.CreateUser; import com.example.users.UaaClient; import com.example.users.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map; import java.util.Optional; package com.example.ums.users; @RestController @RequestMapping("/users") public class UsersController { @Autowired private UaaClient createUserUaaClient; @RequestMapping(method = RequestMethod.POST)
public ResponseEntity<User> create(@RequestBody Map<String, String> params) {
mikegehard/userManagementEvolution
applications/ums/src/main/java/com/example/ums/users/UsersController.java
// Path: components/users/src/main/java/com/example/users/CreateUser.java // public class CreateUser { // private final UaaClient uaaClient; // // public CreateUser(UaaClient uaaClient) { // this.uaaClient = uaaClient; // } // public Optional<User> run(String name, String password) { // return uaaClient.createUser(name, password); // } // } // // Path: components/users/src/main/java/com/example/users/UaaClient.java // public class UaaClient { // private final String clientId; // private final String clientSecret; // private final String uaaUrl; // private final RestTemplate restTemplate; // // public UaaClient(String clientId, String clientSecret, String uaaUrl) { // this.clientId = clientId; // this.clientSecret = clientSecret; // this.uaaUrl = uaaUrl; // this.restTemplate = new RestTemplate(); // } // // public Optional<User> createUser(String name, String password) { // String clientToken = getClientToken(clientId, clientSecret); // // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", "Bearer " + clientToken); // // ParameterizedTypeReference<Map<String, ?>> userReturnValue = new ParameterizedTypeReference<Map<String, ?>>() { // }; // // Map<String, Object> userData = createUserData(name, password); // // HttpEntity<Map<String, ?>> request = new HttpEntity<>(userData, headers); // ResponseEntity<Map<String, ?>> response = restTemplate.exchange( // uaaUrl + "/uaa/Users", // HttpMethod.POST, // request, // userReturnValue // ); // // return Optional.of(new User(name, (String) response.getBody().get("id"))); // } // // public Optional<Session> logIn(String name, String password) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "password"); // form.add("username", name); // form.add("password", password); // // ParameterizedTypeReference<Map<String, String>> returnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // request, // returnValue // ); // // return Optional.of(new Session(clientTokenResponse.getBody().get("access_token"))); // } // // private String getAuthorizationHeader(String clientId, String clientSecret) { // return "Basic " + new String(Base64.encodeBase64((clientId + ":" + clientSecret).getBytes(Charset.forName("US-ASCII")))); // } // // private Map<String, Object> createUserData(String userName, String password) { // Map<String, Object> data = new HashMap<>(); // // /* // { // "userName":"username", // "password": "user password", // "emails": [{ // "value": "foo@example.com" // }] // } // */ // // data.put("userName", userName); // data.put("password", password); // List<Map<String, String>> emails = new ArrayList<>(); // Map<String, String> email = new HashMap<>(); // emails.add(email); // email.put("value", "user-" + userName + "@example.com"); // data.put("emails", emails); // // return data; // } // // private String getClientToken(String clientId, String clientSecret) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "client_credentials"); // // ParameterizedTypeReference<Map<String, String>> clientTokenReturnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> clientTokenRequest = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // clientTokenRequest, // clientTokenReturnValue // ); // // return clientTokenResponse.getBody().get("access_token"); // } // } // // Path: components/users/src/main/java/com/example/users/User.java // public class User { // private final String userName; // private final String id; // // public User(String userName, String id) { // // this.userName = userName; // this.id = id; // } // // public String getUserName() { // return userName; // } // // public String getId() { // return id; // } // }
import com.example.users.CreateUser; import com.example.users.UaaClient; import com.example.users.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map; import java.util.Optional;
package com.example.ums.users; @RestController @RequestMapping("/users") public class UsersController { @Autowired private UaaClient createUserUaaClient; @RequestMapping(method = RequestMethod.POST) public ResponseEntity<User> create(@RequestBody Map<String, String> params) {
// Path: components/users/src/main/java/com/example/users/CreateUser.java // public class CreateUser { // private final UaaClient uaaClient; // // public CreateUser(UaaClient uaaClient) { // this.uaaClient = uaaClient; // } // public Optional<User> run(String name, String password) { // return uaaClient.createUser(name, password); // } // } // // Path: components/users/src/main/java/com/example/users/UaaClient.java // public class UaaClient { // private final String clientId; // private final String clientSecret; // private final String uaaUrl; // private final RestTemplate restTemplate; // // public UaaClient(String clientId, String clientSecret, String uaaUrl) { // this.clientId = clientId; // this.clientSecret = clientSecret; // this.uaaUrl = uaaUrl; // this.restTemplate = new RestTemplate(); // } // // public Optional<User> createUser(String name, String password) { // String clientToken = getClientToken(clientId, clientSecret); // // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", "Bearer " + clientToken); // // ParameterizedTypeReference<Map<String, ?>> userReturnValue = new ParameterizedTypeReference<Map<String, ?>>() { // }; // // Map<String, Object> userData = createUserData(name, password); // // HttpEntity<Map<String, ?>> request = new HttpEntity<>(userData, headers); // ResponseEntity<Map<String, ?>> response = restTemplate.exchange( // uaaUrl + "/uaa/Users", // HttpMethod.POST, // request, // userReturnValue // ); // // return Optional.of(new User(name, (String) response.getBody().get("id"))); // } // // public Optional<Session> logIn(String name, String password) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "password"); // form.add("username", name); // form.add("password", password); // // ParameterizedTypeReference<Map<String, String>> returnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // request, // returnValue // ); // // return Optional.of(new Session(clientTokenResponse.getBody().get("access_token"))); // } // // private String getAuthorizationHeader(String clientId, String clientSecret) { // return "Basic " + new String(Base64.encodeBase64((clientId + ":" + clientSecret).getBytes(Charset.forName("US-ASCII")))); // } // // private Map<String, Object> createUserData(String userName, String password) { // Map<String, Object> data = new HashMap<>(); // // /* // { // "userName":"username", // "password": "user password", // "emails": [{ // "value": "foo@example.com" // }] // } // */ // // data.put("userName", userName); // data.put("password", password); // List<Map<String, String>> emails = new ArrayList<>(); // Map<String, String> email = new HashMap<>(); // emails.add(email); // email.put("value", "user-" + userName + "@example.com"); // data.put("emails", emails); // // return data; // } // // private String getClientToken(String clientId, String clientSecret) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "client_credentials"); // // ParameterizedTypeReference<Map<String, String>> clientTokenReturnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> clientTokenRequest = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // clientTokenRequest, // clientTokenReturnValue // ); // // return clientTokenResponse.getBody().get("access_token"); // } // } // // Path: components/users/src/main/java/com/example/users/User.java // public class User { // private final String userName; // private final String id; // // public User(String userName, String id) { // // this.userName = userName; // this.id = id; // } // // public String getUserName() { // return userName; // } // // public String getId() { // return id; // } // } // Path: applications/ums/src/main/java/com/example/ums/users/UsersController.java import com.example.users.CreateUser; import com.example.users.UaaClient; import com.example.users.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map; import java.util.Optional; package com.example.ums.users; @RestController @RequestMapping("/users") public class UsersController { @Autowired private UaaClient createUserUaaClient; @RequestMapping(method = RequestMethod.POST) public ResponseEntity<User> create(@RequestBody Map<String, String> params) {
Optional<User> user = new CreateUser(createUserUaaClient).run(params.get("name"), params.get("password"));
mikegehard/userManagementEvolution
components/subscriptions/src/main/java/com/example/subscriptions/CreateSubscription.java
// Path: components/billing/src/main/java/com/example/billing/BillingRequest.java // public class BillingRequest { // private final String userId; // private final int amount; // // public BillingRequest(String userId, int amount) { // this.userId = userId; // this.amount = amount; // } // // public String getUserId() { // return userId; // } // // public int getAmount() { // return amount; // } // } // // Path: components/email/src/main/java/com/example/email/EmailMessage.java // public class EmailMessage implements Serializable { // // private final String toAddress; // private final String subject; // private final String body; // // public EmailMessage(String toAddress, String subject, String body) { // // this.toAddress = toAddress; // this.subject = subject; // this.body = body; // } // // public String getToAddress() { // return toAddress; // } // // public String getSubject() { // return subject; // } // // public String getBody() { // return body; // } // } // // Path: components/email/src/main/java/com/example/email/SendEmail.java // public class SendEmail { // private final String queueName; // private final RabbitTemplate rabbitTemplate; // // public SendEmail(String queueName, RabbitTemplate rabbitTemplate) { // this.queueName = queueName; // this.rabbitTemplate = rabbitTemplate; // } // // public void run(EmailMessage message) { // rabbitTemplate.convertAndSend(queueName, message); // } // }
import com.example.billing.BillingRequest; import com.example.billing.Service; import com.example.email.EmailMessage; import com.example.email.SendEmail;
package com.example.subscriptions; public class CreateSubscription { private final Service billingService;
// Path: components/billing/src/main/java/com/example/billing/BillingRequest.java // public class BillingRequest { // private final String userId; // private final int amount; // // public BillingRequest(String userId, int amount) { // this.userId = userId; // this.amount = amount; // } // // public String getUserId() { // return userId; // } // // public int getAmount() { // return amount; // } // } // // Path: components/email/src/main/java/com/example/email/EmailMessage.java // public class EmailMessage implements Serializable { // // private final String toAddress; // private final String subject; // private final String body; // // public EmailMessage(String toAddress, String subject, String body) { // // this.toAddress = toAddress; // this.subject = subject; // this.body = body; // } // // public String getToAddress() { // return toAddress; // } // // public String getSubject() { // return subject; // } // // public String getBody() { // return body; // } // } // // Path: components/email/src/main/java/com/example/email/SendEmail.java // public class SendEmail { // private final String queueName; // private final RabbitTemplate rabbitTemplate; // // public SendEmail(String queueName, RabbitTemplate rabbitTemplate) { // this.queueName = queueName; // this.rabbitTemplate = rabbitTemplate; // } // // public void run(EmailMessage message) { // rabbitTemplate.convertAndSend(queueName, message); // } // } // Path: components/subscriptions/src/main/java/com/example/subscriptions/CreateSubscription.java import com.example.billing.BillingRequest; import com.example.billing.Service; import com.example.email.EmailMessage; import com.example.email.SendEmail; package com.example.subscriptions; public class CreateSubscription { private final Service billingService;
private final SendEmail emailSender;
mikegehard/userManagementEvolution
components/subscriptions/src/main/java/com/example/subscriptions/CreateSubscription.java
// Path: components/billing/src/main/java/com/example/billing/BillingRequest.java // public class BillingRequest { // private final String userId; // private final int amount; // // public BillingRequest(String userId, int amount) { // this.userId = userId; // this.amount = amount; // } // // public String getUserId() { // return userId; // } // // public int getAmount() { // return amount; // } // } // // Path: components/email/src/main/java/com/example/email/EmailMessage.java // public class EmailMessage implements Serializable { // // private final String toAddress; // private final String subject; // private final String body; // // public EmailMessage(String toAddress, String subject, String body) { // // this.toAddress = toAddress; // this.subject = subject; // this.body = body; // } // // public String getToAddress() { // return toAddress; // } // // public String getSubject() { // return subject; // } // // public String getBody() { // return body; // } // } // // Path: components/email/src/main/java/com/example/email/SendEmail.java // public class SendEmail { // private final String queueName; // private final RabbitTemplate rabbitTemplate; // // public SendEmail(String queueName, RabbitTemplate rabbitTemplate) { // this.queueName = queueName; // this.rabbitTemplate = rabbitTemplate; // } // // public void run(EmailMessage message) { // rabbitTemplate.convertAndSend(queueName, message); // } // }
import com.example.billing.BillingRequest; import com.example.billing.Service; import com.example.email.EmailMessage; import com.example.email.SendEmail;
package com.example.subscriptions; public class CreateSubscription { private final Service billingService; private final SendEmail emailSender; private final SubscriptionRepository subscriptions; public CreateSubscription( Service billingService, SendEmail emailSender, SubscriptionRepository subscriptions) { this.billingService = billingService; this.emailSender = emailSender; this.subscriptions = subscriptions; } public void run(String userId, String packageId) { subscriptions.create(new Subscription(userId, packageId));
// Path: components/billing/src/main/java/com/example/billing/BillingRequest.java // public class BillingRequest { // private final String userId; // private final int amount; // // public BillingRequest(String userId, int amount) { // this.userId = userId; // this.amount = amount; // } // // public String getUserId() { // return userId; // } // // public int getAmount() { // return amount; // } // } // // Path: components/email/src/main/java/com/example/email/EmailMessage.java // public class EmailMessage implements Serializable { // // private final String toAddress; // private final String subject; // private final String body; // // public EmailMessage(String toAddress, String subject, String body) { // // this.toAddress = toAddress; // this.subject = subject; // this.body = body; // } // // public String getToAddress() { // return toAddress; // } // // public String getSubject() { // return subject; // } // // public String getBody() { // return body; // } // } // // Path: components/email/src/main/java/com/example/email/SendEmail.java // public class SendEmail { // private final String queueName; // private final RabbitTemplate rabbitTemplate; // // public SendEmail(String queueName, RabbitTemplate rabbitTemplate) { // this.queueName = queueName; // this.rabbitTemplate = rabbitTemplate; // } // // public void run(EmailMessage message) { // rabbitTemplate.convertAndSend(queueName, message); // } // } // Path: components/subscriptions/src/main/java/com/example/subscriptions/CreateSubscription.java import com.example.billing.BillingRequest; import com.example.billing.Service; import com.example.email.EmailMessage; import com.example.email.SendEmail; package com.example.subscriptions; public class CreateSubscription { private final Service billingService; private final SendEmail emailSender; private final SubscriptionRepository subscriptions; public CreateSubscription( Service billingService, SendEmail emailSender, SubscriptionRepository subscriptions) { this.billingService = billingService; this.emailSender = emailSender; this.subscriptions = subscriptions; } public void run(String userId, String packageId) { subscriptions.create(new Subscription(userId, packageId));
billingService.billUser(new BillingRequest(userId, 100));
mikegehard/userManagementEvolution
components/subscriptions/src/main/java/com/example/subscriptions/CreateSubscription.java
// Path: components/billing/src/main/java/com/example/billing/BillingRequest.java // public class BillingRequest { // private final String userId; // private final int amount; // // public BillingRequest(String userId, int amount) { // this.userId = userId; // this.amount = amount; // } // // public String getUserId() { // return userId; // } // // public int getAmount() { // return amount; // } // } // // Path: components/email/src/main/java/com/example/email/EmailMessage.java // public class EmailMessage implements Serializable { // // private final String toAddress; // private final String subject; // private final String body; // // public EmailMessage(String toAddress, String subject, String body) { // // this.toAddress = toAddress; // this.subject = subject; // this.body = body; // } // // public String getToAddress() { // return toAddress; // } // // public String getSubject() { // return subject; // } // // public String getBody() { // return body; // } // } // // Path: components/email/src/main/java/com/example/email/SendEmail.java // public class SendEmail { // private final String queueName; // private final RabbitTemplate rabbitTemplate; // // public SendEmail(String queueName, RabbitTemplate rabbitTemplate) { // this.queueName = queueName; // this.rabbitTemplate = rabbitTemplate; // } // // public void run(EmailMessage message) { // rabbitTemplate.convertAndSend(queueName, message); // } // }
import com.example.billing.BillingRequest; import com.example.billing.Service; import com.example.email.EmailMessage; import com.example.email.SendEmail;
package com.example.subscriptions; public class CreateSubscription { private final Service billingService; private final SendEmail emailSender; private final SubscriptionRepository subscriptions; public CreateSubscription( Service billingService, SendEmail emailSender, SubscriptionRepository subscriptions) { this.billingService = billingService; this.emailSender = emailSender; this.subscriptions = subscriptions; } public void run(String userId, String packageId) { subscriptions.create(new Subscription(userId, packageId)); billingService.billUser(new BillingRequest(userId, 100));
// Path: components/billing/src/main/java/com/example/billing/BillingRequest.java // public class BillingRequest { // private final String userId; // private final int amount; // // public BillingRequest(String userId, int amount) { // this.userId = userId; // this.amount = amount; // } // // public String getUserId() { // return userId; // } // // public int getAmount() { // return amount; // } // } // // Path: components/email/src/main/java/com/example/email/EmailMessage.java // public class EmailMessage implements Serializable { // // private final String toAddress; // private final String subject; // private final String body; // // public EmailMessage(String toAddress, String subject, String body) { // // this.toAddress = toAddress; // this.subject = subject; // this.body = body; // } // // public String getToAddress() { // return toAddress; // } // // public String getSubject() { // return subject; // } // // public String getBody() { // return body; // } // } // // Path: components/email/src/main/java/com/example/email/SendEmail.java // public class SendEmail { // private final String queueName; // private final RabbitTemplate rabbitTemplate; // // public SendEmail(String queueName, RabbitTemplate rabbitTemplate) { // this.queueName = queueName; // this.rabbitTemplate = rabbitTemplate; // } // // public void run(EmailMessage message) { // rabbitTemplate.convertAndSend(queueName, message); // } // } // Path: components/subscriptions/src/main/java/com/example/subscriptions/CreateSubscription.java import com.example.billing.BillingRequest; import com.example.billing.Service; import com.example.email.EmailMessage; import com.example.email.SendEmail; package com.example.subscriptions; public class CreateSubscription { private final Service billingService; private final SendEmail emailSender; private final SubscriptionRepository subscriptions; public CreateSubscription( Service billingService, SendEmail emailSender, SubscriptionRepository subscriptions) { this.billingService = billingService; this.emailSender = emailSender; this.subscriptions = subscriptions; } public void run(String userId, String packageId) { subscriptions.create(new Subscription(userId, packageId)); billingService.billUser(new BillingRequest(userId, 100));
emailSender.run(new EmailMessage("me@example.com", "Subscription Created", "Some email body"));
mikegehard/userManagementEvolution
applications/ums/src/main/java/com/example/ums/sessions/SessionsController.java
// Path: components/users/src/main/java/com/example/users/LogIn.java // public class LogIn { // private final UaaClient uaaClient; // // public LogIn(UaaClient uaaClient) { // this.uaaClient = uaaClient; // } // // public Optional<Session> run(String name, String password) { // return uaaClient.logIn(name, password); // } // } // // Path: components/users/src/main/java/com/example/users/Session.java // public class Session { // private final String jwtToken; // // public Session(String jwtToken) { // this.jwtToken = jwtToken; // } // // public String getJwtToken() { // return jwtToken; // } // } // // Path: components/users/src/main/java/com/example/users/UaaClient.java // public class UaaClient { // private final String clientId; // private final String clientSecret; // private final String uaaUrl; // private final RestTemplate restTemplate; // // public UaaClient(String clientId, String clientSecret, String uaaUrl) { // this.clientId = clientId; // this.clientSecret = clientSecret; // this.uaaUrl = uaaUrl; // this.restTemplate = new RestTemplate(); // } // // public Optional<User> createUser(String name, String password) { // String clientToken = getClientToken(clientId, clientSecret); // // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", "Bearer " + clientToken); // // ParameterizedTypeReference<Map<String, ?>> userReturnValue = new ParameterizedTypeReference<Map<String, ?>>() { // }; // // Map<String, Object> userData = createUserData(name, password); // // HttpEntity<Map<String, ?>> request = new HttpEntity<>(userData, headers); // ResponseEntity<Map<String, ?>> response = restTemplate.exchange( // uaaUrl + "/uaa/Users", // HttpMethod.POST, // request, // userReturnValue // ); // // return Optional.of(new User(name, (String) response.getBody().get("id"))); // } // // public Optional<Session> logIn(String name, String password) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "password"); // form.add("username", name); // form.add("password", password); // // ParameterizedTypeReference<Map<String, String>> returnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // request, // returnValue // ); // // return Optional.of(new Session(clientTokenResponse.getBody().get("access_token"))); // } // // private String getAuthorizationHeader(String clientId, String clientSecret) { // return "Basic " + new String(Base64.encodeBase64((clientId + ":" + clientSecret).getBytes(Charset.forName("US-ASCII")))); // } // // private Map<String, Object> createUserData(String userName, String password) { // Map<String, Object> data = new HashMap<>(); // // /* // { // "userName":"username", // "password": "user password", // "emails": [{ // "value": "foo@example.com" // }] // } // */ // // data.put("userName", userName); // data.put("password", password); // List<Map<String, String>> emails = new ArrayList<>(); // Map<String, String> email = new HashMap<>(); // emails.add(email); // email.put("value", "user-" + userName + "@example.com"); // data.put("emails", emails); // // return data; // } // // private String getClientToken(String clientId, String clientSecret) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "client_credentials"); // // ParameterizedTypeReference<Map<String, String>> clientTokenReturnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> clientTokenRequest = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // clientTokenRequest, // clientTokenReturnValue // ); // // return clientTokenResponse.getBody().get("access_token"); // } // }
import com.example.users.LogIn; import com.example.users.Session; import com.example.users.UaaClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map; import java.util.Optional;
package com.example.ums.sessions; @RestController @RequestMapping("/sessions") public class SessionsController { @Autowired
// Path: components/users/src/main/java/com/example/users/LogIn.java // public class LogIn { // private final UaaClient uaaClient; // // public LogIn(UaaClient uaaClient) { // this.uaaClient = uaaClient; // } // // public Optional<Session> run(String name, String password) { // return uaaClient.logIn(name, password); // } // } // // Path: components/users/src/main/java/com/example/users/Session.java // public class Session { // private final String jwtToken; // // public Session(String jwtToken) { // this.jwtToken = jwtToken; // } // // public String getJwtToken() { // return jwtToken; // } // } // // Path: components/users/src/main/java/com/example/users/UaaClient.java // public class UaaClient { // private final String clientId; // private final String clientSecret; // private final String uaaUrl; // private final RestTemplate restTemplate; // // public UaaClient(String clientId, String clientSecret, String uaaUrl) { // this.clientId = clientId; // this.clientSecret = clientSecret; // this.uaaUrl = uaaUrl; // this.restTemplate = new RestTemplate(); // } // // public Optional<User> createUser(String name, String password) { // String clientToken = getClientToken(clientId, clientSecret); // // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", "Bearer " + clientToken); // // ParameterizedTypeReference<Map<String, ?>> userReturnValue = new ParameterizedTypeReference<Map<String, ?>>() { // }; // // Map<String, Object> userData = createUserData(name, password); // // HttpEntity<Map<String, ?>> request = new HttpEntity<>(userData, headers); // ResponseEntity<Map<String, ?>> response = restTemplate.exchange( // uaaUrl + "/uaa/Users", // HttpMethod.POST, // request, // userReturnValue // ); // // return Optional.of(new User(name, (String) response.getBody().get("id"))); // } // // public Optional<Session> logIn(String name, String password) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "password"); // form.add("username", name); // form.add("password", password); // // ParameterizedTypeReference<Map<String, String>> returnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // request, // returnValue // ); // // return Optional.of(new Session(clientTokenResponse.getBody().get("access_token"))); // } // // private String getAuthorizationHeader(String clientId, String clientSecret) { // return "Basic " + new String(Base64.encodeBase64((clientId + ":" + clientSecret).getBytes(Charset.forName("US-ASCII")))); // } // // private Map<String, Object> createUserData(String userName, String password) { // Map<String, Object> data = new HashMap<>(); // // /* // { // "userName":"username", // "password": "user password", // "emails": [{ // "value": "foo@example.com" // }] // } // */ // // data.put("userName", userName); // data.put("password", password); // List<Map<String, String>> emails = new ArrayList<>(); // Map<String, String> email = new HashMap<>(); // emails.add(email); // email.put("value", "user-" + userName + "@example.com"); // data.put("emails", emails); // // return data; // } // // private String getClientToken(String clientId, String clientSecret) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "client_credentials"); // // ParameterizedTypeReference<Map<String, String>> clientTokenReturnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> clientTokenRequest = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // clientTokenRequest, // clientTokenReturnValue // ); // // return clientTokenResponse.getBody().get("access_token"); // } // } // Path: applications/ums/src/main/java/com/example/ums/sessions/SessionsController.java import com.example.users.LogIn; import com.example.users.Session; import com.example.users.UaaClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map; import java.util.Optional; package com.example.ums.sessions; @RestController @RequestMapping("/sessions") public class SessionsController { @Autowired
private UaaClient loginUserUaaClient;
mikegehard/userManagementEvolution
applications/ums/src/main/java/com/example/ums/sessions/SessionsController.java
// Path: components/users/src/main/java/com/example/users/LogIn.java // public class LogIn { // private final UaaClient uaaClient; // // public LogIn(UaaClient uaaClient) { // this.uaaClient = uaaClient; // } // // public Optional<Session> run(String name, String password) { // return uaaClient.logIn(name, password); // } // } // // Path: components/users/src/main/java/com/example/users/Session.java // public class Session { // private final String jwtToken; // // public Session(String jwtToken) { // this.jwtToken = jwtToken; // } // // public String getJwtToken() { // return jwtToken; // } // } // // Path: components/users/src/main/java/com/example/users/UaaClient.java // public class UaaClient { // private final String clientId; // private final String clientSecret; // private final String uaaUrl; // private final RestTemplate restTemplate; // // public UaaClient(String clientId, String clientSecret, String uaaUrl) { // this.clientId = clientId; // this.clientSecret = clientSecret; // this.uaaUrl = uaaUrl; // this.restTemplate = new RestTemplate(); // } // // public Optional<User> createUser(String name, String password) { // String clientToken = getClientToken(clientId, clientSecret); // // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", "Bearer " + clientToken); // // ParameterizedTypeReference<Map<String, ?>> userReturnValue = new ParameterizedTypeReference<Map<String, ?>>() { // }; // // Map<String, Object> userData = createUserData(name, password); // // HttpEntity<Map<String, ?>> request = new HttpEntity<>(userData, headers); // ResponseEntity<Map<String, ?>> response = restTemplate.exchange( // uaaUrl + "/uaa/Users", // HttpMethod.POST, // request, // userReturnValue // ); // // return Optional.of(new User(name, (String) response.getBody().get("id"))); // } // // public Optional<Session> logIn(String name, String password) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "password"); // form.add("username", name); // form.add("password", password); // // ParameterizedTypeReference<Map<String, String>> returnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // request, // returnValue // ); // // return Optional.of(new Session(clientTokenResponse.getBody().get("access_token"))); // } // // private String getAuthorizationHeader(String clientId, String clientSecret) { // return "Basic " + new String(Base64.encodeBase64((clientId + ":" + clientSecret).getBytes(Charset.forName("US-ASCII")))); // } // // private Map<String, Object> createUserData(String userName, String password) { // Map<String, Object> data = new HashMap<>(); // // /* // { // "userName":"username", // "password": "user password", // "emails": [{ // "value": "foo@example.com" // }] // } // */ // // data.put("userName", userName); // data.put("password", password); // List<Map<String, String>> emails = new ArrayList<>(); // Map<String, String> email = new HashMap<>(); // emails.add(email); // email.put("value", "user-" + userName + "@example.com"); // data.put("emails", emails); // // return data; // } // // private String getClientToken(String clientId, String clientSecret) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "client_credentials"); // // ParameterizedTypeReference<Map<String, String>> clientTokenReturnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> clientTokenRequest = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // clientTokenRequest, // clientTokenReturnValue // ); // // return clientTokenResponse.getBody().get("access_token"); // } // }
import com.example.users.LogIn; import com.example.users.Session; import com.example.users.UaaClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map; import java.util.Optional;
package com.example.ums.sessions; @RestController @RequestMapping("/sessions") public class SessionsController { @Autowired private UaaClient loginUserUaaClient; @RequestMapping(method = RequestMethod.POST)
// Path: components/users/src/main/java/com/example/users/LogIn.java // public class LogIn { // private final UaaClient uaaClient; // // public LogIn(UaaClient uaaClient) { // this.uaaClient = uaaClient; // } // // public Optional<Session> run(String name, String password) { // return uaaClient.logIn(name, password); // } // } // // Path: components/users/src/main/java/com/example/users/Session.java // public class Session { // private final String jwtToken; // // public Session(String jwtToken) { // this.jwtToken = jwtToken; // } // // public String getJwtToken() { // return jwtToken; // } // } // // Path: components/users/src/main/java/com/example/users/UaaClient.java // public class UaaClient { // private final String clientId; // private final String clientSecret; // private final String uaaUrl; // private final RestTemplate restTemplate; // // public UaaClient(String clientId, String clientSecret, String uaaUrl) { // this.clientId = clientId; // this.clientSecret = clientSecret; // this.uaaUrl = uaaUrl; // this.restTemplate = new RestTemplate(); // } // // public Optional<User> createUser(String name, String password) { // String clientToken = getClientToken(clientId, clientSecret); // // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", "Bearer " + clientToken); // // ParameterizedTypeReference<Map<String, ?>> userReturnValue = new ParameterizedTypeReference<Map<String, ?>>() { // }; // // Map<String, Object> userData = createUserData(name, password); // // HttpEntity<Map<String, ?>> request = new HttpEntity<>(userData, headers); // ResponseEntity<Map<String, ?>> response = restTemplate.exchange( // uaaUrl + "/uaa/Users", // HttpMethod.POST, // request, // userReturnValue // ); // // return Optional.of(new User(name, (String) response.getBody().get("id"))); // } // // public Optional<Session> logIn(String name, String password) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "password"); // form.add("username", name); // form.add("password", password); // // ParameterizedTypeReference<Map<String, String>> returnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // request, // returnValue // ); // // return Optional.of(new Session(clientTokenResponse.getBody().get("access_token"))); // } // // private String getAuthorizationHeader(String clientId, String clientSecret) { // return "Basic " + new String(Base64.encodeBase64((clientId + ":" + clientSecret).getBytes(Charset.forName("US-ASCII")))); // } // // private Map<String, Object> createUserData(String userName, String password) { // Map<String, Object> data = new HashMap<>(); // // /* // { // "userName":"username", // "password": "user password", // "emails": [{ // "value": "foo@example.com" // }] // } // */ // // data.put("userName", userName); // data.put("password", password); // List<Map<String, String>> emails = new ArrayList<>(); // Map<String, String> email = new HashMap<>(); // emails.add(email); // email.put("value", "user-" + userName + "@example.com"); // data.put("emails", emails); // // return data; // } // // private String getClientToken(String clientId, String clientSecret) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "client_credentials"); // // ParameterizedTypeReference<Map<String, String>> clientTokenReturnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> clientTokenRequest = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // clientTokenRequest, // clientTokenReturnValue // ); // // return clientTokenResponse.getBody().get("access_token"); // } // } // Path: applications/ums/src/main/java/com/example/ums/sessions/SessionsController.java import com.example.users.LogIn; import com.example.users.Session; import com.example.users.UaaClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map; import java.util.Optional; package com.example.ums.sessions; @RestController @RequestMapping("/sessions") public class SessionsController { @Autowired private UaaClient loginUserUaaClient; @RequestMapping(method = RequestMethod.POST)
public ResponseEntity<Session> login(@RequestBody Map<String, String> params) {
mikegehard/userManagementEvolution
applications/ums/src/main/java/com/example/ums/sessions/SessionsController.java
// Path: components/users/src/main/java/com/example/users/LogIn.java // public class LogIn { // private final UaaClient uaaClient; // // public LogIn(UaaClient uaaClient) { // this.uaaClient = uaaClient; // } // // public Optional<Session> run(String name, String password) { // return uaaClient.logIn(name, password); // } // } // // Path: components/users/src/main/java/com/example/users/Session.java // public class Session { // private final String jwtToken; // // public Session(String jwtToken) { // this.jwtToken = jwtToken; // } // // public String getJwtToken() { // return jwtToken; // } // } // // Path: components/users/src/main/java/com/example/users/UaaClient.java // public class UaaClient { // private final String clientId; // private final String clientSecret; // private final String uaaUrl; // private final RestTemplate restTemplate; // // public UaaClient(String clientId, String clientSecret, String uaaUrl) { // this.clientId = clientId; // this.clientSecret = clientSecret; // this.uaaUrl = uaaUrl; // this.restTemplate = new RestTemplate(); // } // // public Optional<User> createUser(String name, String password) { // String clientToken = getClientToken(clientId, clientSecret); // // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", "Bearer " + clientToken); // // ParameterizedTypeReference<Map<String, ?>> userReturnValue = new ParameterizedTypeReference<Map<String, ?>>() { // }; // // Map<String, Object> userData = createUserData(name, password); // // HttpEntity<Map<String, ?>> request = new HttpEntity<>(userData, headers); // ResponseEntity<Map<String, ?>> response = restTemplate.exchange( // uaaUrl + "/uaa/Users", // HttpMethod.POST, // request, // userReturnValue // ); // // return Optional.of(new User(name, (String) response.getBody().get("id"))); // } // // public Optional<Session> logIn(String name, String password) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "password"); // form.add("username", name); // form.add("password", password); // // ParameterizedTypeReference<Map<String, String>> returnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // request, // returnValue // ); // // return Optional.of(new Session(clientTokenResponse.getBody().get("access_token"))); // } // // private String getAuthorizationHeader(String clientId, String clientSecret) { // return "Basic " + new String(Base64.encodeBase64((clientId + ":" + clientSecret).getBytes(Charset.forName("US-ASCII")))); // } // // private Map<String, Object> createUserData(String userName, String password) { // Map<String, Object> data = new HashMap<>(); // // /* // { // "userName":"username", // "password": "user password", // "emails": [{ // "value": "foo@example.com" // }] // } // */ // // data.put("userName", userName); // data.put("password", password); // List<Map<String, String>> emails = new ArrayList<>(); // Map<String, String> email = new HashMap<>(); // emails.add(email); // email.put("value", "user-" + userName + "@example.com"); // data.put("emails", emails); // // return data; // } // // private String getClientToken(String clientId, String clientSecret) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "client_credentials"); // // ParameterizedTypeReference<Map<String, String>> clientTokenReturnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> clientTokenRequest = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // clientTokenRequest, // clientTokenReturnValue // ); // // return clientTokenResponse.getBody().get("access_token"); // } // }
import com.example.users.LogIn; import com.example.users.Session; import com.example.users.UaaClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map; import java.util.Optional;
package com.example.ums.sessions; @RestController @RequestMapping("/sessions") public class SessionsController { @Autowired private UaaClient loginUserUaaClient; @RequestMapping(method = RequestMethod.POST) public ResponseEntity<Session> login(@RequestBody Map<String, String> params) {
// Path: components/users/src/main/java/com/example/users/LogIn.java // public class LogIn { // private final UaaClient uaaClient; // // public LogIn(UaaClient uaaClient) { // this.uaaClient = uaaClient; // } // // public Optional<Session> run(String name, String password) { // return uaaClient.logIn(name, password); // } // } // // Path: components/users/src/main/java/com/example/users/Session.java // public class Session { // private final String jwtToken; // // public Session(String jwtToken) { // this.jwtToken = jwtToken; // } // // public String getJwtToken() { // return jwtToken; // } // } // // Path: components/users/src/main/java/com/example/users/UaaClient.java // public class UaaClient { // private final String clientId; // private final String clientSecret; // private final String uaaUrl; // private final RestTemplate restTemplate; // // public UaaClient(String clientId, String clientSecret, String uaaUrl) { // this.clientId = clientId; // this.clientSecret = clientSecret; // this.uaaUrl = uaaUrl; // this.restTemplate = new RestTemplate(); // } // // public Optional<User> createUser(String name, String password) { // String clientToken = getClientToken(clientId, clientSecret); // // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", "Bearer " + clientToken); // // ParameterizedTypeReference<Map<String, ?>> userReturnValue = new ParameterizedTypeReference<Map<String, ?>>() { // }; // // Map<String, Object> userData = createUserData(name, password); // // HttpEntity<Map<String, ?>> request = new HttpEntity<>(userData, headers); // ResponseEntity<Map<String, ?>> response = restTemplate.exchange( // uaaUrl + "/uaa/Users", // HttpMethod.POST, // request, // userReturnValue // ); // // return Optional.of(new User(name, (String) response.getBody().get("id"))); // } // // public Optional<Session> logIn(String name, String password) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "password"); // form.add("username", name); // form.add("password", password); // // ParameterizedTypeReference<Map<String, String>> returnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // request, // returnValue // ); // // return Optional.of(new Session(clientTokenResponse.getBody().get("access_token"))); // } // // private String getAuthorizationHeader(String clientId, String clientSecret) { // return "Basic " + new String(Base64.encodeBase64((clientId + ":" + clientSecret).getBytes(Charset.forName("US-ASCII")))); // } // // private Map<String, Object> createUserData(String userName, String password) { // Map<String, Object> data = new HashMap<>(); // // /* // { // "userName":"username", // "password": "user password", // "emails": [{ // "value": "foo@example.com" // }] // } // */ // // data.put("userName", userName); // data.put("password", password); // List<Map<String, String>> emails = new ArrayList<>(); // Map<String, String> email = new HashMap<>(); // emails.add(email); // email.put("value", "user-" + userName + "@example.com"); // data.put("emails", emails); // // return data; // } // // private String getClientToken(String clientId, String clientSecret) { // HttpHeaders headers = new HttpHeaders(); // headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret)); // // MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); // form.add("client_id", clientId); // form.add("client_secret", clientSecret); // form.add("grant_type", "client_credentials"); // // ParameterizedTypeReference<Map<String, String>> clientTokenReturnValue = new ParameterizedTypeReference<Map<String, String>>() { // }; // // HttpEntity<MultiValueMap<String, String>> clientTokenRequest = new HttpEntity<>(form, headers); // ResponseEntity<Map<String, String>> clientTokenResponse = restTemplate.exchange( // uaaUrl + "/uaa/oauth/token", // HttpMethod.POST, // clientTokenRequest, // clientTokenReturnValue // ); // // return clientTokenResponse.getBody().get("access_token"); // } // } // Path: applications/ums/src/main/java/com/example/ums/sessions/SessionsController.java import com.example.users.LogIn; import com.example.users.Session; import com.example.users.UaaClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map; import java.util.Optional; package com.example.ums.sessions; @RestController @RequestMapping("/sessions") public class SessionsController { @Autowired private UaaClient loginUserUaaClient; @RequestMapping(method = RequestMethod.POST) public ResponseEntity<Session> login(@RequestBody Map<String, String> params) {
Optional<Session> session = new LogIn(loginUserUaaClient).run(params.get("name"), params.get("password"));
mikegehard/userManagementEvolution
applications/billing/src/main/java/com/example/billing/Application.java
// Path: applications/billing/src/main/java/com/example/billing/reocurringPayments/Service.java // public class Service { // private static final Logger logger = LoggerFactory.getLogger(Service.class); // // private static final Random rand = new Random(); // // @HystrixCommand(fallbackMethod = "thisMayFailFallback") // public String thisMayFail() { // if (rand.nextInt(100) % 10 == 0) // throw new RuntimeException("BOOM!"); // return "SUCCESS!"; // } // // public String thisMayFailFallback() { // logger.info("*********************** Calling Fallback... *************************"); // return "FALLBACK!"; // } // }
import com.example.billing.reocurringPayments.Service; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.context.annotation.Bean;
package com.example.billing; @SpringBootApplication @EnableDiscoveryClient @EnableCircuitBreaker public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } // Wire up the specific implementation of the payment gateway. Because this is an // interface, the rest of the code doesn't know anything about the concrete implementation. // This implementation can be switched out easily by the Spring IoC framework for testing so // that tests do not hit the actual gateway API. @Bean public com.example.payments.Gateway paymentGateway(){ return new com.example.payments.RecurlyGateway(); } // You need a bean for this service so that Spring Boot will automatically connect // the bean to Hystrix. // See http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html#_circuit_breaker_hystrix_clients. @Bean
// Path: applications/billing/src/main/java/com/example/billing/reocurringPayments/Service.java // public class Service { // private static final Logger logger = LoggerFactory.getLogger(Service.class); // // private static final Random rand = new Random(); // // @HystrixCommand(fallbackMethod = "thisMayFailFallback") // public String thisMayFail() { // if (rand.nextInt(100) % 10 == 0) // throw new RuntimeException("BOOM!"); // return "SUCCESS!"; // } // // public String thisMayFailFallback() { // logger.info("*********************** Calling Fallback... *************************"); // return "FALLBACK!"; // } // } // Path: applications/billing/src/main/java/com/example/billing/Application.java import com.example.billing.reocurringPayments.Service; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.context.annotation.Bean; package com.example.billing; @SpringBootApplication @EnableDiscoveryClient @EnableCircuitBreaker public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } // Wire up the specific implementation of the payment gateway. Because this is an // interface, the rest of the code doesn't know anything about the concrete implementation. // This implementation can be switched out easily by the Spring IoC framework for testing so // that tests do not hit the actual gateway API. @Bean public com.example.payments.Gateway paymentGateway(){ return new com.example.payments.RecurlyGateway(); } // You need a bean for this service so that Spring Boot will automatically connect // the bean to Hystrix. // See http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html#_circuit_breaker_hystrix_clients. @Bean
public Service serviceThatMayFail() {
mikegehard/userManagementEvolution
applications/ums/src/main/java/com/example/ums/subscriptions/SubscriptionsController.java
// Path: components/email/src/main/java/com/example/email/SendEmail.java // public class SendEmail { // private final String queueName; // private final RabbitTemplate rabbitTemplate; // // public SendEmail(String queueName, RabbitTemplate rabbitTemplate) { // this.queueName = queueName; // this.rabbitTemplate = rabbitTemplate; // } // // public void run(EmailMessage message) { // rabbitTemplate.convertAndSend(queueName, message); // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/CreateSubscription.java // public class CreateSubscription { // // private final Service billingService; // private final SendEmail emailSender; // private final SubscriptionRepository subscriptions; // // public CreateSubscription( // Service billingService, // SendEmail emailSender, SubscriptionRepository subscriptions) { // this.billingService = billingService; // this.emailSender = emailSender; // this.subscriptions = subscriptions; // } // // public void run(String userId, String packageId) { // subscriptions.create(new Subscription(userId, packageId)); // billingService.billUser(new BillingRequest(userId, 100)); // emailSender.run(new EmailMessage("me@example.com", "Subscription Created", "Some email body")); // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/Subscription.java // @Entity // public class Subscription { // // @Id // @GeneratedValue // private Long id; // // private String userId; // // private String packageId; // // protected Subscription() {} // // public Subscription(String userId, String packageId) { // this.userId = userId; // this.packageId = packageId; // } // // public String getUserId() { // return userId; // } // // public void setUserId(String userId) { // this.userId = userId; // } // // public String getPackageId() { // return packageId; // } // // public void setPackageId(String packageId) { // this.packageId = packageId; // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/SubscriptionRepository.java // public class SubscriptionRepository { // private NamedParameterJdbcTemplate datasource; // // public SubscriptionRepository(NamedParameterJdbcTemplate datasource){ // // this.datasource = datasource; // } // // public List<Subscription> all() { // return datasource.query("SELECT * FROM subscriptions;", (record, rowNumber) -> { // return new Subscription(record.getString("userId"), record.getString("packageId")); // }); // } // // public void create(Subscription subscription) { // HashMap<String, Object> values = new HashMap<>(); // values.put("userId", subscription.getUserId()); // values.put("packageId", subscription.getPackageId()); // // datasource.update("INSERT INTO subscriptions (userId, packageId) VALUES (:userId, :packageId);", values); // } // }
import com.example.billing.Service; import com.example.email.SendEmail; import com.example.subscriptions.CreateSubscription; import com.example.subscriptions.Subscription; import com.example.subscriptions.SubscriptionRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.metrics.CounterService; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map;
package com.example.ums.subscriptions; @RestController @RequestMapping("/subscriptions") public class SubscriptionsController { @Autowired
// Path: components/email/src/main/java/com/example/email/SendEmail.java // public class SendEmail { // private final String queueName; // private final RabbitTemplate rabbitTemplate; // // public SendEmail(String queueName, RabbitTemplate rabbitTemplate) { // this.queueName = queueName; // this.rabbitTemplate = rabbitTemplate; // } // // public void run(EmailMessage message) { // rabbitTemplate.convertAndSend(queueName, message); // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/CreateSubscription.java // public class CreateSubscription { // // private final Service billingService; // private final SendEmail emailSender; // private final SubscriptionRepository subscriptions; // // public CreateSubscription( // Service billingService, // SendEmail emailSender, SubscriptionRepository subscriptions) { // this.billingService = billingService; // this.emailSender = emailSender; // this.subscriptions = subscriptions; // } // // public void run(String userId, String packageId) { // subscriptions.create(new Subscription(userId, packageId)); // billingService.billUser(new BillingRequest(userId, 100)); // emailSender.run(new EmailMessage("me@example.com", "Subscription Created", "Some email body")); // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/Subscription.java // @Entity // public class Subscription { // // @Id // @GeneratedValue // private Long id; // // private String userId; // // private String packageId; // // protected Subscription() {} // // public Subscription(String userId, String packageId) { // this.userId = userId; // this.packageId = packageId; // } // // public String getUserId() { // return userId; // } // // public void setUserId(String userId) { // this.userId = userId; // } // // public String getPackageId() { // return packageId; // } // // public void setPackageId(String packageId) { // this.packageId = packageId; // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/SubscriptionRepository.java // public class SubscriptionRepository { // private NamedParameterJdbcTemplate datasource; // // public SubscriptionRepository(NamedParameterJdbcTemplate datasource){ // // this.datasource = datasource; // } // // public List<Subscription> all() { // return datasource.query("SELECT * FROM subscriptions;", (record, rowNumber) -> { // return new Subscription(record.getString("userId"), record.getString("packageId")); // }); // } // // public void create(Subscription subscription) { // HashMap<String, Object> values = new HashMap<>(); // values.put("userId", subscription.getUserId()); // values.put("packageId", subscription.getPackageId()); // // datasource.update("INSERT INTO subscriptions (userId, packageId) VALUES (:userId, :packageId);", values); // } // } // Path: applications/ums/src/main/java/com/example/ums/subscriptions/SubscriptionsController.java import com.example.billing.Service; import com.example.email.SendEmail; import com.example.subscriptions.CreateSubscription; import com.example.subscriptions.Subscription; import com.example.subscriptions.SubscriptionRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.metrics.CounterService; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map; package com.example.ums.subscriptions; @RestController @RequestMapping("/subscriptions") public class SubscriptionsController { @Autowired
SubscriptionRepository subscriptions;
mikegehard/userManagementEvolution
applications/ums/src/main/java/com/example/ums/subscriptions/SubscriptionsController.java
// Path: components/email/src/main/java/com/example/email/SendEmail.java // public class SendEmail { // private final String queueName; // private final RabbitTemplate rabbitTemplate; // // public SendEmail(String queueName, RabbitTemplate rabbitTemplate) { // this.queueName = queueName; // this.rabbitTemplate = rabbitTemplate; // } // // public void run(EmailMessage message) { // rabbitTemplate.convertAndSend(queueName, message); // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/CreateSubscription.java // public class CreateSubscription { // // private final Service billingService; // private final SendEmail emailSender; // private final SubscriptionRepository subscriptions; // // public CreateSubscription( // Service billingService, // SendEmail emailSender, SubscriptionRepository subscriptions) { // this.billingService = billingService; // this.emailSender = emailSender; // this.subscriptions = subscriptions; // } // // public void run(String userId, String packageId) { // subscriptions.create(new Subscription(userId, packageId)); // billingService.billUser(new BillingRequest(userId, 100)); // emailSender.run(new EmailMessage("me@example.com", "Subscription Created", "Some email body")); // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/Subscription.java // @Entity // public class Subscription { // // @Id // @GeneratedValue // private Long id; // // private String userId; // // private String packageId; // // protected Subscription() {} // // public Subscription(String userId, String packageId) { // this.userId = userId; // this.packageId = packageId; // } // // public String getUserId() { // return userId; // } // // public void setUserId(String userId) { // this.userId = userId; // } // // public String getPackageId() { // return packageId; // } // // public void setPackageId(String packageId) { // this.packageId = packageId; // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/SubscriptionRepository.java // public class SubscriptionRepository { // private NamedParameterJdbcTemplate datasource; // // public SubscriptionRepository(NamedParameterJdbcTemplate datasource){ // // this.datasource = datasource; // } // // public List<Subscription> all() { // return datasource.query("SELECT * FROM subscriptions;", (record, rowNumber) -> { // return new Subscription(record.getString("userId"), record.getString("packageId")); // }); // } // // public void create(Subscription subscription) { // HashMap<String, Object> values = new HashMap<>(); // values.put("userId", subscription.getUserId()); // values.put("packageId", subscription.getPackageId()); // // datasource.update("INSERT INTO subscriptions (userId, packageId) VALUES (:userId, :packageId);", values); // } // }
import com.example.billing.Service; import com.example.email.SendEmail; import com.example.subscriptions.CreateSubscription; import com.example.subscriptions.Subscription; import com.example.subscriptions.SubscriptionRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.metrics.CounterService; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map;
package com.example.ums.subscriptions; @RestController @RequestMapping("/subscriptions") public class SubscriptionsController { @Autowired SubscriptionRepository subscriptions; @Autowired Service billingService; @Autowired
// Path: components/email/src/main/java/com/example/email/SendEmail.java // public class SendEmail { // private final String queueName; // private final RabbitTemplate rabbitTemplate; // // public SendEmail(String queueName, RabbitTemplate rabbitTemplate) { // this.queueName = queueName; // this.rabbitTemplate = rabbitTemplate; // } // // public void run(EmailMessage message) { // rabbitTemplate.convertAndSend(queueName, message); // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/CreateSubscription.java // public class CreateSubscription { // // private final Service billingService; // private final SendEmail emailSender; // private final SubscriptionRepository subscriptions; // // public CreateSubscription( // Service billingService, // SendEmail emailSender, SubscriptionRepository subscriptions) { // this.billingService = billingService; // this.emailSender = emailSender; // this.subscriptions = subscriptions; // } // // public void run(String userId, String packageId) { // subscriptions.create(new Subscription(userId, packageId)); // billingService.billUser(new BillingRequest(userId, 100)); // emailSender.run(new EmailMessage("me@example.com", "Subscription Created", "Some email body")); // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/Subscription.java // @Entity // public class Subscription { // // @Id // @GeneratedValue // private Long id; // // private String userId; // // private String packageId; // // protected Subscription() {} // // public Subscription(String userId, String packageId) { // this.userId = userId; // this.packageId = packageId; // } // // public String getUserId() { // return userId; // } // // public void setUserId(String userId) { // this.userId = userId; // } // // public String getPackageId() { // return packageId; // } // // public void setPackageId(String packageId) { // this.packageId = packageId; // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/SubscriptionRepository.java // public class SubscriptionRepository { // private NamedParameterJdbcTemplate datasource; // // public SubscriptionRepository(NamedParameterJdbcTemplate datasource){ // // this.datasource = datasource; // } // // public List<Subscription> all() { // return datasource.query("SELECT * FROM subscriptions;", (record, rowNumber) -> { // return new Subscription(record.getString("userId"), record.getString("packageId")); // }); // } // // public void create(Subscription subscription) { // HashMap<String, Object> values = new HashMap<>(); // values.put("userId", subscription.getUserId()); // values.put("packageId", subscription.getPackageId()); // // datasource.update("INSERT INTO subscriptions (userId, packageId) VALUES (:userId, :packageId);", values); // } // } // Path: applications/ums/src/main/java/com/example/ums/subscriptions/SubscriptionsController.java import com.example.billing.Service; import com.example.email.SendEmail; import com.example.subscriptions.CreateSubscription; import com.example.subscriptions.Subscription; import com.example.subscriptions.SubscriptionRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.metrics.CounterService; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map; package com.example.ums.subscriptions; @RestController @RequestMapping("/subscriptions") public class SubscriptionsController { @Autowired SubscriptionRepository subscriptions; @Autowired Service billingService; @Autowired
SendEmail emailSender;
mikegehard/userManagementEvolution
applications/ums/src/main/java/com/example/ums/subscriptions/SubscriptionsController.java
// Path: components/email/src/main/java/com/example/email/SendEmail.java // public class SendEmail { // private final String queueName; // private final RabbitTemplate rabbitTemplate; // // public SendEmail(String queueName, RabbitTemplate rabbitTemplate) { // this.queueName = queueName; // this.rabbitTemplate = rabbitTemplate; // } // // public void run(EmailMessage message) { // rabbitTemplate.convertAndSend(queueName, message); // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/CreateSubscription.java // public class CreateSubscription { // // private final Service billingService; // private final SendEmail emailSender; // private final SubscriptionRepository subscriptions; // // public CreateSubscription( // Service billingService, // SendEmail emailSender, SubscriptionRepository subscriptions) { // this.billingService = billingService; // this.emailSender = emailSender; // this.subscriptions = subscriptions; // } // // public void run(String userId, String packageId) { // subscriptions.create(new Subscription(userId, packageId)); // billingService.billUser(new BillingRequest(userId, 100)); // emailSender.run(new EmailMessage("me@example.com", "Subscription Created", "Some email body")); // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/Subscription.java // @Entity // public class Subscription { // // @Id // @GeneratedValue // private Long id; // // private String userId; // // private String packageId; // // protected Subscription() {} // // public Subscription(String userId, String packageId) { // this.userId = userId; // this.packageId = packageId; // } // // public String getUserId() { // return userId; // } // // public void setUserId(String userId) { // this.userId = userId; // } // // public String getPackageId() { // return packageId; // } // // public void setPackageId(String packageId) { // this.packageId = packageId; // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/SubscriptionRepository.java // public class SubscriptionRepository { // private NamedParameterJdbcTemplate datasource; // // public SubscriptionRepository(NamedParameterJdbcTemplate datasource){ // // this.datasource = datasource; // } // // public List<Subscription> all() { // return datasource.query("SELECT * FROM subscriptions;", (record, rowNumber) -> { // return new Subscription(record.getString("userId"), record.getString("packageId")); // }); // } // // public void create(Subscription subscription) { // HashMap<String, Object> values = new HashMap<>(); // values.put("userId", subscription.getUserId()); // values.put("packageId", subscription.getPackageId()); // // datasource.update("INSERT INTO subscriptions (userId, packageId) VALUES (:userId, :packageId);", values); // } // }
import com.example.billing.Service; import com.example.email.SendEmail; import com.example.subscriptions.CreateSubscription; import com.example.subscriptions.Subscription; import com.example.subscriptions.SubscriptionRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.metrics.CounterService; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map;
package com.example.ums.subscriptions; @RestController @RequestMapping("/subscriptions") public class SubscriptionsController { @Autowired SubscriptionRepository subscriptions; @Autowired Service billingService; @Autowired SendEmail emailSender; @Autowired private CounterService counter; @RequestMapping(method = RequestMethod.GET)
// Path: components/email/src/main/java/com/example/email/SendEmail.java // public class SendEmail { // private final String queueName; // private final RabbitTemplate rabbitTemplate; // // public SendEmail(String queueName, RabbitTemplate rabbitTemplate) { // this.queueName = queueName; // this.rabbitTemplate = rabbitTemplate; // } // // public void run(EmailMessage message) { // rabbitTemplate.convertAndSend(queueName, message); // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/CreateSubscription.java // public class CreateSubscription { // // private final Service billingService; // private final SendEmail emailSender; // private final SubscriptionRepository subscriptions; // // public CreateSubscription( // Service billingService, // SendEmail emailSender, SubscriptionRepository subscriptions) { // this.billingService = billingService; // this.emailSender = emailSender; // this.subscriptions = subscriptions; // } // // public void run(String userId, String packageId) { // subscriptions.create(new Subscription(userId, packageId)); // billingService.billUser(new BillingRequest(userId, 100)); // emailSender.run(new EmailMessage("me@example.com", "Subscription Created", "Some email body")); // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/Subscription.java // @Entity // public class Subscription { // // @Id // @GeneratedValue // private Long id; // // private String userId; // // private String packageId; // // protected Subscription() {} // // public Subscription(String userId, String packageId) { // this.userId = userId; // this.packageId = packageId; // } // // public String getUserId() { // return userId; // } // // public void setUserId(String userId) { // this.userId = userId; // } // // public String getPackageId() { // return packageId; // } // // public void setPackageId(String packageId) { // this.packageId = packageId; // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/SubscriptionRepository.java // public class SubscriptionRepository { // private NamedParameterJdbcTemplate datasource; // // public SubscriptionRepository(NamedParameterJdbcTemplate datasource){ // // this.datasource = datasource; // } // // public List<Subscription> all() { // return datasource.query("SELECT * FROM subscriptions;", (record, rowNumber) -> { // return new Subscription(record.getString("userId"), record.getString("packageId")); // }); // } // // public void create(Subscription subscription) { // HashMap<String, Object> values = new HashMap<>(); // values.put("userId", subscription.getUserId()); // values.put("packageId", subscription.getPackageId()); // // datasource.update("INSERT INTO subscriptions (userId, packageId) VALUES (:userId, :packageId);", values); // } // } // Path: applications/ums/src/main/java/com/example/ums/subscriptions/SubscriptionsController.java import com.example.billing.Service; import com.example.email.SendEmail; import com.example.subscriptions.CreateSubscription; import com.example.subscriptions.Subscription; import com.example.subscriptions.SubscriptionRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.metrics.CounterService; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map; package com.example.ums.subscriptions; @RestController @RequestMapping("/subscriptions") public class SubscriptionsController { @Autowired SubscriptionRepository subscriptions; @Autowired Service billingService; @Autowired SendEmail emailSender; @Autowired private CounterService counter; @RequestMapping(method = RequestMethod.GET)
public Iterable<Subscription> index() {
mikegehard/userManagementEvolution
applications/ums/src/main/java/com/example/ums/subscriptions/SubscriptionsController.java
// Path: components/email/src/main/java/com/example/email/SendEmail.java // public class SendEmail { // private final String queueName; // private final RabbitTemplate rabbitTemplate; // // public SendEmail(String queueName, RabbitTemplate rabbitTemplate) { // this.queueName = queueName; // this.rabbitTemplate = rabbitTemplate; // } // // public void run(EmailMessage message) { // rabbitTemplate.convertAndSend(queueName, message); // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/CreateSubscription.java // public class CreateSubscription { // // private final Service billingService; // private final SendEmail emailSender; // private final SubscriptionRepository subscriptions; // // public CreateSubscription( // Service billingService, // SendEmail emailSender, SubscriptionRepository subscriptions) { // this.billingService = billingService; // this.emailSender = emailSender; // this.subscriptions = subscriptions; // } // // public void run(String userId, String packageId) { // subscriptions.create(new Subscription(userId, packageId)); // billingService.billUser(new BillingRequest(userId, 100)); // emailSender.run(new EmailMessage("me@example.com", "Subscription Created", "Some email body")); // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/Subscription.java // @Entity // public class Subscription { // // @Id // @GeneratedValue // private Long id; // // private String userId; // // private String packageId; // // protected Subscription() {} // // public Subscription(String userId, String packageId) { // this.userId = userId; // this.packageId = packageId; // } // // public String getUserId() { // return userId; // } // // public void setUserId(String userId) { // this.userId = userId; // } // // public String getPackageId() { // return packageId; // } // // public void setPackageId(String packageId) { // this.packageId = packageId; // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/SubscriptionRepository.java // public class SubscriptionRepository { // private NamedParameterJdbcTemplate datasource; // // public SubscriptionRepository(NamedParameterJdbcTemplate datasource){ // // this.datasource = datasource; // } // // public List<Subscription> all() { // return datasource.query("SELECT * FROM subscriptions;", (record, rowNumber) -> { // return new Subscription(record.getString("userId"), record.getString("packageId")); // }); // } // // public void create(Subscription subscription) { // HashMap<String, Object> values = new HashMap<>(); // values.put("userId", subscription.getUserId()); // values.put("packageId", subscription.getPackageId()); // // datasource.update("INSERT INTO subscriptions (userId, packageId) VALUES (:userId, :packageId);", values); // } // }
import com.example.billing.Service; import com.example.email.SendEmail; import com.example.subscriptions.CreateSubscription; import com.example.subscriptions.Subscription; import com.example.subscriptions.SubscriptionRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.metrics.CounterService; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map;
package com.example.ums.subscriptions; @RestController @RequestMapping("/subscriptions") public class SubscriptionsController { @Autowired SubscriptionRepository subscriptions; @Autowired Service billingService; @Autowired SendEmail emailSender; @Autowired private CounterService counter; @RequestMapping(method = RequestMethod.GET) public Iterable<Subscription> index() { return subscriptions.all(); } @RequestMapping(method = RequestMethod.POST) public ResponseEntity<String> create(@RequestBody Map<String, String> params) { HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.add("content-type", MediaType.APPLICATION_JSON.toString());
// Path: components/email/src/main/java/com/example/email/SendEmail.java // public class SendEmail { // private final String queueName; // private final RabbitTemplate rabbitTemplate; // // public SendEmail(String queueName, RabbitTemplate rabbitTemplate) { // this.queueName = queueName; // this.rabbitTemplate = rabbitTemplate; // } // // public void run(EmailMessage message) { // rabbitTemplate.convertAndSend(queueName, message); // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/CreateSubscription.java // public class CreateSubscription { // // private final Service billingService; // private final SendEmail emailSender; // private final SubscriptionRepository subscriptions; // // public CreateSubscription( // Service billingService, // SendEmail emailSender, SubscriptionRepository subscriptions) { // this.billingService = billingService; // this.emailSender = emailSender; // this.subscriptions = subscriptions; // } // // public void run(String userId, String packageId) { // subscriptions.create(new Subscription(userId, packageId)); // billingService.billUser(new BillingRequest(userId, 100)); // emailSender.run(new EmailMessage("me@example.com", "Subscription Created", "Some email body")); // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/Subscription.java // @Entity // public class Subscription { // // @Id // @GeneratedValue // private Long id; // // private String userId; // // private String packageId; // // protected Subscription() {} // // public Subscription(String userId, String packageId) { // this.userId = userId; // this.packageId = packageId; // } // // public String getUserId() { // return userId; // } // // public void setUserId(String userId) { // this.userId = userId; // } // // public String getPackageId() { // return packageId; // } // // public void setPackageId(String packageId) { // this.packageId = packageId; // } // } // // Path: components/subscriptions/src/main/java/com/example/subscriptions/SubscriptionRepository.java // public class SubscriptionRepository { // private NamedParameterJdbcTemplate datasource; // // public SubscriptionRepository(NamedParameterJdbcTemplate datasource){ // // this.datasource = datasource; // } // // public List<Subscription> all() { // return datasource.query("SELECT * FROM subscriptions;", (record, rowNumber) -> { // return new Subscription(record.getString("userId"), record.getString("packageId")); // }); // } // // public void create(Subscription subscription) { // HashMap<String, Object> values = new HashMap<>(); // values.put("userId", subscription.getUserId()); // values.put("packageId", subscription.getPackageId()); // // datasource.update("INSERT INTO subscriptions (userId, packageId) VALUES (:userId, :packageId);", values); // } // } // Path: applications/ums/src/main/java/com/example/ums/subscriptions/SubscriptionsController.java import com.example.billing.Service; import com.example.email.SendEmail; import com.example.subscriptions.CreateSubscription; import com.example.subscriptions.Subscription; import com.example.subscriptions.SubscriptionRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.metrics.CounterService; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Map; package com.example.ums.subscriptions; @RestController @RequestMapping("/subscriptions") public class SubscriptionsController { @Autowired SubscriptionRepository subscriptions; @Autowired Service billingService; @Autowired SendEmail emailSender; @Autowired private CounterService counter; @RequestMapping(method = RequestMethod.GET) public Iterable<Subscription> index() { return subscriptions.all(); } @RequestMapping(method = RequestMethod.POST) public ResponseEntity<String> create(@RequestBody Map<String, String> params) { HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.add("content-type", MediaType.APPLICATION_JSON.toString());
new CreateSubscription(billingService, emailSender, subscriptions)
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/ExprFunction.java
// Path: src/main/java/com/btk5h/skriptmirror/FunctionWrapper.java // public class FunctionWrapper { // private final String name; // private final Object[] arguments; // // public FunctionWrapper(String name, Object[] arguments) { // this.name = name; // this.arguments = arguments; // } // // public String getName() { // return name; // } // // public Object[] getArguments() { // return arguments; // } // // public Function getFunction() { // Function<?> function = Functions.getFunction(name); // if (function == null) { // Skript.warning(String.format("The function '%s' could not be resolved.", name)); // return NoOpFunction.INSTANCE; // } // return function; // } // // private static class NoOpFunction extends Function<Object> { // private static NoOpFunction INSTANCE = new NoOpFunction(); // // private NoOpFunction() { // super("$noop", new Parameter[0], Classes.getExactClassInfo(Object.class), true); // } // // @Override // public Object[] execute(FunctionEvent e, Object[][] params) { // return null; // } // // @Override // public boolean resetReturnValue() { // return false; // } // } // } // // Path: src/main/java/com/btk5h/skriptmirror/util/SkriptUtil.java // public class SkriptUtil { // @SuppressWarnings("unchecked") // public static <T> Expression<T> defendExpression(Expression<?> expr) { // if (expr instanceof UnparsedLiteral) { // Literal<?> parsed = ((UnparsedLiteral) expr).getConvertedExpression(Object.class); // return (Expression<T>) (parsed == null ? expr : parsed); // } else if (expr instanceof ExpressionList) { // Expression[] exprs = ((ExpressionList) expr).getExpressions(); // for (int i = 0; i < exprs.length; i++) { // exprs[i] = defendExpression(exprs[i]); // } // } // return (Expression<T>) expr; // } // // public static boolean hasUnparsedLiteral(Expression<?> expr) { // return expr instanceof UnparsedLiteral || // (expr instanceof ExpressionList && // Arrays.stream(((ExpressionList) expr).getExpressions()) // .anyMatch(UnparsedLiteral.class::isInstance)); // } // // public static boolean canInitSafely(Expression<?>... expressions) { // return Arrays.stream(expressions) // .filter(Objects::nonNull) // .noneMatch(SkriptUtil::hasUnparsedLiteral); // } // // public static List<TriggerItem> getItemsFromNode(SectionNode node) { // RetainingLogHandler log = SkriptLogger.startRetainingLog(); // try { // return ScriptLoader.loadItems(node); // } finally { // SkriptReflection.printLog(log); // ScriptLoader.deleteCurrentEvent(); // } // } // // public static void clearSectionNode(SectionNode node) { // List<Node> subNodes = new ArrayList<>(); // node.forEach(subNodes::add); // subNodes.forEach(Node::remove); // } // // public static File getCurrentScript() { // Config currentScript = ScriptLoader.currentScript; // return currentScript == null ? null : currentScript.getFile(); // } // // public static ClassInfo<?> getUserClassInfo(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // // ClassInfo<?> ci = Classes.getClassInfoNoError(wordData.getFirst()); // // if (ci == null) { // ci = Classes.getClassInfoFromUserInput(wordData.getFirst()); // } // // if (ci == null) { // Skript.warning(String.format("'%s' is not a valid Skript type. Using 'object' instead.", name)); // return Classes.getExactClassInfo(Object.class); // } // // return ci; // } // // public static NonNullPair<ClassInfo<?>, Boolean> getUserClassInfoAndPlural(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return new NonNullPair<>(ci, wordData.getSecond()); // } // // public static String replaceUserInputPatterns(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return Utils.toEnglishPlural(ci.getCodeName(), wordData.getSecond()); // } // // public static Function<Expression, Object> unwrapWithEvent(Event e) { // return expr -> expr.isSingle() ? expr.getSingle(e) : expr.getArray(e); // } // }
import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.FunctionWrapper; import com.btk5h.skriptmirror.util.SkriptUtil; import org.bukkit.event.Event; import java.util.Arrays;
private Expression<Object> args; @Override protected FunctionWrapper[] get(Event e) { Object[] functionArgs = args == null ? new Object[0] : args.getArray(e); return Arrays.stream(refs.getArray(e)) .map(ref -> new FunctionWrapper(ref, functionArgs)) .toArray(FunctionWrapper[]::new); } @Override public boolean isSingle() { return refs.isSingle(); } @Override public Class<? extends FunctionWrapper> getReturnType() { return FunctionWrapper.class; } @Override public String toString(Event e, boolean debug) { return "function reference of " + refs.toString(e, debug); } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
// Path: src/main/java/com/btk5h/skriptmirror/FunctionWrapper.java // public class FunctionWrapper { // private final String name; // private final Object[] arguments; // // public FunctionWrapper(String name, Object[] arguments) { // this.name = name; // this.arguments = arguments; // } // // public String getName() { // return name; // } // // public Object[] getArguments() { // return arguments; // } // // public Function getFunction() { // Function<?> function = Functions.getFunction(name); // if (function == null) { // Skript.warning(String.format("The function '%s' could not be resolved.", name)); // return NoOpFunction.INSTANCE; // } // return function; // } // // private static class NoOpFunction extends Function<Object> { // private static NoOpFunction INSTANCE = new NoOpFunction(); // // private NoOpFunction() { // super("$noop", new Parameter[0], Classes.getExactClassInfo(Object.class), true); // } // // @Override // public Object[] execute(FunctionEvent e, Object[][] params) { // return null; // } // // @Override // public boolean resetReturnValue() { // return false; // } // } // } // // Path: src/main/java/com/btk5h/skriptmirror/util/SkriptUtil.java // public class SkriptUtil { // @SuppressWarnings("unchecked") // public static <T> Expression<T> defendExpression(Expression<?> expr) { // if (expr instanceof UnparsedLiteral) { // Literal<?> parsed = ((UnparsedLiteral) expr).getConvertedExpression(Object.class); // return (Expression<T>) (parsed == null ? expr : parsed); // } else if (expr instanceof ExpressionList) { // Expression[] exprs = ((ExpressionList) expr).getExpressions(); // for (int i = 0; i < exprs.length; i++) { // exprs[i] = defendExpression(exprs[i]); // } // } // return (Expression<T>) expr; // } // // public static boolean hasUnparsedLiteral(Expression<?> expr) { // return expr instanceof UnparsedLiteral || // (expr instanceof ExpressionList && // Arrays.stream(((ExpressionList) expr).getExpressions()) // .anyMatch(UnparsedLiteral.class::isInstance)); // } // // public static boolean canInitSafely(Expression<?>... expressions) { // return Arrays.stream(expressions) // .filter(Objects::nonNull) // .noneMatch(SkriptUtil::hasUnparsedLiteral); // } // // public static List<TriggerItem> getItemsFromNode(SectionNode node) { // RetainingLogHandler log = SkriptLogger.startRetainingLog(); // try { // return ScriptLoader.loadItems(node); // } finally { // SkriptReflection.printLog(log); // ScriptLoader.deleteCurrentEvent(); // } // } // // public static void clearSectionNode(SectionNode node) { // List<Node> subNodes = new ArrayList<>(); // node.forEach(subNodes::add); // subNodes.forEach(Node::remove); // } // // public static File getCurrentScript() { // Config currentScript = ScriptLoader.currentScript; // return currentScript == null ? null : currentScript.getFile(); // } // // public static ClassInfo<?> getUserClassInfo(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // // ClassInfo<?> ci = Classes.getClassInfoNoError(wordData.getFirst()); // // if (ci == null) { // ci = Classes.getClassInfoFromUserInput(wordData.getFirst()); // } // // if (ci == null) { // Skript.warning(String.format("'%s' is not a valid Skript type. Using 'object' instead.", name)); // return Classes.getExactClassInfo(Object.class); // } // // return ci; // } // // public static NonNullPair<ClassInfo<?>, Boolean> getUserClassInfoAndPlural(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return new NonNullPair<>(ci, wordData.getSecond()); // } // // public static String replaceUserInputPatterns(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return Utils.toEnglishPlural(ci.getCodeName(), wordData.getSecond()); // } // // public static Function<Expression, Object> unwrapWithEvent(Event e) { // return expr -> expr.isSingle() ? expr.getSingle(e) : expr.getArray(e); // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/ExprFunction.java import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.FunctionWrapper; import com.btk5h.skriptmirror.util.SkriptUtil; import org.bukkit.event.Event; import java.util.Arrays; private Expression<Object> args; @Override protected FunctionWrapper[] get(Event e) { Object[] functionArgs = args == null ? new Object[0] : args.getArray(e); return Arrays.stream(refs.getArray(e)) .map(ref -> new FunctionWrapper(ref, functionArgs)) .toArray(FunctionWrapper[]::new); } @Override public boolean isSingle() { return refs.isSingle(); } @Override public Class<? extends FunctionWrapper> getReturnType() { return FunctionWrapper.class; } @Override public String toString(Event e, boolean debug) { return "function reference of " + refs.toString(e, debug); } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
refs = SkriptUtil.defendExpression(exprs[0]);
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/custom/expression/EffReturn.java
// Path: src/main/java/com/btk5h/skriptmirror/util/SkriptUtil.java // public class SkriptUtil { // @SuppressWarnings("unchecked") // public static <T> Expression<T> defendExpression(Expression<?> expr) { // if (expr instanceof UnparsedLiteral) { // Literal<?> parsed = ((UnparsedLiteral) expr).getConvertedExpression(Object.class); // return (Expression<T>) (parsed == null ? expr : parsed); // } else if (expr instanceof ExpressionList) { // Expression[] exprs = ((ExpressionList) expr).getExpressions(); // for (int i = 0; i < exprs.length; i++) { // exprs[i] = defendExpression(exprs[i]); // } // } // return (Expression<T>) expr; // } // // public static boolean hasUnparsedLiteral(Expression<?> expr) { // return expr instanceof UnparsedLiteral || // (expr instanceof ExpressionList && // Arrays.stream(((ExpressionList) expr).getExpressions()) // .anyMatch(UnparsedLiteral.class::isInstance)); // } // // public static boolean canInitSafely(Expression<?>... expressions) { // return Arrays.stream(expressions) // .filter(Objects::nonNull) // .noneMatch(SkriptUtil::hasUnparsedLiteral); // } // // public static List<TriggerItem> getItemsFromNode(SectionNode node) { // RetainingLogHandler log = SkriptLogger.startRetainingLog(); // try { // return ScriptLoader.loadItems(node); // } finally { // SkriptReflection.printLog(log); // ScriptLoader.deleteCurrentEvent(); // } // } // // public static void clearSectionNode(SectionNode node) { // List<Node> subNodes = new ArrayList<>(); // node.forEach(subNodes::add); // subNodes.forEach(Node::remove); // } // // public static File getCurrentScript() { // Config currentScript = ScriptLoader.currentScript; // return currentScript == null ? null : currentScript.getFile(); // } // // public static ClassInfo<?> getUserClassInfo(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // // ClassInfo<?> ci = Classes.getClassInfoNoError(wordData.getFirst()); // // if (ci == null) { // ci = Classes.getClassInfoFromUserInput(wordData.getFirst()); // } // // if (ci == null) { // Skript.warning(String.format("'%s' is not a valid Skript type. Using 'object' instead.", name)); // return Classes.getExactClassInfo(Object.class); // } // // return ci; // } // // public static NonNullPair<ClassInfo<?>, Boolean> getUserClassInfoAndPlural(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return new NonNullPair<>(ci, wordData.getSecond()); // } // // public static String replaceUserInputPatterns(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return Utils.toEnglishPlural(ci.getCodeName(), wordData.getSecond()); // } // // public static Function<Expression, Object> unwrapWithEvent(Event e) { // return expr -> expr.isSingle() ? expr.getSingle(e) : expr.getArray(e); // } // }
import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Effect; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.TriggerItem; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.util.SkriptUtil; import org.bukkit.event.Event;
@Override protected TriggerItem walk(Event e) { if (objects != null) { ((ExpressionGetEvent) e).setOutput(objects.getAll(e)); } else { ((ExpressionGetEvent) e).setOutput(new Object[0]); } return null; } @Override public String toString(Event e, boolean debug) { if (objects == null) { return "empty return"; } return "return " + objects.toString(e, debug); } @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent(ExpressionGetEvent.class, ConstantGetEvent.class)) { Skript.error("Return may only be used in custom expression getters.", ErrorQuality.SEMANTIC_ERROR); return false; } if (!isDelayed.isTrue()) { Skript.error("Return may not be used if the code before it contains any delays.", ErrorQuality.SEMANTIC_ERROR); }
// Path: src/main/java/com/btk5h/skriptmirror/util/SkriptUtil.java // public class SkriptUtil { // @SuppressWarnings("unchecked") // public static <T> Expression<T> defendExpression(Expression<?> expr) { // if (expr instanceof UnparsedLiteral) { // Literal<?> parsed = ((UnparsedLiteral) expr).getConvertedExpression(Object.class); // return (Expression<T>) (parsed == null ? expr : parsed); // } else if (expr instanceof ExpressionList) { // Expression[] exprs = ((ExpressionList) expr).getExpressions(); // for (int i = 0; i < exprs.length; i++) { // exprs[i] = defendExpression(exprs[i]); // } // } // return (Expression<T>) expr; // } // // public static boolean hasUnparsedLiteral(Expression<?> expr) { // return expr instanceof UnparsedLiteral || // (expr instanceof ExpressionList && // Arrays.stream(((ExpressionList) expr).getExpressions()) // .anyMatch(UnparsedLiteral.class::isInstance)); // } // // public static boolean canInitSafely(Expression<?>... expressions) { // return Arrays.stream(expressions) // .filter(Objects::nonNull) // .noneMatch(SkriptUtil::hasUnparsedLiteral); // } // // public static List<TriggerItem> getItemsFromNode(SectionNode node) { // RetainingLogHandler log = SkriptLogger.startRetainingLog(); // try { // return ScriptLoader.loadItems(node); // } finally { // SkriptReflection.printLog(log); // ScriptLoader.deleteCurrentEvent(); // } // } // // public static void clearSectionNode(SectionNode node) { // List<Node> subNodes = new ArrayList<>(); // node.forEach(subNodes::add); // subNodes.forEach(Node::remove); // } // // public static File getCurrentScript() { // Config currentScript = ScriptLoader.currentScript; // return currentScript == null ? null : currentScript.getFile(); // } // // public static ClassInfo<?> getUserClassInfo(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // // ClassInfo<?> ci = Classes.getClassInfoNoError(wordData.getFirst()); // // if (ci == null) { // ci = Classes.getClassInfoFromUserInput(wordData.getFirst()); // } // // if (ci == null) { // Skript.warning(String.format("'%s' is not a valid Skript type. Using 'object' instead.", name)); // return Classes.getExactClassInfo(Object.class); // } // // return ci; // } // // public static NonNullPair<ClassInfo<?>, Boolean> getUserClassInfoAndPlural(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return new NonNullPair<>(ci, wordData.getSecond()); // } // // public static String replaceUserInputPatterns(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return Utils.toEnglishPlural(ci.getCodeName(), wordData.getSecond()); // } // // public static Function<Expression, Object> unwrapWithEvent(Event e) { // return expr -> expr.isSingle() ? expr.getSingle(e) : expr.getArray(e); // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/EffReturn.java import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Effect; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.TriggerItem; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.util.SkriptUtil; import org.bukkit.event.Event; @Override protected TriggerItem walk(Event e) { if (objects != null) { ((ExpressionGetEvent) e).setOutput(objects.getAll(e)); } else { ((ExpressionGetEvent) e).setOutput(new Object[0]); } return null; } @Override public String toString(Event e, boolean debug) { if (objects == null) { return "empty return"; } return "return " + objects.toString(e, debug); } @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent(ExpressionGetEvent.class, ConstantGetEvent.class)) { Skript.error("Return may only be used in custom expression getters.", ErrorQuality.SEMANTIC_ERROR); return false; } if (!isDelayed.isTrue()) { Skript.error("Return may not be used if the code before it contains any delays.", ErrorQuality.SEMANTIC_ERROR); }
objects = SkriptUtil.defendExpression(exprs[0]);
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/custom/ExprParseMark.java
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // }
import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event;
package com.btk5h.skriptmirror.skript.custom; public class ExprParseMark extends SimpleExpression<Number> { static { Skript.registerExpression(ExprParseMark.class, Number.class, ExpressionType.SIMPLE, "[the] [parse[r]] mark"); } @Override protected Number[] get(Event e) { return new Number[]{((CustomSyntaxEvent) e).getParseResult().mark}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Number> getReturnType() { return Number.class; } @Override public String toString(Event e, boolean debug) { return "parser mark"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent(
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/ExprParseMark.java import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event; package com.btk5h.skriptmirror.skript.custom; public class ExprParseMark extends SimpleExpression<Number> { static { Skript.registerExpression(ExprParseMark.class, Number.class, ExpressionType.SIMPLE, "[the] [parse[r]] mark"); } @Override protected Number[] get(Event e) { return new Number[]{((CustomSyntaxEvent) e).getParseResult().mark}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Number> getReturnType() { return Number.class; } @Override public String toString(Event e, boolean debug) { return "parser mark"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent(
EffectTriggerEvent.class,
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/custom/ExprParseMark.java
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // }
import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event;
package com.btk5h.skriptmirror.skript.custom; public class ExprParseMark extends SimpleExpression<Number> { static { Skript.registerExpression(ExprParseMark.class, Number.class, ExpressionType.SIMPLE, "[the] [parse[r]] mark"); } @Override protected Number[] get(Event e) { return new Number[]{((CustomSyntaxEvent) e).getParseResult().mark}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Number> getReturnType() { return Number.class; } @Override public String toString(Event e, boolean debug) { return "parser mark"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class,
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/ExprParseMark.java import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event; package com.btk5h.skriptmirror.skript.custom; public class ExprParseMark extends SimpleExpression<Number> { static { Skript.registerExpression(ExprParseMark.class, Number.class, ExpressionType.SIMPLE, "[the] [parse[r]] mark"); } @Override protected Number[] get(Event e) { return new Number[]{((CustomSyntaxEvent) e).getParseResult().mark}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Number> getReturnType() { return Number.class; } @Override public String toString(Event e, boolean debug) { return "parser mark"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class,
ExpressionGetEvent.class,
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/custom/ExprParseMark.java
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // }
import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event;
package com.btk5h.skriptmirror.skript.custom; public class ExprParseMark extends SimpleExpression<Number> { static { Skript.registerExpression(ExprParseMark.class, Number.class, ExpressionType.SIMPLE, "[the] [parse[r]] mark"); } @Override protected Number[] get(Event e) { return new Number[]{((CustomSyntaxEvent) e).getParseResult().mark}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Number> getReturnType() { return Number.class; } @Override public String toString(Event e, boolean debug) { return "parser mark"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class, ExpressionGetEvent.class,
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/ExprParseMark.java import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event; package com.btk5h.skriptmirror.skript.custom; public class ExprParseMark extends SimpleExpression<Number> { static { Skript.registerExpression(ExprParseMark.class, Number.class, ExpressionType.SIMPLE, "[the] [parse[r]] mark"); } @Override protected Number[] get(Event e) { return new Number[]{((CustomSyntaxEvent) e).getParseResult().mark}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Number> getReturnType() { return Number.class; } @Override public String toString(Event e, boolean debug) { return "parser mark"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class, ExpressionGetEvent.class,
ExpressionChangeEvent.class,
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/custom/ExprParseMark.java
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // }
import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event;
package com.btk5h.skriptmirror.skript.custom; public class ExprParseMark extends SimpleExpression<Number> { static { Skript.registerExpression(ExprParseMark.class, Number.class, ExpressionType.SIMPLE, "[the] [parse[r]] mark"); } @Override protected Number[] get(Event e) { return new Number[]{((CustomSyntaxEvent) e).getParseResult().mark}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Number> getReturnType() { return Number.class; } @Override public String toString(Event e, boolean debug) { return "parser mark"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class, ExpressionGetEvent.class, ExpressionChangeEvent.class,
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/ExprParseMark.java import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event; package com.btk5h.skriptmirror.skript.custom; public class ExprParseMark extends SimpleExpression<Number> { static { Skript.registerExpression(ExprParseMark.class, Number.class, ExpressionType.SIMPLE, "[the] [parse[r]] mark"); } @Override protected Number[] get(Event e) { return new Number[]{((CustomSyntaxEvent) e).getParseResult().mark}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Number> getReturnType() { return Number.class; } @Override public String toString(Event e, boolean debug) { return "parser mark"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class, ExpressionGetEvent.class, ExpressionChangeEvent.class,
ConditionCheckEvent.class
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/custom/EffContinue.java
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // }
import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.*; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import org.bukkit.event.Event;
package com.btk5h.skriptmirror.skript.custom; public class EffContinue extends Effect { static { Skript.registerEffect(EffContinue.class, "continue [if (%-boolean%|<.+>)]"); } private Expression<Boolean> condition; private Condition skriptCondition; @Override protected void execute(Event e) { throw new UnsupportedOperationException(); } @Override protected TriggerItem walk(Event e) { if (skriptCondition != null && !skriptCondition.check(e) || condition != null && condition.getSingle(e) != Boolean.TRUE) { return null; }
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/EffContinue.java import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.*; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import org.bukkit.event.Event; package com.btk5h.skriptmirror.skript.custom; public class EffContinue extends Effect { static { Skript.registerEffect(EffContinue.class, "continue [if (%-boolean%|<.+>)]"); } private Expression<Boolean> condition; private Condition skriptCondition; @Override protected void execute(Event e) { throw new UnsupportedOperationException(); } @Override protected TriggerItem walk(Event e) { if (skriptCondition != null && !skriptCondition.check(e) || condition != null && condition.getSingle(e) != Boolean.TRUE) { return null; }
if (e instanceof EffectTriggerEvent) {
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/custom/EffContinue.java
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // }
import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.*; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import org.bukkit.event.Event;
package com.btk5h.skriptmirror.skript.custom; public class EffContinue extends Effect { static { Skript.registerEffect(EffContinue.class, "continue [if (%-boolean%|<.+>)]"); } private Expression<Boolean> condition; private Condition skriptCondition; @Override protected void execute(Event e) { throw new UnsupportedOperationException(); } @Override protected TriggerItem walk(Event e) { if (skriptCondition != null && !skriptCondition.check(e) || condition != null && condition.getSingle(e) != Boolean.TRUE) { return null; } if (e instanceof EffectTriggerEvent) { if (((EffectTriggerEvent) e).isSync()) { Skript.warning("Synchronous events should not be continued. " + "Call 'delay effect' to delay the effect's execution."); } else { TriggerItem.walk(((EffectTriggerEvent) e).getNext(), ((EffectTriggerEvent) e).getDirectEvent()); }
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/EffContinue.java import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.*; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import org.bukkit.event.Event; package com.btk5h.skriptmirror.skript.custom; public class EffContinue extends Effect { static { Skript.registerEffect(EffContinue.class, "continue [if (%-boolean%|<.+>)]"); } private Expression<Boolean> condition; private Condition skriptCondition; @Override protected void execute(Event e) { throw new UnsupportedOperationException(); } @Override protected TriggerItem walk(Event e) { if (skriptCondition != null && !skriptCondition.check(e) || condition != null && condition.getSingle(e) != Boolean.TRUE) { return null; } if (e instanceof EffectTriggerEvent) { if (((EffectTriggerEvent) e).isSync()) { Skript.warning("Synchronous events should not be continued. " + "Call 'delay effect' to delay the effect's execution."); } else { TriggerItem.walk(((EffectTriggerEvent) e).getNext(), ((EffectTriggerEvent) e).getDirectEvent()); }
} else if (e instanceof ConditionCheckEvent) {
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/custom/ExprRawExpression.java
// Path: src/main/java/com/btk5h/skriptmirror/util/SkriptUtil.java // public class SkriptUtil { // @SuppressWarnings("unchecked") // public static <T> Expression<T> defendExpression(Expression<?> expr) { // if (expr instanceof UnparsedLiteral) { // Literal<?> parsed = ((UnparsedLiteral) expr).getConvertedExpression(Object.class); // return (Expression<T>) (parsed == null ? expr : parsed); // } else if (expr instanceof ExpressionList) { // Expression[] exprs = ((ExpressionList) expr).getExpressions(); // for (int i = 0; i < exprs.length; i++) { // exprs[i] = defendExpression(exprs[i]); // } // } // return (Expression<T>) expr; // } // // public static boolean hasUnparsedLiteral(Expression<?> expr) { // return expr instanceof UnparsedLiteral || // (expr instanceof ExpressionList && // Arrays.stream(((ExpressionList) expr).getExpressions()) // .anyMatch(UnparsedLiteral.class::isInstance)); // } // // public static boolean canInitSafely(Expression<?>... expressions) { // return Arrays.stream(expressions) // .filter(Objects::nonNull) // .noneMatch(SkriptUtil::hasUnparsedLiteral); // } // // public static List<TriggerItem> getItemsFromNode(SectionNode node) { // RetainingLogHandler log = SkriptLogger.startRetainingLog(); // try { // return ScriptLoader.loadItems(node); // } finally { // SkriptReflection.printLog(log); // ScriptLoader.deleteCurrentEvent(); // } // } // // public static void clearSectionNode(SectionNode node) { // List<Node> subNodes = new ArrayList<>(); // node.forEach(subNodes::add); // subNodes.forEach(Node::remove); // } // // public static File getCurrentScript() { // Config currentScript = ScriptLoader.currentScript; // return currentScript == null ? null : currentScript.getFile(); // } // // public static ClassInfo<?> getUserClassInfo(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // // ClassInfo<?> ci = Classes.getClassInfoNoError(wordData.getFirst()); // // if (ci == null) { // ci = Classes.getClassInfoFromUserInput(wordData.getFirst()); // } // // if (ci == null) { // Skript.warning(String.format("'%s' is not a valid Skript type. Using 'object' instead.", name)); // return Classes.getExactClassInfo(Object.class); // } // // return ci; // } // // public static NonNullPair<ClassInfo<?>, Boolean> getUserClassInfoAndPlural(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return new NonNullPair<>(ci, wordData.getSecond()); // } // // public static String replaceUserInputPatterns(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return Utils.toEnglishPlural(ci.getCodeName(), wordData.getSecond()); // } // // public static Function<Expression, Object> unwrapWithEvent(Event e) { // return expr -> expr.isSingle() ? expr.getSingle(e) : expr.getArray(e); // } // }
import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.util.SkriptUtil; import org.bukkit.event.Event;
package com.btk5h.skriptmirror.skript.custom; public class ExprRawExpression extends SimpleExpression<Expression> { static { Skript.registerExpression(ExprRawExpression.class, Expression.class, ExpressionType.COMBINED, "[the] raw %objects%"); } private Expression<?> expr; @Override protected Expression[] get(Event e) { Expression<?> expr = this.expr; if (expr instanceof ExprExpression && e instanceof CustomSyntaxEvent) { expr = ((ExprExpression) expr).getExpression(e).getSource(); } return new Expression[]{expr}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Expression> getReturnType() { return Expression.class; } @Override public String toString(Event e, boolean debug) { return "raw " + expr.toString(e, debug); } @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
// Path: src/main/java/com/btk5h/skriptmirror/util/SkriptUtil.java // public class SkriptUtil { // @SuppressWarnings("unchecked") // public static <T> Expression<T> defendExpression(Expression<?> expr) { // if (expr instanceof UnparsedLiteral) { // Literal<?> parsed = ((UnparsedLiteral) expr).getConvertedExpression(Object.class); // return (Expression<T>) (parsed == null ? expr : parsed); // } else if (expr instanceof ExpressionList) { // Expression[] exprs = ((ExpressionList) expr).getExpressions(); // for (int i = 0; i < exprs.length; i++) { // exprs[i] = defendExpression(exprs[i]); // } // } // return (Expression<T>) expr; // } // // public static boolean hasUnparsedLiteral(Expression<?> expr) { // return expr instanceof UnparsedLiteral || // (expr instanceof ExpressionList && // Arrays.stream(((ExpressionList) expr).getExpressions()) // .anyMatch(UnparsedLiteral.class::isInstance)); // } // // public static boolean canInitSafely(Expression<?>... expressions) { // return Arrays.stream(expressions) // .filter(Objects::nonNull) // .noneMatch(SkriptUtil::hasUnparsedLiteral); // } // // public static List<TriggerItem> getItemsFromNode(SectionNode node) { // RetainingLogHandler log = SkriptLogger.startRetainingLog(); // try { // return ScriptLoader.loadItems(node); // } finally { // SkriptReflection.printLog(log); // ScriptLoader.deleteCurrentEvent(); // } // } // // public static void clearSectionNode(SectionNode node) { // List<Node> subNodes = new ArrayList<>(); // node.forEach(subNodes::add); // subNodes.forEach(Node::remove); // } // // public static File getCurrentScript() { // Config currentScript = ScriptLoader.currentScript; // return currentScript == null ? null : currentScript.getFile(); // } // // public static ClassInfo<?> getUserClassInfo(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // // ClassInfo<?> ci = Classes.getClassInfoNoError(wordData.getFirst()); // // if (ci == null) { // ci = Classes.getClassInfoFromUserInput(wordData.getFirst()); // } // // if (ci == null) { // Skript.warning(String.format("'%s' is not a valid Skript type. Using 'object' instead.", name)); // return Classes.getExactClassInfo(Object.class); // } // // return ci; // } // // public static NonNullPair<ClassInfo<?>, Boolean> getUserClassInfoAndPlural(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return new NonNullPair<>(ci, wordData.getSecond()); // } // // public static String replaceUserInputPatterns(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return Utils.toEnglishPlural(ci.getCodeName(), wordData.getSecond()); // } // // public static Function<Expression, Object> unwrapWithEvent(Event e) { // return expr -> expr.isSingle() ? expr.getSingle(e) : expr.getArray(e); // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/ExprRawExpression.java import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.util.SkriptUtil; import org.bukkit.event.Event; package com.btk5h.skriptmirror.skript.custom; public class ExprRawExpression extends SimpleExpression<Expression> { static { Skript.registerExpression(ExprRawExpression.class, Expression.class, ExpressionType.COMBINED, "[the] raw %objects%"); } private Expression<?> expr; @Override protected Expression[] get(Event e) { Expression<?> expr = this.expr; if (expr instanceof ExprExpression && e instanceof CustomSyntaxEvent) { expr = ((ExprExpression) expr).getExpression(e).getSource(); } return new Expression[]{expr}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Expression> getReturnType() { return Expression.class; } @Override public String toString(Event e, boolean debug) { return "raw " + expr.toString(e, debug); } @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
expr = SkriptUtil.defendExpression(exprs[0]);
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/reflect/ExprEvent.java
// Path: src/main/java/com/btk5h/skriptmirror/WrappedEvent.java // public abstract class WrappedEvent extends Event { // private final Event event; // // protected WrappedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event instanceof WrappedEvent ? ((WrappedEvent) event).getEvent() : event; // } // // public Event getDirectEvent() { // return event; // } // }
import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.WrappedEvent; import org.bukkit.event.Event;
package com.btk5h.skriptmirror.skript.reflect; public class ExprEvent extends SimpleExpression<Event> { static { Skript.registerExpression(ExprEvent.class, Event.class, ExpressionType.SIMPLE, "[the] event"); } @Override protected Event[] get(Event e) {
// Path: src/main/java/com/btk5h/skriptmirror/WrappedEvent.java // public abstract class WrappedEvent extends Event { // private final Event event; // // protected WrappedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event instanceof WrappedEvent ? ((WrappedEvent) event).getEvent() : event; // } // // public Event getDirectEvent() { // return event; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/reflect/ExprEvent.java import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.WrappedEvent; import org.bukkit.event.Event; package com.btk5h.skriptmirror.skript.reflect; public class ExprEvent extends SimpleExpression<Event> { static { Skript.registerExpression(ExprEvent.class, Event.class, ExpressionType.SIMPLE, "[the] event"); } @Override protected Event[] get(Event e) {
if (e instanceof WrappedEvent) {
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/custom/SyntaxParseEvent.java
// Path: src/main/java/com/btk5h/skriptmirror/util/SkriptUtil.java // public class SkriptUtil { // @SuppressWarnings("unchecked") // public static <T> Expression<T> defendExpression(Expression<?> expr) { // if (expr instanceof UnparsedLiteral) { // Literal<?> parsed = ((UnparsedLiteral) expr).getConvertedExpression(Object.class); // return (Expression<T>) (parsed == null ? expr : parsed); // } else if (expr instanceof ExpressionList) { // Expression[] exprs = ((ExpressionList) expr).getExpressions(); // for (int i = 0; i < exprs.length; i++) { // exprs[i] = defendExpression(exprs[i]); // } // } // return (Expression<T>) expr; // } // // public static boolean hasUnparsedLiteral(Expression<?> expr) { // return expr instanceof UnparsedLiteral || // (expr instanceof ExpressionList && // Arrays.stream(((ExpressionList) expr).getExpressions()) // .anyMatch(UnparsedLiteral.class::isInstance)); // } // // public static boolean canInitSafely(Expression<?>... expressions) { // return Arrays.stream(expressions) // .filter(Objects::nonNull) // .noneMatch(SkriptUtil::hasUnparsedLiteral); // } // // public static List<TriggerItem> getItemsFromNode(SectionNode node) { // RetainingLogHandler log = SkriptLogger.startRetainingLog(); // try { // return ScriptLoader.loadItems(node); // } finally { // SkriptReflection.printLog(log); // ScriptLoader.deleteCurrentEvent(); // } // } // // public static void clearSectionNode(SectionNode node) { // List<Node> subNodes = new ArrayList<>(); // node.forEach(subNodes::add); // subNodes.forEach(Node::remove); // } // // public static File getCurrentScript() { // Config currentScript = ScriptLoader.currentScript; // return currentScript == null ? null : currentScript.getFile(); // } // // public static ClassInfo<?> getUserClassInfo(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // // ClassInfo<?> ci = Classes.getClassInfoNoError(wordData.getFirst()); // // if (ci == null) { // ci = Classes.getClassInfoFromUserInput(wordData.getFirst()); // } // // if (ci == null) { // Skript.warning(String.format("'%s' is not a valid Skript type. Using 'object' instead.", name)); // return Classes.getExactClassInfo(Object.class); // } // // return ci; // } // // public static NonNullPair<ClassInfo<?>, Boolean> getUserClassInfoAndPlural(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return new NonNullPair<>(ci, wordData.getSecond()); // } // // public static String replaceUserInputPatterns(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return Utils.toEnglishPlural(ci.getCodeName(), wordData.getSecond()); // } // // public static Function<Expression, Object> unwrapWithEvent(Event e) { // return expr -> expr.isSingle() ? expr.getSingle(e) : expr.getArray(e); // } // }
import ch.njol.skript.ScriptLoader; import ch.njol.skript.config.SectionNode; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.Trigger; import ch.njol.skript.lang.TriggerItem; import ch.njol.skript.lang.util.SimpleLiteral; import com.btk5h.skriptmirror.util.SkriptUtil; import org.bukkit.event.HandlerList; import java.util.Arrays; import java.util.List; import java.util.Map;
.map(expr -> expr == null ? null : new SimpleLiteral<>(expr, false)) .toArray(Expression[]::new); } public static HandlerList getHandlerList() { return handlers; } public Class<?>[] getEventClasses() { return eventClasses; } public boolean isMarkedContinue() { return markedContinue; } public void markContinue() { markedContinue = true; } @Override public HandlerList getHandlers() { return handlers; } @SuppressWarnings("unchecked") public static <T extends CustomSyntaxSection.SyntaxData> void register(CustomSyntaxSection<T> section, SectionNode parseNode, List<T> whichInfo, Map<T, Trigger> parserHandlers) { ScriptLoader.setCurrentEvent("custom syntax parser", SyntaxParseEvent.class);
// Path: src/main/java/com/btk5h/skriptmirror/util/SkriptUtil.java // public class SkriptUtil { // @SuppressWarnings("unchecked") // public static <T> Expression<T> defendExpression(Expression<?> expr) { // if (expr instanceof UnparsedLiteral) { // Literal<?> parsed = ((UnparsedLiteral) expr).getConvertedExpression(Object.class); // return (Expression<T>) (parsed == null ? expr : parsed); // } else if (expr instanceof ExpressionList) { // Expression[] exprs = ((ExpressionList) expr).getExpressions(); // for (int i = 0; i < exprs.length; i++) { // exprs[i] = defendExpression(exprs[i]); // } // } // return (Expression<T>) expr; // } // // public static boolean hasUnparsedLiteral(Expression<?> expr) { // return expr instanceof UnparsedLiteral || // (expr instanceof ExpressionList && // Arrays.stream(((ExpressionList) expr).getExpressions()) // .anyMatch(UnparsedLiteral.class::isInstance)); // } // // public static boolean canInitSafely(Expression<?>... expressions) { // return Arrays.stream(expressions) // .filter(Objects::nonNull) // .noneMatch(SkriptUtil::hasUnparsedLiteral); // } // // public static List<TriggerItem> getItemsFromNode(SectionNode node) { // RetainingLogHandler log = SkriptLogger.startRetainingLog(); // try { // return ScriptLoader.loadItems(node); // } finally { // SkriptReflection.printLog(log); // ScriptLoader.deleteCurrentEvent(); // } // } // // public static void clearSectionNode(SectionNode node) { // List<Node> subNodes = new ArrayList<>(); // node.forEach(subNodes::add); // subNodes.forEach(Node::remove); // } // // public static File getCurrentScript() { // Config currentScript = ScriptLoader.currentScript; // return currentScript == null ? null : currentScript.getFile(); // } // // public static ClassInfo<?> getUserClassInfo(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // // ClassInfo<?> ci = Classes.getClassInfoNoError(wordData.getFirst()); // // if (ci == null) { // ci = Classes.getClassInfoFromUserInput(wordData.getFirst()); // } // // if (ci == null) { // Skript.warning(String.format("'%s' is not a valid Skript type. Using 'object' instead.", name)); // return Classes.getExactClassInfo(Object.class); // } // // return ci; // } // // public static NonNullPair<ClassInfo<?>, Boolean> getUserClassInfoAndPlural(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return new NonNullPair<>(ci, wordData.getSecond()); // } // // public static String replaceUserInputPatterns(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return Utils.toEnglishPlural(ci.getCodeName(), wordData.getSecond()); // } // // public static Function<Expression, Object> unwrapWithEvent(Event e) { // return expr -> expr.isSingle() ? expr.getSingle(e) : expr.getArray(e); // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/SyntaxParseEvent.java import ch.njol.skript.ScriptLoader; import ch.njol.skript.config.SectionNode; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.Trigger; import ch.njol.skript.lang.TriggerItem; import ch.njol.skript.lang.util.SimpleLiteral; import com.btk5h.skriptmirror.util.SkriptUtil; import org.bukkit.event.HandlerList; import java.util.Arrays; import java.util.List; import java.util.Map; .map(expr -> expr == null ? null : new SimpleLiteral<>(expr, false)) .toArray(Expression[]::new); } public static HandlerList getHandlerList() { return handlers; } public Class<?>[] getEventClasses() { return eventClasses; } public boolean isMarkedContinue() { return markedContinue; } public void markContinue() { markedContinue = true; } @Override public HandlerList getHandlers() { return handlers; } @SuppressWarnings("unchecked") public static <T extends CustomSyntaxSection.SyntaxData> void register(CustomSyntaxSection<T> section, SectionNode parseNode, List<T> whichInfo, Map<T, Trigger> parserHandlers) { ScriptLoader.setCurrentEvent("custom syntax parser", SyntaxParseEvent.class);
List<TriggerItem> items = SkriptUtil.getItemsFromNode(parseNode);
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/CondParseLater.java
// Path: src/main/java/com/btk5h/skriptmirror/ScriptLoaderState.java // public class ScriptLoaderState { // private Config currentScript; // private String currentEventName; // private Class<? extends Event>[] currentEvents; // private Kleenean hasDelayBefore; // // private ScriptLoaderState(Config currentScript, String currentEventName, Class<? extends Event>[] currentEvents, // Kleenean hasDelayBefore) { // this.currentScript = currentScript; // this.currentEventName = currentEventName; // this.currentEvents = currentEvents; // this.hasDelayBefore = hasDelayBefore; // } // // public void applyToCurrentState() { // ScriptLoader.currentScript = currentScript; // ScriptLoader.setCurrentEvent(currentEventName, currentEvents); // ScriptLoader.hasDelayBefore = hasDelayBefore; // } // // public static ScriptLoaderState copyOfCurrentState() { // return new ScriptLoaderState( // ScriptLoader.currentScript, // ScriptLoader.getCurrentEventName(), // ScriptLoader.getCurrentEvents(), // ScriptLoader.hasDelayBefore // ); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/util/SkriptUtil.java // public class SkriptUtil { // @SuppressWarnings("unchecked") // public static <T> Expression<T> defendExpression(Expression<?> expr) { // if (expr instanceof UnparsedLiteral) { // Literal<?> parsed = ((UnparsedLiteral) expr).getConvertedExpression(Object.class); // return (Expression<T>) (parsed == null ? expr : parsed); // } else if (expr instanceof ExpressionList) { // Expression[] exprs = ((ExpressionList) expr).getExpressions(); // for (int i = 0; i < exprs.length; i++) { // exprs[i] = defendExpression(exprs[i]); // } // } // return (Expression<T>) expr; // } // // public static boolean hasUnparsedLiteral(Expression<?> expr) { // return expr instanceof UnparsedLiteral || // (expr instanceof ExpressionList && // Arrays.stream(((ExpressionList) expr).getExpressions()) // .anyMatch(UnparsedLiteral.class::isInstance)); // } // // public static boolean canInitSafely(Expression<?>... expressions) { // return Arrays.stream(expressions) // .filter(Objects::nonNull) // .noneMatch(SkriptUtil::hasUnparsedLiteral); // } // // public static List<TriggerItem> getItemsFromNode(SectionNode node) { // RetainingLogHandler log = SkriptLogger.startRetainingLog(); // try { // return ScriptLoader.loadItems(node); // } finally { // SkriptReflection.printLog(log); // ScriptLoader.deleteCurrentEvent(); // } // } // // public static void clearSectionNode(SectionNode node) { // List<Node> subNodes = new ArrayList<>(); // node.forEach(subNodes::add); // subNodes.forEach(Node::remove); // } // // public static File getCurrentScript() { // Config currentScript = ScriptLoader.currentScript; // return currentScript == null ? null : currentScript.getFile(); // } // // public static ClassInfo<?> getUserClassInfo(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // // ClassInfo<?> ci = Classes.getClassInfoNoError(wordData.getFirst()); // // if (ci == null) { // ci = Classes.getClassInfoFromUserInput(wordData.getFirst()); // } // // if (ci == null) { // Skript.warning(String.format("'%s' is not a valid Skript type. Using 'object' instead.", name)); // return Classes.getExactClassInfo(Object.class); // } // // return ci; // } // // public static NonNullPair<ClassInfo<?>, Boolean> getUserClassInfoAndPlural(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return new NonNullPair<>(ci, wordData.getSecond()); // } // // public static String replaceUserInputPatterns(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return Utils.toEnglishPlural(ci.getCodeName(), wordData.getSecond()); // } // // public static Function<Expression, Object> unwrapWithEvent(Event e) { // return expr -> expr.isSingle() ? expr.getSingle(e) : expr.getArray(e); // } // }
import ch.njol.skript.Skript; import ch.njol.skript.lang.*; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.ScriptLoaderState; import com.btk5h.skriptmirror.util.SkriptUtil; import org.bukkit.event.Event;
package com.btk5h.skriptmirror.skript; public class CondParseLater extends Condition { static { Skript.registerCondition(CondParseLater.class, "\\(parse[d] later\\) <.+>"); } private String statement;
// Path: src/main/java/com/btk5h/skriptmirror/ScriptLoaderState.java // public class ScriptLoaderState { // private Config currentScript; // private String currentEventName; // private Class<? extends Event>[] currentEvents; // private Kleenean hasDelayBefore; // // private ScriptLoaderState(Config currentScript, String currentEventName, Class<? extends Event>[] currentEvents, // Kleenean hasDelayBefore) { // this.currentScript = currentScript; // this.currentEventName = currentEventName; // this.currentEvents = currentEvents; // this.hasDelayBefore = hasDelayBefore; // } // // public void applyToCurrentState() { // ScriptLoader.currentScript = currentScript; // ScriptLoader.setCurrentEvent(currentEventName, currentEvents); // ScriptLoader.hasDelayBefore = hasDelayBefore; // } // // public static ScriptLoaderState copyOfCurrentState() { // return new ScriptLoaderState( // ScriptLoader.currentScript, // ScriptLoader.getCurrentEventName(), // ScriptLoader.getCurrentEvents(), // ScriptLoader.hasDelayBefore // ); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/util/SkriptUtil.java // public class SkriptUtil { // @SuppressWarnings("unchecked") // public static <T> Expression<T> defendExpression(Expression<?> expr) { // if (expr instanceof UnparsedLiteral) { // Literal<?> parsed = ((UnparsedLiteral) expr).getConvertedExpression(Object.class); // return (Expression<T>) (parsed == null ? expr : parsed); // } else if (expr instanceof ExpressionList) { // Expression[] exprs = ((ExpressionList) expr).getExpressions(); // for (int i = 0; i < exprs.length; i++) { // exprs[i] = defendExpression(exprs[i]); // } // } // return (Expression<T>) expr; // } // // public static boolean hasUnparsedLiteral(Expression<?> expr) { // return expr instanceof UnparsedLiteral || // (expr instanceof ExpressionList && // Arrays.stream(((ExpressionList) expr).getExpressions()) // .anyMatch(UnparsedLiteral.class::isInstance)); // } // // public static boolean canInitSafely(Expression<?>... expressions) { // return Arrays.stream(expressions) // .filter(Objects::nonNull) // .noneMatch(SkriptUtil::hasUnparsedLiteral); // } // // public static List<TriggerItem> getItemsFromNode(SectionNode node) { // RetainingLogHandler log = SkriptLogger.startRetainingLog(); // try { // return ScriptLoader.loadItems(node); // } finally { // SkriptReflection.printLog(log); // ScriptLoader.deleteCurrentEvent(); // } // } // // public static void clearSectionNode(SectionNode node) { // List<Node> subNodes = new ArrayList<>(); // node.forEach(subNodes::add); // subNodes.forEach(Node::remove); // } // // public static File getCurrentScript() { // Config currentScript = ScriptLoader.currentScript; // return currentScript == null ? null : currentScript.getFile(); // } // // public static ClassInfo<?> getUserClassInfo(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // // ClassInfo<?> ci = Classes.getClassInfoNoError(wordData.getFirst()); // // if (ci == null) { // ci = Classes.getClassInfoFromUserInput(wordData.getFirst()); // } // // if (ci == null) { // Skript.warning(String.format("'%s' is not a valid Skript type. Using 'object' instead.", name)); // return Classes.getExactClassInfo(Object.class); // } // // return ci; // } // // public static NonNullPair<ClassInfo<?>, Boolean> getUserClassInfoAndPlural(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return new NonNullPair<>(ci, wordData.getSecond()); // } // // public static String replaceUserInputPatterns(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return Utils.toEnglishPlural(ci.getCodeName(), wordData.getSecond()); // } // // public static Function<Expression, Object> unwrapWithEvent(Event e) { // return expr -> expr.isSingle() ? expr.getSingle(e) : expr.getArray(e); // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/CondParseLater.java import ch.njol.skript.Skript; import ch.njol.skript.lang.*; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.ScriptLoaderState; import com.btk5h.skriptmirror.util.SkriptUtil; import org.bukkit.event.Event; package com.btk5h.skriptmirror.skript; public class CondParseLater extends Condition { static { Skript.registerCondition(CondParseLater.class, "\\(parse[d] later\\) <.+>"); } private String statement;
private ScriptLoaderState scriptLoaderState;
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/CondParseLater.java
// Path: src/main/java/com/btk5h/skriptmirror/ScriptLoaderState.java // public class ScriptLoaderState { // private Config currentScript; // private String currentEventName; // private Class<? extends Event>[] currentEvents; // private Kleenean hasDelayBefore; // // private ScriptLoaderState(Config currentScript, String currentEventName, Class<? extends Event>[] currentEvents, // Kleenean hasDelayBefore) { // this.currentScript = currentScript; // this.currentEventName = currentEventName; // this.currentEvents = currentEvents; // this.hasDelayBefore = hasDelayBefore; // } // // public void applyToCurrentState() { // ScriptLoader.currentScript = currentScript; // ScriptLoader.setCurrentEvent(currentEventName, currentEvents); // ScriptLoader.hasDelayBefore = hasDelayBefore; // } // // public static ScriptLoaderState copyOfCurrentState() { // return new ScriptLoaderState( // ScriptLoader.currentScript, // ScriptLoader.getCurrentEventName(), // ScriptLoader.getCurrentEvents(), // ScriptLoader.hasDelayBefore // ); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/util/SkriptUtil.java // public class SkriptUtil { // @SuppressWarnings("unchecked") // public static <T> Expression<T> defendExpression(Expression<?> expr) { // if (expr instanceof UnparsedLiteral) { // Literal<?> parsed = ((UnparsedLiteral) expr).getConvertedExpression(Object.class); // return (Expression<T>) (parsed == null ? expr : parsed); // } else if (expr instanceof ExpressionList) { // Expression[] exprs = ((ExpressionList) expr).getExpressions(); // for (int i = 0; i < exprs.length; i++) { // exprs[i] = defendExpression(exprs[i]); // } // } // return (Expression<T>) expr; // } // // public static boolean hasUnparsedLiteral(Expression<?> expr) { // return expr instanceof UnparsedLiteral || // (expr instanceof ExpressionList && // Arrays.stream(((ExpressionList) expr).getExpressions()) // .anyMatch(UnparsedLiteral.class::isInstance)); // } // // public static boolean canInitSafely(Expression<?>... expressions) { // return Arrays.stream(expressions) // .filter(Objects::nonNull) // .noneMatch(SkriptUtil::hasUnparsedLiteral); // } // // public static List<TriggerItem> getItemsFromNode(SectionNode node) { // RetainingLogHandler log = SkriptLogger.startRetainingLog(); // try { // return ScriptLoader.loadItems(node); // } finally { // SkriptReflection.printLog(log); // ScriptLoader.deleteCurrentEvent(); // } // } // // public static void clearSectionNode(SectionNode node) { // List<Node> subNodes = new ArrayList<>(); // node.forEach(subNodes::add); // subNodes.forEach(Node::remove); // } // // public static File getCurrentScript() { // Config currentScript = ScriptLoader.currentScript; // return currentScript == null ? null : currentScript.getFile(); // } // // public static ClassInfo<?> getUserClassInfo(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // // ClassInfo<?> ci = Classes.getClassInfoNoError(wordData.getFirst()); // // if (ci == null) { // ci = Classes.getClassInfoFromUserInput(wordData.getFirst()); // } // // if (ci == null) { // Skript.warning(String.format("'%s' is not a valid Skript type. Using 'object' instead.", name)); // return Classes.getExactClassInfo(Object.class); // } // // return ci; // } // // public static NonNullPair<ClassInfo<?>, Boolean> getUserClassInfoAndPlural(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return new NonNullPair<>(ci, wordData.getSecond()); // } // // public static String replaceUserInputPatterns(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return Utils.toEnglishPlural(ci.getCodeName(), wordData.getSecond()); // } // // public static Function<Expression, Object> unwrapWithEvent(Event e) { // return expr -> expr.isSingle() ? expr.getSingle(e) : expr.getArray(e); // } // }
import ch.njol.skript.Skript; import ch.njol.skript.lang.*; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.ScriptLoaderState; import com.btk5h.skriptmirror.util.SkriptUtil; import org.bukkit.event.Event;
} return parsedCondition.check(e); } @Override protected TriggerItem walk(Event e) { Statement parsedStatement = getParsedStatement(); if (parsedStatement == null) { return null; } TriggerItem.walk(parsedStatement, e); return null; } @Override public String toString(Event e, boolean debug) { if (parsedStatement != null) { return "parsed later: " + parsedStatement.toString(e, debug); } return "not parsed yet: " + statement; } @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
// Path: src/main/java/com/btk5h/skriptmirror/ScriptLoaderState.java // public class ScriptLoaderState { // private Config currentScript; // private String currentEventName; // private Class<? extends Event>[] currentEvents; // private Kleenean hasDelayBefore; // // private ScriptLoaderState(Config currentScript, String currentEventName, Class<? extends Event>[] currentEvents, // Kleenean hasDelayBefore) { // this.currentScript = currentScript; // this.currentEventName = currentEventName; // this.currentEvents = currentEvents; // this.hasDelayBefore = hasDelayBefore; // } // // public void applyToCurrentState() { // ScriptLoader.currentScript = currentScript; // ScriptLoader.setCurrentEvent(currentEventName, currentEvents); // ScriptLoader.hasDelayBefore = hasDelayBefore; // } // // public static ScriptLoaderState copyOfCurrentState() { // return new ScriptLoaderState( // ScriptLoader.currentScript, // ScriptLoader.getCurrentEventName(), // ScriptLoader.getCurrentEvents(), // ScriptLoader.hasDelayBefore // ); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/util/SkriptUtil.java // public class SkriptUtil { // @SuppressWarnings("unchecked") // public static <T> Expression<T> defendExpression(Expression<?> expr) { // if (expr instanceof UnparsedLiteral) { // Literal<?> parsed = ((UnparsedLiteral) expr).getConvertedExpression(Object.class); // return (Expression<T>) (parsed == null ? expr : parsed); // } else if (expr instanceof ExpressionList) { // Expression[] exprs = ((ExpressionList) expr).getExpressions(); // for (int i = 0; i < exprs.length; i++) { // exprs[i] = defendExpression(exprs[i]); // } // } // return (Expression<T>) expr; // } // // public static boolean hasUnparsedLiteral(Expression<?> expr) { // return expr instanceof UnparsedLiteral || // (expr instanceof ExpressionList && // Arrays.stream(((ExpressionList) expr).getExpressions()) // .anyMatch(UnparsedLiteral.class::isInstance)); // } // // public static boolean canInitSafely(Expression<?>... expressions) { // return Arrays.stream(expressions) // .filter(Objects::nonNull) // .noneMatch(SkriptUtil::hasUnparsedLiteral); // } // // public static List<TriggerItem> getItemsFromNode(SectionNode node) { // RetainingLogHandler log = SkriptLogger.startRetainingLog(); // try { // return ScriptLoader.loadItems(node); // } finally { // SkriptReflection.printLog(log); // ScriptLoader.deleteCurrentEvent(); // } // } // // public static void clearSectionNode(SectionNode node) { // List<Node> subNodes = new ArrayList<>(); // node.forEach(subNodes::add); // subNodes.forEach(Node::remove); // } // // public static File getCurrentScript() { // Config currentScript = ScriptLoader.currentScript; // return currentScript == null ? null : currentScript.getFile(); // } // // public static ClassInfo<?> getUserClassInfo(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // // ClassInfo<?> ci = Classes.getClassInfoNoError(wordData.getFirst()); // // if (ci == null) { // ci = Classes.getClassInfoFromUserInput(wordData.getFirst()); // } // // if (ci == null) { // Skript.warning(String.format("'%s' is not a valid Skript type. Using 'object' instead.", name)); // return Classes.getExactClassInfo(Object.class); // } // // return ci; // } // // public static NonNullPair<ClassInfo<?>, Boolean> getUserClassInfoAndPlural(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return new NonNullPair<>(ci, wordData.getSecond()); // } // // public static String replaceUserInputPatterns(String name) { // NonNullPair<String, Boolean> wordData = Utils.getEnglishPlural(name); // ClassInfo<?> ci = getUserClassInfo(name); // // return Utils.toEnglishPlural(ci.getCodeName(), wordData.getSecond()); // } // // public static Function<Expression, Object> unwrapWithEvent(Event e) { // return expr -> expr.isSingle() ? expr.getSingle(e) : expr.getArray(e); // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/CondParseLater.java import ch.njol.skript.Skript; import ch.njol.skript.lang.*; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.ScriptLoaderState; import com.btk5h.skriptmirror.util.SkriptUtil; import org.bukkit.event.Event; } return parsedCondition.check(e); } @Override protected TriggerItem walk(Event e) { Statement parsedStatement = getParsedStatement(); if (parsedStatement == null) { return null; } TriggerItem.walk(parsedStatement, e); return null; } @Override public String toString(Event e, boolean debug) { if (parsedStatement != null) { return "parsed later: " + parsedStatement.toString(e, debug); } return "not parsed yet: " + statement; } @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
if (!Consent.Feature.DEFERRED_PARSING.hasConsent(SkriptUtil.getCurrentScript())) {
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/util/SkriptMirrorUtil.java
// Path: src/main/java/com/btk5h/skriptmirror/JavaType.java // public final class JavaType { // private final Class<?> javaClass; // // public JavaType(Class<?> javaClass) { // this.javaClass = javaClass; // } // // public Class<?> getJavaClass() { // return javaClass; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // JavaType javaType1 = (JavaType) o; // return Objects.equals(javaClass, javaType1.javaClass); // } // // @Override // public int hashCode() { // return Objects.hash(javaClass); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/Null.java // public class Null { // private static Null instance = new Null(); // // private Null() {} // // public static Null getInstance() { // return instance; // } // // // } // // Path: src/main/java/com/btk5h/skriptmirror/ObjectWrapper.java // public class ObjectWrapper { // protected Object object; // // private ObjectWrapper(Object object) { // this.object = object; // } // // public static ObjectWrapper create(Object object) { // if (object instanceof ObjectWrapper) { // return (ObjectWrapper) object; // } // // if (object.getClass().isArray()) { // return new OfArray((Object[]) object); // } // // return new ObjectWrapper(object); // } // // public static Object wrapIfNecessary(Object returnedValue, boolean forceWrap) { // Class<?> returnedClass = returnedValue.getClass(); // if (returnedClass.isArray()) { // returnedValue = create(JavaUtil.boxPrimitiveArray(returnedValue)); // } else if (forceWrap || Classes.getSuperClassInfo(returnedClass).getC() == Object.class) { // returnedValue = create(returnedValue); // } // return returnedValue; // } // // public static Object unwrapIfNecessary(Object o) { // if (o instanceof ObjectWrapper) { // return ((ObjectWrapper) o).get(); // } // // return o; // } // // public Object get() { // return object; // } // // @Override // public String toString() { // return object.toString(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // ObjectWrapper that = (ObjectWrapper) o; // return Objects.equals(object, that.object); // } // // @Override // public int hashCode() { // return Objects.hash(object); // } // // public static class OfArray extends ObjectWrapper { // private OfArray(Object[] object) { // super(object); // } // // @Override // public Object[] get() { // return (Object[]) object; // } // // @Override // public String toString() { // return Arrays.deepToString(get()); // } // } // }
import ch.njol.skript.Skript; import com.btk5h.skriptmirror.JavaType; import com.btk5h.skriptmirror.Null; import com.btk5h.skriptmirror.ObjectWrapper; import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors;
package com.btk5h.skriptmirror.util; public class SkriptMirrorUtil { public static final String IDENTIFIER = "[_a-zA-Z$][\\w$]*"; public static final String PACKAGE = "(?:" + IDENTIFIER + "\\.)*(?:" + IDENTIFIER + ")"; private static final Pattern TYPE_PREFIXES = Pattern.compile("^[-*~]*"); public static Class<?> toClassUnwrapJavaTypes(Object o) {
// Path: src/main/java/com/btk5h/skriptmirror/JavaType.java // public final class JavaType { // private final Class<?> javaClass; // // public JavaType(Class<?> javaClass) { // this.javaClass = javaClass; // } // // public Class<?> getJavaClass() { // return javaClass; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // JavaType javaType1 = (JavaType) o; // return Objects.equals(javaClass, javaType1.javaClass); // } // // @Override // public int hashCode() { // return Objects.hash(javaClass); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/Null.java // public class Null { // private static Null instance = new Null(); // // private Null() {} // // public static Null getInstance() { // return instance; // } // // // } // // Path: src/main/java/com/btk5h/skriptmirror/ObjectWrapper.java // public class ObjectWrapper { // protected Object object; // // private ObjectWrapper(Object object) { // this.object = object; // } // // public static ObjectWrapper create(Object object) { // if (object instanceof ObjectWrapper) { // return (ObjectWrapper) object; // } // // if (object.getClass().isArray()) { // return new OfArray((Object[]) object); // } // // return new ObjectWrapper(object); // } // // public static Object wrapIfNecessary(Object returnedValue, boolean forceWrap) { // Class<?> returnedClass = returnedValue.getClass(); // if (returnedClass.isArray()) { // returnedValue = create(JavaUtil.boxPrimitiveArray(returnedValue)); // } else if (forceWrap || Classes.getSuperClassInfo(returnedClass).getC() == Object.class) { // returnedValue = create(returnedValue); // } // return returnedValue; // } // // public static Object unwrapIfNecessary(Object o) { // if (o instanceof ObjectWrapper) { // return ((ObjectWrapper) o).get(); // } // // return o; // } // // public Object get() { // return object; // } // // @Override // public String toString() { // return object.toString(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // ObjectWrapper that = (ObjectWrapper) o; // return Objects.equals(object, that.object); // } // // @Override // public int hashCode() { // return Objects.hash(object); // } // // public static class OfArray extends ObjectWrapper { // private OfArray(Object[] object) { // super(object); // } // // @Override // public Object[] get() { // return (Object[]) object; // } // // @Override // public String toString() { // return Arrays.deepToString(get()); // } // } // } // Path: src/main/java/com/btk5h/skriptmirror/util/SkriptMirrorUtil.java import ch.njol.skript.Skript; import com.btk5h.skriptmirror.JavaType; import com.btk5h.skriptmirror.Null; import com.btk5h.skriptmirror.ObjectWrapper; import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; package com.btk5h.skriptmirror.util; public class SkriptMirrorUtil { public static final String IDENTIFIER = "[_a-zA-Z$][\\w$]*"; public static final String PACKAGE = "(?:" + IDENTIFIER + "\\.)*(?:" + IDENTIFIER + ")"; private static final Pattern TYPE_PREFIXES = Pattern.compile("^[-*~]*"); public static Class<?> toClassUnwrapJavaTypes(Object o) {
if (o instanceof JavaType) {
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/util/SkriptMirrorUtil.java
// Path: src/main/java/com/btk5h/skriptmirror/JavaType.java // public final class JavaType { // private final Class<?> javaClass; // // public JavaType(Class<?> javaClass) { // this.javaClass = javaClass; // } // // public Class<?> getJavaClass() { // return javaClass; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // JavaType javaType1 = (JavaType) o; // return Objects.equals(javaClass, javaType1.javaClass); // } // // @Override // public int hashCode() { // return Objects.hash(javaClass); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/Null.java // public class Null { // private static Null instance = new Null(); // // private Null() {} // // public static Null getInstance() { // return instance; // } // // // } // // Path: src/main/java/com/btk5h/skriptmirror/ObjectWrapper.java // public class ObjectWrapper { // protected Object object; // // private ObjectWrapper(Object object) { // this.object = object; // } // // public static ObjectWrapper create(Object object) { // if (object instanceof ObjectWrapper) { // return (ObjectWrapper) object; // } // // if (object.getClass().isArray()) { // return new OfArray((Object[]) object); // } // // return new ObjectWrapper(object); // } // // public static Object wrapIfNecessary(Object returnedValue, boolean forceWrap) { // Class<?> returnedClass = returnedValue.getClass(); // if (returnedClass.isArray()) { // returnedValue = create(JavaUtil.boxPrimitiveArray(returnedValue)); // } else if (forceWrap || Classes.getSuperClassInfo(returnedClass).getC() == Object.class) { // returnedValue = create(returnedValue); // } // return returnedValue; // } // // public static Object unwrapIfNecessary(Object o) { // if (o instanceof ObjectWrapper) { // return ((ObjectWrapper) o).get(); // } // // return o; // } // // public Object get() { // return object; // } // // @Override // public String toString() { // return object.toString(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // ObjectWrapper that = (ObjectWrapper) o; // return Objects.equals(object, that.object); // } // // @Override // public int hashCode() { // return Objects.hash(object); // } // // public static class OfArray extends ObjectWrapper { // private OfArray(Object[] object) { // super(object); // } // // @Override // public Object[] get() { // return (Object[]) object; // } // // @Override // public String toString() { // return Arrays.deepToString(get()); // } // } // }
import ch.njol.skript.Skript; import com.btk5h.skriptmirror.JavaType; import com.btk5h.skriptmirror.Null; import com.btk5h.skriptmirror.ObjectWrapper; import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors;
package com.btk5h.skriptmirror.util; public class SkriptMirrorUtil { public static final String IDENTIFIER = "[_a-zA-Z$][\\w$]*"; public static final String PACKAGE = "(?:" + IDENTIFIER + "\\.)*(?:" + IDENTIFIER + ")"; private static final Pattern TYPE_PREFIXES = Pattern.compile("^[-*~]*"); public static Class<?> toClassUnwrapJavaTypes(Object o) { if (o instanceof JavaType) { return ((JavaType) o).getJavaClass(); } return getClass(o); } public static String getDebugName(Class<?> cls) { return Skript.logVeryHigh() ? cls.getName() : cls.getSimpleName(); } public static Class<?> getClass(Object o) {
// Path: src/main/java/com/btk5h/skriptmirror/JavaType.java // public final class JavaType { // private final Class<?> javaClass; // // public JavaType(Class<?> javaClass) { // this.javaClass = javaClass; // } // // public Class<?> getJavaClass() { // return javaClass; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // JavaType javaType1 = (JavaType) o; // return Objects.equals(javaClass, javaType1.javaClass); // } // // @Override // public int hashCode() { // return Objects.hash(javaClass); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/Null.java // public class Null { // private static Null instance = new Null(); // // private Null() {} // // public static Null getInstance() { // return instance; // } // // // } // // Path: src/main/java/com/btk5h/skriptmirror/ObjectWrapper.java // public class ObjectWrapper { // protected Object object; // // private ObjectWrapper(Object object) { // this.object = object; // } // // public static ObjectWrapper create(Object object) { // if (object instanceof ObjectWrapper) { // return (ObjectWrapper) object; // } // // if (object.getClass().isArray()) { // return new OfArray((Object[]) object); // } // // return new ObjectWrapper(object); // } // // public static Object wrapIfNecessary(Object returnedValue, boolean forceWrap) { // Class<?> returnedClass = returnedValue.getClass(); // if (returnedClass.isArray()) { // returnedValue = create(JavaUtil.boxPrimitiveArray(returnedValue)); // } else if (forceWrap || Classes.getSuperClassInfo(returnedClass).getC() == Object.class) { // returnedValue = create(returnedValue); // } // return returnedValue; // } // // public static Object unwrapIfNecessary(Object o) { // if (o instanceof ObjectWrapper) { // return ((ObjectWrapper) o).get(); // } // // return o; // } // // public Object get() { // return object; // } // // @Override // public String toString() { // return object.toString(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // ObjectWrapper that = (ObjectWrapper) o; // return Objects.equals(object, that.object); // } // // @Override // public int hashCode() { // return Objects.hash(object); // } // // public static class OfArray extends ObjectWrapper { // private OfArray(Object[] object) { // super(object); // } // // @Override // public Object[] get() { // return (Object[]) object; // } // // @Override // public String toString() { // return Arrays.deepToString(get()); // } // } // } // Path: src/main/java/com/btk5h/skriptmirror/util/SkriptMirrorUtil.java import ch.njol.skript.Skript; import com.btk5h.skriptmirror.JavaType; import com.btk5h.skriptmirror.Null; import com.btk5h.skriptmirror.ObjectWrapper; import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; package com.btk5h.skriptmirror.util; public class SkriptMirrorUtil { public static final String IDENTIFIER = "[_a-zA-Z$][\\w$]*"; public static final String PACKAGE = "(?:" + IDENTIFIER + "\\.)*(?:" + IDENTIFIER + ")"; private static final Pattern TYPE_PREFIXES = Pattern.compile("^[-*~]*"); public static Class<?> toClassUnwrapJavaTypes(Object o) { if (o instanceof JavaType) { return ((JavaType) o).getJavaClass(); } return getClass(o); } public static String getDebugName(Class<?> cls) { return Skript.logVeryHigh() ? cls.getName() : cls.getSimpleName(); } public static Class<?> getClass(Object o) {
o = ObjectWrapper.unwrapIfNecessary(o);
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/util/SkriptMirrorUtil.java
// Path: src/main/java/com/btk5h/skriptmirror/JavaType.java // public final class JavaType { // private final Class<?> javaClass; // // public JavaType(Class<?> javaClass) { // this.javaClass = javaClass; // } // // public Class<?> getJavaClass() { // return javaClass; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // JavaType javaType1 = (JavaType) o; // return Objects.equals(javaClass, javaType1.javaClass); // } // // @Override // public int hashCode() { // return Objects.hash(javaClass); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/Null.java // public class Null { // private static Null instance = new Null(); // // private Null() {} // // public static Null getInstance() { // return instance; // } // // // } // // Path: src/main/java/com/btk5h/skriptmirror/ObjectWrapper.java // public class ObjectWrapper { // protected Object object; // // private ObjectWrapper(Object object) { // this.object = object; // } // // public static ObjectWrapper create(Object object) { // if (object instanceof ObjectWrapper) { // return (ObjectWrapper) object; // } // // if (object.getClass().isArray()) { // return new OfArray((Object[]) object); // } // // return new ObjectWrapper(object); // } // // public static Object wrapIfNecessary(Object returnedValue, boolean forceWrap) { // Class<?> returnedClass = returnedValue.getClass(); // if (returnedClass.isArray()) { // returnedValue = create(JavaUtil.boxPrimitiveArray(returnedValue)); // } else if (forceWrap || Classes.getSuperClassInfo(returnedClass).getC() == Object.class) { // returnedValue = create(returnedValue); // } // return returnedValue; // } // // public static Object unwrapIfNecessary(Object o) { // if (o instanceof ObjectWrapper) { // return ((ObjectWrapper) o).get(); // } // // return o; // } // // public Object get() { // return object; // } // // @Override // public String toString() { // return object.toString(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // ObjectWrapper that = (ObjectWrapper) o; // return Objects.equals(object, that.object); // } // // @Override // public int hashCode() { // return Objects.hash(object); // } // // public static class OfArray extends ObjectWrapper { // private OfArray(Object[] object) { // super(object); // } // // @Override // public Object[] get() { // return (Object[]) object; // } // // @Override // public String toString() { // return Arrays.deepToString(get()); // } // } // }
import ch.njol.skript.Skript; import com.btk5h.skriptmirror.JavaType; import com.btk5h.skriptmirror.Null; import com.btk5h.skriptmirror.ObjectWrapper; import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors;
public static String processTypes(String part) { if (part.length() > 0) { // copy all prefixes String prefixes = ""; Matcher prefixMatcher = TYPE_PREFIXES.matcher(part); if (prefixMatcher.find()) { prefixes = prefixMatcher.group(); } part = part.substring(prefixes.length()); // copy all suffixes String suffixes = ""; int timeIndex = part.indexOf("@"); if (timeIndex != -1) { suffixes = part.substring(timeIndex); part = part.substring(0, timeIndex); } // replace user input patterns String types = Arrays.stream(part.split("/")) .map(SkriptUtil::replaceUserInputPatterns) .collect(Collectors.joining("/")); return prefixes + types + suffixes; } return part; } public static Object reifyIfNull(Object o) {
// Path: src/main/java/com/btk5h/skriptmirror/JavaType.java // public final class JavaType { // private final Class<?> javaClass; // // public JavaType(Class<?> javaClass) { // this.javaClass = javaClass; // } // // public Class<?> getJavaClass() { // return javaClass; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // JavaType javaType1 = (JavaType) o; // return Objects.equals(javaClass, javaType1.javaClass); // } // // @Override // public int hashCode() { // return Objects.hash(javaClass); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/Null.java // public class Null { // private static Null instance = new Null(); // // private Null() {} // // public static Null getInstance() { // return instance; // } // // // } // // Path: src/main/java/com/btk5h/skriptmirror/ObjectWrapper.java // public class ObjectWrapper { // protected Object object; // // private ObjectWrapper(Object object) { // this.object = object; // } // // public static ObjectWrapper create(Object object) { // if (object instanceof ObjectWrapper) { // return (ObjectWrapper) object; // } // // if (object.getClass().isArray()) { // return new OfArray((Object[]) object); // } // // return new ObjectWrapper(object); // } // // public static Object wrapIfNecessary(Object returnedValue, boolean forceWrap) { // Class<?> returnedClass = returnedValue.getClass(); // if (returnedClass.isArray()) { // returnedValue = create(JavaUtil.boxPrimitiveArray(returnedValue)); // } else if (forceWrap || Classes.getSuperClassInfo(returnedClass).getC() == Object.class) { // returnedValue = create(returnedValue); // } // return returnedValue; // } // // public static Object unwrapIfNecessary(Object o) { // if (o instanceof ObjectWrapper) { // return ((ObjectWrapper) o).get(); // } // // return o; // } // // public Object get() { // return object; // } // // @Override // public String toString() { // return object.toString(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // ObjectWrapper that = (ObjectWrapper) o; // return Objects.equals(object, that.object); // } // // @Override // public int hashCode() { // return Objects.hash(object); // } // // public static class OfArray extends ObjectWrapper { // private OfArray(Object[] object) { // super(object); // } // // @Override // public Object[] get() { // return (Object[]) object; // } // // @Override // public String toString() { // return Arrays.deepToString(get()); // } // } // } // Path: src/main/java/com/btk5h/skriptmirror/util/SkriptMirrorUtil.java import ch.njol.skript.Skript; import com.btk5h.skriptmirror.JavaType; import com.btk5h.skriptmirror.Null; import com.btk5h.skriptmirror.ObjectWrapper; import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; public static String processTypes(String part) { if (part.length() > 0) { // copy all prefixes String prefixes = ""; Matcher prefixMatcher = TYPE_PREFIXES.matcher(part); if (prefixMatcher.find()) { prefixes = prefixMatcher.group(); } part = part.substring(prefixes.length()); // copy all suffixes String suffixes = ""; int timeIndex = part.indexOf("@"); if (timeIndex != -1) { suffixes = part.substring(timeIndex); part = part.substring(0, timeIndex); } // replace user input patterns String types = Arrays.stream(part.split("/")) .map(SkriptUtil::replaceUserInputPatterns) .collect(Collectors.joining("/")); return prefixes + types + suffixes; } return part; } public static Object reifyIfNull(Object o) {
return o == null ? Null.getInstance() : o;
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/custom/ExprParseRegex.java
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // }
import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.skript.util.Utils; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event; import java.util.List; import java.util.regex.MatchResult;
for (int i = 1; i <= groupCount; i++) { groups[i - 1] = match.group(i); } return groups; } return new String[0]; } @Override public boolean isSingle() { return false; } @Override public Class<? extends String> getReturnType() { return String.class; } @Override public String toString(Event e, boolean debug) { return "parser mark"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent(
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/ExprParseRegex.java import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.skript.util.Utils; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event; import java.util.List; import java.util.regex.MatchResult; for (int i = 1; i <= groupCount; i++) { groups[i - 1] = match.group(i); } return groups; } return new String[0]; } @Override public boolean isSingle() { return false; } @Override public Class<? extends String> getReturnType() { return String.class; } @Override public String toString(Event e, boolean debug) { return "parser mark"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent(
EffectTriggerEvent.class,
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/custom/ExprParseRegex.java
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // }
import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.skript.util.Utils; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event; import java.util.List; import java.util.regex.MatchResult;
for (int i = 1; i <= groupCount; i++) { groups[i - 1] = match.group(i); } return groups; } return new String[0]; } @Override public boolean isSingle() { return false; } @Override public Class<? extends String> getReturnType() { return String.class; } @Override public String toString(Event e, boolean debug) { return "parser mark"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class,
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/ExprParseRegex.java import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.skript.util.Utils; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event; import java.util.List; import java.util.regex.MatchResult; for (int i = 1; i <= groupCount; i++) { groups[i - 1] = match.group(i); } return groups; } return new String[0]; } @Override public boolean isSingle() { return false; } @Override public Class<? extends String> getReturnType() { return String.class; } @Override public String toString(Event e, boolean debug) { return "parser mark"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class,
ExpressionGetEvent.class,
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/custom/ExprParseRegex.java
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // }
import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.skript.util.Utils; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event; import java.util.List; import java.util.regex.MatchResult;
groups[i - 1] = match.group(i); } return groups; } return new String[0]; } @Override public boolean isSingle() { return false; } @Override public Class<? extends String> getReturnType() { return String.class; } @Override public String toString(Event e, boolean debug) { return "parser mark"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class, ExpressionGetEvent.class,
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/ExprParseRegex.java import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.skript.util.Utils; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event; import java.util.List; import java.util.regex.MatchResult; groups[i - 1] = match.group(i); } return groups; } return new String[0]; } @Override public boolean isSingle() { return false; } @Override public Class<? extends String> getReturnType() { return String.class; } @Override public String toString(Event e, boolean debug) { return "parser mark"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class, ExpressionGetEvent.class,
ExpressionChangeEvent.class,
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/custom/ExprParseRegex.java
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // }
import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.skript.util.Utils; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event; import java.util.List; import java.util.regex.MatchResult;
} return groups; } return new String[0]; } @Override public boolean isSingle() { return false; } @Override public Class<? extends String> getReturnType() { return String.class; } @Override public String toString(Event e, boolean debug) { return "parser mark"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class, ExpressionGetEvent.class, ExpressionChangeEvent.class,
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/ExprParseRegex.java import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.skript.util.Utils; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event; import java.util.List; import java.util.regex.MatchResult; } return groups; } return new String[0]; } @Override public boolean isSingle() { return false; } @Override public Class<? extends String> getReturnType() { return String.class; } @Override public String toString(Event e, boolean debug) { return "parser mark"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class, ExpressionGetEvent.class, ExpressionChangeEvent.class,
ConditionCheckEvent.class
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/reflect/ExprJavaType.java
// Path: src/main/java/com/btk5h/skriptmirror/JavaType.java // public final class JavaType { // private final Class<?> javaClass; // // public JavaType(Class<?> javaClass) { // this.javaClass = javaClass; // } // // public Class<?> getJavaClass() { // return javaClass; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // JavaType javaType1 = (JavaType) o; // return Objects.equals(javaClass, javaType1.javaClass); // } // // @Override // public int hashCode() { // return Objects.hash(javaClass); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/LibraryLoader.java // public class LibraryLoader { // private static ClassLoader classLoader = LibraryLoader.class.getClassLoader(); // // private static final PathMatcher MATCHER = // FileSystems.getDefault().getPathMatcher("glob:**/*.jar"); // // private static class LibraryVisitor extends SimpleFileVisitor<Path> { // private List<URL> urls = new ArrayList<>(); // // @Override // public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { // if (MATCHER.matches(file)) { // Skript.info("Loaded external library " + file.getFileName()); // urls.add(file.toUri().toURL()); // } // return super.visitFile(file, attrs); // } // // public URL[] getUrls() { // return urls.toArray(new URL[urls.size()]); // } // } // // public static void loadLibraries(Path dataFolder) throws IOException { // if (Files.isDirectory(dataFolder)) { // LibraryVisitor visitor = new LibraryVisitor(); // Files.walkFileTree(dataFolder, visitor); // classLoader = new URLClassLoader(visitor.getUrls(), LibraryLoader.class.getClassLoader()); // } else { // Files.createDirectory(dataFolder); // } // } // // public static ClassLoader getClassLoader() { // return classLoader; // } // }
import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.JavaType; import com.btk5h.skriptmirror.LibraryLoader; import org.bukkit.event.Event;
package com.btk5h.skriptmirror.skript.reflect; public class ExprJavaType extends SimpleExpression<JavaType> { static { Skript.registerExpression(ExprJavaType.class, JavaType.class, ExpressionType.COMBINED, "[the] [java] class %string%"); } private Expression<String> className; @Override protected JavaType[] get(Event e) { String cls = className.getSingle(e); if (cls == null) { return null; } try {
// Path: src/main/java/com/btk5h/skriptmirror/JavaType.java // public final class JavaType { // private final Class<?> javaClass; // // public JavaType(Class<?> javaClass) { // this.javaClass = javaClass; // } // // public Class<?> getJavaClass() { // return javaClass; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // JavaType javaType1 = (JavaType) o; // return Objects.equals(javaClass, javaType1.javaClass); // } // // @Override // public int hashCode() { // return Objects.hash(javaClass); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/LibraryLoader.java // public class LibraryLoader { // private static ClassLoader classLoader = LibraryLoader.class.getClassLoader(); // // private static final PathMatcher MATCHER = // FileSystems.getDefault().getPathMatcher("glob:**/*.jar"); // // private static class LibraryVisitor extends SimpleFileVisitor<Path> { // private List<URL> urls = new ArrayList<>(); // // @Override // public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { // if (MATCHER.matches(file)) { // Skript.info("Loaded external library " + file.getFileName()); // urls.add(file.toUri().toURL()); // } // return super.visitFile(file, attrs); // } // // public URL[] getUrls() { // return urls.toArray(new URL[urls.size()]); // } // } // // public static void loadLibraries(Path dataFolder) throws IOException { // if (Files.isDirectory(dataFolder)) { // LibraryVisitor visitor = new LibraryVisitor(); // Files.walkFileTree(dataFolder, visitor); // classLoader = new URLClassLoader(visitor.getUrls(), LibraryLoader.class.getClassLoader()); // } else { // Files.createDirectory(dataFolder); // } // } // // public static ClassLoader getClassLoader() { // return classLoader; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/reflect/ExprJavaType.java import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.JavaType; import com.btk5h.skriptmirror.LibraryLoader; import org.bukkit.event.Event; package com.btk5h.skriptmirror.skript.reflect; public class ExprJavaType extends SimpleExpression<JavaType> { static { Skript.registerExpression(ExprJavaType.class, JavaType.class, ExpressionType.COMBINED, "[the] [java] class %string%"); } private Expression<String> className; @Override protected JavaType[] get(Event e) { String cls = className.getSingle(e); if (cls == null) { return null; } try {
return new JavaType[]{new JavaType(LibraryLoader.getClassLoader().loadClass(cls))};
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/custom/ExprMatchedPattern.java
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // }
import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event;
package com.btk5h.skriptmirror.skript.custom; public class ExprMatchedPattern extends SimpleExpression<Number> { static { Skript.registerExpression(ExprMatchedPattern.class, Number.class, ExpressionType.SIMPLE, "[the] [matched] pattern"); } @Override protected Number[] get(Event e) { return new Number[]{((CustomSyntaxEvent) e).getMatchedPattern()}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Number> getReturnType() { return Number.class; } @Override public String toString(Event e, boolean debug) { return "matched pattern"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent(
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/ExprMatchedPattern.java import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event; package com.btk5h.skriptmirror.skript.custom; public class ExprMatchedPattern extends SimpleExpression<Number> { static { Skript.registerExpression(ExprMatchedPattern.class, Number.class, ExpressionType.SIMPLE, "[the] [matched] pattern"); } @Override protected Number[] get(Event e) { return new Number[]{((CustomSyntaxEvent) e).getMatchedPattern()}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Number> getReturnType() { return Number.class; } @Override public String toString(Event e, boolean debug) { return "matched pattern"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent(
EffectTriggerEvent.class,
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/custom/ExprMatchedPattern.java
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // }
import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event;
package com.btk5h.skriptmirror.skript.custom; public class ExprMatchedPattern extends SimpleExpression<Number> { static { Skript.registerExpression(ExprMatchedPattern.class, Number.class, ExpressionType.SIMPLE, "[the] [matched] pattern"); } @Override protected Number[] get(Event e) { return new Number[]{((CustomSyntaxEvent) e).getMatchedPattern()}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Number> getReturnType() { return Number.class; } @Override public String toString(Event e, boolean debug) { return "matched pattern"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class,
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/ExprMatchedPattern.java import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event; package com.btk5h.skriptmirror.skript.custom; public class ExprMatchedPattern extends SimpleExpression<Number> { static { Skript.registerExpression(ExprMatchedPattern.class, Number.class, ExpressionType.SIMPLE, "[the] [matched] pattern"); } @Override protected Number[] get(Event e) { return new Number[]{((CustomSyntaxEvent) e).getMatchedPattern()}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Number> getReturnType() { return Number.class; } @Override public String toString(Event e, boolean debug) { return "matched pattern"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class,
ExpressionGetEvent.class,
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/custom/ExprMatchedPattern.java
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // }
import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event;
package com.btk5h.skriptmirror.skript.custom; public class ExprMatchedPattern extends SimpleExpression<Number> { static { Skript.registerExpression(ExprMatchedPattern.class, Number.class, ExpressionType.SIMPLE, "[the] [matched] pattern"); } @Override protected Number[] get(Event e) { return new Number[]{((CustomSyntaxEvent) e).getMatchedPattern()}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Number> getReturnType() { return Number.class; } @Override public String toString(Event e, boolean debug) { return "matched pattern"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class, ExpressionGetEvent.class,
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/ExprMatchedPattern.java import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event; package com.btk5h.skriptmirror.skript.custom; public class ExprMatchedPattern extends SimpleExpression<Number> { static { Skript.registerExpression(ExprMatchedPattern.class, Number.class, ExpressionType.SIMPLE, "[the] [matched] pattern"); } @Override protected Number[] get(Event e) { return new Number[]{((CustomSyntaxEvent) e).getMatchedPattern()}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Number> getReturnType() { return Number.class; } @Override public String toString(Event e, boolean debug) { return "matched pattern"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class, ExpressionGetEvent.class,
ExpressionChangeEvent.class,
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/custom/ExprMatchedPattern.java
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // }
import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event;
package com.btk5h.skriptmirror.skript.custom; public class ExprMatchedPattern extends SimpleExpression<Number> { static { Skript.registerExpression(ExprMatchedPattern.class, Number.class, ExpressionType.SIMPLE, "[the] [matched] pattern"); } @Override protected Number[] get(Event e) { return new Number[]{((CustomSyntaxEvent) e).getMatchedPattern()}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Number> getReturnType() { return Number.class; } @Override public String toString(Event e, boolean debug) { return "matched pattern"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class, ExpressionGetEvent.class, ExpressionChangeEvent.class,
// Path: src/main/java/com/btk5h/skriptmirror/skript/custom/condition/ConditionCheckEvent.java // public class ConditionCheckEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private boolean markedContinue; // private boolean markedNegated; // // public ConditionCheckEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public boolean isMarkedContinue() { // return markedContinue; // } // // public boolean isMarkedNegated() { // return markedNegated; // } // // public void markContinue() { // markedContinue = true; // } // // public void markNegated() { // markedNegated = true; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/effect/EffectTriggerEvent.java // public class EffectTriggerEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final String which; // private final TriggerItem next; // private boolean sync = true; // // public EffectTriggerEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, String which, TriggerItem next) { // super(event, expressions, matchedPattern, parseResult); // this.which = which; // this.next = next; // } // // public String getWhich() { // return which; // } // // public TriggerItem getNext() { // return next; // } // // public boolean isSync() { // return sync; // } // // public void setSync(boolean sync) { // this.sync = sync; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionChangeEvent.java // public class ExpressionChangeEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private final Object[] delta; // // public ExpressionChangeEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult, Object[] delta) { // super(event, expressions, matchedPattern, parseResult); // this.delta = delta; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getDelta() { // return delta; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/expression/ExpressionGetEvent.java // public class ExpressionGetEvent extends CustomSyntaxEvent { // private final static HandlerList handlers = new HandlerList(); // private Object[] output; // // public ExpressionGetEvent(Event event, Expression<?>[] expressions, int matchedPattern, // SkriptParser.ParseResult parseResult) { // super(event, expressions, matchedPattern, parseResult); // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public Object[] getOutput() { // return output; // } // // public void setOutput(Object[] output) { // this.output = output; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/custom/ExprMatchedPattern.java import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.skript.custom.condition.ConditionCheckEvent; import com.btk5h.skriptmirror.skript.custom.effect.EffectTriggerEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionChangeEvent; import com.btk5h.skriptmirror.skript.custom.expression.ExpressionGetEvent; import org.bukkit.event.Event; package com.btk5h.skriptmirror.skript.custom; public class ExprMatchedPattern extends SimpleExpression<Number> { static { Skript.registerExpression(ExprMatchedPattern.class, Number.class, ExpressionType.SIMPLE, "[the] [matched] pattern"); } @Override protected Number[] get(Event e) { return new Number[]{((CustomSyntaxEvent) e).getMatchedPattern()}; } @Override public boolean isSingle() { return true; } @Override public Class<? extends Number> getReturnType() { return Number.class; } @Override public String toString(Event e, boolean debug) { return "matched pattern"; } @SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent( EffectTriggerEvent.class, ExpressionGetEvent.class, ExpressionChangeEvent.class,
ConditionCheckEvent.class
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/reflect/EvtByReflection.java
// Path: src/main/java/com/btk5h/skriptmirror/JavaType.java // public final class JavaType { // private final Class<?> javaClass; // // public JavaType(Class<?> javaClass) { // this.javaClass = javaClass; // } // // public Class<?> getJavaClass() { // return javaClass; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // JavaType javaType1 = (JavaType) o; // return Objects.equals(javaClass, javaType1.javaClass); // } // // @Override // public int hashCode() { // return Objects.hash(javaClass); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/SkriptMirror.java // public class SkriptMirror extends JavaPlugin { // private static SkriptMirror instance; // private static SkriptAddon addonInstance; // // public SkriptMirror() { // if (instance == null) { // instance = this; // } else { // throw new IllegalStateException(); // } // } // // @Override // public void onEnable() { // try { // getAddonInstance().loadClasses("com.btk5h.skriptmirror.skript"); // // Path dataFolder = SkriptMirror.getInstance().getDataFolder().toPath(); // LibraryLoader.loadLibraries(dataFolder); // // ParseOrderWorkarounds.reorderSyntax(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // public static SkriptAddon getAddonInstance() { // if (addonInstance == null) { // addonInstance = Skript.registerAddon(getInstance()) // .setLanguageFileDirectory("lang"); // } // return addonInstance; // } // // public static SkriptMirror getInstance() { // if (instance == null) { // throw new IllegalStateException(); // } // return instance; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/WrappedEvent.java // public abstract class WrappedEvent extends Event { // private final Event event; // // protected WrappedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event instanceof WrappedEvent ? ((WrappedEvent) event).getEvent() : event; // } // // public Event getDirectEvent() { // return event; // } // }
import ch.njol.skript.Skript; import ch.njol.skript.SkriptConfig; import ch.njol.skript.lang.Literal; import ch.njol.skript.lang.SkriptEvent; import ch.njol.skript.lang.SkriptParser; import com.btk5h.skriptmirror.JavaType; import com.btk5h.skriptmirror.SkriptMirror; import com.btk5h.skriptmirror.WrappedEvent; import org.bukkit.Bukkit; import org.bukkit.event.*; import org.bukkit.plugin.EventExecutor; import java.util.Arrays; import java.util.HashSet; import java.util.Set;
package com.btk5h.skriptmirror.skript.reflect; public class EvtByReflection extends SkriptEvent { static { Skript.registerEvent("Bukkit Event", EvtByReflection.class, BukkitEvent.class, "[(1¦all)] %javatypes% [(at|on|with) priority <.+>]"); } private static class PriorityListener implements Listener { private EventPriority priority; private Set<Class<? extends Event>> events = new HashSet<>(); public PriorityListener(int priority) { this.priority = EventPriority.values()[priority]; } public EventPriority getPriority() { return priority; } public Set<Class<? extends Event>> getEvents() { return events; } } private static EventExecutor executor = (listener, event) -> Bukkit.getPluginManager() .callEvent(new BukkitEvent(event, ((PriorityListener) listener).getPriority())); private static PriorityListener[] listeners; static { listeners = Arrays.stream(EventPriority.values()) .mapToInt(EventPriority::ordinal) .mapToObj(PriorityListener::new) .toArray(PriorityListener[]::new); }
// Path: src/main/java/com/btk5h/skriptmirror/JavaType.java // public final class JavaType { // private final Class<?> javaClass; // // public JavaType(Class<?> javaClass) { // this.javaClass = javaClass; // } // // public Class<?> getJavaClass() { // return javaClass; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // JavaType javaType1 = (JavaType) o; // return Objects.equals(javaClass, javaType1.javaClass); // } // // @Override // public int hashCode() { // return Objects.hash(javaClass); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/SkriptMirror.java // public class SkriptMirror extends JavaPlugin { // private static SkriptMirror instance; // private static SkriptAddon addonInstance; // // public SkriptMirror() { // if (instance == null) { // instance = this; // } else { // throw new IllegalStateException(); // } // } // // @Override // public void onEnable() { // try { // getAddonInstance().loadClasses("com.btk5h.skriptmirror.skript"); // // Path dataFolder = SkriptMirror.getInstance().getDataFolder().toPath(); // LibraryLoader.loadLibraries(dataFolder); // // ParseOrderWorkarounds.reorderSyntax(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // public static SkriptAddon getAddonInstance() { // if (addonInstance == null) { // addonInstance = Skript.registerAddon(getInstance()) // .setLanguageFileDirectory("lang"); // } // return addonInstance; // } // // public static SkriptMirror getInstance() { // if (instance == null) { // throw new IllegalStateException(); // } // return instance; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/WrappedEvent.java // public abstract class WrappedEvent extends Event { // private final Event event; // // protected WrappedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event instanceof WrappedEvent ? ((WrappedEvent) event).getEvent() : event; // } // // public Event getDirectEvent() { // return event; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/reflect/EvtByReflection.java import ch.njol.skript.Skript; import ch.njol.skript.SkriptConfig; import ch.njol.skript.lang.Literal; import ch.njol.skript.lang.SkriptEvent; import ch.njol.skript.lang.SkriptParser; import com.btk5h.skriptmirror.JavaType; import com.btk5h.skriptmirror.SkriptMirror; import com.btk5h.skriptmirror.WrappedEvent; import org.bukkit.Bukkit; import org.bukkit.event.*; import org.bukkit.plugin.EventExecutor; import java.util.Arrays; import java.util.HashSet; import java.util.Set; package com.btk5h.skriptmirror.skript.reflect; public class EvtByReflection extends SkriptEvent { static { Skript.registerEvent("Bukkit Event", EvtByReflection.class, BukkitEvent.class, "[(1¦all)] %javatypes% [(at|on|with) priority <.+>]"); } private static class PriorityListener implements Listener { private EventPriority priority; private Set<Class<? extends Event>> events = new HashSet<>(); public PriorityListener(int priority) { this.priority = EventPriority.values()[priority]; } public EventPriority getPriority() { return priority; } public Set<Class<? extends Event>> getEvents() { return events; } } private static EventExecutor executor = (listener, event) -> Bukkit.getPluginManager() .callEvent(new BukkitEvent(event, ((PriorityListener) listener).getPriority())); private static PriorityListener[] listeners; static { listeners = Arrays.stream(EventPriority.values()) .mapToInt(EventPriority::ordinal) .mapToObj(PriorityListener::new) .toArray(PriorityListener[]::new); }
private static class BukkitEvent extends WrappedEvent implements Cancellable {
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/reflect/EvtByReflection.java
// Path: src/main/java/com/btk5h/skriptmirror/JavaType.java // public final class JavaType { // private final Class<?> javaClass; // // public JavaType(Class<?> javaClass) { // this.javaClass = javaClass; // } // // public Class<?> getJavaClass() { // return javaClass; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // JavaType javaType1 = (JavaType) o; // return Objects.equals(javaClass, javaType1.javaClass); // } // // @Override // public int hashCode() { // return Objects.hash(javaClass); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/SkriptMirror.java // public class SkriptMirror extends JavaPlugin { // private static SkriptMirror instance; // private static SkriptAddon addonInstance; // // public SkriptMirror() { // if (instance == null) { // instance = this; // } else { // throw new IllegalStateException(); // } // } // // @Override // public void onEnable() { // try { // getAddonInstance().loadClasses("com.btk5h.skriptmirror.skript"); // // Path dataFolder = SkriptMirror.getInstance().getDataFolder().toPath(); // LibraryLoader.loadLibraries(dataFolder); // // ParseOrderWorkarounds.reorderSyntax(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // public static SkriptAddon getAddonInstance() { // if (addonInstance == null) { // addonInstance = Skript.registerAddon(getInstance()) // .setLanguageFileDirectory("lang"); // } // return addonInstance; // } // // public static SkriptMirror getInstance() { // if (instance == null) { // throw new IllegalStateException(); // } // return instance; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/WrappedEvent.java // public abstract class WrappedEvent extends Event { // private final Event event; // // protected WrappedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event instanceof WrappedEvent ? ((WrappedEvent) event).getEvent() : event; // } // // public Event getDirectEvent() { // return event; // } // }
import ch.njol.skript.Skript; import ch.njol.skript.SkriptConfig; import ch.njol.skript.lang.Literal; import ch.njol.skript.lang.SkriptEvent; import ch.njol.skript.lang.SkriptParser; import com.btk5h.skriptmirror.JavaType; import com.btk5h.skriptmirror.SkriptMirror; import com.btk5h.skriptmirror.WrappedEvent; import org.bukkit.Bukkit; import org.bukkit.event.*; import org.bukkit.plugin.EventExecutor; import java.util.Arrays; import java.util.HashSet; import java.util.Set;
return handlers; } @Override public HandlerList getHandlers() { return handlers; } @Override public boolean isCancelled() { Event event = getEvent(); return getEvent() instanceof Cancellable && ((Cancellable) event).isCancelled(); } @Override public void setCancelled(boolean cancel) { Event event = getEvent(); if (event instanceof Cancellable) { ((Cancellable) event).setCancelled(cancel); } } } private static void registerEvent(Class<? extends Event> event, EventPriority priority, boolean ignoreCancelled) { PriorityListener listener = listeners[priority.ordinal()]; Set<Class<? extends Event>> events = listener.getEvents(); if (!events.contains(event)) { events.add(event); Bukkit.getPluginManager()
// Path: src/main/java/com/btk5h/skriptmirror/JavaType.java // public final class JavaType { // private final Class<?> javaClass; // // public JavaType(Class<?> javaClass) { // this.javaClass = javaClass; // } // // public Class<?> getJavaClass() { // return javaClass; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // JavaType javaType1 = (JavaType) o; // return Objects.equals(javaClass, javaType1.javaClass); // } // // @Override // public int hashCode() { // return Objects.hash(javaClass); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/SkriptMirror.java // public class SkriptMirror extends JavaPlugin { // private static SkriptMirror instance; // private static SkriptAddon addonInstance; // // public SkriptMirror() { // if (instance == null) { // instance = this; // } else { // throw new IllegalStateException(); // } // } // // @Override // public void onEnable() { // try { // getAddonInstance().loadClasses("com.btk5h.skriptmirror.skript"); // // Path dataFolder = SkriptMirror.getInstance().getDataFolder().toPath(); // LibraryLoader.loadLibraries(dataFolder); // // ParseOrderWorkarounds.reorderSyntax(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // public static SkriptAddon getAddonInstance() { // if (addonInstance == null) { // addonInstance = Skript.registerAddon(getInstance()) // .setLanguageFileDirectory("lang"); // } // return addonInstance; // } // // public static SkriptMirror getInstance() { // if (instance == null) { // throw new IllegalStateException(); // } // return instance; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/WrappedEvent.java // public abstract class WrappedEvent extends Event { // private final Event event; // // protected WrappedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event instanceof WrappedEvent ? ((WrappedEvent) event).getEvent() : event; // } // // public Event getDirectEvent() { // return event; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/reflect/EvtByReflection.java import ch.njol.skript.Skript; import ch.njol.skript.SkriptConfig; import ch.njol.skript.lang.Literal; import ch.njol.skript.lang.SkriptEvent; import ch.njol.skript.lang.SkriptParser; import com.btk5h.skriptmirror.JavaType; import com.btk5h.skriptmirror.SkriptMirror; import com.btk5h.skriptmirror.WrappedEvent; import org.bukkit.Bukkit; import org.bukkit.event.*; import org.bukkit.plugin.EventExecutor; import java.util.Arrays; import java.util.HashSet; import java.util.Set; return handlers; } @Override public HandlerList getHandlers() { return handlers; } @Override public boolean isCancelled() { Event event = getEvent(); return getEvent() instanceof Cancellable && ((Cancellable) event).isCancelled(); } @Override public void setCancelled(boolean cancel) { Event event = getEvent(); if (event instanceof Cancellable) { ((Cancellable) event).setCancelled(cancel); } } } private static void registerEvent(Class<? extends Event> event, EventPriority priority, boolean ignoreCancelled) { PriorityListener listener = listeners[priority.ordinal()]; Set<Class<? extends Event>> events = listener.getEvents(); if (!events.contains(event)) { events.add(event); Bukkit.getPluginManager()
.registerEvent(event, listener, priority, executor, SkriptMirror.getInstance(), ignoreCancelled);
btk5h/skript-mirror
src/main/java/com/btk5h/skriptmirror/skript/reflect/EvtByReflection.java
// Path: src/main/java/com/btk5h/skriptmirror/JavaType.java // public final class JavaType { // private final Class<?> javaClass; // // public JavaType(Class<?> javaClass) { // this.javaClass = javaClass; // } // // public Class<?> getJavaClass() { // return javaClass; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // JavaType javaType1 = (JavaType) o; // return Objects.equals(javaClass, javaType1.javaClass); // } // // @Override // public int hashCode() { // return Objects.hash(javaClass); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/SkriptMirror.java // public class SkriptMirror extends JavaPlugin { // private static SkriptMirror instance; // private static SkriptAddon addonInstance; // // public SkriptMirror() { // if (instance == null) { // instance = this; // } else { // throw new IllegalStateException(); // } // } // // @Override // public void onEnable() { // try { // getAddonInstance().loadClasses("com.btk5h.skriptmirror.skript"); // // Path dataFolder = SkriptMirror.getInstance().getDataFolder().toPath(); // LibraryLoader.loadLibraries(dataFolder); // // ParseOrderWorkarounds.reorderSyntax(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // public static SkriptAddon getAddonInstance() { // if (addonInstance == null) { // addonInstance = Skript.registerAddon(getInstance()) // .setLanguageFileDirectory("lang"); // } // return addonInstance; // } // // public static SkriptMirror getInstance() { // if (instance == null) { // throw new IllegalStateException(); // } // return instance; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/WrappedEvent.java // public abstract class WrappedEvent extends Event { // private final Event event; // // protected WrappedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event instanceof WrappedEvent ? ((WrappedEvent) event).getEvent() : event; // } // // public Event getDirectEvent() { // return event; // } // }
import ch.njol.skript.Skript; import ch.njol.skript.SkriptConfig; import ch.njol.skript.lang.Literal; import ch.njol.skript.lang.SkriptEvent; import ch.njol.skript.lang.SkriptParser; import com.btk5h.skriptmirror.JavaType; import com.btk5h.skriptmirror.SkriptMirror; import com.btk5h.skriptmirror.WrappedEvent; import org.bukkit.Bukkit; import org.bukkit.event.*; import org.bukkit.plugin.EventExecutor; import java.util.Arrays; import java.util.HashSet; import java.util.Set;
Event event = getEvent(); return getEvent() instanceof Cancellable && ((Cancellable) event).isCancelled(); } @Override public void setCancelled(boolean cancel) { Event event = getEvent(); if (event instanceof Cancellable) { ((Cancellable) event).setCancelled(cancel); } } } private static void registerEvent(Class<? extends Event> event, EventPriority priority, boolean ignoreCancelled) { PriorityListener listener = listeners[priority.ordinal()]; Set<Class<? extends Event>> events = listener.getEvents(); if (!events.contains(event)) { events.add(event); Bukkit.getPluginManager() .registerEvent(event, listener, priority, executor, SkriptMirror.getInstance(), ignoreCancelled); } } private Class<? extends Event>[] classes; private EventPriority priority; @SuppressWarnings("unchecked") @Override public boolean init(Literal<?>[] args, int matchedPattern, SkriptParser.ParseResult parseResult) {
// Path: src/main/java/com/btk5h/skriptmirror/JavaType.java // public final class JavaType { // private final Class<?> javaClass; // // public JavaType(Class<?> javaClass) { // this.javaClass = javaClass; // } // // public Class<?> getJavaClass() { // return javaClass; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // JavaType javaType1 = (JavaType) o; // return Objects.equals(javaClass, javaType1.javaClass); // } // // @Override // public int hashCode() { // return Objects.hash(javaClass); // } // } // // Path: src/main/java/com/btk5h/skriptmirror/SkriptMirror.java // public class SkriptMirror extends JavaPlugin { // private static SkriptMirror instance; // private static SkriptAddon addonInstance; // // public SkriptMirror() { // if (instance == null) { // instance = this; // } else { // throw new IllegalStateException(); // } // } // // @Override // public void onEnable() { // try { // getAddonInstance().loadClasses("com.btk5h.skriptmirror.skript"); // // Path dataFolder = SkriptMirror.getInstance().getDataFolder().toPath(); // LibraryLoader.loadLibraries(dataFolder); // // ParseOrderWorkarounds.reorderSyntax(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // public static SkriptAddon getAddonInstance() { // if (addonInstance == null) { // addonInstance = Skript.registerAddon(getInstance()) // .setLanguageFileDirectory("lang"); // } // return addonInstance; // } // // public static SkriptMirror getInstance() { // if (instance == null) { // throw new IllegalStateException(); // } // return instance; // } // } // // Path: src/main/java/com/btk5h/skriptmirror/WrappedEvent.java // public abstract class WrappedEvent extends Event { // private final Event event; // // protected WrappedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event instanceof WrappedEvent ? ((WrappedEvent) event).getEvent() : event; // } // // public Event getDirectEvent() { // return event; // } // } // Path: src/main/java/com/btk5h/skriptmirror/skript/reflect/EvtByReflection.java import ch.njol.skript.Skript; import ch.njol.skript.SkriptConfig; import ch.njol.skript.lang.Literal; import ch.njol.skript.lang.SkriptEvent; import ch.njol.skript.lang.SkriptParser; import com.btk5h.skriptmirror.JavaType; import com.btk5h.skriptmirror.SkriptMirror; import com.btk5h.skriptmirror.WrappedEvent; import org.bukkit.Bukkit; import org.bukkit.event.*; import org.bukkit.plugin.EventExecutor; import java.util.Arrays; import java.util.HashSet; import java.util.Set; Event event = getEvent(); return getEvent() instanceof Cancellable && ((Cancellable) event).isCancelled(); } @Override public void setCancelled(boolean cancel) { Event event = getEvent(); if (event instanceof Cancellable) { ((Cancellable) event).setCancelled(cancel); } } } private static void registerEvent(Class<? extends Event> event, EventPriority priority, boolean ignoreCancelled) { PriorityListener listener = listeners[priority.ordinal()]; Set<Class<? extends Event>> events = listener.getEvents(); if (!events.contains(event)) { events.add(event); Bukkit.getPluginManager() .registerEvent(event, listener, priority, executor, SkriptMirror.getInstance(), ignoreCancelled); } } private Class<? extends Event>[] classes; private EventPriority priority; @SuppressWarnings("unchecked") @Override public boolean init(Literal<?>[] args, int matchedPattern, SkriptParser.ParseResult parseResult) {
classes = Arrays.stream(((Literal<JavaType>) args[0]).getArray())
osgi/osgi.enroute
examples/microservice/rest-service/src/main/java/org/osgi/enroute/examples/microservice/rest/RestComponentImpl.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java // @ProviderType // public interface PersonDao { // // public List<PersonDTO> select(); // // public PersonDTO findByPK(Long pk) ; // // public Long save(PersonDTO data); // // public void update(PersonDTO data); // // public void delete(Long pk) ; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // }
import java.util.List; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.osgi.enroute.examples.microservice.dao.PersonDao; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardResource; import org.osgi.service.jaxrs.whiteboard.propertytypes.JSONRequired; import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource;
package org.osgi.enroute.examples.microservice.rest; @Component(service=RestComponentImpl.class) @JaxrsResource @Path("person") @Produces(MediaType.APPLICATION_JSON) @JSONRequired @HttpWhiteboardResource(pattern="/microservice/*", prefix="static") public class RestComponentImpl { @Reference
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java // @ProviderType // public interface PersonDao { // // public List<PersonDTO> select(); // // public PersonDTO findByPK(Long pk) ; // // public Long save(PersonDTO data); // // public void update(PersonDTO data); // // public void delete(Long pk) ; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // } // Path: examples/microservice/rest-service/src/main/java/org/osgi/enroute/examples/microservice/rest/RestComponentImpl.java import java.util.List; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.osgi.enroute.examples.microservice.dao.PersonDao; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardResource; import org.osgi.service.jaxrs.whiteboard.propertytypes.JSONRequired; import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource; package org.osgi.enroute.examples.microservice.rest; @Component(service=RestComponentImpl.class) @JaxrsResource @Path("person") @Produces(MediaType.APPLICATION_JSON) @JSONRequired @HttpWhiteboardResource(pattern="/microservice/*", prefix="static") public class RestComponentImpl { @Reference
private PersonDao personDao;
osgi/osgi.enroute
examples/microservice/rest-service/src/main/java/org/osgi/enroute/examples/microservice/rest/RestComponentImpl.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java // @ProviderType // public interface PersonDao { // // public List<PersonDTO> select(); // // public PersonDTO findByPK(Long pk) ; // // public Long save(PersonDTO data); // // public void update(PersonDTO data); // // public void delete(Long pk) ; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // }
import java.util.List; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.osgi.enroute.examples.microservice.dao.PersonDao; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardResource; import org.osgi.service.jaxrs.whiteboard.propertytypes.JSONRequired; import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource;
package org.osgi.enroute.examples.microservice.rest; @Component(service=RestComponentImpl.class) @JaxrsResource @Path("person") @Produces(MediaType.APPLICATION_JSON) @JSONRequired @HttpWhiteboardResource(pattern="/microservice/*", prefix="static") public class RestComponentImpl { @Reference private PersonDao personDao; @GET @Path("{person}")
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java // @ProviderType // public interface PersonDao { // // public List<PersonDTO> select(); // // public PersonDTO findByPK(Long pk) ; // // public Long save(PersonDTO data); // // public void update(PersonDTO data); // // public void delete(Long pk) ; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // } // Path: examples/microservice/rest-service/src/main/java/org/osgi/enroute/examples/microservice/rest/RestComponentImpl.java import java.util.List; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.osgi.enroute.examples.microservice.dao.PersonDao; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardResource; import org.osgi.service.jaxrs.whiteboard.propertytypes.JSONRequired; import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource; package org.osgi.enroute.examples.microservice.rest; @Component(service=RestComponentImpl.class) @JaxrsResource @Path("person") @Produces(MediaType.APPLICATION_JSON) @JSONRequired @HttpWhiteboardResource(pattern="/microservice/*", prefix="static") public class RestComponentImpl { @Reference private PersonDao personDao; @GET @Path("{person}")
public PersonDTO getPerson(@PathParam("person") Long personId) {
osgi/osgi.enroute
examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/PersonDaoImpl.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java // @ProviderType // public interface PersonDao { // // public List<PersonDTO> select(); // // public PersonDTO findByPK(Long pk) ; // // public Long save(PersonDTO data); // // public void update(PersonDTO data); // // public void delete(Long pk) ; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // } // // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/PersonEntity.java // @Entity // @Table(name="persons") // public class PersonEntity { // // @GeneratedValue(strategy = IDENTITY) // @Id // @Column(name="person_id") // private Long personId; // // @Column(name="first_name") // private String firstName; // // @Column(name="last_name") // private String lastName; // // @OneToMany(mappedBy="person", cascade=ALL) // private List<AddressEntity> addresses = new ArrayList<>(); // // public Long getPersonId() { // return personId; // } // // public PersonDTO toDTO() { // PersonDTO dto = new PersonDTO(); // dto.personId = personId; // dto.firstName = firstName; // dto.lastName = lastName; // dto.addresses = addresses.stream() // .map(AddressEntity::toDTO) // .collect(toList()); // return dto; // } // // public static PersonEntity fromDTO(PersonDTO dto) { // PersonEntity entity = new PersonEntity(); // if(dto.personId != 0) { // entity.personId = Long.valueOf(dto.personId); // } // entity.firstName = dto.firstName; // entity.lastName = dto.lastName; // entity.addresses = dto.addresses.stream() // .map(a -> AddressEntity.fromDTO(entity, a)) // .collect(toList()); // // return entity; // } // }
import static java.util.stream.Collectors.toList; import java.sql.SQLException; import java.util.List; import java.util.Map; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaDelete; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import org.osgi.enroute.examples.microservice.dao.PersonDao; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; import org.osgi.enroute.examples.microservice.dao.impl.jpa.entities.PersonEntity; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.transaction.control.TransactionControl; import org.osgi.service.transaction.control.jpa.JPAEntityManagerProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package org.osgi.enroute.examples.microservice.dao.impl.jpa; @Component public class PersonDaoImpl implements PersonDao { private static final Logger logger = LoggerFactory.getLogger(PersonDaoImpl.class); @Reference TransactionControl transactionControl; @Reference(name="provider") JPAEntityManagerProvider jpaEntityManagerProvider; EntityManager em; @Activate void activate(Map<String, Object> props) throws SQLException { em = jpaEntityManagerProvider.getResource(transactionControl); } @Override
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java // @ProviderType // public interface PersonDao { // // public List<PersonDTO> select(); // // public PersonDTO findByPK(Long pk) ; // // public Long save(PersonDTO data); // // public void update(PersonDTO data); // // public void delete(Long pk) ; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // } // // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/PersonEntity.java // @Entity // @Table(name="persons") // public class PersonEntity { // // @GeneratedValue(strategy = IDENTITY) // @Id // @Column(name="person_id") // private Long personId; // // @Column(name="first_name") // private String firstName; // // @Column(name="last_name") // private String lastName; // // @OneToMany(mappedBy="person", cascade=ALL) // private List<AddressEntity> addresses = new ArrayList<>(); // // public Long getPersonId() { // return personId; // } // // public PersonDTO toDTO() { // PersonDTO dto = new PersonDTO(); // dto.personId = personId; // dto.firstName = firstName; // dto.lastName = lastName; // dto.addresses = addresses.stream() // .map(AddressEntity::toDTO) // .collect(toList()); // return dto; // } // // public static PersonEntity fromDTO(PersonDTO dto) { // PersonEntity entity = new PersonEntity(); // if(dto.personId != 0) { // entity.personId = Long.valueOf(dto.personId); // } // entity.firstName = dto.firstName; // entity.lastName = dto.lastName; // entity.addresses = dto.addresses.stream() // .map(a -> AddressEntity.fromDTO(entity, a)) // .collect(toList()); // // return entity; // } // } // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/PersonDaoImpl.java import static java.util.stream.Collectors.toList; import java.sql.SQLException; import java.util.List; import java.util.Map; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaDelete; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import org.osgi.enroute.examples.microservice.dao.PersonDao; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; import org.osgi.enroute.examples.microservice.dao.impl.jpa.entities.PersonEntity; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.transaction.control.TransactionControl; import org.osgi.service.transaction.control.jpa.JPAEntityManagerProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; package org.osgi.enroute.examples.microservice.dao.impl.jpa; @Component public class PersonDaoImpl implements PersonDao { private static final Logger logger = LoggerFactory.getLogger(PersonDaoImpl.class); @Reference TransactionControl transactionControl; @Reference(name="provider") JPAEntityManagerProvider jpaEntityManagerProvider; EntityManager em; @Activate void activate(Map<String, Object> props) throws SQLException { em = jpaEntityManagerProvider.getResource(transactionControl); } @Override
public List<PersonDTO> select() {
osgi/osgi.enroute
examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/PersonDaoImpl.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java // @ProviderType // public interface PersonDao { // // public List<PersonDTO> select(); // // public PersonDTO findByPK(Long pk) ; // // public Long save(PersonDTO data); // // public void update(PersonDTO data); // // public void delete(Long pk) ; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // } // // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/PersonEntity.java // @Entity // @Table(name="persons") // public class PersonEntity { // // @GeneratedValue(strategy = IDENTITY) // @Id // @Column(name="person_id") // private Long personId; // // @Column(name="first_name") // private String firstName; // // @Column(name="last_name") // private String lastName; // // @OneToMany(mappedBy="person", cascade=ALL) // private List<AddressEntity> addresses = new ArrayList<>(); // // public Long getPersonId() { // return personId; // } // // public PersonDTO toDTO() { // PersonDTO dto = new PersonDTO(); // dto.personId = personId; // dto.firstName = firstName; // dto.lastName = lastName; // dto.addresses = addresses.stream() // .map(AddressEntity::toDTO) // .collect(toList()); // return dto; // } // // public static PersonEntity fromDTO(PersonDTO dto) { // PersonEntity entity = new PersonEntity(); // if(dto.personId != 0) { // entity.personId = Long.valueOf(dto.personId); // } // entity.firstName = dto.firstName; // entity.lastName = dto.lastName; // entity.addresses = dto.addresses.stream() // .map(a -> AddressEntity.fromDTO(entity, a)) // .collect(toList()); // // return entity; // } // }
import static java.util.stream.Collectors.toList; import java.sql.SQLException; import java.util.List; import java.util.Map; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaDelete; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import org.osgi.enroute.examples.microservice.dao.PersonDao; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; import org.osgi.enroute.examples.microservice.dao.impl.jpa.entities.PersonEntity; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.transaction.control.TransactionControl; import org.osgi.service.transaction.control.jpa.JPAEntityManagerProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package org.osgi.enroute.examples.microservice.dao.impl.jpa; @Component public class PersonDaoImpl implements PersonDao { private static final Logger logger = LoggerFactory.getLogger(PersonDaoImpl.class); @Reference TransactionControl transactionControl; @Reference(name="provider") JPAEntityManagerProvider jpaEntityManagerProvider; EntityManager em; @Activate void activate(Map<String, Object> props) throws SQLException { em = jpaEntityManagerProvider.getResource(transactionControl); } @Override public List<PersonDTO> select() { return transactionControl.notSupported(() -> { CriteriaBuilder builder = em.getCriteriaBuilder();
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java // @ProviderType // public interface PersonDao { // // public List<PersonDTO> select(); // // public PersonDTO findByPK(Long pk) ; // // public Long save(PersonDTO data); // // public void update(PersonDTO data); // // public void delete(Long pk) ; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // } // // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/PersonEntity.java // @Entity // @Table(name="persons") // public class PersonEntity { // // @GeneratedValue(strategy = IDENTITY) // @Id // @Column(name="person_id") // private Long personId; // // @Column(name="first_name") // private String firstName; // // @Column(name="last_name") // private String lastName; // // @OneToMany(mappedBy="person", cascade=ALL) // private List<AddressEntity> addresses = new ArrayList<>(); // // public Long getPersonId() { // return personId; // } // // public PersonDTO toDTO() { // PersonDTO dto = new PersonDTO(); // dto.personId = personId; // dto.firstName = firstName; // dto.lastName = lastName; // dto.addresses = addresses.stream() // .map(AddressEntity::toDTO) // .collect(toList()); // return dto; // } // // public static PersonEntity fromDTO(PersonDTO dto) { // PersonEntity entity = new PersonEntity(); // if(dto.personId != 0) { // entity.personId = Long.valueOf(dto.personId); // } // entity.firstName = dto.firstName; // entity.lastName = dto.lastName; // entity.addresses = dto.addresses.stream() // .map(a -> AddressEntity.fromDTO(entity, a)) // .collect(toList()); // // return entity; // } // } // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/PersonDaoImpl.java import static java.util.stream.Collectors.toList; import java.sql.SQLException; import java.util.List; import java.util.Map; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaDelete; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import org.osgi.enroute.examples.microservice.dao.PersonDao; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; import org.osgi.enroute.examples.microservice.dao.impl.jpa.entities.PersonEntity; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.transaction.control.TransactionControl; import org.osgi.service.transaction.control.jpa.JPAEntityManagerProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; package org.osgi.enroute.examples.microservice.dao.impl.jpa; @Component public class PersonDaoImpl implements PersonDao { private static final Logger logger = LoggerFactory.getLogger(PersonDaoImpl.class); @Reference TransactionControl transactionControl; @Reference(name="provider") JPAEntityManagerProvider jpaEntityManagerProvider; EntityManager em; @Activate void activate(Map<String, Object> props) throws SQLException { em = jpaEntityManagerProvider.getResource(transactionControl); } @Override public List<PersonDTO> select() { return transactionControl.notSupported(() -> { CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<PersonEntity> query = builder.createQuery(PersonEntity.class);
osgi/osgi.enroute
examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // }
import java.util.List; import org.osgi.annotation.versioning.ProviderType; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO;
package org.osgi.enroute.examples.microservice.dao; @ProviderType public interface PersonDao {
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // } // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java import java.util.List; import org.osgi.annotation.versioning.ProviderType; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; package org.osgi.enroute.examples.microservice.dao; @ProviderType public interface PersonDao {
public List<PersonDTO> select();
osgi/osgi.enroute
examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/AddressDaoImpl.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/AddressDao.java // @ProviderType // public interface AddressDao { // // public List<AddressDTO> select(Long personId); // // public AddressDTO findByPK(String emailAddress); // // public void save(Long personId,AddressDTO data); // // public void update(Long personId,AddressDTO data); // // public void delete(Long personId) ; // // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/AddressDTO.java // public class AddressDTO { // // public long personId; // public String emailAddress; // public String city; // public String country; // } // // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/AddressEntity.java // @Entity // @Table(name="addresses") // public class AddressEntity { // // @ManyToOne // @JoinColumn(name="person_id", foreignKey=@ForeignKey(name="person")) // private PersonEntity person; // // @Id // @Column(name="email_address") // private String emailAddress; // private String city; // private String country; // // public static AddressEntity fromDTO(PersonEntity person, AddressDTO dto) { // AddressEntity entity = new AddressEntity(); // entity.person = person; // entity.emailAddress = dto.emailAddress; // entity.city = dto.city; // entity.country = dto.country; // // return entity; // } // // public AddressDTO toDTO() { // AddressDTO dto = new AddressDTO(); // dto.personId = person.getPersonId(); // dto.emailAddress = emailAddress; // dto.city = city; // dto.country = country; // // return dto; // } // // public void setCity(String city) { // this.city = city; // } // // public void setCountry(String country) { // this.country = country; // } // } // // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/PersonEntity.java // @Entity // @Table(name="persons") // public class PersonEntity { // // @GeneratedValue(strategy = IDENTITY) // @Id // @Column(name="person_id") // private Long personId; // // @Column(name="first_name") // private String firstName; // // @Column(name="last_name") // private String lastName; // // @OneToMany(mappedBy="person", cascade=ALL) // private List<AddressEntity> addresses = new ArrayList<>(); // // public Long getPersonId() { // return personId; // } // // public PersonDTO toDTO() { // PersonDTO dto = new PersonDTO(); // dto.personId = personId; // dto.firstName = firstName; // dto.lastName = lastName; // dto.addresses = addresses.stream() // .map(AddressEntity::toDTO) // .collect(toList()); // return dto; // } // // public static PersonEntity fromDTO(PersonDTO dto) { // PersonEntity entity = new PersonEntity(); // if(dto.personId != 0) { // entity.personId = Long.valueOf(dto.personId); // } // entity.firstName = dto.firstName; // entity.lastName = dto.lastName; // entity.addresses = dto.addresses.stream() // .map(a -> AddressEntity.fromDTO(entity, a)) // .collect(toList()); // // return entity; // } // }
import static java.util.stream.Collectors.toList; import java.sql.SQLException; import java.util.List; import java.util.Map; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaDelete; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import org.osgi.enroute.examples.microservice.dao.AddressDao; import org.osgi.enroute.examples.microservice.dao.dto.AddressDTO; import org.osgi.enroute.examples.microservice.dao.impl.jpa.entities.AddressEntity; import org.osgi.enroute.examples.microservice.dao.impl.jpa.entities.PersonEntity; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.transaction.control.TransactionControl; import org.osgi.service.transaction.control.jpa.JPAEntityManagerProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package org.osgi.enroute.examples.microservice.dao.impl.jpa; @Component public class AddressDaoImpl implements AddressDao { private static final Logger logger = LoggerFactory.getLogger(AddressDaoImpl.class); @Reference TransactionControl transactionControl; @Reference(name="provider") JPAEntityManagerProvider jpaEntityManagerProvider; EntityManager em; @Activate void activate(Map<String, Object> props) throws SQLException { em = jpaEntityManagerProvider.getResource(transactionControl); } @Override
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/AddressDao.java // @ProviderType // public interface AddressDao { // // public List<AddressDTO> select(Long personId); // // public AddressDTO findByPK(String emailAddress); // // public void save(Long personId,AddressDTO data); // // public void update(Long personId,AddressDTO data); // // public void delete(Long personId) ; // // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/AddressDTO.java // public class AddressDTO { // // public long personId; // public String emailAddress; // public String city; // public String country; // } // // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/AddressEntity.java // @Entity // @Table(name="addresses") // public class AddressEntity { // // @ManyToOne // @JoinColumn(name="person_id", foreignKey=@ForeignKey(name="person")) // private PersonEntity person; // // @Id // @Column(name="email_address") // private String emailAddress; // private String city; // private String country; // // public static AddressEntity fromDTO(PersonEntity person, AddressDTO dto) { // AddressEntity entity = new AddressEntity(); // entity.person = person; // entity.emailAddress = dto.emailAddress; // entity.city = dto.city; // entity.country = dto.country; // // return entity; // } // // public AddressDTO toDTO() { // AddressDTO dto = new AddressDTO(); // dto.personId = person.getPersonId(); // dto.emailAddress = emailAddress; // dto.city = city; // dto.country = country; // // return dto; // } // // public void setCity(String city) { // this.city = city; // } // // public void setCountry(String country) { // this.country = country; // } // } // // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/PersonEntity.java // @Entity // @Table(name="persons") // public class PersonEntity { // // @GeneratedValue(strategy = IDENTITY) // @Id // @Column(name="person_id") // private Long personId; // // @Column(name="first_name") // private String firstName; // // @Column(name="last_name") // private String lastName; // // @OneToMany(mappedBy="person", cascade=ALL) // private List<AddressEntity> addresses = new ArrayList<>(); // // public Long getPersonId() { // return personId; // } // // public PersonDTO toDTO() { // PersonDTO dto = new PersonDTO(); // dto.personId = personId; // dto.firstName = firstName; // dto.lastName = lastName; // dto.addresses = addresses.stream() // .map(AddressEntity::toDTO) // .collect(toList()); // return dto; // } // // public static PersonEntity fromDTO(PersonDTO dto) { // PersonEntity entity = new PersonEntity(); // if(dto.personId != 0) { // entity.personId = Long.valueOf(dto.personId); // } // entity.firstName = dto.firstName; // entity.lastName = dto.lastName; // entity.addresses = dto.addresses.stream() // .map(a -> AddressEntity.fromDTO(entity, a)) // .collect(toList()); // // return entity; // } // } // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/AddressDaoImpl.java import static java.util.stream.Collectors.toList; import java.sql.SQLException; import java.util.List; import java.util.Map; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaDelete; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import org.osgi.enroute.examples.microservice.dao.AddressDao; import org.osgi.enroute.examples.microservice.dao.dto.AddressDTO; import org.osgi.enroute.examples.microservice.dao.impl.jpa.entities.AddressEntity; import org.osgi.enroute.examples.microservice.dao.impl.jpa.entities.PersonEntity; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.transaction.control.TransactionControl; import org.osgi.service.transaction.control.jpa.JPAEntityManagerProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; package org.osgi.enroute.examples.microservice.dao.impl.jpa; @Component public class AddressDaoImpl implements AddressDao { private static final Logger logger = LoggerFactory.getLogger(AddressDaoImpl.class); @Reference TransactionControl transactionControl; @Reference(name="provider") JPAEntityManagerProvider jpaEntityManagerProvider; EntityManager em; @Activate void activate(Map<String, Object> props) throws SQLException { em = jpaEntityManagerProvider.getResource(transactionControl); } @Override
public List<AddressDTO> select(Long personId) {
osgi/osgi.enroute
examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/AddressDaoImpl.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/AddressDao.java // @ProviderType // public interface AddressDao { // // public List<AddressDTO> select(Long personId); // // public AddressDTO findByPK(String emailAddress); // // public void save(Long personId,AddressDTO data); // // public void update(Long personId,AddressDTO data); // // public void delete(Long personId) ; // // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/AddressDTO.java // public class AddressDTO { // // public long personId; // public String emailAddress; // public String city; // public String country; // } // // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/AddressEntity.java // @Entity // @Table(name="addresses") // public class AddressEntity { // // @ManyToOne // @JoinColumn(name="person_id", foreignKey=@ForeignKey(name="person")) // private PersonEntity person; // // @Id // @Column(name="email_address") // private String emailAddress; // private String city; // private String country; // // public static AddressEntity fromDTO(PersonEntity person, AddressDTO dto) { // AddressEntity entity = new AddressEntity(); // entity.person = person; // entity.emailAddress = dto.emailAddress; // entity.city = dto.city; // entity.country = dto.country; // // return entity; // } // // public AddressDTO toDTO() { // AddressDTO dto = new AddressDTO(); // dto.personId = person.getPersonId(); // dto.emailAddress = emailAddress; // dto.city = city; // dto.country = country; // // return dto; // } // // public void setCity(String city) { // this.city = city; // } // // public void setCountry(String country) { // this.country = country; // } // } // // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/PersonEntity.java // @Entity // @Table(name="persons") // public class PersonEntity { // // @GeneratedValue(strategy = IDENTITY) // @Id // @Column(name="person_id") // private Long personId; // // @Column(name="first_name") // private String firstName; // // @Column(name="last_name") // private String lastName; // // @OneToMany(mappedBy="person", cascade=ALL) // private List<AddressEntity> addresses = new ArrayList<>(); // // public Long getPersonId() { // return personId; // } // // public PersonDTO toDTO() { // PersonDTO dto = new PersonDTO(); // dto.personId = personId; // dto.firstName = firstName; // dto.lastName = lastName; // dto.addresses = addresses.stream() // .map(AddressEntity::toDTO) // .collect(toList()); // return dto; // } // // public static PersonEntity fromDTO(PersonDTO dto) { // PersonEntity entity = new PersonEntity(); // if(dto.personId != 0) { // entity.personId = Long.valueOf(dto.personId); // } // entity.firstName = dto.firstName; // entity.lastName = dto.lastName; // entity.addresses = dto.addresses.stream() // .map(a -> AddressEntity.fromDTO(entity, a)) // .collect(toList()); // // return entity; // } // }
import static java.util.stream.Collectors.toList; import java.sql.SQLException; import java.util.List; import java.util.Map; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaDelete; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import org.osgi.enroute.examples.microservice.dao.AddressDao; import org.osgi.enroute.examples.microservice.dao.dto.AddressDTO; import org.osgi.enroute.examples.microservice.dao.impl.jpa.entities.AddressEntity; import org.osgi.enroute.examples.microservice.dao.impl.jpa.entities.PersonEntity; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.transaction.control.TransactionControl; import org.osgi.service.transaction.control.jpa.JPAEntityManagerProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package org.osgi.enroute.examples.microservice.dao.impl.jpa; @Component public class AddressDaoImpl implements AddressDao { private static final Logger logger = LoggerFactory.getLogger(AddressDaoImpl.class); @Reference TransactionControl transactionControl; @Reference(name="provider") JPAEntityManagerProvider jpaEntityManagerProvider; EntityManager em; @Activate void activate(Map<String, Object> props) throws SQLException { em = jpaEntityManagerProvider.getResource(transactionControl); } @Override public List<AddressDTO> select(Long personId) { return transactionControl.notSupported(() -> { CriteriaBuilder builder = em.getCriteriaBuilder();
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/AddressDao.java // @ProviderType // public interface AddressDao { // // public List<AddressDTO> select(Long personId); // // public AddressDTO findByPK(String emailAddress); // // public void save(Long personId,AddressDTO data); // // public void update(Long personId,AddressDTO data); // // public void delete(Long personId) ; // // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/AddressDTO.java // public class AddressDTO { // // public long personId; // public String emailAddress; // public String city; // public String country; // } // // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/AddressEntity.java // @Entity // @Table(name="addresses") // public class AddressEntity { // // @ManyToOne // @JoinColumn(name="person_id", foreignKey=@ForeignKey(name="person")) // private PersonEntity person; // // @Id // @Column(name="email_address") // private String emailAddress; // private String city; // private String country; // // public static AddressEntity fromDTO(PersonEntity person, AddressDTO dto) { // AddressEntity entity = new AddressEntity(); // entity.person = person; // entity.emailAddress = dto.emailAddress; // entity.city = dto.city; // entity.country = dto.country; // // return entity; // } // // public AddressDTO toDTO() { // AddressDTO dto = new AddressDTO(); // dto.personId = person.getPersonId(); // dto.emailAddress = emailAddress; // dto.city = city; // dto.country = country; // // return dto; // } // // public void setCity(String city) { // this.city = city; // } // // public void setCountry(String country) { // this.country = country; // } // } // // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/PersonEntity.java // @Entity // @Table(name="persons") // public class PersonEntity { // // @GeneratedValue(strategy = IDENTITY) // @Id // @Column(name="person_id") // private Long personId; // // @Column(name="first_name") // private String firstName; // // @Column(name="last_name") // private String lastName; // // @OneToMany(mappedBy="person", cascade=ALL) // private List<AddressEntity> addresses = new ArrayList<>(); // // public Long getPersonId() { // return personId; // } // // public PersonDTO toDTO() { // PersonDTO dto = new PersonDTO(); // dto.personId = personId; // dto.firstName = firstName; // dto.lastName = lastName; // dto.addresses = addresses.stream() // .map(AddressEntity::toDTO) // .collect(toList()); // return dto; // } // // public static PersonEntity fromDTO(PersonDTO dto) { // PersonEntity entity = new PersonEntity(); // if(dto.personId != 0) { // entity.personId = Long.valueOf(dto.personId); // } // entity.firstName = dto.firstName; // entity.lastName = dto.lastName; // entity.addresses = dto.addresses.stream() // .map(a -> AddressEntity.fromDTO(entity, a)) // .collect(toList()); // // return entity; // } // } // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/AddressDaoImpl.java import static java.util.stream.Collectors.toList; import java.sql.SQLException; import java.util.List; import java.util.Map; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaDelete; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import org.osgi.enroute.examples.microservice.dao.AddressDao; import org.osgi.enroute.examples.microservice.dao.dto.AddressDTO; import org.osgi.enroute.examples.microservice.dao.impl.jpa.entities.AddressEntity; import org.osgi.enroute.examples.microservice.dao.impl.jpa.entities.PersonEntity; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.transaction.control.TransactionControl; import org.osgi.service.transaction.control.jpa.JPAEntityManagerProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; package org.osgi.enroute.examples.microservice.dao.impl.jpa; @Component public class AddressDaoImpl implements AddressDao { private static final Logger logger = LoggerFactory.getLogger(AddressDaoImpl.class); @Reference TransactionControl transactionControl; @Reference(name="provider") JPAEntityManagerProvider jpaEntityManagerProvider; EntityManager em; @Activate void activate(Map<String, Object> props) throws SQLException { em = jpaEntityManagerProvider.getResource(transactionControl); } @Override public List<AddressDTO> select(Long personId) { return transactionControl.notSupported(() -> { CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<AddressEntity> query = builder.createQuery(AddressEntity.class);
osgi/osgi.enroute
examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/AddressDaoImpl.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/AddressDao.java // @ProviderType // public interface AddressDao { // // public List<AddressDTO> select(Long personId); // // public AddressDTO findByPK(String emailAddress); // // public void save(Long personId,AddressDTO data); // // public void update(Long personId,AddressDTO data); // // public void delete(Long personId) ; // // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/AddressDTO.java // public class AddressDTO { // // public long personId; // public String emailAddress; // public String city; // public String country; // } // // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/AddressEntity.java // @Entity // @Table(name="addresses") // public class AddressEntity { // // @ManyToOne // @JoinColumn(name="person_id", foreignKey=@ForeignKey(name="person")) // private PersonEntity person; // // @Id // @Column(name="email_address") // private String emailAddress; // private String city; // private String country; // // public static AddressEntity fromDTO(PersonEntity person, AddressDTO dto) { // AddressEntity entity = new AddressEntity(); // entity.person = person; // entity.emailAddress = dto.emailAddress; // entity.city = dto.city; // entity.country = dto.country; // // return entity; // } // // public AddressDTO toDTO() { // AddressDTO dto = new AddressDTO(); // dto.personId = person.getPersonId(); // dto.emailAddress = emailAddress; // dto.city = city; // dto.country = country; // // return dto; // } // // public void setCity(String city) { // this.city = city; // } // // public void setCountry(String country) { // this.country = country; // } // } // // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/PersonEntity.java // @Entity // @Table(name="persons") // public class PersonEntity { // // @GeneratedValue(strategy = IDENTITY) // @Id // @Column(name="person_id") // private Long personId; // // @Column(name="first_name") // private String firstName; // // @Column(name="last_name") // private String lastName; // // @OneToMany(mappedBy="person", cascade=ALL) // private List<AddressEntity> addresses = new ArrayList<>(); // // public Long getPersonId() { // return personId; // } // // public PersonDTO toDTO() { // PersonDTO dto = new PersonDTO(); // dto.personId = personId; // dto.firstName = firstName; // dto.lastName = lastName; // dto.addresses = addresses.stream() // .map(AddressEntity::toDTO) // .collect(toList()); // return dto; // } // // public static PersonEntity fromDTO(PersonDTO dto) { // PersonEntity entity = new PersonEntity(); // if(dto.personId != 0) { // entity.personId = Long.valueOf(dto.personId); // } // entity.firstName = dto.firstName; // entity.lastName = dto.lastName; // entity.addresses = dto.addresses.stream() // .map(a -> AddressEntity.fromDTO(entity, a)) // .collect(toList()); // // return entity; // } // }
import static java.util.stream.Collectors.toList; import java.sql.SQLException; import java.util.List; import java.util.Map; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaDelete; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import org.osgi.enroute.examples.microservice.dao.AddressDao; import org.osgi.enroute.examples.microservice.dao.dto.AddressDTO; import org.osgi.enroute.examples.microservice.dao.impl.jpa.entities.AddressEntity; import org.osgi.enroute.examples.microservice.dao.impl.jpa.entities.PersonEntity; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.transaction.control.TransactionControl; import org.osgi.service.transaction.control.jpa.JPAEntityManagerProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
return transactionControl.notSupported(() -> { CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<AddressEntity> query = builder.createQuery(AddressEntity.class); Root<AddressEntity> from = query.from(AddressEntity.class); query.where(builder.equal(from.get("person").get("personId"), personId)); return em.createQuery(query).getResultList().stream() .map(AddressEntity::toDTO) .collect(toList()); }); } @Override public AddressDTO findByPK(String pk) { return transactionControl.supports(() -> { AddressEntity address = em.find(AddressEntity.class, pk); return address == null ? null : address.toDTO(); }); } @Override public void save(Long personId, AddressDTO data) { transactionControl.required(() -> {
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/AddressDao.java // @ProviderType // public interface AddressDao { // // public List<AddressDTO> select(Long personId); // // public AddressDTO findByPK(String emailAddress); // // public void save(Long personId,AddressDTO data); // // public void update(Long personId,AddressDTO data); // // public void delete(Long personId) ; // // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/AddressDTO.java // public class AddressDTO { // // public long personId; // public String emailAddress; // public String city; // public String country; // } // // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/AddressEntity.java // @Entity // @Table(name="addresses") // public class AddressEntity { // // @ManyToOne // @JoinColumn(name="person_id", foreignKey=@ForeignKey(name="person")) // private PersonEntity person; // // @Id // @Column(name="email_address") // private String emailAddress; // private String city; // private String country; // // public static AddressEntity fromDTO(PersonEntity person, AddressDTO dto) { // AddressEntity entity = new AddressEntity(); // entity.person = person; // entity.emailAddress = dto.emailAddress; // entity.city = dto.city; // entity.country = dto.country; // // return entity; // } // // public AddressDTO toDTO() { // AddressDTO dto = new AddressDTO(); // dto.personId = person.getPersonId(); // dto.emailAddress = emailAddress; // dto.city = city; // dto.country = country; // // return dto; // } // // public void setCity(String city) { // this.city = city; // } // // public void setCountry(String country) { // this.country = country; // } // } // // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/PersonEntity.java // @Entity // @Table(name="persons") // public class PersonEntity { // // @GeneratedValue(strategy = IDENTITY) // @Id // @Column(name="person_id") // private Long personId; // // @Column(name="first_name") // private String firstName; // // @Column(name="last_name") // private String lastName; // // @OneToMany(mappedBy="person", cascade=ALL) // private List<AddressEntity> addresses = new ArrayList<>(); // // public Long getPersonId() { // return personId; // } // // public PersonDTO toDTO() { // PersonDTO dto = new PersonDTO(); // dto.personId = personId; // dto.firstName = firstName; // dto.lastName = lastName; // dto.addresses = addresses.stream() // .map(AddressEntity::toDTO) // .collect(toList()); // return dto; // } // // public static PersonEntity fromDTO(PersonDTO dto) { // PersonEntity entity = new PersonEntity(); // if(dto.personId != 0) { // entity.personId = Long.valueOf(dto.personId); // } // entity.firstName = dto.firstName; // entity.lastName = dto.lastName; // entity.addresses = dto.addresses.stream() // .map(a -> AddressEntity.fromDTO(entity, a)) // .collect(toList()); // // return entity; // } // } // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/AddressDaoImpl.java import static java.util.stream.Collectors.toList; import java.sql.SQLException; import java.util.List; import java.util.Map; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaDelete; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import org.osgi.enroute.examples.microservice.dao.AddressDao; import org.osgi.enroute.examples.microservice.dao.dto.AddressDTO; import org.osgi.enroute.examples.microservice.dao.impl.jpa.entities.AddressEntity; import org.osgi.enroute.examples.microservice.dao.impl.jpa.entities.PersonEntity; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.transaction.control.TransactionControl; import org.osgi.service.transaction.control.jpa.JPAEntityManagerProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; return transactionControl.notSupported(() -> { CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<AddressEntity> query = builder.createQuery(AddressEntity.class); Root<AddressEntity> from = query.from(AddressEntity.class); query.where(builder.equal(from.get("person").get("personId"), personId)); return em.createQuery(query).getResultList().stream() .map(AddressEntity::toDTO) .collect(toList()); }); } @Override public AddressDTO findByPK(String pk) { return transactionControl.supports(() -> { AddressEntity address = em.find(AddressEntity.class, pk); return address == null ? null : address.toDTO(); }); } @Override public void save(Long personId, AddressDTO data) { transactionControl.required(() -> {
PersonEntity person = em.find(PersonEntity.class, personId);
osgi/osgi.enroute
examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/AddressDao.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/AddressDTO.java // public class AddressDTO { // // public long personId; // public String emailAddress; // public String city; // public String country; // }
import java.util.List; import org.osgi.annotation.versioning.ProviderType; import org.osgi.enroute.examples.microservice.dao.dto.AddressDTO;
package org.osgi.enroute.examples.microservice.dao; @ProviderType public interface AddressDao {
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/AddressDTO.java // public class AddressDTO { // // public long personId; // public String emailAddress; // public String city; // public String country; // } // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/AddressDao.java import java.util.List; import org.osgi.annotation.versioning.ProviderType; import org.osgi.enroute.examples.microservice.dao.dto.AddressDTO; package org.osgi.enroute.examples.microservice.dao; @ProviderType public interface AddressDao {
public List<AddressDTO> select(Long personId);
osgi/osgi.enroute
examples/microservice/rest-service/src/test/java/org/osgi/enroute/examples/microservice/rest/JsonConverterTest.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/AddressDTO.java // public class AddressDTO { // // public long personId; // public String emailAddress; // public String city; // public String country; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // }
import static org.junit.Assert.assertEquals; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import org.junit.Test; import org.osgi.enroute.examples.microservice.dao.dto.AddressDTO; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO;
package org.osgi.enroute.examples.microservice.rest; public class JsonConverterTest { @Test public void testJSONSerialization() throws WebApplicationException, IOException {
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/AddressDTO.java // public class AddressDTO { // // public long personId; // public String emailAddress; // public String city; // public String country; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // } // Path: examples/microservice/rest-service/src/test/java/org/osgi/enroute/examples/microservice/rest/JsonConverterTest.java import static org.junit.Assert.assertEquals; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import org.junit.Test; import org.osgi.enroute.examples.microservice.dao.dto.AddressDTO; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; package org.osgi.enroute.examples.microservice.rest; public class JsonConverterTest { @Test public void testJSONSerialization() throws WebApplicationException, IOException {
JsonpConvertingPlugin<PersonDTO> plugin = new JsonpConvertingPlugin<>();
osgi/osgi.enroute
examples/microservice/rest-service/src/test/java/org/osgi/enroute/examples/microservice/rest/JsonConverterTest.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/AddressDTO.java // public class AddressDTO { // // public long personId; // public String emailAddress; // public String city; // public String country; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // }
import static org.junit.Assert.assertEquals; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import org.junit.Test; import org.osgi.enroute.examples.microservice.dao.dto.AddressDTO; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO;
package org.osgi.enroute.examples.microservice.rest; public class JsonConverterTest { @Test public void testJSONSerialization() throws WebApplicationException, IOException { JsonpConvertingPlugin<PersonDTO> plugin = new JsonpConvertingPlugin<>(); PersonDTO dto = new PersonDTO(); dto.firstName = "Tim"; dto.lastName = "Ward"; dto.personId = 1234;
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/AddressDTO.java // public class AddressDTO { // // public long personId; // public String emailAddress; // public String city; // public String country; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // } // Path: examples/microservice/rest-service/src/test/java/org/osgi/enroute/examples/microservice/rest/JsonConverterTest.java import static org.junit.Assert.assertEquals; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import org.junit.Test; import org.osgi.enroute.examples.microservice.dao.dto.AddressDTO; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; package org.osgi.enroute.examples.microservice.rest; public class JsonConverterTest { @Test public void testJSONSerialization() throws WebApplicationException, IOException { JsonpConvertingPlugin<PersonDTO> plugin = new JsonpConvertingPlugin<>(); PersonDTO dto = new PersonDTO(); dto.firstName = "Tim"; dto.lastName = "Ward"; dto.personId = 1234;
AddressDTO dto2 = new AddressDTO();
osgi/osgi.enroute
examples/microservice/dao-impl/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/AddressDaoImpl.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/AddressDao.java // @ProviderType // public interface AddressDao { // // public List<AddressDTO> select(Long personId); // // public AddressDTO findByPK(String emailAddress); // // public void save(Long personId,AddressDTO data); // // public void update(Long personId,AddressDTO data); // // public void delete(Long personId) ; // // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/AddressDTO.java // public class AddressDTO { // // public long personId; // public String emailAddress; // public String city; // public String country; // }
import static org.osgi.enroute.examples.microservice.dao.impl.AddressTable.SQL_ADD_ADDRESS; import static org.osgi.enroute.examples.microservice.dao.impl.AddressTable.SQL_DELETE_ALL_ADDRESS_BY_PERSON_ID; import static org.osgi.enroute.examples.microservice.dao.impl.AddressTable.SQL_SELECT_ADDRESS_BY_PERSON; import static org.osgi.enroute.examples.microservice.dao.impl.AddressTable.SQL_SELECT_ADDRESS_BY_PK; import static org.osgi.enroute.examples.microservice.dao.impl.AddressTable.SQL_UPDATE_ADDRESS_BY_PK_AND_PERSON_ID; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.osgi.enroute.examples.microservice.dao.AddressDao; import org.osgi.enroute.examples.microservice.dao.dto.AddressDTO; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.transaction.control.TransactionControl; import org.osgi.service.transaction.control.jdbc.JDBCConnectionProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package org.osgi.enroute.examples.microservice.dao.impl; @Component public class AddressDaoImpl implements AddressDao { private static final Logger logger = LoggerFactory.getLogger(AddressDaoImpl.class); @Reference TransactionControl transactionControl; @Reference(name="provider") JDBCConnectionProvider jdbcConnectionProvider; Connection connection; @Activate void activate(Map<String, Object> props) throws SQLException { connection = jdbcConnectionProvider.getResource(transactionControl); transactionControl.supports( () -> connection.prepareStatement(AddressTable.INIT).execute()); } @Override
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/AddressDao.java // @ProviderType // public interface AddressDao { // // public List<AddressDTO> select(Long personId); // // public AddressDTO findByPK(String emailAddress); // // public void save(Long personId,AddressDTO data); // // public void update(Long personId,AddressDTO data); // // public void delete(Long personId) ; // // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/AddressDTO.java // public class AddressDTO { // // public long personId; // public String emailAddress; // public String city; // public String country; // } // Path: examples/microservice/dao-impl/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/AddressDaoImpl.java import static org.osgi.enroute.examples.microservice.dao.impl.AddressTable.SQL_ADD_ADDRESS; import static org.osgi.enroute.examples.microservice.dao.impl.AddressTable.SQL_DELETE_ALL_ADDRESS_BY_PERSON_ID; import static org.osgi.enroute.examples.microservice.dao.impl.AddressTable.SQL_SELECT_ADDRESS_BY_PERSON; import static org.osgi.enroute.examples.microservice.dao.impl.AddressTable.SQL_SELECT_ADDRESS_BY_PK; import static org.osgi.enroute.examples.microservice.dao.impl.AddressTable.SQL_UPDATE_ADDRESS_BY_PK_AND_PERSON_ID; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.osgi.enroute.examples.microservice.dao.AddressDao; import org.osgi.enroute.examples.microservice.dao.dto.AddressDTO; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.transaction.control.TransactionControl; import org.osgi.service.transaction.control.jdbc.JDBCConnectionProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; package org.osgi.enroute.examples.microservice.dao.impl; @Component public class AddressDaoImpl implements AddressDao { private static final Logger logger = LoggerFactory.getLogger(AddressDaoImpl.class); @Reference TransactionControl transactionControl; @Reference(name="provider") JDBCConnectionProvider jdbcConnectionProvider; Connection connection; @Activate void activate(Map<String, Object> props) throws SQLException { connection = jdbcConnectionProvider.getResource(transactionControl); transactionControl.supports( () -> connection.prepareStatement(AddressTable.INIT).execute()); } @Override
public List<AddressDTO> select(Long personId) {
osgi/osgi.enroute
examples/microservice/dao-impl/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/PersonDaoImpl.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/AddressDao.java // @ProviderType // public interface AddressDao { // // public List<AddressDTO> select(Long personId); // // public AddressDTO findByPK(String emailAddress); // // public void save(Long personId,AddressDTO data); // // public void update(Long personId,AddressDTO data); // // public void delete(Long personId) ; // // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java // @ProviderType // public interface PersonDao { // // public List<PersonDTO> select(); // // public PersonDTO findByPK(Long pk) ; // // public Long save(PersonDTO data); // // public void update(PersonDTO data); // // public void delete(Long pk) ; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // }
import static java.sql.Statement.RETURN_GENERATED_KEYS; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.FIRST_NAME; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.INIT; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.LAST_NAME; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.PERSON_ID; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_DELETE_PERSON_BY_PK; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_INSERT_PERSON; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_SELECT_ALL_PERSONS; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_SELECT_PERSON_BY_PK; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_UPDATE_PERSON_BY_PK; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicLong; import org.osgi.enroute.examples.microservice.dao.AddressDao; import org.osgi.enroute.examples.microservice.dao.PersonDao; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.transaction.control.TransactionControl; import org.osgi.service.transaction.control.jdbc.JDBCConnectionProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package org.osgi.enroute.examples.microservice.dao.impl; @Component public class PersonDaoImpl implements PersonDao { private static final Logger logger = LoggerFactory.getLogger(PersonDaoImpl.class); @Reference TransactionControl transactionControl; @Reference(name="provider") JDBCConnectionProvider jdbcConnectionProvider; @Reference
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/AddressDao.java // @ProviderType // public interface AddressDao { // // public List<AddressDTO> select(Long personId); // // public AddressDTO findByPK(String emailAddress); // // public void save(Long personId,AddressDTO data); // // public void update(Long personId,AddressDTO data); // // public void delete(Long personId) ; // // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java // @ProviderType // public interface PersonDao { // // public List<PersonDTO> select(); // // public PersonDTO findByPK(Long pk) ; // // public Long save(PersonDTO data); // // public void update(PersonDTO data); // // public void delete(Long pk) ; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // } // Path: examples/microservice/dao-impl/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/PersonDaoImpl.java import static java.sql.Statement.RETURN_GENERATED_KEYS; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.FIRST_NAME; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.INIT; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.LAST_NAME; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.PERSON_ID; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_DELETE_PERSON_BY_PK; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_INSERT_PERSON; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_SELECT_ALL_PERSONS; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_SELECT_PERSON_BY_PK; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_UPDATE_PERSON_BY_PK; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicLong; import org.osgi.enroute.examples.microservice.dao.AddressDao; import org.osgi.enroute.examples.microservice.dao.PersonDao; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.transaction.control.TransactionControl; import org.osgi.service.transaction.control.jdbc.JDBCConnectionProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; package org.osgi.enroute.examples.microservice.dao.impl; @Component public class PersonDaoImpl implements PersonDao { private static final Logger logger = LoggerFactory.getLogger(PersonDaoImpl.class); @Reference TransactionControl transactionControl; @Reference(name="provider") JDBCConnectionProvider jdbcConnectionProvider; @Reference
AddressDao addressDao;
osgi/osgi.enroute
examples/microservice/dao-impl/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/PersonDaoImpl.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/AddressDao.java // @ProviderType // public interface AddressDao { // // public List<AddressDTO> select(Long personId); // // public AddressDTO findByPK(String emailAddress); // // public void save(Long personId,AddressDTO data); // // public void update(Long personId,AddressDTO data); // // public void delete(Long personId) ; // // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java // @ProviderType // public interface PersonDao { // // public List<PersonDTO> select(); // // public PersonDTO findByPK(Long pk) ; // // public Long save(PersonDTO data); // // public void update(PersonDTO data); // // public void delete(Long pk) ; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // }
import static java.sql.Statement.RETURN_GENERATED_KEYS; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.FIRST_NAME; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.INIT; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.LAST_NAME; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.PERSON_ID; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_DELETE_PERSON_BY_PK; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_INSERT_PERSON; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_SELECT_ALL_PERSONS; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_SELECT_PERSON_BY_PK; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_UPDATE_PERSON_BY_PK; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicLong; import org.osgi.enroute.examples.microservice.dao.AddressDao; import org.osgi.enroute.examples.microservice.dao.PersonDao; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.transaction.control.TransactionControl; import org.osgi.service.transaction.control.jdbc.JDBCConnectionProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package org.osgi.enroute.examples.microservice.dao.impl; @Component public class PersonDaoImpl implements PersonDao { private static final Logger logger = LoggerFactory.getLogger(PersonDaoImpl.class); @Reference TransactionControl transactionControl; @Reference(name="provider") JDBCConnectionProvider jdbcConnectionProvider; @Reference AddressDao addressDao; Connection connection; @Activate void start(Map<String, Object> props) throws SQLException { connection = jdbcConnectionProvider.getResource(transactionControl); transactionControl.supports(() -> connection.prepareStatement(INIT).execute()); } @Override
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/AddressDao.java // @ProviderType // public interface AddressDao { // // public List<AddressDTO> select(Long personId); // // public AddressDTO findByPK(String emailAddress); // // public void save(Long personId,AddressDTO data); // // public void update(Long personId,AddressDTO data); // // public void delete(Long personId) ; // // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java // @ProviderType // public interface PersonDao { // // public List<PersonDTO> select(); // // public PersonDTO findByPK(Long pk) ; // // public Long save(PersonDTO data); // // public void update(PersonDTO data); // // public void delete(Long pk) ; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // } // Path: examples/microservice/dao-impl/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/PersonDaoImpl.java import static java.sql.Statement.RETURN_GENERATED_KEYS; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.FIRST_NAME; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.INIT; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.LAST_NAME; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.PERSON_ID; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_DELETE_PERSON_BY_PK; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_INSERT_PERSON; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_SELECT_ALL_PERSONS; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_SELECT_PERSON_BY_PK; import static org.osgi.enroute.examples.microservice.dao.impl.PersonTable.SQL_UPDATE_PERSON_BY_PK; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicLong; import org.osgi.enroute.examples.microservice.dao.AddressDao; import org.osgi.enroute.examples.microservice.dao.PersonDao; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.osgi.service.transaction.control.TransactionControl; import org.osgi.service.transaction.control.jdbc.JDBCConnectionProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; package org.osgi.enroute.examples.microservice.dao.impl; @Component public class PersonDaoImpl implements PersonDao { private static final Logger logger = LoggerFactory.getLogger(PersonDaoImpl.class); @Reference TransactionControl transactionControl; @Reference(name="provider") JDBCConnectionProvider jdbcConnectionProvider; @Reference AddressDao addressDao; Connection connection; @Activate void start(Map<String, Object> props) throws SQLException { connection = jdbcConnectionProvider.getResource(transactionControl); transactionControl.supports(() -> connection.prepareStatement(INIT).execute()); } @Override
public List<PersonDTO> select() {
osgi/osgi.enroute
examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/AddressEntity.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/AddressDTO.java // public class AddressDTO { // // public long personId; // public String emailAddress; // public String city; // public String country; // }
import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.ForeignKey; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import org.osgi.enroute.examples.microservice.dao.dto.AddressDTO;
package org.osgi.enroute.examples.microservice.dao.impl.jpa.entities; @Entity @Table(name="addresses") public class AddressEntity { @ManyToOne @JoinColumn(name="person_id", foreignKey=@ForeignKey(name="person")) private PersonEntity person; @Id @Column(name="email_address") private String emailAddress; private String city; private String country;
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/AddressDTO.java // public class AddressDTO { // // public long personId; // public String emailAddress; // public String city; // public String country; // } // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/AddressEntity.java import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.ForeignKey; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import org.osgi.enroute.examples.microservice.dao.dto.AddressDTO; package org.osgi.enroute.examples.microservice.dao.impl.jpa.entities; @Entity @Table(name="addresses") public class AddressEntity { @ManyToOne @JoinColumn(name="person_id", foreignKey=@ForeignKey(name="person")) private PersonEntity person; @Id @Column(name="email_address") private String emailAddress; private String city; private String country;
public static AddressEntity fromDTO(PersonEntity person, AddressDTO dto) {
osgi/osgi.enroute
examples/microservice/rest-service-test/src/main/java/org/osgi/enroute/examples/microservice/rest/service/test/RestServiceIntegrationTest.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java // @ProviderType // public interface PersonDao { // // public List<PersonDTO> select(); // // public PersonDTO findByPK(Long pk) ; // // public Long save(PersonDTO data); // // public void update(PersonDTO data); // // public void delete(Long pk) ; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.mock; import static org.osgi.namespace.service.ServiceNamespace.SERVICE_NAMESPACE; import static org.osgi.service.jaxrs.runtime.JaxrsServiceRuntimeConstants.JAX_RS_SERVICE_ENDPOINT; import java.util.Collections; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; import org.osgi.annotation.bundle.Capability; import org.osgi.enroute.examples.microservice.dao.PersonDao; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; import org.osgi.framework.ServiceRegistration; import org.osgi.service.jaxrs.runtime.JaxrsServiceRuntime; import org.osgi.util.converter.Converters; import org.osgi.util.tracker.ServiceTracker;
package org.osgi.enroute.examples.microservice.rest.service.test; @Capability(namespace=SERVICE_NAMESPACE, attribute="objectClass=org.osgi.enroute.examples.microservice.dao.PersonDao") public class RestServiceIntegrationTest { private final Bundle bundle = FrameworkUtil.getBundle(this.getClass());
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java // @ProviderType // public interface PersonDao { // // public List<PersonDTO> select(); // // public PersonDTO findByPK(Long pk) ; // // public Long save(PersonDTO data); // // public void update(PersonDTO data); // // public void delete(Long pk) ; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // } // Path: examples/microservice/rest-service-test/src/main/java/org/osgi/enroute/examples/microservice/rest/service/test/RestServiceIntegrationTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.mock; import static org.osgi.namespace.service.ServiceNamespace.SERVICE_NAMESPACE; import static org.osgi.service.jaxrs.runtime.JaxrsServiceRuntimeConstants.JAX_RS_SERVICE_ENDPOINT; import java.util.Collections; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; import org.osgi.annotation.bundle.Capability; import org.osgi.enroute.examples.microservice.dao.PersonDao; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; import org.osgi.framework.ServiceRegistration; import org.osgi.service.jaxrs.runtime.JaxrsServiceRuntime; import org.osgi.util.converter.Converters; import org.osgi.util.tracker.ServiceTracker; package org.osgi.enroute.examples.microservice.rest.service.test; @Capability(namespace=SERVICE_NAMESPACE, attribute="objectClass=org.osgi.enroute.examples.microservice.dao.PersonDao") public class RestServiceIntegrationTest { private final Bundle bundle = FrameworkUtil.getBundle(this.getClass());
private PersonDao mockDAO;
osgi/osgi.enroute
examples/microservice/rest-service-test/src/main/java/org/osgi/enroute/examples/microservice/rest/service/test/RestServiceIntegrationTest.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java // @ProviderType // public interface PersonDao { // // public List<PersonDTO> select(); // // public PersonDTO findByPK(Long pk) ; // // public Long save(PersonDTO data); // // public void update(PersonDTO data); // // public void delete(Long pk) ; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.mock; import static org.osgi.namespace.service.ServiceNamespace.SERVICE_NAMESPACE; import static org.osgi.service.jaxrs.runtime.JaxrsServiceRuntimeConstants.JAX_RS_SERVICE_ENDPOINT; import java.util.Collections; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; import org.osgi.annotation.bundle.Capability; import org.osgi.enroute.examples.microservice.dao.PersonDao; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; import org.osgi.framework.ServiceRegistration; import org.osgi.service.jaxrs.runtime.JaxrsServiceRuntime; import org.osgi.util.converter.Converters; import org.osgi.util.tracker.ServiceTracker;
private void registerDao() { registration = bundle.getBundleContext().registerService(PersonDao.class, mockDAO, null); } @Test public void testRestServiceRegistered() throws Exception { assertEquals(0, jaxrsServiceRuntime.getRuntimeDTO().defaultApplication.resourceDTOs.length); registerDao(); assertEquals(1, jaxrsServiceRuntime.getRuntimeDTO().defaultApplication.resourceDTOs.length); } @Test public void testGetPerson() throws Exception { registerDao(); // Set up a Base URI String base = Converters.standardConverter().convert( runtimeTracker.getServiceReference().getProperty(JAX_RS_SERVICE_ENDPOINT)).to(String.class); WebTarget target = client.target(base); // There should be no results in the answer assertEquals("[]", target.path("person") .request() .get(String.class)); // Add a person to the DAO
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/PersonDao.java // @ProviderType // public interface PersonDao { // // public List<PersonDTO> select(); // // public PersonDTO findByPK(Long pk) ; // // public Long save(PersonDTO data); // // public void update(PersonDTO data); // // public void delete(Long pk) ; // } // // Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // } // Path: examples/microservice/rest-service-test/src/main/java/org/osgi/enroute/examples/microservice/rest/service/test/RestServiceIntegrationTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.mock; import static org.osgi.namespace.service.ServiceNamespace.SERVICE_NAMESPACE; import static org.osgi.service.jaxrs.runtime.JaxrsServiceRuntimeConstants.JAX_RS_SERVICE_ENDPOINT; import java.util.Collections; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; import org.osgi.annotation.bundle.Capability; import org.osgi.enroute.examples.microservice.dao.PersonDao; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; import org.osgi.framework.ServiceRegistration; import org.osgi.service.jaxrs.runtime.JaxrsServiceRuntime; import org.osgi.util.converter.Converters; import org.osgi.util.tracker.ServiceTracker; private void registerDao() { registration = bundle.getBundleContext().registerService(PersonDao.class, mockDAO, null); } @Test public void testRestServiceRegistered() throws Exception { assertEquals(0, jaxrsServiceRuntime.getRuntimeDTO().defaultApplication.resourceDTOs.length); registerDao(); assertEquals(1, jaxrsServiceRuntime.getRuntimeDTO().defaultApplication.resourceDTOs.length); } @Test public void testGetPerson() throws Exception { registerDao(); // Set up a Base URI String base = Converters.standardConverter().convert( runtimeTracker.getServiceReference().getProperty(JAX_RS_SERVICE_ENDPOINT)).to(String.class); WebTarget target = client.target(base); // There should be no results in the answer assertEquals("[]", target.path("person") .request() .get(String.class)); // Add a person to the DAO
PersonDTO dto = new PersonDTO();
osgi/osgi.enroute
examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/PersonEntity.java
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // }
import static java.util.stream.Collectors.toList; import static javax.persistence.CascadeType.ALL; import static javax.persistence.GenerationType.IDENTITY; import java.util.ArrayList; import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.Table; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO;
package org.osgi.enroute.examples.microservice.dao.impl.jpa.entities; @Entity @Table(name="persons") public class PersonEntity { @GeneratedValue(strategy = IDENTITY) @Id @Column(name="person_id") private Long personId; @Column(name="first_name") private String firstName; @Column(name="last_name") private String lastName; @OneToMany(mappedBy="person", cascade=ALL) private List<AddressEntity> addresses = new ArrayList<>(); public Long getPersonId() { return personId; }
// Path: examples/microservice/dao-api/src/main/java/org/osgi/enroute/examples/microservice/dao/dto/PersonDTO.java // public class PersonDTO { // // public long personId; // public String firstName; // public String lastName; // // public List<AddressDTO> addresses = new ArrayList<>(); // } // Path: examples/microservice/dao-impl-jpa/src/main/java/org/osgi/enroute/examples/microservice/dao/impl/jpa/entities/PersonEntity.java import static java.util.stream.Collectors.toList; import static javax.persistence.CascadeType.ALL; import static javax.persistence.GenerationType.IDENTITY; import java.util.ArrayList; import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.Table; import org.osgi.enroute.examples.microservice.dao.dto.PersonDTO; package org.osgi.enroute.examples.microservice.dao.impl.jpa.entities; @Entity @Table(name="persons") public class PersonEntity { @GeneratedValue(strategy = IDENTITY) @Id @Column(name="person_id") private Long personId; @Column(name="first_name") private String firstName; @Column(name="last_name") private String lastName; @OneToMany(mappedBy="person", cascade=ALL) private List<AddressEntity> addresses = new ArrayList<>(); public Long getPersonId() { return personId; }
public PersonDTO toDTO() {
kislayverma/Rulette
rulette-mysql-provider/src/main/java/com/github/kislayverma/rulette/mysql/model/RuleSystemMetadataMysqlModel.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java // public class RuleInputMetaData implements Serializable { // private static final long serialVersionUID = 7018331311799000825L; // private final String name; // private final int priority; // private final RuleInputType ruleInputType; // private final String dataType; // private final String rangeLowerBoundFieldName; // private final String rangeUpperBoundFieldName; // // public RuleInputMetaData(String name, int priority, RuleInputType ruleType, String dataType, // String rangeLowerBoundFieldName, String rangeUpperBoundFieldName) { // this.name = name; // this.priority = priority; // this.ruleInputType = ruleType; // this.dataType = dataType; // this.rangeLowerBoundFieldName = rangeLowerBoundFieldName; // this.rangeUpperBoundFieldName = rangeUpperBoundFieldName; // } // // public String getName() { // return name; // } // // public int getPriority() { // return priority; // } // // public RuleInputType getRuleInputType() { // return ruleInputType; // } // // public String getDataType() { // return dataType; // } // // public String getRangeLowerBoundFieldName() { // return rangeLowerBoundFieldName; // } // // public String getRangeUpperBoundFieldName() { // return rangeUpperBoundFieldName; // } // // @Override // public String toString() { // return "RuleInputMetaData{" + // "name='" + name + '\'' + // ", priority=" + priority + // ", ruleInputType=" + ruleInputType + // ", dataType='" + dataType + '\'' + // ", rangeLowerBoundFieldName='" + rangeLowerBoundFieldName + '\'' + // ", rangeUpperBoundFieldName='" + rangeUpperBoundFieldName + '\'' + // '}'; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleSystemMetaData.java // public class RuleSystemMetaData { // private final DefaultBuilderRegistry BUILDER_REGISTRY = new DefaultBuilderRegistry(); // // private final String ruleSystemName; // private final String tableName; // private final List<RuleInputMetaData> inputColumnList; // private final String uniqueIdColumnName; // private final String uniqueOutputColumnName; // // public RuleSystemMetaData( // String ruleSystemName, // String tableName, // String uniqueIdColName, // String uniqueOutputColName, // List<RuleInputMetaData> inputs) { // this.ruleSystemName = ruleSystemName; // this.tableName = tableName; // this.uniqueIdColumnName = uniqueIdColName; // this.uniqueOutputColumnName = uniqueOutputColName; // this.inputColumnList = inputs; // } // // /** // * This method loads default configuration for all rule inputs if no custom override // * is given (in which case it overrides the defaults). // * Input and output columns always get default configuration. // * // * @param configuration Custom configuration for rule inputs // */ // public void applyCustomConfiguration(RuleInputConfigurator configuration) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // this.uniqueIdColumnName, BUILDER_REGISTRY.getDefaultBuilder(DefaultDataType.STRING.name())); // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // this.uniqueOutputColumnName, BUILDER_REGISTRY.getDefaultBuilder(DefaultDataType.STRING.name())); // // if (configuration == null) { // for (RuleInputMetaData rimd : inputColumnList) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), BUILDER_REGISTRY.getDefaultBuilder(rimd.getDataType())); // } // } else { // for (RuleInputMetaData rimd : inputColumnList) { // RuleInputConfiguration inputConfig = configuration.getConfig(rimd.getName()); // if (inputConfig != null) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), inputConfig.getInputValueBuilder()); // } else { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), BUILDER_REGISTRY.getDefaultBuilder(rimd.getDataType())); // } // } // } // } // // public String getTableName() { // return tableName; // } // // public String getUniqueIdColumnName() { // return uniqueIdColumnName; // } // // public String getUniqueOutputColumnName() { // return uniqueOutputColumnName; // } // // public List<RuleInputMetaData> getInputColumnList() { // return inputColumnList; // } // // public String getRuleSystemName() { // return ruleSystemName; // } // // @Override // public String toString() { // return "RuleSystemMetaData{" + // "ruleSystemName='" + ruleSystemName + '\'' + // ", tableName='" + tableName + '\'' + // ", inputColumnList=" + inputColumnList + // ", uniqueIdColumnName='" + uniqueIdColumnName + '\'' + // ", uniqueOutputColumnName='" + uniqueOutputColumnName + '\'' + // '}'; // } // }
import com.github.kislayverma.rulette.core.metadata.RuleInputMetaData; import com.github.kislayverma.rulette.core.metadata.RuleSystemMetaData; import java.util.List;
package com.github.kislayverma.rulette.mysql.model; /** * This is a Mysql provider specific extension of rule system meta data. It additionally capture the rule system's unique * row id from the MySQL table */ public class RuleSystemMetadataMysqlModel extends RuleSystemMetaData { private final Long ruleSystemId; public RuleSystemMetadataMysqlModel(String ruleSystemName, String tableName, String uniqueIdColName, String uniqueOutputColName,
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java // public class RuleInputMetaData implements Serializable { // private static final long serialVersionUID = 7018331311799000825L; // private final String name; // private final int priority; // private final RuleInputType ruleInputType; // private final String dataType; // private final String rangeLowerBoundFieldName; // private final String rangeUpperBoundFieldName; // // public RuleInputMetaData(String name, int priority, RuleInputType ruleType, String dataType, // String rangeLowerBoundFieldName, String rangeUpperBoundFieldName) { // this.name = name; // this.priority = priority; // this.ruleInputType = ruleType; // this.dataType = dataType; // this.rangeLowerBoundFieldName = rangeLowerBoundFieldName; // this.rangeUpperBoundFieldName = rangeUpperBoundFieldName; // } // // public String getName() { // return name; // } // // public int getPriority() { // return priority; // } // // public RuleInputType getRuleInputType() { // return ruleInputType; // } // // public String getDataType() { // return dataType; // } // // public String getRangeLowerBoundFieldName() { // return rangeLowerBoundFieldName; // } // // public String getRangeUpperBoundFieldName() { // return rangeUpperBoundFieldName; // } // // @Override // public String toString() { // return "RuleInputMetaData{" + // "name='" + name + '\'' + // ", priority=" + priority + // ", ruleInputType=" + ruleInputType + // ", dataType='" + dataType + '\'' + // ", rangeLowerBoundFieldName='" + rangeLowerBoundFieldName + '\'' + // ", rangeUpperBoundFieldName='" + rangeUpperBoundFieldName + '\'' + // '}'; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleSystemMetaData.java // public class RuleSystemMetaData { // private final DefaultBuilderRegistry BUILDER_REGISTRY = new DefaultBuilderRegistry(); // // private final String ruleSystemName; // private final String tableName; // private final List<RuleInputMetaData> inputColumnList; // private final String uniqueIdColumnName; // private final String uniqueOutputColumnName; // // public RuleSystemMetaData( // String ruleSystemName, // String tableName, // String uniqueIdColName, // String uniqueOutputColName, // List<RuleInputMetaData> inputs) { // this.ruleSystemName = ruleSystemName; // this.tableName = tableName; // this.uniqueIdColumnName = uniqueIdColName; // this.uniqueOutputColumnName = uniqueOutputColName; // this.inputColumnList = inputs; // } // // /** // * This method loads default configuration for all rule inputs if no custom override // * is given (in which case it overrides the defaults). // * Input and output columns always get default configuration. // * // * @param configuration Custom configuration for rule inputs // */ // public void applyCustomConfiguration(RuleInputConfigurator configuration) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // this.uniqueIdColumnName, BUILDER_REGISTRY.getDefaultBuilder(DefaultDataType.STRING.name())); // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // this.uniqueOutputColumnName, BUILDER_REGISTRY.getDefaultBuilder(DefaultDataType.STRING.name())); // // if (configuration == null) { // for (RuleInputMetaData rimd : inputColumnList) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), BUILDER_REGISTRY.getDefaultBuilder(rimd.getDataType())); // } // } else { // for (RuleInputMetaData rimd : inputColumnList) { // RuleInputConfiguration inputConfig = configuration.getConfig(rimd.getName()); // if (inputConfig != null) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), inputConfig.getInputValueBuilder()); // } else { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), BUILDER_REGISTRY.getDefaultBuilder(rimd.getDataType())); // } // } // } // } // // public String getTableName() { // return tableName; // } // // public String getUniqueIdColumnName() { // return uniqueIdColumnName; // } // // public String getUniqueOutputColumnName() { // return uniqueOutputColumnName; // } // // public List<RuleInputMetaData> getInputColumnList() { // return inputColumnList; // } // // public String getRuleSystemName() { // return ruleSystemName; // } // // @Override // public String toString() { // return "RuleSystemMetaData{" + // "ruleSystemName='" + ruleSystemName + '\'' + // ", tableName='" + tableName + '\'' + // ", inputColumnList=" + inputColumnList + // ", uniqueIdColumnName='" + uniqueIdColumnName + '\'' + // ", uniqueOutputColumnName='" + uniqueOutputColumnName + '\'' + // '}'; // } // } // Path: rulette-mysql-provider/src/main/java/com/github/kislayverma/rulette/mysql/model/RuleSystemMetadataMysqlModel.java import com.github.kislayverma.rulette.core.metadata.RuleInputMetaData; import com.github.kislayverma.rulette.core.metadata.RuleSystemMetaData; import java.util.List; package com.github.kislayverma.rulette.mysql.model; /** * This is a Mysql provider specific extension of rule system meta data. It additionally capture the rule system's unique * row id from the MySQL table */ public class RuleSystemMetadataMysqlModel extends RuleSystemMetaData { private final Long ruleSystemId; public RuleSystemMetadataMysqlModel(String ruleSystemName, String tableName, String uniqueIdColName, String uniqueOutputColName,
List<RuleInputMetaData> inputs,
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/defaults/DefaultStringInputBuilder.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValueBuilder.java // public interface IInputValueBuilder<T> { // IInputValue<T> build(String value); // }
import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValueBuilder;
package com.github.kislayverma.rulette.core.ruleinput.value.defaults; public class DefaultStringInputBuilder implements IInputValueBuilder<String>{ @Override
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValueBuilder.java // public interface IInputValueBuilder<T> { // IInputValue<T> build(String value); // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/defaults/DefaultStringInputBuilder.java import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValueBuilder; package com.github.kislayverma.rulette.core.ruleinput.value.defaults; public class DefaultStringInputBuilder implements IInputValueBuilder<String>{ @Override
public IInputValue<String> build(String value) {
kislayverma/Rulette
rulette-engine/src/main/java/com/github/kislayverma/rulette/engine/impl/trie/node/ValueNode.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInput.java // public abstract class RuleInput implements Serializable { // private static final long serialVersionUID = 2370282382386651591L; // // protected RuleInputMetaData metaData; // protected String rawInput; // // protected RuleInput(String name, int priority, RuleInputType ruleInputType, // String inputDataType, String rangeLowerBound, String rangeUpperBound) { // // this.metaData = new RuleInputMetaData( // name, priority, ruleInputType, inputDataType, rangeLowerBound, rangeUpperBound); // if (ruleInputType == RuleInputType.VALUE) { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound); // } else { // if (rangeLowerBound == null && rangeUpperBound == null) { // this.rawInput = ""; // } else { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound) + "-" + // (rangeUpperBound == null ? "" : rangeUpperBound); // } // } // } // // /** // * This method matches the given value against this rule input and returns true if it fits. // * For value inputs, match means either same value or 'Any'. For Range input, match means // * 'Any' or the value should fall within the defined range of the input. // * @param value The value to compare against this input // * @return true if the value matches the input definition, false otherwise // */ // public abstract boolean evaluate(String value); // // /** // * This method determines if this rule input conflicts with the given input. For value inputs, // * conflict means having the same value. For range inputs, conflict means having partially // * overlapping range (e.g [1,5] and [2,10]). Ranges DO NOT conflict if one is completely // * contained within the other. // * @param input The rule input to compare with // * @return true if inputs are conflicting // */ // public abstract boolean isConflicting(RuleInput input); // // /** // * This method is used to determine if this rule input is a better than the given rule input // * for the same value. It assumes that both inputs match the value and that they are non-conflicting. // * // * @param input The rule input to be matched against // * @return 0 if both input are identical in fit // * 1 if this input is a better fit // * -1 if this input is not the better fit // */ // public abstract int isBetterFit(RuleInput input); // // public final String getRawValue() { // return this.rawInput; // } // // public String getName() { // return this.metaData.getName(); // } // // public int getPriority() { // return this.metaData.getPriority(); // } // // public RuleInputType getRuleInputType() { // return this.metaData.getRuleInputType(); // } // // public String getRuleInputDataType() { // return this.metaData.getDataType(); // } // // /** // * This method returns true if this rule input is of the 'Any' (match all) type. // * // * @return true if input is 'Any', false otherwise // */ // public abstract boolean isAny(); // // /** // * This method returns true if this input is exactly same as the given other input. // * // * @param otherInput The rule input to compare against // * @return true if this and the given inputs are exactly same, false otherwise // */ // public abstract boolean equals(RuleInput otherInput); // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // builder.append(this.metaData.getName()) // .append(":") // .append(this.rawInput) // .append("\t"); // return builder.toString(); // } // }
import com.github.kislayverma.rulette.core.ruleinput.RuleInput; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap;
package com.github.kislayverma.rulette.engine.impl.trie.node; public class ValueNode extends Node implements Serializable { private static final long serialVersionUID = -5626901234179734237L; private final Map<String, Node> fieldMap = new ConcurrentHashMap<>(); public ValueNode(String fieldName) { super(fieldName); } @Override
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInput.java // public abstract class RuleInput implements Serializable { // private static final long serialVersionUID = 2370282382386651591L; // // protected RuleInputMetaData metaData; // protected String rawInput; // // protected RuleInput(String name, int priority, RuleInputType ruleInputType, // String inputDataType, String rangeLowerBound, String rangeUpperBound) { // // this.metaData = new RuleInputMetaData( // name, priority, ruleInputType, inputDataType, rangeLowerBound, rangeUpperBound); // if (ruleInputType == RuleInputType.VALUE) { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound); // } else { // if (rangeLowerBound == null && rangeUpperBound == null) { // this.rawInput = ""; // } else { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound) + "-" + // (rangeUpperBound == null ? "" : rangeUpperBound); // } // } // } // // /** // * This method matches the given value against this rule input and returns true if it fits. // * For value inputs, match means either same value or 'Any'. For Range input, match means // * 'Any' or the value should fall within the defined range of the input. // * @param value The value to compare against this input // * @return true if the value matches the input definition, false otherwise // */ // public abstract boolean evaluate(String value); // // /** // * This method determines if this rule input conflicts with the given input. For value inputs, // * conflict means having the same value. For range inputs, conflict means having partially // * overlapping range (e.g [1,5] and [2,10]). Ranges DO NOT conflict if one is completely // * contained within the other. // * @param input The rule input to compare with // * @return true if inputs are conflicting // */ // public abstract boolean isConflicting(RuleInput input); // // /** // * This method is used to determine if this rule input is a better than the given rule input // * for the same value. It assumes that both inputs match the value and that they are non-conflicting. // * // * @param input The rule input to be matched against // * @return 0 if both input are identical in fit // * 1 if this input is a better fit // * -1 if this input is not the better fit // */ // public abstract int isBetterFit(RuleInput input); // // public final String getRawValue() { // return this.rawInput; // } // // public String getName() { // return this.metaData.getName(); // } // // public int getPriority() { // return this.metaData.getPriority(); // } // // public RuleInputType getRuleInputType() { // return this.metaData.getRuleInputType(); // } // // public String getRuleInputDataType() { // return this.metaData.getDataType(); // } // // /** // * This method returns true if this rule input is of the 'Any' (match all) type. // * // * @return true if input is 'Any', false otherwise // */ // public abstract boolean isAny(); // // /** // * This method returns true if this input is exactly same as the given other input. // * // * @param otherInput The rule input to compare against // * @return true if this and the given inputs are exactly same, false otherwise // */ // public abstract boolean equals(RuleInput otherInput); // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // builder.append(this.metaData.getName()) // .append(":") // .append(this.rawInput) // .append("\t"); // return builder.toString(); // } // } // Path: rulette-engine/src/main/java/com/github/kislayverma/rulette/engine/impl/trie/node/ValueNode.java import com.github.kislayverma.rulette.core.ruleinput.RuleInput; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; package com.github.kislayverma.rulette.engine.impl.trie.node; public class ValueNode extends Node implements Serializable { private static final long serialVersionUID = -5626901234179734237L; private final Map<String, Node> fieldMap = new ConcurrentHashMap<>(); public ValueNode(String fieldName) { super(fieldName); } @Override
public void addChildNode(RuleInput ruleInput, Node childNode) {
kislayverma/Rulette
rulette-engine/src/main/java/com/github/kislayverma/rulette/engine/impl/trie/node/RangeNode.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInput.java // public abstract class RuleInput implements Serializable { // private static final long serialVersionUID = 2370282382386651591L; // // protected RuleInputMetaData metaData; // protected String rawInput; // // protected RuleInput(String name, int priority, RuleInputType ruleInputType, // String inputDataType, String rangeLowerBound, String rangeUpperBound) { // // this.metaData = new RuleInputMetaData( // name, priority, ruleInputType, inputDataType, rangeLowerBound, rangeUpperBound); // if (ruleInputType == RuleInputType.VALUE) { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound); // } else { // if (rangeLowerBound == null && rangeUpperBound == null) { // this.rawInput = ""; // } else { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound) + "-" + // (rangeUpperBound == null ? "" : rangeUpperBound); // } // } // } // // /** // * This method matches the given value against this rule input and returns true if it fits. // * For value inputs, match means either same value or 'Any'. For Range input, match means // * 'Any' or the value should fall within the defined range of the input. // * @param value The value to compare against this input // * @return true if the value matches the input definition, false otherwise // */ // public abstract boolean evaluate(String value); // // /** // * This method determines if this rule input conflicts with the given input. For value inputs, // * conflict means having the same value. For range inputs, conflict means having partially // * overlapping range (e.g [1,5] and [2,10]). Ranges DO NOT conflict if one is completely // * contained within the other. // * @param input The rule input to compare with // * @return true if inputs are conflicting // */ // public abstract boolean isConflicting(RuleInput input); // // /** // * This method is used to determine if this rule input is a better than the given rule input // * for the same value. It assumes that both inputs match the value and that they are non-conflicting. // * // * @param input The rule input to be matched against // * @return 0 if both input are identical in fit // * 1 if this input is a better fit // * -1 if this input is not the better fit // */ // public abstract int isBetterFit(RuleInput input); // // public final String getRawValue() { // return this.rawInput; // } // // public String getName() { // return this.metaData.getName(); // } // // public int getPriority() { // return this.metaData.getPriority(); // } // // public RuleInputType getRuleInputType() { // return this.metaData.getRuleInputType(); // } // // public String getRuleInputDataType() { // return this.metaData.getDataType(); // } // // /** // * This method returns true if this rule input is of the 'Any' (match all) type. // * // * @return true if input is 'Any', false otherwise // */ // public abstract boolean isAny(); // // /** // * This method returns true if this input is exactly same as the given other input. // * // * @param otherInput The rule input to compare against // * @return true if this and the given inputs are exactly same, false otherwise // */ // public abstract boolean equals(RuleInput otherInput); // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // builder.append(this.metaData.getName()) // .append(":") // .append(this.rawInput) // .append("\t"); // return builder.toString(); // } // }
import com.github.kislayverma.rulette.core.ruleinput.RuleInput; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap;
package com.github.kislayverma.rulette.engine.impl.trie.node; public class RangeNode extends Node implements Serializable { private static final long serialVersionUID = 8644727351374435060L;
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInput.java // public abstract class RuleInput implements Serializable { // private static final long serialVersionUID = 2370282382386651591L; // // protected RuleInputMetaData metaData; // protected String rawInput; // // protected RuleInput(String name, int priority, RuleInputType ruleInputType, // String inputDataType, String rangeLowerBound, String rangeUpperBound) { // // this.metaData = new RuleInputMetaData( // name, priority, ruleInputType, inputDataType, rangeLowerBound, rangeUpperBound); // if (ruleInputType == RuleInputType.VALUE) { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound); // } else { // if (rangeLowerBound == null && rangeUpperBound == null) { // this.rawInput = ""; // } else { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound) + "-" + // (rangeUpperBound == null ? "" : rangeUpperBound); // } // } // } // // /** // * This method matches the given value against this rule input and returns true if it fits. // * For value inputs, match means either same value or 'Any'. For Range input, match means // * 'Any' or the value should fall within the defined range of the input. // * @param value The value to compare against this input // * @return true if the value matches the input definition, false otherwise // */ // public abstract boolean evaluate(String value); // // /** // * This method determines if this rule input conflicts with the given input. For value inputs, // * conflict means having the same value. For range inputs, conflict means having partially // * overlapping range (e.g [1,5] and [2,10]). Ranges DO NOT conflict if one is completely // * contained within the other. // * @param input The rule input to compare with // * @return true if inputs are conflicting // */ // public abstract boolean isConflicting(RuleInput input); // // /** // * This method is used to determine if this rule input is a better than the given rule input // * for the same value. It assumes that both inputs match the value and that they are non-conflicting. // * // * @param input The rule input to be matched against // * @return 0 if both input are identical in fit // * 1 if this input is a better fit // * -1 if this input is not the better fit // */ // public abstract int isBetterFit(RuleInput input); // // public final String getRawValue() { // return this.rawInput; // } // // public String getName() { // return this.metaData.getName(); // } // // public int getPriority() { // return this.metaData.getPriority(); // } // // public RuleInputType getRuleInputType() { // return this.metaData.getRuleInputType(); // } // // public String getRuleInputDataType() { // return this.metaData.getDataType(); // } // // /** // * This method returns true if this rule input is of the 'Any' (match all) type. // * // * @return true if input is 'Any', false otherwise // */ // public abstract boolean isAny(); // // /** // * This method returns true if this input is exactly same as the given other input. // * // * @param otherInput The rule input to compare against // * @return true if this and the given inputs are exactly same, false otherwise // */ // public abstract boolean equals(RuleInput otherInput); // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // builder.append(this.metaData.getName()) // .append(":") // .append(this.rawInput) // .append("\t"); // return builder.toString(); // } // } // Path: rulette-engine/src/main/java/com/github/kislayverma/rulette/engine/impl/trie/node/RangeNode.java import com.github.kislayverma.rulette.core.ruleinput.RuleInput; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; package com.github.kislayverma.rulette.engine.impl.trie.node; public class RangeNode extends Node implements Serializable { private static final long serialVersionUID = 8644727351374435060L;
private final Map<RuleInput, Node> fieldMap = new ConcurrentHashMap<>();
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/gaia/RuleSystemMetaDataMother.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleSystemMetaData.java // public class RuleSystemMetaData { // private final DefaultBuilderRegistry BUILDER_REGISTRY = new DefaultBuilderRegistry(); // // private final String ruleSystemName; // private final String tableName; // private final List<RuleInputMetaData> inputColumnList; // private final String uniqueIdColumnName; // private final String uniqueOutputColumnName; // // public RuleSystemMetaData( // String ruleSystemName, // String tableName, // String uniqueIdColName, // String uniqueOutputColName, // List<RuleInputMetaData> inputs) { // this.ruleSystemName = ruleSystemName; // this.tableName = tableName; // this.uniqueIdColumnName = uniqueIdColName; // this.uniqueOutputColumnName = uniqueOutputColName; // this.inputColumnList = inputs; // } // // /** // * This method loads default configuration for all rule inputs if no custom override // * is given (in which case it overrides the defaults). // * Input and output columns always get default configuration. // * // * @param configuration Custom configuration for rule inputs // */ // public void applyCustomConfiguration(RuleInputConfigurator configuration) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // this.uniqueIdColumnName, BUILDER_REGISTRY.getDefaultBuilder(DefaultDataType.STRING.name())); // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // this.uniqueOutputColumnName, BUILDER_REGISTRY.getDefaultBuilder(DefaultDataType.STRING.name())); // // if (configuration == null) { // for (RuleInputMetaData rimd : inputColumnList) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), BUILDER_REGISTRY.getDefaultBuilder(rimd.getDataType())); // } // } else { // for (RuleInputMetaData rimd : inputColumnList) { // RuleInputConfiguration inputConfig = configuration.getConfig(rimd.getName()); // if (inputConfig != null) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), inputConfig.getInputValueBuilder()); // } else { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), BUILDER_REGISTRY.getDefaultBuilder(rimd.getDataType())); // } // } // } // } // // public String getTableName() { // return tableName; // } // // public String getUniqueIdColumnName() { // return uniqueIdColumnName; // } // // public String getUniqueOutputColumnName() { // return uniqueOutputColumnName; // } // // public List<RuleInputMetaData> getInputColumnList() { // return inputColumnList; // } // // public String getRuleSystemName() { // return ruleSystemName; // } // // @Override // public String toString() { // return "RuleSystemMetaData{" + // "ruleSystemName='" + ruleSystemName + '\'' + // ", tableName='" + tableName + '\'' + // ", inputColumnList=" + inputColumnList + // ", uniqueIdColumnName='" + uniqueIdColumnName + '\'' + // ", uniqueOutputColumnName='" + uniqueOutputColumnName + '\'' + // '}'; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java // public class RuleInputMetaData implements Serializable { // private static final long serialVersionUID = 7018331311799000825L; // private final String name; // private final int priority; // private final RuleInputType ruleInputType; // private final String dataType; // private final String rangeLowerBoundFieldName; // private final String rangeUpperBoundFieldName; // // public RuleInputMetaData(String name, int priority, RuleInputType ruleType, String dataType, // String rangeLowerBoundFieldName, String rangeUpperBoundFieldName) { // this.name = name; // this.priority = priority; // this.ruleInputType = ruleType; // this.dataType = dataType; // this.rangeLowerBoundFieldName = rangeLowerBoundFieldName; // this.rangeUpperBoundFieldName = rangeUpperBoundFieldName; // } // // public String getName() { // return name; // } // // public int getPriority() { // return priority; // } // // public RuleInputType getRuleInputType() { // return ruleInputType; // } // // public String getDataType() { // return dataType; // } // // public String getRangeLowerBoundFieldName() { // return rangeLowerBoundFieldName; // } // // public String getRangeUpperBoundFieldName() { // return rangeUpperBoundFieldName; // } // // @Override // public String toString() { // return "RuleInputMetaData{" + // "name='" + name + '\'' + // ", priority=" + priority + // ", ruleInputType=" + ruleInputType + // ", dataType='" + dataType + '\'' + // ", rangeLowerBoundFieldName='" + rangeLowerBoundFieldName + '\'' + // ", rangeUpperBoundFieldName='" + rangeUpperBoundFieldName + '\'' + // '}'; // } // }
import com.github.kislayverma.rulette.core.metadata.RuleSystemMetaData; import com.github.kislayverma.rulette.core.metadata.RuleInputMetaData; import java.util.List;
package com.github.kislayverma.rulette.core.gaia; public class RuleSystemMetaDataMother { private static final String ruleSystemName = "gaia_rule_system"; private static final String tableName = "gaia_table"; private static final String uniqueIdColumnName = "rule_id"; private static final String uniqueOutputColumnName = "rule_output_id";
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleSystemMetaData.java // public class RuleSystemMetaData { // private final DefaultBuilderRegistry BUILDER_REGISTRY = new DefaultBuilderRegistry(); // // private final String ruleSystemName; // private final String tableName; // private final List<RuleInputMetaData> inputColumnList; // private final String uniqueIdColumnName; // private final String uniqueOutputColumnName; // // public RuleSystemMetaData( // String ruleSystemName, // String tableName, // String uniqueIdColName, // String uniqueOutputColName, // List<RuleInputMetaData> inputs) { // this.ruleSystemName = ruleSystemName; // this.tableName = tableName; // this.uniqueIdColumnName = uniqueIdColName; // this.uniqueOutputColumnName = uniqueOutputColName; // this.inputColumnList = inputs; // } // // /** // * This method loads default configuration for all rule inputs if no custom override // * is given (in which case it overrides the defaults). // * Input and output columns always get default configuration. // * // * @param configuration Custom configuration for rule inputs // */ // public void applyCustomConfiguration(RuleInputConfigurator configuration) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // this.uniqueIdColumnName, BUILDER_REGISTRY.getDefaultBuilder(DefaultDataType.STRING.name())); // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // this.uniqueOutputColumnName, BUILDER_REGISTRY.getDefaultBuilder(DefaultDataType.STRING.name())); // // if (configuration == null) { // for (RuleInputMetaData rimd : inputColumnList) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), BUILDER_REGISTRY.getDefaultBuilder(rimd.getDataType())); // } // } else { // for (RuleInputMetaData rimd : inputColumnList) { // RuleInputConfiguration inputConfig = configuration.getConfig(rimd.getName()); // if (inputConfig != null) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), inputConfig.getInputValueBuilder()); // } else { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), BUILDER_REGISTRY.getDefaultBuilder(rimd.getDataType())); // } // } // } // } // // public String getTableName() { // return tableName; // } // // public String getUniqueIdColumnName() { // return uniqueIdColumnName; // } // // public String getUniqueOutputColumnName() { // return uniqueOutputColumnName; // } // // public List<RuleInputMetaData> getInputColumnList() { // return inputColumnList; // } // // public String getRuleSystemName() { // return ruleSystemName; // } // // @Override // public String toString() { // return "RuleSystemMetaData{" + // "ruleSystemName='" + ruleSystemName + '\'' + // ", tableName='" + tableName + '\'' + // ", inputColumnList=" + inputColumnList + // ", uniqueIdColumnName='" + uniqueIdColumnName + '\'' + // ", uniqueOutputColumnName='" + uniqueOutputColumnName + '\'' + // '}'; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java // public class RuleInputMetaData implements Serializable { // private static final long serialVersionUID = 7018331311799000825L; // private final String name; // private final int priority; // private final RuleInputType ruleInputType; // private final String dataType; // private final String rangeLowerBoundFieldName; // private final String rangeUpperBoundFieldName; // // public RuleInputMetaData(String name, int priority, RuleInputType ruleType, String dataType, // String rangeLowerBoundFieldName, String rangeUpperBoundFieldName) { // this.name = name; // this.priority = priority; // this.ruleInputType = ruleType; // this.dataType = dataType; // this.rangeLowerBoundFieldName = rangeLowerBoundFieldName; // this.rangeUpperBoundFieldName = rangeUpperBoundFieldName; // } // // public String getName() { // return name; // } // // public int getPriority() { // return priority; // } // // public RuleInputType getRuleInputType() { // return ruleInputType; // } // // public String getDataType() { // return dataType; // } // // public String getRangeLowerBoundFieldName() { // return rangeLowerBoundFieldName; // } // // public String getRangeUpperBoundFieldName() { // return rangeUpperBoundFieldName; // } // // @Override // public String toString() { // return "RuleInputMetaData{" + // "name='" + name + '\'' + // ", priority=" + priority + // ", ruleInputType=" + ruleInputType + // ", dataType='" + dataType + '\'' + // ", rangeLowerBoundFieldName='" + rangeLowerBoundFieldName + '\'' + // ", rangeUpperBoundFieldName='" + rangeUpperBoundFieldName + '\'' + // '}'; // } // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/gaia/RuleSystemMetaDataMother.java import com.github.kislayverma.rulette.core.metadata.RuleSystemMetaData; import com.github.kislayverma.rulette.core.metadata.RuleInputMetaData; import java.util.List; package com.github.kislayverma.rulette.core.gaia; public class RuleSystemMetaDataMother { private static final String ruleSystemName = "gaia_rule_system"; private static final String tableName = "gaia_table"; private static final String uniqueIdColumnName = "rule_id"; private static final String uniqueOutputColumnName = "rule_output_id";
public static RuleSystemMetaData getDefaultMetaData() throws Exception {
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/gaia/RuleSystemMetaDataMother.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleSystemMetaData.java // public class RuleSystemMetaData { // private final DefaultBuilderRegistry BUILDER_REGISTRY = new DefaultBuilderRegistry(); // // private final String ruleSystemName; // private final String tableName; // private final List<RuleInputMetaData> inputColumnList; // private final String uniqueIdColumnName; // private final String uniqueOutputColumnName; // // public RuleSystemMetaData( // String ruleSystemName, // String tableName, // String uniqueIdColName, // String uniqueOutputColName, // List<RuleInputMetaData> inputs) { // this.ruleSystemName = ruleSystemName; // this.tableName = tableName; // this.uniqueIdColumnName = uniqueIdColName; // this.uniqueOutputColumnName = uniqueOutputColName; // this.inputColumnList = inputs; // } // // /** // * This method loads default configuration for all rule inputs if no custom override // * is given (in which case it overrides the defaults). // * Input and output columns always get default configuration. // * // * @param configuration Custom configuration for rule inputs // */ // public void applyCustomConfiguration(RuleInputConfigurator configuration) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // this.uniqueIdColumnName, BUILDER_REGISTRY.getDefaultBuilder(DefaultDataType.STRING.name())); // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // this.uniqueOutputColumnName, BUILDER_REGISTRY.getDefaultBuilder(DefaultDataType.STRING.name())); // // if (configuration == null) { // for (RuleInputMetaData rimd : inputColumnList) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), BUILDER_REGISTRY.getDefaultBuilder(rimd.getDataType())); // } // } else { // for (RuleInputMetaData rimd : inputColumnList) { // RuleInputConfiguration inputConfig = configuration.getConfig(rimd.getName()); // if (inputConfig != null) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), inputConfig.getInputValueBuilder()); // } else { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), BUILDER_REGISTRY.getDefaultBuilder(rimd.getDataType())); // } // } // } // } // // public String getTableName() { // return tableName; // } // // public String getUniqueIdColumnName() { // return uniqueIdColumnName; // } // // public String getUniqueOutputColumnName() { // return uniqueOutputColumnName; // } // // public List<RuleInputMetaData> getInputColumnList() { // return inputColumnList; // } // // public String getRuleSystemName() { // return ruleSystemName; // } // // @Override // public String toString() { // return "RuleSystemMetaData{" + // "ruleSystemName='" + ruleSystemName + '\'' + // ", tableName='" + tableName + '\'' + // ", inputColumnList=" + inputColumnList + // ", uniqueIdColumnName='" + uniqueIdColumnName + '\'' + // ", uniqueOutputColumnName='" + uniqueOutputColumnName + '\'' + // '}'; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java // public class RuleInputMetaData implements Serializable { // private static final long serialVersionUID = 7018331311799000825L; // private final String name; // private final int priority; // private final RuleInputType ruleInputType; // private final String dataType; // private final String rangeLowerBoundFieldName; // private final String rangeUpperBoundFieldName; // // public RuleInputMetaData(String name, int priority, RuleInputType ruleType, String dataType, // String rangeLowerBoundFieldName, String rangeUpperBoundFieldName) { // this.name = name; // this.priority = priority; // this.ruleInputType = ruleType; // this.dataType = dataType; // this.rangeLowerBoundFieldName = rangeLowerBoundFieldName; // this.rangeUpperBoundFieldName = rangeUpperBoundFieldName; // } // // public String getName() { // return name; // } // // public int getPriority() { // return priority; // } // // public RuleInputType getRuleInputType() { // return ruleInputType; // } // // public String getDataType() { // return dataType; // } // // public String getRangeLowerBoundFieldName() { // return rangeLowerBoundFieldName; // } // // public String getRangeUpperBoundFieldName() { // return rangeUpperBoundFieldName; // } // // @Override // public String toString() { // return "RuleInputMetaData{" + // "name='" + name + '\'' + // ", priority=" + priority + // ", ruleInputType=" + ruleInputType + // ", dataType='" + dataType + '\'' + // ", rangeLowerBoundFieldName='" + rangeLowerBoundFieldName + '\'' + // ", rangeUpperBoundFieldName='" + rangeUpperBoundFieldName + '\'' + // '}'; // } // }
import com.github.kislayverma.rulette.core.metadata.RuleSystemMetaData; import com.github.kislayverma.rulette.core.metadata.RuleInputMetaData; import java.util.List;
package com.github.kislayverma.rulette.core.gaia; public class RuleSystemMetaDataMother { private static final String ruleSystemName = "gaia_rule_system"; private static final String tableName = "gaia_table"; private static final String uniqueIdColumnName = "rule_id"; private static final String uniqueOutputColumnName = "rule_output_id"; public static RuleSystemMetaData getDefaultMetaData() throws Exception {
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleSystemMetaData.java // public class RuleSystemMetaData { // private final DefaultBuilderRegistry BUILDER_REGISTRY = new DefaultBuilderRegistry(); // // private final String ruleSystemName; // private final String tableName; // private final List<RuleInputMetaData> inputColumnList; // private final String uniqueIdColumnName; // private final String uniqueOutputColumnName; // // public RuleSystemMetaData( // String ruleSystemName, // String tableName, // String uniqueIdColName, // String uniqueOutputColName, // List<RuleInputMetaData> inputs) { // this.ruleSystemName = ruleSystemName; // this.tableName = tableName; // this.uniqueIdColumnName = uniqueIdColName; // this.uniqueOutputColumnName = uniqueOutputColName; // this.inputColumnList = inputs; // } // // /** // * This method loads default configuration for all rule inputs if no custom override // * is given (in which case it overrides the defaults). // * Input and output columns always get default configuration. // * // * @param configuration Custom configuration for rule inputs // */ // public void applyCustomConfiguration(RuleInputConfigurator configuration) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // this.uniqueIdColumnName, BUILDER_REGISTRY.getDefaultBuilder(DefaultDataType.STRING.name())); // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // this.uniqueOutputColumnName, BUILDER_REGISTRY.getDefaultBuilder(DefaultDataType.STRING.name())); // // if (configuration == null) { // for (RuleInputMetaData rimd : inputColumnList) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), BUILDER_REGISTRY.getDefaultBuilder(rimd.getDataType())); // } // } else { // for (RuleInputMetaData rimd : inputColumnList) { // RuleInputConfiguration inputConfig = configuration.getConfig(rimd.getName()); // if (inputConfig != null) { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), inputConfig.getInputValueBuilder()); // } else { // RuleInputValueFactory.getInstance().registerRuleInputBuilder( // rimd.getName(), BUILDER_REGISTRY.getDefaultBuilder(rimd.getDataType())); // } // } // } // } // // public String getTableName() { // return tableName; // } // // public String getUniqueIdColumnName() { // return uniqueIdColumnName; // } // // public String getUniqueOutputColumnName() { // return uniqueOutputColumnName; // } // // public List<RuleInputMetaData> getInputColumnList() { // return inputColumnList; // } // // public String getRuleSystemName() { // return ruleSystemName; // } // // @Override // public String toString() { // return "RuleSystemMetaData{" + // "ruleSystemName='" + ruleSystemName + '\'' + // ", tableName='" + tableName + '\'' + // ", inputColumnList=" + inputColumnList + // ", uniqueIdColumnName='" + uniqueIdColumnName + '\'' + // ", uniqueOutputColumnName='" + uniqueOutputColumnName + '\'' + // '}'; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java // public class RuleInputMetaData implements Serializable { // private static final long serialVersionUID = 7018331311799000825L; // private final String name; // private final int priority; // private final RuleInputType ruleInputType; // private final String dataType; // private final String rangeLowerBoundFieldName; // private final String rangeUpperBoundFieldName; // // public RuleInputMetaData(String name, int priority, RuleInputType ruleType, String dataType, // String rangeLowerBoundFieldName, String rangeUpperBoundFieldName) { // this.name = name; // this.priority = priority; // this.ruleInputType = ruleType; // this.dataType = dataType; // this.rangeLowerBoundFieldName = rangeLowerBoundFieldName; // this.rangeUpperBoundFieldName = rangeUpperBoundFieldName; // } // // public String getName() { // return name; // } // // public int getPriority() { // return priority; // } // // public RuleInputType getRuleInputType() { // return ruleInputType; // } // // public String getDataType() { // return dataType; // } // // public String getRangeLowerBoundFieldName() { // return rangeLowerBoundFieldName; // } // // public String getRangeUpperBoundFieldName() { // return rangeUpperBoundFieldName; // } // // @Override // public String toString() { // return "RuleInputMetaData{" + // "name='" + name + '\'' + // ", priority=" + priority + // ", ruleInputType=" + ruleInputType + // ", dataType='" + dataType + '\'' + // ", rangeLowerBoundFieldName='" + rangeLowerBoundFieldName + '\'' + // ", rangeUpperBoundFieldName='" + rangeUpperBoundFieldName + '\'' + // '}'; // } // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/gaia/RuleSystemMetaDataMother.java import com.github.kislayverma.rulette.core.metadata.RuleSystemMetaData; import com.github.kislayverma.rulette.core.metadata.RuleInputMetaData; import java.util.List; package com.github.kislayverma.rulette.core.gaia; public class RuleSystemMetaDataMother { private static final String ruleSystemName = "gaia_rule_system"; private static final String tableName = "gaia_table"; private static final String uniqueIdColumnName = "rule_id"; private static final String uniqueOutputColumnName = "rule_output_id"; public static RuleSystemMetaData getDefaultMetaData() throws Exception {
List<RuleInputMetaData> ruleInputs = RuleInputMetaDataMother.getDefaultValueMetaData(5);
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/defaults/DefaultDateInputBuilder.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValueBuilder.java // public interface IInputValueBuilder<T> { // IInputValue<T> build(String value); // }
import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValueBuilder; import java.util.Date;
package com.github.kislayverma.rulette.core.ruleinput.value.defaults; public class DefaultDateInputBuilder implements IInputValueBuilder<Date>{ @Override
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValueBuilder.java // public interface IInputValueBuilder<T> { // IInputValue<T> build(String value); // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/defaults/DefaultDateInputBuilder.java import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValueBuilder; import java.util.Date; package com.github.kislayverma.rulette.core.ruleinput.value.defaults; public class DefaultDateInputBuilder implements IInputValueBuilder<Date>{ @Override
public IInputValue<Date> build(String value) {
kislayverma/Rulette
rulette-mysql-provider/src/main/java/com/github/kislayverma/rulette/mysql/dao/DataSource.java
// Path: rulette-mysql-provider/src/main/java/com/github/kislayverma/rulette/mysql/util/Utils.java // public class Utils { // private static final String PROPERTY_MYSQL_DRIVER_CLASS = "driverClass"; // private static final String PROPERTY_JDBC_URL = "jdbcUrl"; // private static final String PROPERTY_USER_NAME = "username"; // private static final String PROPERTY_PASSWORD = "password"; // private static final String PROPERTY_MAX_POOL_SIZE = "maxPoolSize"; // private static final String PROPERTY_CONN_TIMEOUT = "connectionTimeout"; // // /** // * Read a properties file from the class path and return a Properties object // * // * @param fileName file to read // * @return Properties object loaded with properties from the given file // * @throws IOException on file reading error // */ // public static Properties readProperties(String fileName) throws IOException { // File f = new File(fileName); // if (!f.canRead()) { // throw new IOException("Could not read the datasource file"); // } // // URL url = f.toURI().toURL(); // InputStream in = url.openStream(); // Properties props = new Properties(); // props.load(in); // // return props; // } // // /** // * This method build a {@link HikariConfig} object from the given properties file. // * @param fileName A property file containing the Hikari configurations // */ // public static HikariConfig getHikariConfig(String fileName) throws IOException { // return getHikariConfig(Utils.readProperties(fileName)); // } // // /** // * This method build a {@link HikariConfig} object from the given properties file. // * @param props An {@link Properties} object encapsulating Hikari properties // */ // public static HikariConfig getHikariConfig(Properties props) { // HikariConfig hikariConfig = new HikariConfig(); // hikariConfig.setDriverClassName(props.getProperty(PROPERTY_MYSQL_DRIVER_CLASS)); // hikariConfig.setJdbcUrl(props.getProperty(PROPERTY_JDBC_URL)); // hikariConfig.setUsername(props.getProperty(PROPERTY_USER_NAME)); // hikariConfig.setPassword(props.getProperty(PROPERTY_PASSWORD)); // hikariConfig.setMaximumPoolSize(Integer.parseInt(props.getProperty(PROPERTY_MAX_POOL_SIZE))); // hikariConfig.setConnectionTimeout(Long.parseLong(props.getProperty(PROPERTY_CONN_TIMEOUT))); // // return hikariConfig; // } // // public static void closeSqlArtifacts(ResultSet resultSet, Statement statement, Connection connection) { // try { // if (resultSet != null) { // resultSet.close(); // } // if (statement != null) { // statement.close(); // } // if (connection != null) { // connection.close(); // } // } catch (Exception e) { // throw new DataAccessException("Failed to close database connection", e); // } // } // }
import java.io.IOException; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; import com.github.kislayverma.rulette.mysql.util.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource;
package com.github.kislayverma.rulette.mysql.dao; /** * This class represents the underlying MySQL connection pool */ public class DataSource { private static final Logger LOGGER = LoggerFactory.getLogger(DataSource.class); private HikariDataSource hikariDatasource; public DataSource(String fileName) throws IOException, SQLException {
// Path: rulette-mysql-provider/src/main/java/com/github/kislayverma/rulette/mysql/util/Utils.java // public class Utils { // private static final String PROPERTY_MYSQL_DRIVER_CLASS = "driverClass"; // private static final String PROPERTY_JDBC_URL = "jdbcUrl"; // private static final String PROPERTY_USER_NAME = "username"; // private static final String PROPERTY_PASSWORD = "password"; // private static final String PROPERTY_MAX_POOL_SIZE = "maxPoolSize"; // private static final String PROPERTY_CONN_TIMEOUT = "connectionTimeout"; // // /** // * Read a properties file from the class path and return a Properties object // * // * @param fileName file to read // * @return Properties object loaded with properties from the given file // * @throws IOException on file reading error // */ // public static Properties readProperties(String fileName) throws IOException { // File f = new File(fileName); // if (!f.canRead()) { // throw new IOException("Could not read the datasource file"); // } // // URL url = f.toURI().toURL(); // InputStream in = url.openStream(); // Properties props = new Properties(); // props.load(in); // // return props; // } // // /** // * This method build a {@link HikariConfig} object from the given properties file. // * @param fileName A property file containing the Hikari configurations // */ // public static HikariConfig getHikariConfig(String fileName) throws IOException { // return getHikariConfig(Utils.readProperties(fileName)); // } // // /** // * This method build a {@link HikariConfig} object from the given properties file. // * @param props An {@link Properties} object encapsulating Hikari properties // */ // public static HikariConfig getHikariConfig(Properties props) { // HikariConfig hikariConfig = new HikariConfig(); // hikariConfig.setDriverClassName(props.getProperty(PROPERTY_MYSQL_DRIVER_CLASS)); // hikariConfig.setJdbcUrl(props.getProperty(PROPERTY_JDBC_URL)); // hikariConfig.setUsername(props.getProperty(PROPERTY_USER_NAME)); // hikariConfig.setPassword(props.getProperty(PROPERTY_PASSWORD)); // hikariConfig.setMaximumPoolSize(Integer.parseInt(props.getProperty(PROPERTY_MAX_POOL_SIZE))); // hikariConfig.setConnectionTimeout(Long.parseLong(props.getProperty(PROPERTY_CONN_TIMEOUT))); // // return hikariConfig; // } // // public static void closeSqlArtifacts(ResultSet resultSet, Statement statement, Connection connection) { // try { // if (resultSet != null) { // resultSet.close(); // } // if (statement != null) { // statement.close(); // } // if (connection != null) { // connection.close(); // } // } catch (Exception e) { // throw new DataAccessException("Failed to close database connection", e); // } // } // } // Path: rulette-mysql-provider/src/main/java/com/github/kislayverma/rulette/mysql/dao/DataSource.java import java.io.IOException; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; import com.github.kislayverma.rulette.mysql.util.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; package com.github.kislayverma.rulette.mysql.dao; /** * This class represents the underlying MySQL connection pool */ public class DataSource { private static final Logger LOGGER = LoggerFactory.getLogger(DataSource.class); private HikariDataSource hikariDatasource; public DataSource(String fileName) throws IOException, SQLException {
this(Utils.getHikariConfig(fileName));
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/RangeInput.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInput.java // public abstract class RuleInput implements Serializable { // private static final long serialVersionUID = 2370282382386651591L; // // protected RuleInputMetaData metaData; // protected String rawInput; // // protected RuleInput(String name, int priority, RuleInputType ruleInputType, // String inputDataType, String rangeLowerBound, String rangeUpperBound) { // // this.metaData = new RuleInputMetaData( // name, priority, ruleInputType, inputDataType, rangeLowerBound, rangeUpperBound); // if (ruleInputType == RuleInputType.VALUE) { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound); // } else { // if (rangeLowerBound == null && rangeUpperBound == null) { // this.rawInput = ""; // } else { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound) + "-" + // (rangeUpperBound == null ? "" : rangeUpperBound); // } // } // } // // /** // * This method matches the given value against this rule input and returns true if it fits. // * For value inputs, match means either same value or 'Any'. For Range input, match means // * 'Any' or the value should fall within the defined range of the input. // * @param value The value to compare against this input // * @return true if the value matches the input definition, false otherwise // */ // public abstract boolean evaluate(String value); // // /** // * This method determines if this rule input conflicts with the given input. For value inputs, // * conflict means having the same value. For range inputs, conflict means having partially // * overlapping range (e.g [1,5] and [2,10]). Ranges DO NOT conflict if one is completely // * contained within the other. // * @param input The rule input to compare with // * @return true if inputs are conflicting // */ // public abstract boolean isConflicting(RuleInput input); // // /** // * This method is used to determine if this rule input is a better than the given rule input // * for the same value. It assumes that both inputs match the value and that they are non-conflicting. // * // * @param input The rule input to be matched against // * @return 0 if both input are identical in fit // * 1 if this input is a better fit // * -1 if this input is not the better fit // */ // public abstract int isBetterFit(RuleInput input); // // public final String getRawValue() { // return this.rawInput; // } // // public String getName() { // return this.metaData.getName(); // } // // public int getPriority() { // return this.metaData.getPriority(); // } // // public RuleInputType getRuleInputType() { // return this.metaData.getRuleInputType(); // } // // public String getRuleInputDataType() { // return this.metaData.getDataType(); // } // // /** // * This method returns true if this rule input is of the 'Any' (match all) type. // * // * @return true if input is 'Any', false otherwise // */ // public abstract boolean isAny(); // // /** // * This method returns true if this input is exactly same as the given other input. // * // * @param otherInput The rule input to compare against // * @return true if this and the given inputs are exactly same, false otherwise // */ // public abstract boolean equals(RuleInput otherInput); // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // builder.append(this.metaData.getName()) // .append(":") // .append(this.rawInput) // .append("\t"); // return builder.toString(); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java // public class RuleInputValueFactory { // private static RuleInputValueFactory INSTANCE; // private final Map<String, IInputValueBuilder> builderMap; // private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); // // private RuleInputValueFactory() { // LOGGER.info("Initializing input data type factory..."); // this.builderMap = new ConcurrentHashMap<>(); // LOGGER.info("Input data type factory initialized"); // } // // public static RuleInputValueFactory getInstance() { // if (INSTANCE == null) { // INSTANCE = new RuleInputValueFactory(); // } // // return INSTANCE; // } // // public IInputValue buildRuleInputVaue(String ruleInputName, String rawValue) { // // IInputValueBuilder builder = builderMap.get(ruleInputName); // if (builder == null) { // throw new IllegalArgumentException("No input value builder registered for input " + ruleInputName); // } else { // return builder.build(rawValue); // } // } // // public void registerRuleInputBuilder(String ruleInputName, IInputValueBuilder builder) { // builderMap.put(ruleInputName, builder); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // }
import com.github.kislayverma.rulette.core.ruleinput.RuleInput; import com.github.kislayverma.rulette.core.ruleinput.RuleInputValueFactory; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import java.io.Serializable;
package com.github.kislayverma.rulette.core.ruleinput.type; public class RangeInput extends RuleInput implements Serializable { private static final long serialVersionUID = 7246688913819092267L;
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInput.java // public abstract class RuleInput implements Serializable { // private static final long serialVersionUID = 2370282382386651591L; // // protected RuleInputMetaData metaData; // protected String rawInput; // // protected RuleInput(String name, int priority, RuleInputType ruleInputType, // String inputDataType, String rangeLowerBound, String rangeUpperBound) { // // this.metaData = new RuleInputMetaData( // name, priority, ruleInputType, inputDataType, rangeLowerBound, rangeUpperBound); // if (ruleInputType == RuleInputType.VALUE) { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound); // } else { // if (rangeLowerBound == null && rangeUpperBound == null) { // this.rawInput = ""; // } else { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound) + "-" + // (rangeUpperBound == null ? "" : rangeUpperBound); // } // } // } // // /** // * This method matches the given value against this rule input and returns true if it fits. // * For value inputs, match means either same value or 'Any'. For Range input, match means // * 'Any' or the value should fall within the defined range of the input. // * @param value The value to compare against this input // * @return true if the value matches the input definition, false otherwise // */ // public abstract boolean evaluate(String value); // // /** // * This method determines if this rule input conflicts with the given input. For value inputs, // * conflict means having the same value. For range inputs, conflict means having partially // * overlapping range (e.g [1,5] and [2,10]). Ranges DO NOT conflict if one is completely // * contained within the other. // * @param input The rule input to compare with // * @return true if inputs are conflicting // */ // public abstract boolean isConflicting(RuleInput input); // // /** // * This method is used to determine if this rule input is a better than the given rule input // * for the same value. It assumes that both inputs match the value and that they are non-conflicting. // * // * @param input The rule input to be matched against // * @return 0 if both input are identical in fit // * 1 if this input is a better fit // * -1 if this input is not the better fit // */ // public abstract int isBetterFit(RuleInput input); // // public final String getRawValue() { // return this.rawInput; // } // // public String getName() { // return this.metaData.getName(); // } // // public int getPriority() { // return this.metaData.getPriority(); // } // // public RuleInputType getRuleInputType() { // return this.metaData.getRuleInputType(); // } // // public String getRuleInputDataType() { // return this.metaData.getDataType(); // } // // /** // * This method returns true if this rule input is of the 'Any' (match all) type. // * // * @return true if input is 'Any', false otherwise // */ // public abstract boolean isAny(); // // /** // * This method returns true if this input is exactly same as the given other input. // * // * @param otherInput The rule input to compare against // * @return true if this and the given inputs are exactly same, false otherwise // */ // public abstract boolean equals(RuleInput otherInput); // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // builder.append(this.metaData.getName()) // .append(":") // .append(this.rawInput) // .append("\t"); // return builder.toString(); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java // public class RuleInputValueFactory { // private static RuleInputValueFactory INSTANCE; // private final Map<String, IInputValueBuilder> builderMap; // private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); // // private RuleInputValueFactory() { // LOGGER.info("Initializing input data type factory..."); // this.builderMap = new ConcurrentHashMap<>(); // LOGGER.info("Input data type factory initialized"); // } // // public static RuleInputValueFactory getInstance() { // if (INSTANCE == null) { // INSTANCE = new RuleInputValueFactory(); // } // // return INSTANCE; // } // // public IInputValue buildRuleInputVaue(String ruleInputName, String rawValue) { // // IInputValueBuilder builder = builderMap.get(ruleInputName); // if (builder == null) { // throw new IllegalArgumentException("No input value builder registered for input " + ruleInputName); // } else { // return builder.build(rawValue); // } // } // // public void registerRuleInputBuilder(String ruleInputName, IInputValueBuilder builder) { // builderMap.put(ruleInputName, builder); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/RangeInput.java import com.github.kislayverma.rulette.core.ruleinput.RuleInput; import com.github.kislayverma.rulette.core.ruleinput.RuleInputValueFactory; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import java.io.Serializable; package com.github.kislayverma.rulette.core.ruleinput.type; public class RangeInput extends RuleInput implements Serializable { private static final long serialVersionUID = 7246688913819092267L;
private final IInputValue lowerBound;
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/RangeInput.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInput.java // public abstract class RuleInput implements Serializable { // private static final long serialVersionUID = 2370282382386651591L; // // protected RuleInputMetaData metaData; // protected String rawInput; // // protected RuleInput(String name, int priority, RuleInputType ruleInputType, // String inputDataType, String rangeLowerBound, String rangeUpperBound) { // // this.metaData = new RuleInputMetaData( // name, priority, ruleInputType, inputDataType, rangeLowerBound, rangeUpperBound); // if (ruleInputType == RuleInputType.VALUE) { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound); // } else { // if (rangeLowerBound == null && rangeUpperBound == null) { // this.rawInput = ""; // } else { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound) + "-" + // (rangeUpperBound == null ? "" : rangeUpperBound); // } // } // } // // /** // * This method matches the given value against this rule input and returns true if it fits. // * For value inputs, match means either same value or 'Any'. For Range input, match means // * 'Any' or the value should fall within the defined range of the input. // * @param value The value to compare against this input // * @return true if the value matches the input definition, false otherwise // */ // public abstract boolean evaluate(String value); // // /** // * This method determines if this rule input conflicts with the given input. For value inputs, // * conflict means having the same value. For range inputs, conflict means having partially // * overlapping range (e.g [1,5] and [2,10]). Ranges DO NOT conflict if one is completely // * contained within the other. // * @param input The rule input to compare with // * @return true if inputs are conflicting // */ // public abstract boolean isConflicting(RuleInput input); // // /** // * This method is used to determine if this rule input is a better than the given rule input // * for the same value. It assumes that both inputs match the value and that they are non-conflicting. // * // * @param input The rule input to be matched against // * @return 0 if both input are identical in fit // * 1 if this input is a better fit // * -1 if this input is not the better fit // */ // public abstract int isBetterFit(RuleInput input); // // public final String getRawValue() { // return this.rawInput; // } // // public String getName() { // return this.metaData.getName(); // } // // public int getPriority() { // return this.metaData.getPriority(); // } // // public RuleInputType getRuleInputType() { // return this.metaData.getRuleInputType(); // } // // public String getRuleInputDataType() { // return this.metaData.getDataType(); // } // // /** // * This method returns true if this rule input is of the 'Any' (match all) type. // * // * @return true if input is 'Any', false otherwise // */ // public abstract boolean isAny(); // // /** // * This method returns true if this input is exactly same as the given other input. // * // * @param otherInput The rule input to compare against // * @return true if this and the given inputs are exactly same, false otherwise // */ // public abstract boolean equals(RuleInput otherInput); // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // builder.append(this.metaData.getName()) // .append(":") // .append(this.rawInput) // .append("\t"); // return builder.toString(); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java // public class RuleInputValueFactory { // private static RuleInputValueFactory INSTANCE; // private final Map<String, IInputValueBuilder> builderMap; // private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); // // private RuleInputValueFactory() { // LOGGER.info("Initializing input data type factory..."); // this.builderMap = new ConcurrentHashMap<>(); // LOGGER.info("Input data type factory initialized"); // } // // public static RuleInputValueFactory getInstance() { // if (INSTANCE == null) { // INSTANCE = new RuleInputValueFactory(); // } // // return INSTANCE; // } // // public IInputValue buildRuleInputVaue(String ruleInputName, String rawValue) { // // IInputValueBuilder builder = builderMap.get(ruleInputName); // if (builder == null) { // throw new IllegalArgumentException("No input value builder registered for input " + ruleInputName); // } else { // return builder.build(rawValue); // } // } // // public void registerRuleInputBuilder(String ruleInputName, IInputValueBuilder builder) { // builderMap.put(ruleInputName, builder); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // }
import com.github.kislayverma.rulette.core.ruleinput.RuleInput; import com.github.kislayverma.rulette.core.ruleinput.RuleInputValueFactory; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import java.io.Serializable;
package com.github.kislayverma.rulette.core.ruleinput.type; public class RangeInput extends RuleInput implements Serializable { private static final long serialVersionUID = 7246688913819092267L; private final IInputValue lowerBound; private final IInputValue upperBound; public RangeInput(String name, int priority, String inputDataType, String lowerBound, String upperBound) { super(name, priority, RuleInputType.RANGE, inputDataType, lowerBound, upperBound);
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInput.java // public abstract class RuleInput implements Serializable { // private static final long serialVersionUID = 2370282382386651591L; // // protected RuleInputMetaData metaData; // protected String rawInput; // // protected RuleInput(String name, int priority, RuleInputType ruleInputType, // String inputDataType, String rangeLowerBound, String rangeUpperBound) { // // this.metaData = new RuleInputMetaData( // name, priority, ruleInputType, inputDataType, rangeLowerBound, rangeUpperBound); // if (ruleInputType == RuleInputType.VALUE) { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound); // } else { // if (rangeLowerBound == null && rangeUpperBound == null) { // this.rawInput = ""; // } else { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound) + "-" + // (rangeUpperBound == null ? "" : rangeUpperBound); // } // } // } // // /** // * This method matches the given value against this rule input and returns true if it fits. // * For value inputs, match means either same value or 'Any'. For Range input, match means // * 'Any' or the value should fall within the defined range of the input. // * @param value The value to compare against this input // * @return true if the value matches the input definition, false otherwise // */ // public abstract boolean evaluate(String value); // // /** // * This method determines if this rule input conflicts with the given input. For value inputs, // * conflict means having the same value. For range inputs, conflict means having partially // * overlapping range (e.g [1,5] and [2,10]). Ranges DO NOT conflict if one is completely // * contained within the other. // * @param input The rule input to compare with // * @return true if inputs are conflicting // */ // public abstract boolean isConflicting(RuleInput input); // // /** // * This method is used to determine if this rule input is a better than the given rule input // * for the same value. It assumes that both inputs match the value and that they are non-conflicting. // * // * @param input The rule input to be matched against // * @return 0 if both input are identical in fit // * 1 if this input is a better fit // * -1 if this input is not the better fit // */ // public abstract int isBetterFit(RuleInput input); // // public final String getRawValue() { // return this.rawInput; // } // // public String getName() { // return this.metaData.getName(); // } // // public int getPriority() { // return this.metaData.getPriority(); // } // // public RuleInputType getRuleInputType() { // return this.metaData.getRuleInputType(); // } // // public String getRuleInputDataType() { // return this.metaData.getDataType(); // } // // /** // * This method returns true if this rule input is of the 'Any' (match all) type. // * // * @return true if input is 'Any', false otherwise // */ // public abstract boolean isAny(); // // /** // * This method returns true if this input is exactly same as the given other input. // * // * @param otherInput The rule input to compare against // * @return true if this and the given inputs are exactly same, false otherwise // */ // public abstract boolean equals(RuleInput otherInput); // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // builder.append(this.metaData.getName()) // .append(":") // .append(this.rawInput) // .append("\t"); // return builder.toString(); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java // public class RuleInputValueFactory { // private static RuleInputValueFactory INSTANCE; // private final Map<String, IInputValueBuilder> builderMap; // private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); // // private RuleInputValueFactory() { // LOGGER.info("Initializing input data type factory..."); // this.builderMap = new ConcurrentHashMap<>(); // LOGGER.info("Input data type factory initialized"); // } // // public static RuleInputValueFactory getInstance() { // if (INSTANCE == null) { // INSTANCE = new RuleInputValueFactory(); // } // // return INSTANCE; // } // // public IInputValue buildRuleInputVaue(String ruleInputName, String rawValue) { // // IInputValueBuilder builder = builderMap.get(ruleInputName); // if (builder == null) { // throw new IllegalArgumentException("No input value builder registered for input " + ruleInputName); // } else { // return builder.build(rawValue); // } // } // // public void registerRuleInputBuilder(String ruleInputName, IInputValueBuilder builder) { // builderMap.put(ruleInputName, builder); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/RangeInput.java import com.github.kislayverma.rulette.core.ruleinput.RuleInput; import com.github.kislayverma.rulette.core.ruleinput.RuleInputValueFactory; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import java.io.Serializable; package com.github.kislayverma.rulette.core.ruleinput.type; public class RangeInput extends RuleInput implements Serializable { private static final long serialVersionUID = 7246688913819092267L; private final IInputValue lowerBound; private final IInputValue upperBound; public RangeInput(String name, int priority, String inputDataType, String lowerBound, String upperBound) { super(name, priority, RuleInputType.RANGE, inputDataType, lowerBound, upperBound);
this.lowerBound = RuleInputValueFactory.getInstance().buildRuleInputVaue(name, lowerBound == null ? "" : lowerBound);
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfiguration.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValueBuilder.java // public interface IInputValueBuilder<T> { // IInputValue<T> build(String value); // }
import com.github.kislayverma.rulette.core.ruleinput.value.IInputValueBuilder;
package com.github.kislayverma.rulette.core.ruleinput; public class RuleInputConfiguration { private final String ruleInputName;
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValueBuilder.java // public interface IInputValueBuilder<T> { // IInputValue<T> build(String value); // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfiguration.java import com.github.kislayverma.rulette.core.ruleinput.value.IInputValueBuilder; package com.github.kislayverma.rulette.core.ruleinput; public class RuleInputConfiguration { private final String ruleInputName;
private final IInputValueBuilder inputValueBuilder;
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/RuleInputType.java // public enum RuleInputType { // VALUE, // RANGE // }
import com.github.kislayverma.rulette.core.ruleinput.type.RuleInputType; import java.io.Serializable;
package com.github.kislayverma.rulette.core.metadata; /** * This class represents the rule input entity model */ public class RuleInputMetaData implements Serializable { private static final long serialVersionUID = 7018331311799000825L; private final String name; private final int priority;
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/RuleInputType.java // public enum RuleInputType { // VALUE, // RANGE // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java import com.github.kislayverma.rulette.core.ruleinput.type.RuleInputType; import java.io.Serializable; package com.github.kislayverma.rulette.core.metadata; /** * This class represents the rule input entity model */ public class RuleInputMetaData implements Serializable { private static final long serialVersionUID = 7018331311799000825L; private final String name; private final int priority;
private final RuleInputType ruleInputType;
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/gaia/RuleInputMetaDataMother.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java // public class RuleInputMetaData implements Serializable { // private static final long serialVersionUID = 7018331311799000825L; // private final String name; // private final int priority; // private final RuleInputType ruleInputType; // private final String dataType; // private final String rangeLowerBoundFieldName; // private final String rangeUpperBoundFieldName; // // public RuleInputMetaData(String name, int priority, RuleInputType ruleType, String dataType, // String rangeLowerBoundFieldName, String rangeUpperBoundFieldName) { // this.name = name; // this.priority = priority; // this.ruleInputType = ruleType; // this.dataType = dataType; // this.rangeLowerBoundFieldName = rangeLowerBoundFieldName; // this.rangeUpperBoundFieldName = rangeUpperBoundFieldName; // } // // public String getName() { // return name; // } // // public int getPriority() { // return priority; // } // // public RuleInputType getRuleInputType() { // return ruleInputType; // } // // public String getDataType() { // return dataType; // } // // public String getRangeLowerBoundFieldName() { // return rangeLowerBoundFieldName; // } // // public String getRangeUpperBoundFieldName() { // return rangeUpperBoundFieldName; // } // // @Override // public String toString() { // return "RuleInputMetaData{" + // "name='" + name + '\'' + // ", priority=" + priority + // ", ruleInputType=" + ruleInputType + // ", dataType='" + dataType + '\'' + // ", rangeLowerBoundFieldName='" + rangeLowerBoundFieldName + '\'' + // ", rangeUpperBoundFieldName='" + rangeUpperBoundFieldName + '\'' + // '}'; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/RuleInputType.java // public enum RuleInputType { // VALUE, // RANGE // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/DefaultDataType.java // public enum DefaultDataType { // NUMBER, // DATE, // STRING // }
import com.github.kislayverma.rulette.core.metadata.RuleInputMetaData; import com.github.kislayverma.rulette.core.ruleinput.type.RuleInputType; import com.github.kislayverma.rulette.core.ruleinput.value.DefaultDataType; import java.util.ArrayList; import java.util.List; import java.util.Random;
package com.github.kislayverma.rulette.core.gaia; public class RuleInputMetaDataMother { private static final Random RANDOM_NUM_GENERATOR = new Random(); private static final String DUMMY_RULE_INPUT_NAME = "input-name-"; private static final String DUMMY_LOWER_BOUND_FIELD_NAME = "lower-bound-field-name-"; private static final String DUMMY_UPPER_BOUND_FIELD_NAME = "upper-bound-field-name-";
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java // public class RuleInputMetaData implements Serializable { // private static final long serialVersionUID = 7018331311799000825L; // private final String name; // private final int priority; // private final RuleInputType ruleInputType; // private final String dataType; // private final String rangeLowerBoundFieldName; // private final String rangeUpperBoundFieldName; // // public RuleInputMetaData(String name, int priority, RuleInputType ruleType, String dataType, // String rangeLowerBoundFieldName, String rangeUpperBoundFieldName) { // this.name = name; // this.priority = priority; // this.ruleInputType = ruleType; // this.dataType = dataType; // this.rangeLowerBoundFieldName = rangeLowerBoundFieldName; // this.rangeUpperBoundFieldName = rangeUpperBoundFieldName; // } // // public String getName() { // return name; // } // // public int getPriority() { // return priority; // } // // public RuleInputType getRuleInputType() { // return ruleInputType; // } // // public String getDataType() { // return dataType; // } // // public String getRangeLowerBoundFieldName() { // return rangeLowerBoundFieldName; // } // // public String getRangeUpperBoundFieldName() { // return rangeUpperBoundFieldName; // } // // @Override // public String toString() { // return "RuleInputMetaData{" + // "name='" + name + '\'' + // ", priority=" + priority + // ", ruleInputType=" + ruleInputType + // ", dataType='" + dataType + '\'' + // ", rangeLowerBoundFieldName='" + rangeLowerBoundFieldName + '\'' + // ", rangeUpperBoundFieldName='" + rangeUpperBoundFieldName + '\'' + // '}'; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/RuleInputType.java // public enum RuleInputType { // VALUE, // RANGE // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/DefaultDataType.java // public enum DefaultDataType { // NUMBER, // DATE, // STRING // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/gaia/RuleInputMetaDataMother.java import com.github.kislayverma.rulette.core.metadata.RuleInputMetaData; import com.github.kislayverma.rulette.core.ruleinput.type.RuleInputType; import com.github.kislayverma.rulette.core.ruleinput.value.DefaultDataType; import java.util.ArrayList; import java.util.List; import java.util.Random; package com.github.kislayverma.rulette.core.gaia; public class RuleInputMetaDataMother { private static final Random RANDOM_NUM_GENERATOR = new Random(); private static final String DUMMY_RULE_INPUT_NAME = "input-name-"; private static final String DUMMY_LOWER_BOUND_FIELD_NAME = "lower-bound-field-name-"; private static final String DUMMY_UPPER_BOUND_FIELD_NAME = "upper-bound-field-name-";
public static List<RuleInputMetaData> getDefaultRangeMetaData(int n) throws Exception {
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/gaia/RuleInputMetaDataMother.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java // public class RuleInputMetaData implements Serializable { // private static final long serialVersionUID = 7018331311799000825L; // private final String name; // private final int priority; // private final RuleInputType ruleInputType; // private final String dataType; // private final String rangeLowerBoundFieldName; // private final String rangeUpperBoundFieldName; // // public RuleInputMetaData(String name, int priority, RuleInputType ruleType, String dataType, // String rangeLowerBoundFieldName, String rangeUpperBoundFieldName) { // this.name = name; // this.priority = priority; // this.ruleInputType = ruleType; // this.dataType = dataType; // this.rangeLowerBoundFieldName = rangeLowerBoundFieldName; // this.rangeUpperBoundFieldName = rangeUpperBoundFieldName; // } // // public String getName() { // return name; // } // // public int getPriority() { // return priority; // } // // public RuleInputType getRuleInputType() { // return ruleInputType; // } // // public String getDataType() { // return dataType; // } // // public String getRangeLowerBoundFieldName() { // return rangeLowerBoundFieldName; // } // // public String getRangeUpperBoundFieldName() { // return rangeUpperBoundFieldName; // } // // @Override // public String toString() { // return "RuleInputMetaData{" + // "name='" + name + '\'' + // ", priority=" + priority + // ", ruleInputType=" + ruleInputType + // ", dataType='" + dataType + '\'' + // ", rangeLowerBoundFieldName='" + rangeLowerBoundFieldName + '\'' + // ", rangeUpperBoundFieldName='" + rangeUpperBoundFieldName + '\'' + // '}'; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/RuleInputType.java // public enum RuleInputType { // VALUE, // RANGE // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/DefaultDataType.java // public enum DefaultDataType { // NUMBER, // DATE, // STRING // }
import com.github.kislayverma.rulette.core.metadata.RuleInputMetaData; import com.github.kislayverma.rulette.core.ruleinput.type.RuleInputType; import com.github.kislayverma.rulette.core.ruleinput.value.DefaultDataType; import java.util.ArrayList; import java.util.List; import java.util.Random;
package com.github.kislayverma.rulette.core.gaia; public class RuleInputMetaDataMother { private static final Random RANDOM_NUM_GENERATOR = new Random(); private static final String DUMMY_RULE_INPUT_NAME = "input-name-"; private static final String DUMMY_LOWER_BOUND_FIELD_NAME = "lower-bound-field-name-"; private static final String DUMMY_UPPER_BOUND_FIELD_NAME = "upper-bound-field-name-"; public static List<RuleInputMetaData> getDefaultRangeMetaData(int n) throws Exception { if (n <= 0) { throw new Exception("0 or less dummy rule input objects requested"); } List<RuleInputMetaData> dummyObjs = new ArrayList<>(); for (int i = 0; i < n; i++) { int id = RANDOM_NUM_GENERATOR.nextInt();
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java // public class RuleInputMetaData implements Serializable { // private static final long serialVersionUID = 7018331311799000825L; // private final String name; // private final int priority; // private final RuleInputType ruleInputType; // private final String dataType; // private final String rangeLowerBoundFieldName; // private final String rangeUpperBoundFieldName; // // public RuleInputMetaData(String name, int priority, RuleInputType ruleType, String dataType, // String rangeLowerBoundFieldName, String rangeUpperBoundFieldName) { // this.name = name; // this.priority = priority; // this.ruleInputType = ruleType; // this.dataType = dataType; // this.rangeLowerBoundFieldName = rangeLowerBoundFieldName; // this.rangeUpperBoundFieldName = rangeUpperBoundFieldName; // } // // public String getName() { // return name; // } // // public int getPriority() { // return priority; // } // // public RuleInputType getRuleInputType() { // return ruleInputType; // } // // public String getDataType() { // return dataType; // } // // public String getRangeLowerBoundFieldName() { // return rangeLowerBoundFieldName; // } // // public String getRangeUpperBoundFieldName() { // return rangeUpperBoundFieldName; // } // // @Override // public String toString() { // return "RuleInputMetaData{" + // "name='" + name + '\'' + // ", priority=" + priority + // ", ruleInputType=" + ruleInputType + // ", dataType='" + dataType + '\'' + // ", rangeLowerBoundFieldName='" + rangeLowerBoundFieldName + '\'' + // ", rangeUpperBoundFieldName='" + rangeUpperBoundFieldName + '\'' + // '}'; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/RuleInputType.java // public enum RuleInputType { // VALUE, // RANGE // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/DefaultDataType.java // public enum DefaultDataType { // NUMBER, // DATE, // STRING // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/gaia/RuleInputMetaDataMother.java import com.github.kislayverma.rulette.core.metadata.RuleInputMetaData; import com.github.kislayverma.rulette.core.ruleinput.type.RuleInputType; import com.github.kislayverma.rulette.core.ruleinput.value.DefaultDataType; import java.util.ArrayList; import java.util.List; import java.util.Random; package com.github.kislayverma.rulette.core.gaia; public class RuleInputMetaDataMother { private static final Random RANDOM_NUM_GENERATOR = new Random(); private static final String DUMMY_RULE_INPUT_NAME = "input-name-"; private static final String DUMMY_LOWER_BOUND_FIELD_NAME = "lower-bound-field-name-"; private static final String DUMMY_UPPER_BOUND_FIELD_NAME = "upper-bound-field-name-"; public static List<RuleInputMetaData> getDefaultRangeMetaData(int n) throws Exception { if (n <= 0) { throw new Exception("0 or less dummy rule input objects requested"); } List<RuleInputMetaData> dummyObjs = new ArrayList<>(); for (int i = 0; i < n; i++) { int id = RANDOM_NUM_GENERATOR.nextInt();
dummyObjs.add(new RuleInputMetaData(DUMMY_RULE_INPUT_NAME + id, id, RuleInputType.RANGE,
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/gaia/RuleInputMetaDataMother.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java // public class RuleInputMetaData implements Serializable { // private static final long serialVersionUID = 7018331311799000825L; // private final String name; // private final int priority; // private final RuleInputType ruleInputType; // private final String dataType; // private final String rangeLowerBoundFieldName; // private final String rangeUpperBoundFieldName; // // public RuleInputMetaData(String name, int priority, RuleInputType ruleType, String dataType, // String rangeLowerBoundFieldName, String rangeUpperBoundFieldName) { // this.name = name; // this.priority = priority; // this.ruleInputType = ruleType; // this.dataType = dataType; // this.rangeLowerBoundFieldName = rangeLowerBoundFieldName; // this.rangeUpperBoundFieldName = rangeUpperBoundFieldName; // } // // public String getName() { // return name; // } // // public int getPriority() { // return priority; // } // // public RuleInputType getRuleInputType() { // return ruleInputType; // } // // public String getDataType() { // return dataType; // } // // public String getRangeLowerBoundFieldName() { // return rangeLowerBoundFieldName; // } // // public String getRangeUpperBoundFieldName() { // return rangeUpperBoundFieldName; // } // // @Override // public String toString() { // return "RuleInputMetaData{" + // "name='" + name + '\'' + // ", priority=" + priority + // ", ruleInputType=" + ruleInputType + // ", dataType='" + dataType + '\'' + // ", rangeLowerBoundFieldName='" + rangeLowerBoundFieldName + '\'' + // ", rangeUpperBoundFieldName='" + rangeUpperBoundFieldName + '\'' + // '}'; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/RuleInputType.java // public enum RuleInputType { // VALUE, // RANGE // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/DefaultDataType.java // public enum DefaultDataType { // NUMBER, // DATE, // STRING // }
import com.github.kislayverma.rulette.core.metadata.RuleInputMetaData; import com.github.kislayverma.rulette.core.ruleinput.type.RuleInputType; import com.github.kislayverma.rulette.core.ruleinput.value.DefaultDataType; import java.util.ArrayList; import java.util.List; import java.util.Random;
package com.github.kislayverma.rulette.core.gaia; public class RuleInputMetaDataMother { private static final Random RANDOM_NUM_GENERATOR = new Random(); private static final String DUMMY_RULE_INPUT_NAME = "input-name-"; private static final String DUMMY_LOWER_BOUND_FIELD_NAME = "lower-bound-field-name-"; private static final String DUMMY_UPPER_BOUND_FIELD_NAME = "upper-bound-field-name-"; public static List<RuleInputMetaData> getDefaultRangeMetaData(int n) throws Exception { if (n <= 0) { throw new Exception("0 or less dummy rule input objects requested"); } List<RuleInputMetaData> dummyObjs = new ArrayList<>(); for (int i = 0; i < n; i++) { int id = RANDOM_NUM_GENERATOR.nextInt(); dummyObjs.add(new RuleInputMetaData(DUMMY_RULE_INPUT_NAME + id, id, RuleInputType.RANGE, String.class.getName(), DUMMY_LOWER_BOUND_FIELD_NAME + i, DUMMY_UPPER_BOUND_FIELD_NAME + i)); } return dummyObjs; } public static List<RuleInputMetaData> getDefaultValueMetaData(int n) throws Exception { if (n <= 0) { throw new Exception("0 or less dummy rule input objects requested"); } List<RuleInputMetaData> dummyObjs = new ArrayList<>(); for (int i = 0; i < n; i++) { int id = RANDOM_NUM_GENERATOR.nextInt(); dummyObjs.add(new RuleInputMetaData(DUMMY_RULE_INPUT_NAME + id, id, RuleInputType.VALUE,
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java // public class RuleInputMetaData implements Serializable { // private static final long serialVersionUID = 7018331311799000825L; // private final String name; // private final int priority; // private final RuleInputType ruleInputType; // private final String dataType; // private final String rangeLowerBoundFieldName; // private final String rangeUpperBoundFieldName; // // public RuleInputMetaData(String name, int priority, RuleInputType ruleType, String dataType, // String rangeLowerBoundFieldName, String rangeUpperBoundFieldName) { // this.name = name; // this.priority = priority; // this.ruleInputType = ruleType; // this.dataType = dataType; // this.rangeLowerBoundFieldName = rangeLowerBoundFieldName; // this.rangeUpperBoundFieldName = rangeUpperBoundFieldName; // } // // public String getName() { // return name; // } // // public int getPriority() { // return priority; // } // // public RuleInputType getRuleInputType() { // return ruleInputType; // } // // public String getDataType() { // return dataType; // } // // public String getRangeLowerBoundFieldName() { // return rangeLowerBoundFieldName; // } // // public String getRangeUpperBoundFieldName() { // return rangeUpperBoundFieldName; // } // // @Override // public String toString() { // return "RuleInputMetaData{" + // "name='" + name + '\'' + // ", priority=" + priority + // ", ruleInputType=" + ruleInputType + // ", dataType='" + dataType + '\'' + // ", rangeLowerBoundFieldName='" + rangeLowerBoundFieldName + '\'' + // ", rangeUpperBoundFieldName='" + rangeUpperBoundFieldName + '\'' + // '}'; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/RuleInputType.java // public enum RuleInputType { // VALUE, // RANGE // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/DefaultDataType.java // public enum DefaultDataType { // NUMBER, // DATE, // STRING // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/gaia/RuleInputMetaDataMother.java import com.github.kislayverma.rulette.core.metadata.RuleInputMetaData; import com.github.kislayverma.rulette.core.ruleinput.type.RuleInputType; import com.github.kislayverma.rulette.core.ruleinput.value.DefaultDataType; import java.util.ArrayList; import java.util.List; import java.util.Random; package com.github.kislayverma.rulette.core.gaia; public class RuleInputMetaDataMother { private static final Random RANDOM_NUM_GENERATOR = new Random(); private static final String DUMMY_RULE_INPUT_NAME = "input-name-"; private static final String DUMMY_LOWER_BOUND_FIELD_NAME = "lower-bound-field-name-"; private static final String DUMMY_UPPER_BOUND_FIELD_NAME = "upper-bound-field-name-"; public static List<RuleInputMetaData> getDefaultRangeMetaData(int n) throws Exception { if (n <= 0) { throw new Exception("0 or less dummy rule input objects requested"); } List<RuleInputMetaData> dummyObjs = new ArrayList<>(); for (int i = 0; i < n; i++) { int id = RANDOM_NUM_GENERATOR.nextInt(); dummyObjs.add(new RuleInputMetaData(DUMMY_RULE_INPUT_NAME + id, id, RuleInputType.RANGE, String.class.getName(), DUMMY_LOWER_BOUND_FIELD_NAME + i, DUMMY_UPPER_BOUND_FIELD_NAME + i)); } return dummyObjs; } public static List<RuleInputMetaData> getDefaultValueMetaData(int n) throws Exception { if (n <= 0) { throw new Exception("0 or less dummy rule input objects requested"); } List<RuleInputMetaData> dummyObjs = new ArrayList<>(); for (int i = 0; i < n; i++) { int id = RANDOM_NUM_GENERATOR.nextInt(); dummyObjs.add(new RuleInputMetaData(DUMMY_RULE_INPUT_NAME + id, id, RuleInputType.VALUE,
DefaultDataType.STRING.name(), "test" + i, null));
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/ValueInput.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInput.java // public abstract class RuleInput implements Serializable { // private static final long serialVersionUID = 2370282382386651591L; // // protected RuleInputMetaData metaData; // protected String rawInput; // // protected RuleInput(String name, int priority, RuleInputType ruleInputType, // String inputDataType, String rangeLowerBound, String rangeUpperBound) { // // this.metaData = new RuleInputMetaData( // name, priority, ruleInputType, inputDataType, rangeLowerBound, rangeUpperBound); // if (ruleInputType == RuleInputType.VALUE) { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound); // } else { // if (rangeLowerBound == null && rangeUpperBound == null) { // this.rawInput = ""; // } else { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound) + "-" + // (rangeUpperBound == null ? "" : rangeUpperBound); // } // } // } // // /** // * This method matches the given value against this rule input and returns true if it fits. // * For value inputs, match means either same value or 'Any'. For Range input, match means // * 'Any' or the value should fall within the defined range of the input. // * @param value The value to compare against this input // * @return true if the value matches the input definition, false otherwise // */ // public abstract boolean evaluate(String value); // // /** // * This method determines if this rule input conflicts with the given input. For value inputs, // * conflict means having the same value. For range inputs, conflict means having partially // * overlapping range (e.g [1,5] and [2,10]). Ranges DO NOT conflict if one is completely // * contained within the other. // * @param input The rule input to compare with // * @return true if inputs are conflicting // */ // public abstract boolean isConflicting(RuleInput input); // // /** // * This method is used to determine if this rule input is a better than the given rule input // * for the same value. It assumes that both inputs match the value and that they are non-conflicting. // * // * @param input The rule input to be matched against // * @return 0 if both input are identical in fit // * 1 if this input is a better fit // * -1 if this input is not the better fit // */ // public abstract int isBetterFit(RuleInput input); // // public final String getRawValue() { // return this.rawInput; // } // // public String getName() { // return this.metaData.getName(); // } // // public int getPriority() { // return this.metaData.getPriority(); // } // // public RuleInputType getRuleInputType() { // return this.metaData.getRuleInputType(); // } // // public String getRuleInputDataType() { // return this.metaData.getDataType(); // } // // /** // * This method returns true if this rule input is of the 'Any' (match all) type. // * // * @return true if input is 'Any', false otherwise // */ // public abstract boolean isAny(); // // /** // * This method returns true if this input is exactly same as the given other input. // * // * @param otherInput The rule input to compare against // * @return true if this and the given inputs are exactly same, false otherwise // */ // public abstract boolean equals(RuleInput otherInput); // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // builder.append(this.metaData.getName()) // .append(":") // .append(this.rawInput) // .append("\t"); // return builder.toString(); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java // public class RuleInputValueFactory { // private static RuleInputValueFactory INSTANCE; // private final Map<String, IInputValueBuilder> builderMap; // private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); // // private RuleInputValueFactory() { // LOGGER.info("Initializing input data type factory..."); // this.builderMap = new ConcurrentHashMap<>(); // LOGGER.info("Input data type factory initialized"); // } // // public static RuleInputValueFactory getInstance() { // if (INSTANCE == null) { // INSTANCE = new RuleInputValueFactory(); // } // // return INSTANCE; // } // // public IInputValue buildRuleInputVaue(String ruleInputName, String rawValue) { // // IInputValueBuilder builder = builderMap.get(ruleInputName); // if (builder == null) { // throw new IllegalArgumentException("No input value builder registered for input " + ruleInputName); // } else { // return builder.build(rawValue); // } // } // // public void registerRuleInputBuilder(String ruleInputName, IInputValueBuilder builder) { // builderMap.put(ruleInputName, builder); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // }
import com.github.kislayverma.rulette.core.ruleinput.RuleInput; import com.github.kislayverma.rulette.core.ruleinput.RuleInputValueFactory; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import java.io.Serializable;
package com.github.kislayverma.rulette.core.ruleinput.type; public class ValueInput extends RuleInput implements Serializable { private static final long serialVersionUID = -6340405995013946354L;
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInput.java // public abstract class RuleInput implements Serializable { // private static final long serialVersionUID = 2370282382386651591L; // // protected RuleInputMetaData metaData; // protected String rawInput; // // protected RuleInput(String name, int priority, RuleInputType ruleInputType, // String inputDataType, String rangeLowerBound, String rangeUpperBound) { // // this.metaData = new RuleInputMetaData( // name, priority, ruleInputType, inputDataType, rangeLowerBound, rangeUpperBound); // if (ruleInputType == RuleInputType.VALUE) { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound); // } else { // if (rangeLowerBound == null && rangeUpperBound == null) { // this.rawInput = ""; // } else { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound) + "-" + // (rangeUpperBound == null ? "" : rangeUpperBound); // } // } // } // // /** // * This method matches the given value against this rule input and returns true if it fits. // * For value inputs, match means either same value or 'Any'. For Range input, match means // * 'Any' or the value should fall within the defined range of the input. // * @param value The value to compare against this input // * @return true if the value matches the input definition, false otherwise // */ // public abstract boolean evaluate(String value); // // /** // * This method determines if this rule input conflicts with the given input. For value inputs, // * conflict means having the same value. For range inputs, conflict means having partially // * overlapping range (e.g [1,5] and [2,10]). Ranges DO NOT conflict if one is completely // * contained within the other. // * @param input The rule input to compare with // * @return true if inputs are conflicting // */ // public abstract boolean isConflicting(RuleInput input); // // /** // * This method is used to determine if this rule input is a better than the given rule input // * for the same value. It assumes that both inputs match the value and that they are non-conflicting. // * // * @param input The rule input to be matched against // * @return 0 if both input are identical in fit // * 1 if this input is a better fit // * -1 if this input is not the better fit // */ // public abstract int isBetterFit(RuleInput input); // // public final String getRawValue() { // return this.rawInput; // } // // public String getName() { // return this.metaData.getName(); // } // // public int getPriority() { // return this.metaData.getPriority(); // } // // public RuleInputType getRuleInputType() { // return this.metaData.getRuleInputType(); // } // // public String getRuleInputDataType() { // return this.metaData.getDataType(); // } // // /** // * This method returns true if this rule input is of the 'Any' (match all) type. // * // * @return true if input is 'Any', false otherwise // */ // public abstract boolean isAny(); // // /** // * This method returns true if this input is exactly same as the given other input. // * // * @param otherInput The rule input to compare against // * @return true if this and the given inputs are exactly same, false otherwise // */ // public abstract boolean equals(RuleInput otherInput); // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // builder.append(this.metaData.getName()) // .append(":") // .append(this.rawInput) // .append("\t"); // return builder.toString(); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java // public class RuleInputValueFactory { // private static RuleInputValueFactory INSTANCE; // private final Map<String, IInputValueBuilder> builderMap; // private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); // // private RuleInputValueFactory() { // LOGGER.info("Initializing input data type factory..."); // this.builderMap = new ConcurrentHashMap<>(); // LOGGER.info("Input data type factory initialized"); // } // // public static RuleInputValueFactory getInstance() { // if (INSTANCE == null) { // INSTANCE = new RuleInputValueFactory(); // } // // return INSTANCE; // } // // public IInputValue buildRuleInputVaue(String ruleInputName, String rawValue) { // // IInputValueBuilder builder = builderMap.get(ruleInputName); // if (builder == null) { // throw new IllegalArgumentException("No input value builder registered for input " + ruleInputName); // } else { // return builder.build(rawValue); // } // } // // public void registerRuleInputBuilder(String ruleInputName, IInputValueBuilder builder) { // builderMap.put(ruleInputName, builder); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/ValueInput.java import com.github.kislayverma.rulette.core.ruleinput.RuleInput; import com.github.kislayverma.rulette.core.ruleinput.RuleInputValueFactory; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import java.io.Serializable; package com.github.kislayverma.rulette.core.ruleinput.type; public class ValueInput extends RuleInput implements Serializable { private static final long serialVersionUID = -6340405995013946354L;
private final IInputValue value;
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/ValueInput.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInput.java // public abstract class RuleInput implements Serializable { // private static final long serialVersionUID = 2370282382386651591L; // // protected RuleInputMetaData metaData; // protected String rawInput; // // protected RuleInput(String name, int priority, RuleInputType ruleInputType, // String inputDataType, String rangeLowerBound, String rangeUpperBound) { // // this.metaData = new RuleInputMetaData( // name, priority, ruleInputType, inputDataType, rangeLowerBound, rangeUpperBound); // if (ruleInputType == RuleInputType.VALUE) { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound); // } else { // if (rangeLowerBound == null && rangeUpperBound == null) { // this.rawInput = ""; // } else { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound) + "-" + // (rangeUpperBound == null ? "" : rangeUpperBound); // } // } // } // // /** // * This method matches the given value against this rule input and returns true if it fits. // * For value inputs, match means either same value or 'Any'. For Range input, match means // * 'Any' or the value should fall within the defined range of the input. // * @param value The value to compare against this input // * @return true if the value matches the input definition, false otherwise // */ // public abstract boolean evaluate(String value); // // /** // * This method determines if this rule input conflicts with the given input. For value inputs, // * conflict means having the same value. For range inputs, conflict means having partially // * overlapping range (e.g [1,5] and [2,10]). Ranges DO NOT conflict if one is completely // * contained within the other. // * @param input The rule input to compare with // * @return true if inputs are conflicting // */ // public abstract boolean isConflicting(RuleInput input); // // /** // * This method is used to determine if this rule input is a better than the given rule input // * for the same value. It assumes that both inputs match the value and that they are non-conflicting. // * // * @param input The rule input to be matched against // * @return 0 if both input are identical in fit // * 1 if this input is a better fit // * -1 if this input is not the better fit // */ // public abstract int isBetterFit(RuleInput input); // // public final String getRawValue() { // return this.rawInput; // } // // public String getName() { // return this.metaData.getName(); // } // // public int getPriority() { // return this.metaData.getPriority(); // } // // public RuleInputType getRuleInputType() { // return this.metaData.getRuleInputType(); // } // // public String getRuleInputDataType() { // return this.metaData.getDataType(); // } // // /** // * This method returns true if this rule input is of the 'Any' (match all) type. // * // * @return true if input is 'Any', false otherwise // */ // public abstract boolean isAny(); // // /** // * This method returns true if this input is exactly same as the given other input. // * // * @param otherInput The rule input to compare against // * @return true if this and the given inputs are exactly same, false otherwise // */ // public abstract boolean equals(RuleInput otherInput); // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // builder.append(this.metaData.getName()) // .append(":") // .append(this.rawInput) // .append("\t"); // return builder.toString(); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java // public class RuleInputValueFactory { // private static RuleInputValueFactory INSTANCE; // private final Map<String, IInputValueBuilder> builderMap; // private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); // // private RuleInputValueFactory() { // LOGGER.info("Initializing input data type factory..."); // this.builderMap = new ConcurrentHashMap<>(); // LOGGER.info("Input data type factory initialized"); // } // // public static RuleInputValueFactory getInstance() { // if (INSTANCE == null) { // INSTANCE = new RuleInputValueFactory(); // } // // return INSTANCE; // } // // public IInputValue buildRuleInputVaue(String ruleInputName, String rawValue) { // // IInputValueBuilder builder = builderMap.get(ruleInputName); // if (builder == null) { // throw new IllegalArgumentException("No input value builder registered for input " + ruleInputName); // } else { // return builder.build(rawValue); // } // } // // public void registerRuleInputBuilder(String ruleInputName, IInputValueBuilder builder) { // builderMap.put(ruleInputName, builder); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // }
import com.github.kislayverma.rulette.core.ruleinput.RuleInput; import com.github.kislayverma.rulette.core.ruleinput.RuleInputValueFactory; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import java.io.Serializable;
package com.github.kislayverma.rulette.core.ruleinput.type; public class ValueInput extends RuleInput implements Serializable { private static final long serialVersionUID = -6340405995013946354L; private final IInputValue value; public ValueInput(String name, int priority, String inputDataType, String value) { super(name, priority, RuleInputType.VALUE, inputDataType, value, null);
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInput.java // public abstract class RuleInput implements Serializable { // private static final long serialVersionUID = 2370282382386651591L; // // protected RuleInputMetaData metaData; // protected String rawInput; // // protected RuleInput(String name, int priority, RuleInputType ruleInputType, // String inputDataType, String rangeLowerBound, String rangeUpperBound) { // // this.metaData = new RuleInputMetaData( // name, priority, ruleInputType, inputDataType, rangeLowerBound, rangeUpperBound); // if (ruleInputType == RuleInputType.VALUE) { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound); // } else { // if (rangeLowerBound == null && rangeUpperBound == null) { // this.rawInput = ""; // } else { // this.rawInput = (rangeLowerBound == null ? "" : rangeLowerBound) + "-" + // (rangeUpperBound == null ? "" : rangeUpperBound); // } // } // } // // /** // * This method matches the given value against this rule input and returns true if it fits. // * For value inputs, match means either same value or 'Any'. For Range input, match means // * 'Any' or the value should fall within the defined range of the input. // * @param value The value to compare against this input // * @return true if the value matches the input definition, false otherwise // */ // public abstract boolean evaluate(String value); // // /** // * This method determines if this rule input conflicts with the given input. For value inputs, // * conflict means having the same value. For range inputs, conflict means having partially // * overlapping range (e.g [1,5] and [2,10]). Ranges DO NOT conflict if one is completely // * contained within the other. // * @param input The rule input to compare with // * @return true if inputs are conflicting // */ // public abstract boolean isConflicting(RuleInput input); // // /** // * This method is used to determine if this rule input is a better than the given rule input // * for the same value. It assumes that both inputs match the value and that they are non-conflicting. // * // * @param input The rule input to be matched against // * @return 0 if both input are identical in fit // * 1 if this input is a better fit // * -1 if this input is not the better fit // */ // public abstract int isBetterFit(RuleInput input); // // public final String getRawValue() { // return this.rawInput; // } // // public String getName() { // return this.metaData.getName(); // } // // public int getPriority() { // return this.metaData.getPriority(); // } // // public RuleInputType getRuleInputType() { // return this.metaData.getRuleInputType(); // } // // public String getRuleInputDataType() { // return this.metaData.getDataType(); // } // // /** // * This method returns true if this rule input is of the 'Any' (match all) type. // * // * @return true if input is 'Any', false otherwise // */ // public abstract boolean isAny(); // // /** // * This method returns true if this input is exactly same as the given other input. // * // * @param otherInput The rule input to compare against // * @return true if this and the given inputs are exactly same, false otherwise // */ // public abstract boolean equals(RuleInput otherInput); // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // builder.append(this.metaData.getName()) // .append(":") // .append(this.rawInput) // .append("\t"); // return builder.toString(); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java // public class RuleInputValueFactory { // private static RuleInputValueFactory INSTANCE; // private final Map<String, IInputValueBuilder> builderMap; // private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); // // private RuleInputValueFactory() { // LOGGER.info("Initializing input data type factory..."); // this.builderMap = new ConcurrentHashMap<>(); // LOGGER.info("Input data type factory initialized"); // } // // public static RuleInputValueFactory getInstance() { // if (INSTANCE == null) { // INSTANCE = new RuleInputValueFactory(); // } // // return INSTANCE; // } // // public IInputValue buildRuleInputVaue(String ruleInputName, String rawValue) { // // IInputValueBuilder builder = builderMap.get(ruleInputName); // if (builder == null) { // throw new IllegalArgumentException("No input value builder registered for input " + ruleInputName); // } else { // return builder.build(rawValue); // } // } // // public void registerRuleInputBuilder(String ruleInputName, IInputValueBuilder builder) { // builderMap.put(ruleInputName, builder); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/ValueInput.java import com.github.kislayverma.rulette.core.ruleinput.RuleInput; import com.github.kislayverma.rulette.core.ruleinput.RuleInputValueFactory; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import java.io.Serializable; package com.github.kislayverma.rulette.core.ruleinput.type; public class ValueInput extends RuleInput implements Serializable { private static final long serialVersionUID = -6340405995013946354L; private final IInputValue value; public ValueInput(String name, int priority, String inputDataType, String value) { super(name, priority, RuleInputType.VALUE, inputDataType, value, null);
this.value = RuleInputValueFactory.getInstance().buildRuleInputVaue(name, value == null ? "" : value);
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInput.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java // public class RuleInputMetaData implements Serializable { // private static final long serialVersionUID = 7018331311799000825L; // private final String name; // private final int priority; // private final RuleInputType ruleInputType; // private final String dataType; // private final String rangeLowerBoundFieldName; // private final String rangeUpperBoundFieldName; // // public RuleInputMetaData(String name, int priority, RuleInputType ruleType, String dataType, // String rangeLowerBoundFieldName, String rangeUpperBoundFieldName) { // this.name = name; // this.priority = priority; // this.ruleInputType = ruleType; // this.dataType = dataType; // this.rangeLowerBoundFieldName = rangeLowerBoundFieldName; // this.rangeUpperBoundFieldName = rangeUpperBoundFieldName; // } // // public String getName() { // return name; // } // // public int getPriority() { // return priority; // } // // public RuleInputType getRuleInputType() { // return ruleInputType; // } // // public String getDataType() { // return dataType; // } // // public String getRangeLowerBoundFieldName() { // return rangeLowerBoundFieldName; // } // // public String getRangeUpperBoundFieldName() { // return rangeUpperBoundFieldName; // } // // @Override // public String toString() { // return "RuleInputMetaData{" + // "name='" + name + '\'' + // ", priority=" + priority + // ", ruleInputType=" + ruleInputType + // ", dataType='" + dataType + '\'' + // ", rangeLowerBoundFieldName='" + rangeLowerBoundFieldName + '\'' + // ", rangeUpperBoundFieldName='" + rangeUpperBoundFieldName + '\'' + // '}'; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/RuleInputType.java // public enum RuleInputType { // VALUE, // RANGE // }
import com.github.kislayverma.rulette.core.metadata.RuleInputMetaData; import com.github.kislayverma.rulette.core.ruleinput.type.RuleInputType; import java.io.Serializable;
package com.github.kislayverma.rulette.core.ruleinput; public abstract class RuleInput implements Serializable { private static final long serialVersionUID = 2370282382386651591L;
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java // public class RuleInputMetaData implements Serializable { // private static final long serialVersionUID = 7018331311799000825L; // private final String name; // private final int priority; // private final RuleInputType ruleInputType; // private final String dataType; // private final String rangeLowerBoundFieldName; // private final String rangeUpperBoundFieldName; // // public RuleInputMetaData(String name, int priority, RuleInputType ruleType, String dataType, // String rangeLowerBoundFieldName, String rangeUpperBoundFieldName) { // this.name = name; // this.priority = priority; // this.ruleInputType = ruleType; // this.dataType = dataType; // this.rangeLowerBoundFieldName = rangeLowerBoundFieldName; // this.rangeUpperBoundFieldName = rangeUpperBoundFieldName; // } // // public String getName() { // return name; // } // // public int getPriority() { // return priority; // } // // public RuleInputType getRuleInputType() { // return ruleInputType; // } // // public String getDataType() { // return dataType; // } // // public String getRangeLowerBoundFieldName() { // return rangeLowerBoundFieldName; // } // // public String getRangeUpperBoundFieldName() { // return rangeUpperBoundFieldName; // } // // @Override // public String toString() { // return "RuleInputMetaData{" + // "name='" + name + '\'' + // ", priority=" + priority + // ", ruleInputType=" + ruleInputType + // ", dataType='" + dataType + '\'' + // ", rangeLowerBoundFieldName='" + rangeLowerBoundFieldName + '\'' + // ", rangeUpperBoundFieldName='" + rangeUpperBoundFieldName + '\'' + // '}'; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/RuleInputType.java // public enum RuleInputType { // VALUE, // RANGE // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInput.java import com.github.kislayverma.rulette.core.metadata.RuleInputMetaData; import com.github.kislayverma.rulette.core.ruleinput.type.RuleInputType; import java.io.Serializable; package com.github.kislayverma.rulette.core.ruleinput; public abstract class RuleInput implements Serializable { private static final long serialVersionUID = 2370282382386651591L;
protected RuleInputMetaData metaData;
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInput.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java // public class RuleInputMetaData implements Serializable { // private static final long serialVersionUID = 7018331311799000825L; // private final String name; // private final int priority; // private final RuleInputType ruleInputType; // private final String dataType; // private final String rangeLowerBoundFieldName; // private final String rangeUpperBoundFieldName; // // public RuleInputMetaData(String name, int priority, RuleInputType ruleType, String dataType, // String rangeLowerBoundFieldName, String rangeUpperBoundFieldName) { // this.name = name; // this.priority = priority; // this.ruleInputType = ruleType; // this.dataType = dataType; // this.rangeLowerBoundFieldName = rangeLowerBoundFieldName; // this.rangeUpperBoundFieldName = rangeUpperBoundFieldName; // } // // public String getName() { // return name; // } // // public int getPriority() { // return priority; // } // // public RuleInputType getRuleInputType() { // return ruleInputType; // } // // public String getDataType() { // return dataType; // } // // public String getRangeLowerBoundFieldName() { // return rangeLowerBoundFieldName; // } // // public String getRangeUpperBoundFieldName() { // return rangeUpperBoundFieldName; // } // // @Override // public String toString() { // return "RuleInputMetaData{" + // "name='" + name + '\'' + // ", priority=" + priority + // ", ruleInputType=" + ruleInputType + // ", dataType='" + dataType + '\'' + // ", rangeLowerBoundFieldName='" + rangeLowerBoundFieldName + '\'' + // ", rangeUpperBoundFieldName='" + rangeUpperBoundFieldName + '\'' + // '}'; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/RuleInputType.java // public enum RuleInputType { // VALUE, // RANGE // }
import com.github.kislayverma.rulette.core.metadata.RuleInputMetaData; import com.github.kislayverma.rulette.core.ruleinput.type.RuleInputType; import java.io.Serializable;
package com.github.kislayverma.rulette.core.ruleinput; public abstract class RuleInput implements Serializable { private static final long serialVersionUID = 2370282382386651591L; protected RuleInputMetaData metaData; protected String rawInput;
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleInputMetaData.java // public class RuleInputMetaData implements Serializable { // private static final long serialVersionUID = 7018331311799000825L; // private final String name; // private final int priority; // private final RuleInputType ruleInputType; // private final String dataType; // private final String rangeLowerBoundFieldName; // private final String rangeUpperBoundFieldName; // // public RuleInputMetaData(String name, int priority, RuleInputType ruleType, String dataType, // String rangeLowerBoundFieldName, String rangeUpperBoundFieldName) { // this.name = name; // this.priority = priority; // this.ruleInputType = ruleType; // this.dataType = dataType; // this.rangeLowerBoundFieldName = rangeLowerBoundFieldName; // this.rangeUpperBoundFieldName = rangeUpperBoundFieldName; // } // // public String getName() { // return name; // } // // public int getPriority() { // return priority; // } // // public RuleInputType getRuleInputType() { // return ruleInputType; // } // // public String getDataType() { // return dataType; // } // // public String getRangeLowerBoundFieldName() { // return rangeLowerBoundFieldName; // } // // public String getRangeUpperBoundFieldName() { // return rangeUpperBoundFieldName; // } // // @Override // public String toString() { // return "RuleInputMetaData{" + // "name='" + name + '\'' + // ", priority=" + priority + // ", ruleInputType=" + ruleInputType + // ", dataType='" + dataType + '\'' + // ", rangeLowerBoundFieldName='" + rangeLowerBoundFieldName + '\'' + // ", rangeUpperBoundFieldName='" + rangeUpperBoundFieldName + '\'' + // '}'; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/type/RuleInputType.java // public enum RuleInputType { // VALUE, // RANGE // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInput.java import com.github.kislayverma.rulette.core.metadata.RuleInputMetaData; import com.github.kislayverma.rulette.core.ruleinput.type.RuleInputType; import java.io.Serializable; package com.github.kislayverma.rulette.core.ruleinput; public abstract class RuleInput implements Serializable { private static final long serialVersionUID = 2370282382386651591L; protected RuleInputMetaData metaData; protected String rawInput;
protected RuleInput(String name, int priority, RuleInputType ruleInputType,
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValueBuilder.java // public interface IInputValueBuilder<T> { // IInputValue<T> build(String value); // }
import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValueBuilder; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package com.github.kislayverma.rulette.core.ruleinput; public class RuleInputValueFactory { private static RuleInputValueFactory INSTANCE;
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValueBuilder.java // public interface IInputValueBuilder<T> { // IInputValue<T> build(String value); // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValueBuilder; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; package com.github.kislayverma.rulette.core.ruleinput; public class RuleInputValueFactory { private static RuleInputValueFactory INSTANCE;
private final Map<String, IInputValueBuilder> builderMap;
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValueBuilder.java // public interface IInputValueBuilder<T> { // IInputValue<T> build(String value); // }
import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValueBuilder; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package com.github.kislayverma.rulette.core.ruleinput; public class RuleInputValueFactory { private static RuleInputValueFactory INSTANCE; private final Map<String, IInputValueBuilder> builderMap; private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); private RuleInputValueFactory() { LOGGER.info("Initializing input data type factory..."); this.builderMap = new ConcurrentHashMap<>(); LOGGER.info("Input data type factory initialized"); } public static RuleInputValueFactory getInstance() { if (INSTANCE == null) { INSTANCE = new RuleInputValueFactory(); } return INSTANCE; }
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValueBuilder.java // public interface IInputValueBuilder<T> { // IInputValue<T> build(String value); // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValueBuilder; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; package com.github.kislayverma.rulette.core.ruleinput; public class RuleInputValueFactory { private static RuleInputValueFactory INSTANCE; private final Map<String, IInputValueBuilder> builderMap; private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); private RuleInputValueFactory() { LOGGER.info("Initializing input data type factory..."); this.builderMap = new ConcurrentHashMap<>(); LOGGER.info("Input data type factory initialized"); } public static RuleInputValueFactory getInstance() { if (INSTANCE == null) { INSTANCE = new RuleInputValueFactory(); } return INSTANCE; }
public IInputValue buildRuleInputVaue(String ruleInputName, String rawValue) {
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleSystemMetaData.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfiguration.java // public class RuleInputConfiguration { // private final String ruleInputName; // private final IInputValueBuilder inputValueBuilder; // // public RuleInputConfiguration(String ruleInputName, IInputValueBuilder inputValueBuilder) { // this.ruleInputName = ruleInputName; // this.inputValueBuilder = inputValueBuilder; // } // // public String getRuleInputName() { // return ruleInputName; // } // // public IInputValueBuilder getInputValueBuilder() { // return inputValueBuilder; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfigurator.java // public class RuleInputConfigurator { // private final Map<String, RuleInputConfiguration> configMap = new ConcurrentHashMap<>(); // // public void addConfiguration(RuleInputConfiguration config) throws Exception { // RuleInputConfiguration existingConfig = configMap.get(config.getRuleInputName()); // if (existingConfig != null) { // throw new Exception("Config already present for input name " + config.getRuleInputName()); // } else { // configMap.put(config.getRuleInputName(), config); // } // } // // public RuleInputConfiguration getConfig(String ruleInputName) { // return this.configMap.get(ruleInputName); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java // public class RuleInputValueFactory { // private static RuleInputValueFactory INSTANCE; // private final Map<String, IInputValueBuilder> builderMap; // private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); // // private RuleInputValueFactory() { // LOGGER.info("Initializing input data type factory..."); // this.builderMap = new ConcurrentHashMap<>(); // LOGGER.info("Input data type factory initialized"); // } // // public static RuleInputValueFactory getInstance() { // if (INSTANCE == null) { // INSTANCE = new RuleInputValueFactory(); // } // // return INSTANCE; // } // // public IInputValue buildRuleInputVaue(String ruleInputName, String rawValue) { // // IInputValueBuilder builder = builderMap.get(ruleInputName); // if (builder == null) { // throw new IllegalArgumentException("No input value builder registered for input " + ruleInputName); // } else { // return builder.build(rawValue); // } // } // // public void registerRuleInputBuilder(String ruleInputName, IInputValueBuilder builder) { // builderMap.put(ruleInputName, builder); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/DefaultDataType.java // public enum DefaultDataType { // NUMBER, // DATE, // STRING // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/defaults/DefaultBuilderRegistry.java // public class DefaultBuilderRegistry { // private final Map<String, IInputValueBuilder> builderRegister; // private static final Logger LOGGER = LoggerFactory.getLogger(DefaultBuilderRegistry.class); // // public DefaultBuilderRegistry() { // LOGGER.info("Initializing default builder registry..."); // // this.builderRegister = new ConcurrentHashMap<>(); // this.builderRegister.put("STRING", new DefaultStringInputBuilder()); // this.builderRegister.put("DATE", new DefaultDateInputBuilder()); // this.builderRegister.put("NUMBER", new DefaultNumberInputBuilder()); // } // // public IInputValueBuilder getDefaultBuilder(String dataType) { // return this.builderRegister.get(dataType); // } // }
import com.github.kislayverma.rulette.core.ruleinput.RuleInputConfiguration; import com.github.kislayverma.rulette.core.ruleinput.RuleInputConfigurator; import com.github.kislayverma.rulette.core.ruleinput.RuleInputValueFactory; import com.github.kislayverma.rulette.core.ruleinput.value.DefaultDataType; import com.github.kislayverma.rulette.core.ruleinput.value.defaults.DefaultBuilderRegistry; import java.util.List;
package com.github.kislayverma.rulette.core.metadata; /** * This class represents the rule systems entity model. */ public class RuleSystemMetaData { private final DefaultBuilderRegistry BUILDER_REGISTRY = new DefaultBuilderRegistry(); private final String ruleSystemName; private final String tableName; private final List<RuleInputMetaData> inputColumnList; private final String uniqueIdColumnName; private final String uniqueOutputColumnName; public RuleSystemMetaData( String ruleSystemName, String tableName, String uniqueIdColName, String uniqueOutputColName, List<RuleInputMetaData> inputs) { this.ruleSystemName = ruleSystemName; this.tableName = tableName; this.uniqueIdColumnName = uniqueIdColName; this.uniqueOutputColumnName = uniqueOutputColName; this.inputColumnList = inputs; } /** * This method loads default configuration for all rule inputs if no custom override * is given (in which case it overrides the defaults). * Input and output columns always get default configuration. * * @param configuration Custom configuration for rule inputs */
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfiguration.java // public class RuleInputConfiguration { // private final String ruleInputName; // private final IInputValueBuilder inputValueBuilder; // // public RuleInputConfiguration(String ruleInputName, IInputValueBuilder inputValueBuilder) { // this.ruleInputName = ruleInputName; // this.inputValueBuilder = inputValueBuilder; // } // // public String getRuleInputName() { // return ruleInputName; // } // // public IInputValueBuilder getInputValueBuilder() { // return inputValueBuilder; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfigurator.java // public class RuleInputConfigurator { // private final Map<String, RuleInputConfiguration> configMap = new ConcurrentHashMap<>(); // // public void addConfiguration(RuleInputConfiguration config) throws Exception { // RuleInputConfiguration existingConfig = configMap.get(config.getRuleInputName()); // if (existingConfig != null) { // throw new Exception("Config already present for input name " + config.getRuleInputName()); // } else { // configMap.put(config.getRuleInputName(), config); // } // } // // public RuleInputConfiguration getConfig(String ruleInputName) { // return this.configMap.get(ruleInputName); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java // public class RuleInputValueFactory { // private static RuleInputValueFactory INSTANCE; // private final Map<String, IInputValueBuilder> builderMap; // private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); // // private RuleInputValueFactory() { // LOGGER.info("Initializing input data type factory..."); // this.builderMap = new ConcurrentHashMap<>(); // LOGGER.info("Input data type factory initialized"); // } // // public static RuleInputValueFactory getInstance() { // if (INSTANCE == null) { // INSTANCE = new RuleInputValueFactory(); // } // // return INSTANCE; // } // // public IInputValue buildRuleInputVaue(String ruleInputName, String rawValue) { // // IInputValueBuilder builder = builderMap.get(ruleInputName); // if (builder == null) { // throw new IllegalArgumentException("No input value builder registered for input " + ruleInputName); // } else { // return builder.build(rawValue); // } // } // // public void registerRuleInputBuilder(String ruleInputName, IInputValueBuilder builder) { // builderMap.put(ruleInputName, builder); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/DefaultDataType.java // public enum DefaultDataType { // NUMBER, // DATE, // STRING // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/defaults/DefaultBuilderRegistry.java // public class DefaultBuilderRegistry { // private final Map<String, IInputValueBuilder> builderRegister; // private static final Logger LOGGER = LoggerFactory.getLogger(DefaultBuilderRegistry.class); // // public DefaultBuilderRegistry() { // LOGGER.info("Initializing default builder registry..."); // // this.builderRegister = new ConcurrentHashMap<>(); // this.builderRegister.put("STRING", new DefaultStringInputBuilder()); // this.builderRegister.put("DATE", new DefaultDateInputBuilder()); // this.builderRegister.put("NUMBER", new DefaultNumberInputBuilder()); // } // // public IInputValueBuilder getDefaultBuilder(String dataType) { // return this.builderRegister.get(dataType); // } // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleSystemMetaData.java import com.github.kislayverma.rulette.core.ruleinput.RuleInputConfiguration; import com.github.kislayverma.rulette.core.ruleinput.RuleInputConfigurator; import com.github.kislayverma.rulette.core.ruleinput.RuleInputValueFactory; import com.github.kislayverma.rulette.core.ruleinput.value.DefaultDataType; import com.github.kislayverma.rulette.core.ruleinput.value.defaults.DefaultBuilderRegistry; import java.util.List; package com.github.kislayverma.rulette.core.metadata; /** * This class represents the rule systems entity model. */ public class RuleSystemMetaData { private final DefaultBuilderRegistry BUILDER_REGISTRY = new DefaultBuilderRegistry(); private final String ruleSystemName; private final String tableName; private final List<RuleInputMetaData> inputColumnList; private final String uniqueIdColumnName; private final String uniqueOutputColumnName; public RuleSystemMetaData( String ruleSystemName, String tableName, String uniqueIdColName, String uniqueOutputColName, List<RuleInputMetaData> inputs) { this.ruleSystemName = ruleSystemName; this.tableName = tableName; this.uniqueIdColumnName = uniqueIdColName; this.uniqueOutputColumnName = uniqueOutputColName; this.inputColumnList = inputs; } /** * This method loads default configuration for all rule inputs if no custom override * is given (in which case it overrides the defaults). * Input and output columns always get default configuration. * * @param configuration Custom configuration for rule inputs */
public void applyCustomConfiguration(RuleInputConfigurator configuration) {
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleSystemMetaData.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfiguration.java // public class RuleInputConfiguration { // private final String ruleInputName; // private final IInputValueBuilder inputValueBuilder; // // public RuleInputConfiguration(String ruleInputName, IInputValueBuilder inputValueBuilder) { // this.ruleInputName = ruleInputName; // this.inputValueBuilder = inputValueBuilder; // } // // public String getRuleInputName() { // return ruleInputName; // } // // public IInputValueBuilder getInputValueBuilder() { // return inputValueBuilder; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfigurator.java // public class RuleInputConfigurator { // private final Map<String, RuleInputConfiguration> configMap = new ConcurrentHashMap<>(); // // public void addConfiguration(RuleInputConfiguration config) throws Exception { // RuleInputConfiguration existingConfig = configMap.get(config.getRuleInputName()); // if (existingConfig != null) { // throw new Exception("Config already present for input name " + config.getRuleInputName()); // } else { // configMap.put(config.getRuleInputName(), config); // } // } // // public RuleInputConfiguration getConfig(String ruleInputName) { // return this.configMap.get(ruleInputName); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java // public class RuleInputValueFactory { // private static RuleInputValueFactory INSTANCE; // private final Map<String, IInputValueBuilder> builderMap; // private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); // // private RuleInputValueFactory() { // LOGGER.info("Initializing input data type factory..."); // this.builderMap = new ConcurrentHashMap<>(); // LOGGER.info("Input data type factory initialized"); // } // // public static RuleInputValueFactory getInstance() { // if (INSTANCE == null) { // INSTANCE = new RuleInputValueFactory(); // } // // return INSTANCE; // } // // public IInputValue buildRuleInputVaue(String ruleInputName, String rawValue) { // // IInputValueBuilder builder = builderMap.get(ruleInputName); // if (builder == null) { // throw new IllegalArgumentException("No input value builder registered for input " + ruleInputName); // } else { // return builder.build(rawValue); // } // } // // public void registerRuleInputBuilder(String ruleInputName, IInputValueBuilder builder) { // builderMap.put(ruleInputName, builder); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/DefaultDataType.java // public enum DefaultDataType { // NUMBER, // DATE, // STRING // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/defaults/DefaultBuilderRegistry.java // public class DefaultBuilderRegistry { // private final Map<String, IInputValueBuilder> builderRegister; // private static final Logger LOGGER = LoggerFactory.getLogger(DefaultBuilderRegistry.class); // // public DefaultBuilderRegistry() { // LOGGER.info("Initializing default builder registry..."); // // this.builderRegister = new ConcurrentHashMap<>(); // this.builderRegister.put("STRING", new DefaultStringInputBuilder()); // this.builderRegister.put("DATE", new DefaultDateInputBuilder()); // this.builderRegister.put("NUMBER", new DefaultNumberInputBuilder()); // } // // public IInputValueBuilder getDefaultBuilder(String dataType) { // return this.builderRegister.get(dataType); // } // }
import com.github.kislayverma.rulette.core.ruleinput.RuleInputConfiguration; import com.github.kislayverma.rulette.core.ruleinput.RuleInputConfigurator; import com.github.kislayverma.rulette.core.ruleinput.RuleInputValueFactory; import com.github.kislayverma.rulette.core.ruleinput.value.DefaultDataType; import com.github.kislayverma.rulette.core.ruleinput.value.defaults.DefaultBuilderRegistry; import java.util.List;
package com.github.kislayverma.rulette.core.metadata; /** * This class represents the rule systems entity model. */ public class RuleSystemMetaData { private final DefaultBuilderRegistry BUILDER_REGISTRY = new DefaultBuilderRegistry(); private final String ruleSystemName; private final String tableName; private final List<RuleInputMetaData> inputColumnList; private final String uniqueIdColumnName; private final String uniqueOutputColumnName; public RuleSystemMetaData( String ruleSystemName, String tableName, String uniqueIdColName, String uniqueOutputColName, List<RuleInputMetaData> inputs) { this.ruleSystemName = ruleSystemName; this.tableName = tableName; this.uniqueIdColumnName = uniqueIdColName; this.uniqueOutputColumnName = uniqueOutputColName; this.inputColumnList = inputs; } /** * This method loads default configuration for all rule inputs if no custom override * is given (in which case it overrides the defaults). * Input and output columns always get default configuration. * * @param configuration Custom configuration for rule inputs */ public void applyCustomConfiguration(RuleInputConfigurator configuration) {
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfiguration.java // public class RuleInputConfiguration { // private final String ruleInputName; // private final IInputValueBuilder inputValueBuilder; // // public RuleInputConfiguration(String ruleInputName, IInputValueBuilder inputValueBuilder) { // this.ruleInputName = ruleInputName; // this.inputValueBuilder = inputValueBuilder; // } // // public String getRuleInputName() { // return ruleInputName; // } // // public IInputValueBuilder getInputValueBuilder() { // return inputValueBuilder; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfigurator.java // public class RuleInputConfigurator { // private final Map<String, RuleInputConfiguration> configMap = new ConcurrentHashMap<>(); // // public void addConfiguration(RuleInputConfiguration config) throws Exception { // RuleInputConfiguration existingConfig = configMap.get(config.getRuleInputName()); // if (existingConfig != null) { // throw new Exception("Config already present for input name " + config.getRuleInputName()); // } else { // configMap.put(config.getRuleInputName(), config); // } // } // // public RuleInputConfiguration getConfig(String ruleInputName) { // return this.configMap.get(ruleInputName); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java // public class RuleInputValueFactory { // private static RuleInputValueFactory INSTANCE; // private final Map<String, IInputValueBuilder> builderMap; // private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); // // private RuleInputValueFactory() { // LOGGER.info("Initializing input data type factory..."); // this.builderMap = new ConcurrentHashMap<>(); // LOGGER.info("Input data type factory initialized"); // } // // public static RuleInputValueFactory getInstance() { // if (INSTANCE == null) { // INSTANCE = new RuleInputValueFactory(); // } // // return INSTANCE; // } // // public IInputValue buildRuleInputVaue(String ruleInputName, String rawValue) { // // IInputValueBuilder builder = builderMap.get(ruleInputName); // if (builder == null) { // throw new IllegalArgumentException("No input value builder registered for input " + ruleInputName); // } else { // return builder.build(rawValue); // } // } // // public void registerRuleInputBuilder(String ruleInputName, IInputValueBuilder builder) { // builderMap.put(ruleInputName, builder); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/DefaultDataType.java // public enum DefaultDataType { // NUMBER, // DATE, // STRING // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/defaults/DefaultBuilderRegistry.java // public class DefaultBuilderRegistry { // private final Map<String, IInputValueBuilder> builderRegister; // private static final Logger LOGGER = LoggerFactory.getLogger(DefaultBuilderRegistry.class); // // public DefaultBuilderRegistry() { // LOGGER.info("Initializing default builder registry..."); // // this.builderRegister = new ConcurrentHashMap<>(); // this.builderRegister.put("STRING", new DefaultStringInputBuilder()); // this.builderRegister.put("DATE", new DefaultDateInputBuilder()); // this.builderRegister.put("NUMBER", new DefaultNumberInputBuilder()); // } // // public IInputValueBuilder getDefaultBuilder(String dataType) { // return this.builderRegister.get(dataType); // } // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleSystemMetaData.java import com.github.kislayverma.rulette.core.ruleinput.RuleInputConfiguration; import com.github.kislayverma.rulette.core.ruleinput.RuleInputConfigurator; import com.github.kislayverma.rulette.core.ruleinput.RuleInputValueFactory; import com.github.kislayverma.rulette.core.ruleinput.value.DefaultDataType; import com.github.kislayverma.rulette.core.ruleinput.value.defaults.DefaultBuilderRegistry; import java.util.List; package com.github.kislayverma.rulette.core.metadata; /** * This class represents the rule systems entity model. */ public class RuleSystemMetaData { private final DefaultBuilderRegistry BUILDER_REGISTRY = new DefaultBuilderRegistry(); private final String ruleSystemName; private final String tableName; private final List<RuleInputMetaData> inputColumnList; private final String uniqueIdColumnName; private final String uniqueOutputColumnName; public RuleSystemMetaData( String ruleSystemName, String tableName, String uniqueIdColName, String uniqueOutputColName, List<RuleInputMetaData> inputs) { this.ruleSystemName = ruleSystemName; this.tableName = tableName; this.uniqueIdColumnName = uniqueIdColName; this.uniqueOutputColumnName = uniqueOutputColName; this.inputColumnList = inputs; } /** * This method loads default configuration for all rule inputs if no custom override * is given (in which case it overrides the defaults). * Input and output columns always get default configuration. * * @param configuration Custom configuration for rule inputs */ public void applyCustomConfiguration(RuleInputConfigurator configuration) {
RuleInputValueFactory.getInstance().registerRuleInputBuilder(
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleSystemMetaData.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfiguration.java // public class RuleInputConfiguration { // private final String ruleInputName; // private final IInputValueBuilder inputValueBuilder; // // public RuleInputConfiguration(String ruleInputName, IInputValueBuilder inputValueBuilder) { // this.ruleInputName = ruleInputName; // this.inputValueBuilder = inputValueBuilder; // } // // public String getRuleInputName() { // return ruleInputName; // } // // public IInputValueBuilder getInputValueBuilder() { // return inputValueBuilder; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfigurator.java // public class RuleInputConfigurator { // private final Map<String, RuleInputConfiguration> configMap = new ConcurrentHashMap<>(); // // public void addConfiguration(RuleInputConfiguration config) throws Exception { // RuleInputConfiguration existingConfig = configMap.get(config.getRuleInputName()); // if (existingConfig != null) { // throw new Exception("Config already present for input name " + config.getRuleInputName()); // } else { // configMap.put(config.getRuleInputName(), config); // } // } // // public RuleInputConfiguration getConfig(String ruleInputName) { // return this.configMap.get(ruleInputName); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java // public class RuleInputValueFactory { // private static RuleInputValueFactory INSTANCE; // private final Map<String, IInputValueBuilder> builderMap; // private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); // // private RuleInputValueFactory() { // LOGGER.info("Initializing input data type factory..."); // this.builderMap = new ConcurrentHashMap<>(); // LOGGER.info("Input data type factory initialized"); // } // // public static RuleInputValueFactory getInstance() { // if (INSTANCE == null) { // INSTANCE = new RuleInputValueFactory(); // } // // return INSTANCE; // } // // public IInputValue buildRuleInputVaue(String ruleInputName, String rawValue) { // // IInputValueBuilder builder = builderMap.get(ruleInputName); // if (builder == null) { // throw new IllegalArgumentException("No input value builder registered for input " + ruleInputName); // } else { // return builder.build(rawValue); // } // } // // public void registerRuleInputBuilder(String ruleInputName, IInputValueBuilder builder) { // builderMap.put(ruleInputName, builder); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/DefaultDataType.java // public enum DefaultDataType { // NUMBER, // DATE, // STRING // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/defaults/DefaultBuilderRegistry.java // public class DefaultBuilderRegistry { // private final Map<String, IInputValueBuilder> builderRegister; // private static final Logger LOGGER = LoggerFactory.getLogger(DefaultBuilderRegistry.class); // // public DefaultBuilderRegistry() { // LOGGER.info("Initializing default builder registry..."); // // this.builderRegister = new ConcurrentHashMap<>(); // this.builderRegister.put("STRING", new DefaultStringInputBuilder()); // this.builderRegister.put("DATE", new DefaultDateInputBuilder()); // this.builderRegister.put("NUMBER", new DefaultNumberInputBuilder()); // } // // public IInputValueBuilder getDefaultBuilder(String dataType) { // return this.builderRegister.get(dataType); // } // }
import com.github.kislayverma.rulette.core.ruleinput.RuleInputConfiguration; import com.github.kislayverma.rulette.core.ruleinput.RuleInputConfigurator; import com.github.kislayverma.rulette.core.ruleinput.RuleInputValueFactory; import com.github.kislayverma.rulette.core.ruleinput.value.DefaultDataType; import com.github.kislayverma.rulette.core.ruleinput.value.defaults.DefaultBuilderRegistry; import java.util.List;
package com.github.kislayverma.rulette.core.metadata; /** * This class represents the rule systems entity model. */ public class RuleSystemMetaData { private final DefaultBuilderRegistry BUILDER_REGISTRY = new DefaultBuilderRegistry(); private final String ruleSystemName; private final String tableName; private final List<RuleInputMetaData> inputColumnList; private final String uniqueIdColumnName; private final String uniqueOutputColumnName; public RuleSystemMetaData( String ruleSystemName, String tableName, String uniqueIdColName, String uniqueOutputColName, List<RuleInputMetaData> inputs) { this.ruleSystemName = ruleSystemName; this.tableName = tableName; this.uniqueIdColumnName = uniqueIdColName; this.uniqueOutputColumnName = uniqueOutputColName; this.inputColumnList = inputs; } /** * This method loads default configuration for all rule inputs if no custom override * is given (in which case it overrides the defaults). * Input and output columns always get default configuration. * * @param configuration Custom configuration for rule inputs */ public void applyCustomConfiguration(RuleInputConfigurator configuration) { RuleInputValueFactory.getInstance().registerRuleInputBuilder(
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfiguration.java // public class RuleInputConfiguration { // private final String ruleInputName; // private final IInputValueBuilder inputValueBuilder; // // public RuleInputConfiguration(String ruleInputName, IInputValueBuilder inputValueBuilder) { // this.ruleInputName = ruleInputName; // this.inputValueBuilder = inputValueBuilder; // } // // public String getRuleInputName() { // return ruleInputName; // } // // public IInputValueBuilder getInputValueBuilder() { // return inputValueBuilder; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfigurator.java // public class RuleInputConfigurator { // private final Map<String, RuleInputConfiguration> configMap = new ConcurrentHashMap<>(); // // public void addConfiguration(RuleInputConfiguration config) throws Exception { // RuleInputConfiguration existingConfig = configMap.get(config.getRuleInputName()); // if (existingConfig != null) { // throw new Exception("Config already present for input name " + config.getRuleInputName()); // } else { // configMap.put(config.getRuleInputName(), config); // } // } // // public RuleInputConfiguration getConfig(String ruleInputName) { // return this.configMap.get(ruleInputName); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java // public class RuleInputValueFactory { // private static RuleInputValueFactory INSTANCE; // private final Map<String, IInputValueBuilder> builderMap; // private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); // // private RuleInputValueFactory() { // LOGGER.info("Initializing input data type factory..."); // this.builderMap = new ConcurrentHashMap<>(); // LOGGER.info("Input data type factory initialized"); // } // // public static RuleInputValueFactory getInstance() { // if (INSTANCE == null) { // INSTANCE = new RuleInputValueFactory(); // } // // return INSTANCE; // } // // public IInputValue buildRuleInputVaue(String ruleInputName, String rawValue) { // // IInputValueBuilder builder = builderMap.get(ruleInputName); // if (builder == null) { // throw new IllegalArgumentException("No input value builder registered for input " + ruleInputName); // } else { // return builder.build(rawValue); // } // } // // public void registerRuleInputBuilder(String ruleInputName, IInputValueBuilder builder) { // builderMap.put(ruleInputName, builder); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/DefaultDataType.java // public enum DefaultDataType { // NUMBER, // DATE, // STRING // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/defaults/DefaultBuilderRegistry.java // public class DefaultBuilderRegistry { // private final Map<String, IInputValueBuilder> builderRegister; // private static final Logger LOGGER = LoggerFactory.getLogger(DefaultBuilderRegistry.class); // // public DefaultBuilderRegistry() { // LOGGER.info("Initializing default builder registry..."); // // this.builderRegister = new ConcurrentHashMap<>(); // this.builderRegister.put("STRING", new DefaultStringInputBuilder()); // this.builderRegister.put("DATE", new DefaultDateInputBuilder()); // this.builderRegister.put("NUMBER", new DefaultNumberInputBuilder()); // } // // public IInputValueBuilder getDefaultBuilder(String dataType) { // return this.builderRegister.get(dataType); // } // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleSystemMetaData.java import com.github.kislayverma.rulette.core.ruleinput.RuleInputConfiguration; import com.github.kislayverma.rulette.core.ruleinput.RuleInputConfigurator; import com.github.kislayverma.rulette.core.ruleinput.RuleInputValueFactory; import com.github.kislayverma.rulette.core.ruleinput.value.DefaultDataType; import com.github.kislayverma.rulette.core.ruleinput.value.defaults.DefaultBuilderRegistry; import java.util.List; package com.github.kislayverma.rulette.core.metadata; /** * This class represents the rule systems entity model. */ public class RuleSystemMetaData { private final DefaultBuilderRegistry BUILDER_REGISTRY = new DefaultBuilderRegistry(); private final String ruleSystemName; private final String tableName; private final List<RuleInputMetaData> inputColumnList; private final String uniqueIdColumnName; private final String uniqueOutputColumnName; public RuleSystemMetaData( String ruleSystemName, String tableName, String uniqueIdColName, String uniqueOutputColName, List<RuleInputMetaData> inputs) { this.ruleSystemName = ruleSystemName; this.tableName = tableName; this.uniqueIdColumnName = uniqueIdColName; this.uniqueOutputColumnName = uniqueOutputColName; this.inputColumnList = inputs; } /** * This method loads default configuration for all rule inputs if no custom override * is given (in which case it overrides the defaults). * Input and output columns always get default configuration. * * @param configuration Custom configuration for rule inputs */ public void applyCustomConfiguration(RuleInputConfigurator configuration) { RuleInputValueFactory.getInstance().registerRuleInputBuilder(
this.uniqueIdColumnName, BUILDER_REGISTRY.getDefaultBuilder(DefaultDataType.STRING.name()));
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleSystemMetaData.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfiguration.java // public class RuleInputConfiguration { // private final String ruleInputName; // private final IInputValueBuilder inputValueBuilder; // // public RuleInputConfiguration(String ruleInputName, IInputValueBuilder inputValueBuilder) { // this.ruleInputName = ruleInputName; // this.inputValueBuilder = inputValueBuilder; // } // // public String getRuleInputName() { // return ruleInputName; // } // // public IInputValueBuilder getInputValueBuilder() { // return inputValueBuilder; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfigurator.java // public class RuleInputConfigurator { // private final Map<String, RuleInputConfiguration> configMap = new ConcurrentHashMap<>(); // // public void addConfiguration(RuleInputConfiguration config) throws Exception { // RuleInputConfiguration existingConfig = configMap.get(config.getRuleInputName()); // if (existingConfig != null) { // throw new Exception("Config already present for input name " + config.getRuleInputName()); // } else { // configMap.put(config.getRuleInputName(), config); // } // } // // public RuleInputConfiguration getConfig(String ruleInputName) { // return this.configMap.get(ruleInputName); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java // public class RuleInputValueFactory { // private static RuleInputValueFactory INSTANCE; // private final Map<String, IInputValueBuilder> builderMap; // private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); // // private RuleInputValueFactory() { // LOGGER.info("Initializing input data type factory..."); // this.builderMap = new ConcurrentHashMap<>(); // LOGGER.info("Input data type factory initialized"); // } // // public static RuleInputValueFactory getInstance() { // if (INSTANCE == null) { // INSTANCE = new RuleInputValueFactory(); // } // // return INSTANCE; // } // // public IInputValue buildRuleInputVaue(String ruleInputName, String rawValue) { // // IInputValueBuilder builder = builderMap.get(ruleInputName); // if (builder == null) { // throw new IllegalArgumentException("No input value builder registered for input " + ruleInputName); // } else { // return builder.build(rawValue); // } // } // // public void registerRuleInputBuilder(String ruleInputName, IInputValueBuilder builder) { // builderMap.put(ruleInputName, builder); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/DefaultDataType.java // public enum DefaultDataType { // NUMBER, // DATE, // STRING // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/defaults/DefaultBuilderRegistry.java // public class DefaultBuilderRegistry { // private final Map<String, IInputValueBuilder> builderRegister; // private static final Logger LOGGER = LoggerFactory.getLogger(DefaultBuilderRegistry.class); // // public DefaultBuilderRegistry() { // LOGGER.info("Initializing default builder registry..."); // // this.builderRegister = new ConcurrentHashMap<>(); // this.builderRegister.put("STRING", new DefaultStringInputBuilder()); // this.builderRegister.put("DATE", new DefaultDateInputBuilder()); // this.builderRegister.put("NUMBER", new DefaultNumberInputBuilder()); // } // // public IInputValueBuilder getDefaultBuilder(String dataType) { // return this.builderRegister.get(dataType); // } // }
import com.github.kislayverma.rulette.core.ruleinput.RuleInputConfiguration; import com.github.kislayverma.rulette.core.ruleinput.RuleInputConfigurator; import com.github.kislayverma.rulette.core.ruleinput.RuleInputValueFactory; import com.github.kislayverma.rulette.core.ruleinput.value.DefaultDataType; import com.github.kislayverma.rulette.core.ruleinput.value.defaults.DefaultBuilderRegistry; import java.util.List;
String uniqueIdColName, String uniqueOutputColName, List<RuleInputMetaData> inputs) { this.ruleSystemName = ruleSystemName; this.tableName = tableName; this.uniqueIdColumnName = uniqueIdColName; this.uniqueOutputColumnName = uniqueOutputColName; this.inputColumnList = inputs; } /** * This method loads default configuration for all rule inputs if no custom override * is given (in which case it overrides the defaults). * Input and output columns always get default configuration. * * @param configuration Custom configuration for rule inputs */ public void applyCustomConfiguration(RuleInputConfigurator configuration) { RuleInputValueFactory.getInstance().registerRuleInputBuilder( this.uniqueIdColumnName, BUILDER_REGISTRY.getDefaultBuilder(DefaultDataType.STRING.name())); RuleInputValueFactory.getInstance().registerRuleInputBuilder( this.uniqueOutputColumnName, BUILDER_REGISTRY.getDefaultBuilder(DefaultDataType.STRING.name())); if (configuration == null) { for (RuleInputMetaData rimd : inputColumnList) { RuleInputValueFactory.getInstance().registerRuleInputBuilder( rimd.getName(), BUILDER_REGISTRY.getDefaultBuilder(rimd.getDataType())); } } else { for (RuleInputMetaData rimd : inputColumnList) {
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfiguration.java // public class RuleInputConfiguration { // private final String ruleInputName; // private final IInputValueBuilder inputValueBuilder; // // public RuleInputConfiguration(String ruleInputName, IInputValueBuilder inputValueBuilder) { // this.ruleInputName = ruleInputName; // this.inputValueBuilder = inputValueBuilder; // } // // public String getRuleInputName() { // return ruleInputName; // } // // public IInputValueBuilder getInputValueBuilder() { // return inputValueBuilder; // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputConfigurator.java // public class RuleInputConfigurator { // private final Map<String, RuleInputConfiguration> configMap = new ConcurrentHashMap<>(); // // public void addConfiguration(RuleInputConfiguration config) throws Exception { // RuleInputConfiguration existingConfig = configMap.get(config.getRuleInputName()); // if (existingConfig != null) { // throw new Exception("Config already present for input name " + config.getRuleInputName()); // } else { // configMap.put(config.getRuleInputName(), config); // } // } // // public RuleInputConfiguration getConfig(String ruleInputName) { // return this.configMap.get(ruleInputName); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/RuleInputValueFactory.java // public class RuleInputValueFactory { // private static RuleInputValueFactory INSTANCE; // private final Map<String, IInputValueBuilder> builderMap; // private static final Logger LOGGER = LoggerFactory.getLogger(RuleInputValueFactory.class); // // private RuleInputValueFactory() { // LOGGER.info("Initializing input data type factory..."); // this.builderMap = new ConcurrentHashMap<>(); // LOGGER.info("Input data type factory initialized"); // } // // public static RuleInputValueFactory getInstance() { // if (INSTANCE == null) { // INSTANCE = new RuleInputValueFactory(); // } // // return INSTANCE; // } // // public IInputValue buildRuleInputVaue(String ruleInputName, String rawValue) { // // IInputValueBuilder builder = builderMap.get(ruleInputName); // if (builder == null) { // throw new IllegalArgumentException("No input value builder registered for input " + ruleInputName); // } else { // return builder.build(rawValue); // } // } // // public void registerRuleInputBuilder(String ruleInputName, IInputValueBuilder builder) { // builderMap.put(ruleInputName, builder); // } // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/DefaultDataType.java // public enum DefaultDataType { // NUMBER, // DATE, // STRING // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/defaults/DefaultBuilderRegistry.java // public class DefaultBuilderRegistry { // private final Map<String, IInputValueBuilder> builderRegister; // private static final Logger LOGGER = LoggerFactory.getLogger(DefaultBuilderRegistry.class); // // public DefaultBuilderRegistry() { // LOGGER.info("Initializing default builder registry..."); // // this.builderRegister = new ConcurrentHashMap<>(); // this.builderRegister.put("STRING", new DefaultStringInputBuilder()); // this.builderRegister.put("DATE", new DefaultDateInputBuilder()); // this.builderRegister.put("NUMBER", new DefaultNumberInputBuilder()); // } // // public IInputValueBuilder getDefaultBuilder(String dataType) { // return this.builderRegister.get(dataType); // } // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/metadata/RuleSystemMetaData.java import com.github.kislayverma.rulette.core.ruleinput.RuleInputConfiguration; import com.github.kislayverma.rulette.core.ruleinput.RuleInputConfigurator; import com.github.kislayverma.rulette.core.ruleinput.RuleInputValueFactory; import com.github.kislayverma.rulette.core.ruleinput.value.DefaultDataType; import com.github.kislayverma.rulette.core.ruleinput.value.defaults.DefaultBuilderRegistry; import java.util.List; String uniqueIdColName, String uniqueOutputColName, List<RuleInputMetaData> inputs) { this.ruleSystemName = ruleSystemName; this.tableName = tableName; this.uniqueIdColumnName = uniqueIdColName; this.uniqueOutputColumnName = uniqueOutputColName; this.inputColumnList = inputs; } /** * This method loads default configuration for all rule inputs if no custom override * is given (in which case it overrides the defaults). * Input and output columns always get default configuration. * * @param configuration Custom configuration for rule inputs */ public void applyCustomConfiguration(RuleInputConfigurator configuration) { RuleInputValueFactory.getInstance().registerRuleInputBuilder( this.uniqueIdColumnName, BUILDER_REGISTRY.getDefaultBuilder(DefaultDataType.STRING.name())); RuleInputValueFactory.getInstance().registerRuleInputBuilder( this.uniqueOutputColumnName, BUILDER_REGISTRY.getDefaultBuilder(DefaultDataType.STRING.name())); if (configuration == null) { for (RuleInputMetaData rimd : inputColumnList) { RuleInputValueFactory.getInstance().registerRuleInputBuilder( rimd.getName(), BUILDER_REGISTRY.getDefaultBuilder(rimd.getDataType())); } } else { for (RuleInputMetaData rimd : inputColumnList) {
RuleInputConfiguration inputConfig = configuration.getConfig(rimd.getName());
kislayverma/Rulette
rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/defaults/DefaultNumberInputBuilder.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValueBuilder.java // public interface IInputValueBuilder<T> { // IInputValue<T> build(String value); // }
import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValueBuilder;
package com.github.kislayverma.rulette.core.ruleinput.value.defaults; public class DefaultNumberInputBuilder implements IInputValueBuilder<Double>{ @Override
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValue.java // public interface IInputValue<T> { // String getDataType(); // T getValue(); // int compareTo(String obj); // int compareTo(IInputValue<T> obj); // boolean isEmpty(); // } // // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/IInputValueBuilder.java // public interface IInputValueBuilder<T> { // IInputValue<T> build(String value); // } // Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/ruleinput/value/defaults/DefaultNumberInputBuilder.java import com.github.kislayverma.rulette.core.ruleinput.value.IInputValue; import com.github.kislayverma.rulette.core.ruleinput.value.IInputValueBuilder; package com.github.kislayverma.rulette.core.ruleinput.value.defaults; public class DefaultNumberInputBuilder implements IInputValueBuilder<Double>{ @Override
public IInputValue<Double> build(String value) {
kislayverma/Rulette
rulette-mysql-provider/src/main/java/com/github/kislayverma/rulette/mysql/util/Utils.java
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/exception/DataAccessException.java // public class DataAccessException extends RuntimeException { // public DataAccessException() { // super(); // } // // public DataAccessException(String message) { // super(message); // } // // public DataAccessException(String message, Throwable cause) { // super(message, cause); // } // }
import com.github.kislayverma.rulette.core.exception.DataAccessException; import com.zaxxer.hikari.HikariConfig; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import java.util.Properties;
} /** * This method build a {@link HikariConfig} object from the given properties file. * @param props An {@link Properties} object encapsulating Hikari properties */ public static HikariConfig getHikariConfig(Properties props) { HikariConfig hikariConfig = new HikariConfig(); hikariConfig.setDriverClassName(props.getProperty(PROPERTY_MYSQL_DRIVER_CLASS)); hikariConfig.setJdbcUrl(props.getProperty(PROPERTY_JDBC_URL)); hikariConfig.setUsername(props.getProperty(PROPERTY_USER_NAME)); hikariConfig.setPassword(props.getProperty(PROPERTY_PASSWORD)); hikariConfig.setMaximumPoolSize(Integer.parseInt(props.getProperty(PROPERTY_MAX_POOL_SIZE))); hikariConfig.setConnectionTimeout(Long.parseLong(props.getProperty(PROPERTY_CONN_TIMEOUT))); return hikariConfig; } public static void closeSqlArtifacts(ResultSet resultSet, Statement statement, Connection connection) { try { if (resultSet != null) { resultSet.close(); } if (statement != null) { statement.close(); } if (connection != null) { connection.close(); } } catch (Exception e) {
// Path: rulette-core/src/main/java/com/github/kislayverma/rulette/core/exception/DataAccessException.java // public class DataAccessException extends RuntimeException { // public DataAccessException() { // super(); // } // // public DataAccessException(String message) { // super(message); // } // // public DataAccessException(String message, Throwable cause) { // super(message, cause); // } // } // Path: rulette-mysql-provider/src/main/java/com/github/kislayverma/rulette/mysql/util/Utils.java import com.github.kislayverma.rulette.core.exception.DataAccessException; import com.zaxxer.hikari.HikariConfig; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import java.util.Properties; } /** * This method build a {@link HikariConfig} object from the given properties file. * @param props An {@link Properties} object encapsulating Hikari properties */ public static HikariConfig getHikariConfig(Properties props) { HikariConfig hikariConfig = new HikariConfig(); hikariConfig.setDriverClassName(props.getProperty(PROPERTY_MYSQL_DRIVER_CLASS)); hikariConfig.setJdbcUrl(props.getProperty(PROPERTY_JDBC_URL)); hikariConfig.setUsername(props.getProperty(PROPERTY_USER_NAME)); hikariConfig.setPassword(props.getProperty(PROPERTY_PASSWORD)); hikariConfig.setMaximumPoolSize(Integer.parseInt(props.getProperty(PROPERTY_MAX_POOL_SIZE))); hikariConfig.setConnectionTimeout(Long.parseLong(props.getProperty(PROPERTY_CONN_TIMEOUT))); return hikariConfig; } public static void closeSqlArtifacts(ResultSet resultSet, Statement statement, Connection connection) { try { if (resultSet != null) { resultSet.close(); } if (statement != null) { statement.close(); } if (connection != null) { connection.close(); } } catch (Exception e) {
throw new DataAccessException("Failed to close database connection", e);
konifar/annict-android
app/src/main/java/com/konifar/annict/view/activity/SearchActivity.java
// Path: app/src/main/java/com/konifar/annict/viewmodel/SearchViewModel.java // public class SearchViewModel extends BaseObservable implements ViewModel { // // private final PageNavigator navigator; // // @Inject // public SearchViewModel(PageNavigator navigator) { // this.navigator = navigator; // } // // public void showData(@Nullable String accessToken, @Nullable String authCode, // @IdRes int layoutResId) { // if (!TextUtils.isEmpty(accessToken)) { // navigator.replaceSearchFragment(layoutResId); // } else { // // After authentication, intent has uri data including auth code. // if (TextUtils.isEmpty(authCode)) { // navigator.startLoginActivity(); // navigator.finish(); // } else { // navigator.replaceSearchFragment(authCode, layoutResId); // } // } // } // // @Override // public void destroy() { // // Do nothing // } // }
import com.konifar.annict.R; import com.konifar.annict.databinding.ActivitySearchBinding; import com.konifar.annict.pref.DefaultPrefs; import com.konifar.annict.viewmodel.SearchViewModel; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.databinding.DataBindingUtil; import android.os.Bundle; import android.util.Log; import javax.inject.Inject;
package com.konifar.annict.view.activity; public class SearchActivity extends BaseActivity { private static final String TAG = SearchActivity.class.getSimpleName(); @Inject
// Path: app/src/main/java/com/konifar/annict/viewmodel/SearchViewModel.java // public class SearchViewModel extends BaseObservable implements ViewModel { // // private final PageNavigator navigator; // // @Inject // public SearchViewModel(PageNavigator navigator) { // this.navigator = navigator; // } // // public void showData(@Nullable String accessToken, @Nullable String authCode, // @IdRes int layoutResId) { // if (!TextUtils.isEmpty(accessToken)) { // navigator.replaceSearchFragment(layoutResId); // } else { // // After authentication, intent has uri data including auth code. // if (TextUtils.isEmpty(authCode)) { // navigator.startLoginActivity(); // navigator.finish(); // } else { // navigator.replaceSearchFragment(authCode, layoutResId); // } // } // } // // @Override // public void destroy() { // // Do nothing // } // } // Path: app/src/main/java/com/konifar/annict/view/activity/SearchActivity.java import com.konifar.annict.R; import com.konifar.annict.databinding.ActivitySearchBinding; import com.konifar.annict.pref.DefaultPrefs; import com.konifar.annict.viewmodel.SearchViewModel; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.databinding.DataBindingUtil; import android.os.Bundle; import android.util.Log; import javax.inject.Inject; package com.konifar.annict.view.activity; public class SearchActivity extends BaseActivity { private static final String TAG = SearchActivity.class.getSimpleName(); @Inject
SearchViewModel viewModel;
konifar/annict-android
app/src/main/java/com/konifar/annict/viewmodel/MyProgramsViewModel.java
// Path: app/src/main/java/com/konifar/annict/model/Program.java // @Parcel // @Table // public class Program { // // public static final String TAG = Program.class.getSimpleName(); // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public long id; // // @Column // @SerializedName("started_at") // public Date startedAt; // // @Column // @SerializedName("is_rebroadcast") // public boolean isRebroadcast; // // @Column(indexed = true) // @SerializedName("channel") // public Channel channel; // // @Column(indexed = true) // @SerializedName("work") // public Work work; // // @Column(indexed = true) // @SerializedName("episode") // public Episode episode; // // public Program() { // // // } // } // // Path: app/src/main/java/com/konifar/annict/repository/ProgramRepository.java // public interface ProgramRepository { // // Observable<List<Program>> getMineOrderByStartedAtDescWithAuth(String authCode, int page); // // Observable<List<Program>> getMineOrderByStartedAtDesc(int page); // } // // Path: app/src/main/java/com/konifar/annict/util/PageNavigator.java // @ActivityScope // public class PageNavigator { // // AppCompatActivity activity; // // @Inject // public PageNavigator(AppCompatActivity activity) { // this.activity = activity; // } // // public void finish() { // activity.finish(); // } // // public void startCustomTab(@NonNull String url) { // CustomTabsIntent intent = new CustomTabsIntent.Builder().setShowTitle(true) // .setToolbarColor(ContextCompat.getColor(activity, R.color.theme500)) // .build(); // // intent.launchUrl(activity, Uri.parse(url)); // } // // public void replaceMainFragment(@IdRes int layoutResId) { // replaceFragment(MainFragment.newInstance(), layoutResId); // } // // private void replaceFragment(@NonNull Fragment fragment, @IdRes int layoutResId) { // final FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction(); // ft.replace(layoutResId, fragment, fragment.getClass().getSimpleName()); // ft.commit(); // } // // public void replaceMainFragment(@NonNull String authCode, @IdRes int layoutResId) { // replaceFragment(MainFragment.newInstance(authCode), layoutResId); // } // // public void replaceMyProgramsFragment(@IdRes int layoutResId) { // replaceFragment(MyProgramsFragment.newInstance(), layoutResId); // } // // public void replaceMyProgramsFragment(@NonNull String authCode, @IdRes int layoutResId) { // replaceFragment(MyProgramsFragment.newInstance(authCode), layoutResId); // } // // public void startLoginActivity() { // activity.startActivity(LoginActivity.createIntent(activity)); // } // // public void startEpisodeDetailActivity(@Nullable Program program) { // activity.startActivity(EpisodeDetailActivity.createIntent(activity, program)); // } // // public void startWorkDetailActivity(@Nullable Work work) { // activity.startActivity(WorkDetailActivity.createIntent(activity, work)); // } // // public void showRecordCreateDialog(Program program) { // RecordCreateDialogFragment dialog = RecordCreateDialogFragment.newInstance(program); // dialog.show(activity.getSupportFragmentManager(), RecordCreateDialogFragment.TAG); // } // // public void startSettingsActivity() { // activity.startActivity(SettingsActivity.createIntent(activity)); // } // // public void showStatusSelectDialog(Status status, StatusSelectDialog.Callback cb) { // StatusSelectDialog.show(activity, status, cb); // } // // public void startSearchActivity() { // SearchActivity.start(activity); // } // // public void replaceSearchFragment(@IdRes int layoutResId) { // replaceFragment(SearchFragment.newInstance(), layoutResId); // } // // public void replaceSearchFragment(@NonNull String authCode, @IdRes int layoutResId) { // replaceFragment(SearchFragment.newInstance(authCode), layoutResId); // } // }
import com.konifar.annict.model.Program; import com.konifar.annict.repository.ProgramRepository; import com.konifar.annict.util.PageNavigator; import android.content.Context; import java.util.List; import javax.inject.Inject; import rx.Observable;
package com.konifar.annict.viewmodel; public class MyProgramsViewModel extends AbstractListViewModel<Program, MyProgramItemViewModel> { private final Context context;
// Path: app/src/main/java/com/konifar/annict/model/Program.java // @Parcel // @Table // public class Program { // // public static final String TAG = Program.class.getSimpleName(); // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public long id; // // @Column // @SerializedName("started_at") // public Date startedAt; // // @Column // @SerializedName("is_rebroadcast") // public boolean isRebroadcast; // // @Column(indexed = true) // @SerializedName("channel") // public Channel channel; // // @Column(indexed = true) // @SerializedName("work") // public Work work; // // @Column(indexed = true) // @SerializedName("episode") // public Episode episode; // // public Program() { // // // } // } // // Path: app/src/main/java/com/konifar/annict/repository/ProgramRepository.java // public interface ProgramRepository { // // Observable<List<Program>> getMineOrderByStartedAtDescWithAuth(String authCode, int page); // // Observable<List<Program>> getMineOrderByStartedAtDesc(int page); // } // // Path: app/src/main/java/com/konifar/annict/util/PageNavigator.java // @ActivityScope // public class PageNavigator { // // AppCompatActivity activity; // // @Inject // public PageNavigator(AppCompatActivity activity) { // this.activity = activity; // } // // public void finish() { // activity.finish(); // } // // public void startCustomTab(@NonNull String url) { // CustomTabsIntent intent = new CustomTabsIntent.Builder().setShowTitle(true) // .setToolbarColor(ContextCompat.getColor(activity, R.color.theme500)) // .build(); // // intent.launchUrl(activity, Uri.parse(url)); // } // // public void replaceMainFragment(@IdRes int layoutResId) { // replaceFragment(MainFragment.newInstance(), layoutResId); // } // // private void replaceFragment(@NonNull Fragment fragment, @IdRes int layoutResId) { // final FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction(); // ft.replace(layoutResId, fragment, fragment.getClass().getSimpleName()); // ft.commit(); // } // // public void replaceMainFragment(@NonNull String authCode, @IdRes int layoutResId) { // replaceFragment(MainFragment.newInstance(authCode), layoutResId); // } // // public void replaceMyProgramsFragment(@IdRes int layoutResId) { // replaceFragment(MyProgramsFragment.newInstance(), layoutResId); // } // // public void replaceMyProgramsFragment(@NonNull String authCode, @IdRes int layoutResId) { // replaceFragment(MyProgramsFragment.newInstance(authCode), layoutResId); // } // // public void startLoginActivity() { // activity.startActivity(LoginActivity.createIntent(activity)); // } // // public void startEpisodeDetailActivity(@Nullable Program program) { // activity.startActivity(EpisodeDetailActivity.createIntent(activity, program)); // } // // public void startWorkDetailActivity(@Nullable Work work) { // activity.startActivity(WorkDetailActivity.createIntent(activity, work)); // } // // public void showRecordCreateDialog(Program program) { // RecordCreateDialogFragment dialog = RecordCreateDialogFragment.newInstance(program); // dialog.show(activity.getSupportFragmentManager(), RecordCreateDialogFragment.TAG); // } // // public void startSettingsActivity() { // activity.startActivity(SettingsActivity.createIntent(activity)); // } // // public void showStatusSelectDialog(Status status, StatusSelectDialog.Callback cb) { // StatusSelectDialog.show(activity, status, cb); // } // // public void startSearchActivity() { // SearchActivity.start(activity); // } // // public void replaceSearchFragment(@IdRes int layoutResId) { // replaceFragment(SearchFragment.newInstance(), layoutResId); // } // // public void replaceSearchFragment(@NonNull String authCode, @IdRes int layoutResId) { // replaceFragment(SearchFragment.newInstance(authCode), layoutResId); // } // } // Path: app/src/main/java/com/konifar/annict/viewmodel/MyProgramsViewModel.java import com.konifar.annict.model.Program; import com.konifar.annict.repository.ProgramRepository; import com.konifar.annict.util.PageNavigator; import android.content.Context; import java.util.List; import javax.inject.Inject; import rx.Observable; package com.konifar.annict.viewmodel; public class MyProgramsViewModel extends AbstractListViewModel<Program, MyProgramItemViewModel> { private final Context context;
private final ProgramRepository repository;
konifar/annict-android
app/src/main/java/com/konifar/annict/viewmodel/MyProgramsViewModel.java
// Path: app/src/main/java/com/konifar/annict/model/Program.java // @Parcel // @Table // public class Program { // // public static final String TAG = Program.class.getSimpleName(); // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public long id; // // @Column // @SerializedName("started_at") // public Date startedAt; // // @Column // @SerializedName("is_rebroadcast") // public boolean isRebroadcast; // // @Column(indexed = true) // @SerializedName("channel") // public Channel channel; // // @Column(indexed = true) // @SerializedName("work") // public Work work; // // @Column(indexed = true) // @SerializedName("episode") // public Episode episode; // // public Program() { // // // } // } // // Path: app/src/main/java/com/konifar/annict/repository/ProgramRepository.java // public interface ProgramRepository { // // Observable<List<Program>> getMineOrderByStartedAtDescWithAuth(String authCode, int page); // // Observable<List<Program>> getMineOrderByStartedAtDesc(int page); // } // // Path: app/src/main/java/com/konifar/annict/util/PageNavigator.java // @ActivityScope // public class PageNavigator { // // AppCompatActivity activity; // // @Inject // public PageNavigator(AppCompatActivity activity) { // this.activity = activity; // } // // public void finish() { // activity.finish(); // } // // public void startCustomTab(@NonNull String url) { // CustomTabsIntent intent = new CustomTabsIntent.Builder().setShowTitle(true) // .setToolbarColor(ContextCompat.getColor(activity, R.color.theme500)) // .build(); // // intent.launchUrl(activity, Uri.parse(url)); // } // // public void replaceMainFragment(@IdRes int layoutResId) { // replaceFragment(MainFragment.newInstance(), layoutResId); // } // // private void replaceFragment(@NonNull Fragment fragment, @IdRes int layoutResId) { // final FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction(); // ft.replace(layoutResId, fragment, fragment.getClass().getSimpleName()); // ft.commit(); // } // // public void replaceMainFragment(@NonNull String authCode, @IdRes int layoutResId) { // replaceFragment(MainFragment.newInstance(authCode), layoutResId); // } // // public void replaceMyProgramsFragment(@IdRes int layoutResId) { // replaceFragment(MyProgramsFragment.newInstance(), layoutResId); // } // // public void replaceMyProgramsFragment(@NonNull String authCode, @IdRes int layoutResId) { // replaceFragment(MyProgramsFragment.newInstance(authCode), layoutResId); // } // // public void startLoginActivity() { // activity.startActivity(LoginActivity.createIntent(activity)); // } // // public void startEpisodeDetailActivity(@Nullable Program program) { // activity.startActivity(EpisodeDetailActivity.createIntent(activity, program)); // } // // public void startWorkDetailActivity(@Nullable Work work) { // activity.startActivity(WorkDetailActivity.createIntent(activity, work)); // } // // public void showRecordCreateDialog(Program program) { // RecordCreateDialogFragment dialog = RecordCreateDialogFragment.newInstance(program); // dialog.show(activity.getSupportFragmentManager(), RecordCreateDialogFragment.TAG); // } // // public void startSettingsActivity() { // activity.startActivity(SettingsActivity.createIntent(activity)); // } // // public void showStatusSelectDialog(Status status, StatusSelectDialog.Callback cb) { // StatusSelectDialog.show(activity, status, cb); // } // // public void startSearchActivity() { // SearchActivity.start(activity); // } // // public void replaceSearchFragment(@IdRes int layoutResId) { // replaceFragment(SearchFragment.newInstance(), layoutResId); // } // // public void replaceSearchFragment(@NonNull String authCode, @IdRes int layoutResId) { // replaceFragment(SearchFragment.newInstance(authCode), layoutResId); // } // }
import com.konifar.annict.model.Program; import com.konifar.annict.repository.ProgramRepository; import com.konifar.annict.util.PageNavigator; import android.content.Context; import java.util.List; import javax.inject.Inject; import rx.Observable;
package com.konifar.annict.viewmodel; public class MyProgramsViewModel extends AbstractListViewModel<Program, MyProgramItemViewModel> { private final Context context; private final ProgramRepository repository;
// Path: app/src/main/java/com/konifar/annict/model/Program.java // @Parcel // @Table // public class Program { // // public static final String TAG = Program.class.getSimpleName(); // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public long id; // // @Column // @SerializedName("started_at") // public Date startedAt; // // @Column // @SerializedName("is_rebroadcast") // public boolean isRebroadcast; // // @Column(indexed = true) // @SerializedName("channel") // public Channel channel; // // @Column(indexed = true) // @SerializedName("work") // public Work work; // // @Column(indexed = true) // @SerializedName("episode") // public Episode episode; // // public Program() { // // // } // } // // Path: app/src/main/java/com/konifar/annict/repository/ProgramRepository.java // public interface ProgramRepository { // // Observable<List<Program>> getMineOrderByStartedAtDescWithAuth(String authCode, int page); // // Observable<List<Program>> getMineOrderByStartedAtDesc(int page); // } // // Path: app/src/main/java/com/konifar/annict/util/PageNavigator.java // @ActivityScope // public class PageNavigator { // // AppCompatActivity activity; // // @Inject // public PageNavigator(AppCompatActivity activity) { // this.activity = activity; // } // // public void finish() { // activity.finish(); // } // // public void startCustomTab(@NonNull String url) { // CustomTabsIntent intent = new CustomTabsIntent.Builder().setShowTitle(true) // .setToolbarColor(ContextCompat.getColor(activity, R.color.theme500)) // .build(); // // intent.launchUrl(activity, Uri.parse(url)); // } // // public void replaceMainFragment(@IdRes int layoutResId) { // replaceFragment(MainFragment.newInstance(), layoutResId); // } // // private void replaceFragment(@NonNull Fragment fragment, @IdRes int layoutResId) { // final FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction(); // ft.replace(layoutResId, fragment, fragment.getClass().getSimpleName()); // ft.commit(); // } // // public void replaceMainFragment(@NonNull String authCode, @IdRes int layoutResId) { // replaceFragment(MainFragment.newInstance(authCode), layoutResId); // } // // public void replaceMyProgramsFragment(@IdRes int layoutResId) { // replaceFragment(MyProgramsFragment.newInstance(), layoutResId); // } // // public void replaceMyProgramsFragment(@NonNull String authCode, @IdRes int layoutResId) { // replaceFragment(MyProgramsFragment.newInstance(authCode), layoutResId); // } // // public void startLoginActivity() { // activity.startActivity(LoginActivity.createIntent(activity)); // } // // public void startEpisodeDetailActivity(@Nullable Program program) { // activity.startActivity(EpisodeDetailActivity.createIntent(activity, program)); // } // // public void startWorkDetailActivity(@Nullable Work work) { // activity.startActivity(WorkDetailActivity.createIntent(activity, work)); // } // // public void showRecordCreateDialog(Program program) { // RecordCreateDialogFragment dialog = RecordCreateDialogFragment.newInstance(program); // dialog.show(activity.getSupportFragmentManager(), RecordCreateDialogFragment.TAG); // } // // public void startSettingsActivity() { // activity.startActivity(SettingsActivity.createIntent(activity)); // } // // public void showStatusSelectDialog(Status status, StatusSelectDialog.Callback cb) { // StatusSelectDialog.show(activity, status, cb); // } // // public void startSearchActivity() { // SearchActivity.start(activity); // } // // public void replaceSearchFragment(@IdRes int layoutResId) { // replaceFragment(SearchFragment.newInstance(), layoutResId); // } // // public void replaceSearchFragment(@NonNull String authCode, @IdRes int layoutResId) { // replaceFragment(SearchFragment.newInstance(authCode), layoutResId); // } // } // Path: app/src/main/java/com/konifar/annict/viewmodel/MyProgramsViewModel.java import com.konifar.annict.model.Program; import com.konifar.annict.repository.ProgramRepository; import com.konifar.annict.util.PageNavigator; import android.content.Context; import java.util.List; import javax.inject.Inject; import rx.Observable; package com.konifar.annict.viewmodel; public class MyProgramsViewModel extends AbstractListViewModel<Program, MyProgramItemViewModel> { private final Context context; private final ProgramRepository repository;
private final PageNavigator pageNavigator;
konifar/annict-android
app/src/main/java/com/konifar/annict/view/widget/SearchToolbar.java
// Path: app/src/main/java/com/konifar/annict/util/LocaleUtil.java // public class LocaleUtil { // // public static boolean shouldRtl() { // return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) // == ViewCompat.LAYOUT_DIRECTION_RTL; // } // }
import com.konifar.annict.R; import com.konifar.annict.databinding.ViewSearchToolbarBinding; import com.konifar.annict.util.LocaleUtil; import android.content.Context; import android.content.res.TypedArray; import android.databinding.DataBindingUtil; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.v7.widget.Toolbar; import android.text.Editable; import android.text.TextWatcher; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.MotionEvent; import android.widget.FrameLayout;
public void setHint(int resId) { binding.editSearch.setHint(resId); } private void toggleCloseButtonVisible(boolean visible) { getCloseDrawable().setAlpha(visible ? 255 : 0); } private void initView() { binding.editSearch.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Do nothing } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { boolean visible = count > 0 || start > 0; toggleCloseButtonVisible(visible); } @Override public void afterTextChanged(Editable s) { // } }); binding.editSearch.setOnTouchListener((v, event) -> { if (event.getAction() == MotionEvent.ACTION_UP) { boolean shouldClear = false;
// Path: app/src/main/java/com/konifar/annict/util/LocaleUtil.java // public class LocaleUtil { // // public static boolean shouldRtl() { // return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) // == ViewCompat.LAYOUT_DIRECTION_RTL; // } // } // Path: app/src/main/java/com/konifar/annict/view/widget/SearchToolbar.java import com.konifar.annict.R; import com.konifar.annict.databinding.ViewSearchToolbarBinding; import com.konifar.annict.util.LocaleUtil; import android.content.Context; import android.content.res.TypedArray; import android.databinding.DataBindingUtil; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.v7.widget.Toolbar; import android.text.Editable; import android.text.TextWatcher; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.MotionEvent; import android.widget.FrameLayout; public void setHint(int resId) { binding.editSearch.setHint(resId); } private void toggleCloseButtonVisible(boolean visible) { getCloseDrawable().setAlpha(visible ? 255 : 0); } private void initView() { binding.editSearch.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Do nothing } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { boolean visible = count > 0 || start > 0; toggleCloseButtonVisible(visible); } @Override public void afterTextChanged(Editable s) { // } }); binding.editSearch.setOnTouchListener((v, event) -> { if (event.getAction() == MotionEvent.ACTION_UP) { boolean shouldClear = false;
if (LocaleUtil.shouldRtl()) {
konifar/annict-android
app/src/main/java/com/konifar/annict/api/AnnictClient.java
// Path: app/src/main/java/com/konifar/annict/model/Programs.java // @Parcel // public class Programs { // // @SerializedName("programs") // public List<Program> list; // } // // Path: app/src/main/java/com/konifar/annict/model/Record.java // @Parcel // @Table // public class Record { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public long id; // // @Column // @SerializedName("comment") // public String comment; // // @Nullable // @Column // @SerializedName("rating") // public Long rating; // // @Column // @SerializedName("is_modified") // public boolean isModified; // // @Column // @SerializedName("likes_count") // public int likesCount; // // @Column // @SerializedName("comments_count") // public int commentsCount; // // @Column // @SerializedName("created_at") // public Date createdAt; // // @Column(indexed = true) // @SerializedName("user") // public User user; // // @Column(indexed = true) // @SerializedName("work") // public Work work; // // @Column(indexed = true) // @SerializedName("episode") // public Work episode; // // public Record() { // // // } // } // // Path: app/src/main/java/com/konifar/annict/model/Token.java // public class Token { // // @SerializedName("access_token") // public String accessToken; // // @SerializedName("token_type") // public String tokenType; // // @SerializedName("expires_in") // public long expiresIn; // // @SerializedName("scope") // public String scope; // // @SerializedName("created_at") // public long createdAt; // } // // Path: app/src/main/java/com/konifar/annict/model/Works.java // @Parcel // public class Works { // // @SerializedName("works") // public List<Work> list; // }
import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.konifar.annict.BuildConfig; import com.konifar.annict.model.Programs; import com.konifar.annict.model.Record; import com.konifar.annict.model.Token; import com.konifar.annict.model.Works; import android.net.Uri; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import javax.inject.Inject; import javax.inject.Singleton; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.PUT; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Observable;
package com.konifar.annict.api; @Singleton public class AnnictClient { private static final String BASE_URI = "https://api.annict.com"; private static final String OAUTH_REDIRECT_URI = "intent://annict-android/authorize"; public final AnnictService service; @Inject public AnnictClient(OkHttpClient client) { Retrofit retrofit = new Retrofit.Builder().client(client) .baseUrl(BASE_URI) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .addConverterFactory(GsonConverterFactory.create(createGson())) .build(); service = retrofit.create(AnnictService.class); } public static Gson createGson() { return new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create(); } public static String getOAuthUrl() { Uri uri = Uri.parse(BASE_URI + "/oauth/authorize") .buildUpon() .appendQueryParameter("client_id", BuildConfig.ANNICT_APPLICATION_ID) .appendQueryParameter("response_type", "code") .appendQueryParameter("redirect_uri", OAUTH_REDIRECT_URI) .build(); return uri.toString(); }
// Path: app/src/main/java/com/konifar/annict/model/Programs.java // @Parcel // public class Programs { // // @SerializedName("programs") // public List<Program> list; // } // // Path: app/src/main/java/com/konifar/annict/model/Record.java // @Parcel // @Table // public class Record { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public long id; // // @Column // @SerializedName("comment") // public String comment; // // @Nullable // @Column // @SerializedName("rating") // public Long rating; // // @Column // @SerializedName("is_modified") // public boolean isModified; // // @Column // @SerializedName("likes_count") // public int likesCount; // // @Column // @SerializedName("comments_count") // public int commentsCount; // // @Column // @SerializedName("created_at") // public Date createdAt; // // @Column(indexed = true) // @SerializedName("user") // public User user; // // @Column(indexed = true) // @SerializedName("work") // public Work work; // // @Column(indexed = true) // @SerializedName("episode") // public Work episode; // // public Record() { // // // } // } // // Path: app/src/main/java/com/konifar/annict/model/Token.java // public class Token { // // @SerializedName("access_token") // public String accessToken; // // @SerializedName("token_type") // public String tokenType; // // @SerializedName("expires_in") // public long expiresIn; // // @SerializedName("scope") // public String scope; // // @SerializedName("created_at") // public long createdAt; // } // // Path: app/src/main/java/com/konifar/annict/model/Works.java // @Parcel // public class Works { // // @SerializedName("works") // public List<Work> list; // } // Path: app/src/main/java/com/konifar/annict/api/AnnictClient.java import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.konifar.annict.BuildConfig; import com.konifar.annict.model.Programs; import com.konifar.annict.model.Record; import com.konifar.annict.model.Token; import com.konifar.annict.model.Works; import android.net.Uri; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import javax.inject.Inject; import javax.inject.Singleton; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.PUT; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Observable; package com.konifar.annict.api; @Singleton public class AnnictClient { private static final String BASE_URI = "https://api.annict.com"; private static final String OAUTH_REDIRECT_URI = "intent://annict-android/authorize"; public final AnnictService service; @Inject public AnnictClient(OkHttpClient client) { Retrofit retrofit = new Retrofit.Builder().client(client) .baseUrl(BASE_URI) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .addConverterFactory(GsonConverterFactory.create(createGson())) .build(); service = retrofit.create(AnnictService.class); } public static Gson createGson() { return new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create(); } public static String getOAuthUrl() { Uri uri = Uri.parse(BASE_URI + "/oauth/authorize") .buildUpon() .appendQueryParameter("client_id", BuildConfig.ANNICT_APPLICATION_ID) .appendQueryParameter("response_type", "code") .appendQueryParameter("redirect_uri", OAUTH_REDIRECT_URI) .build(); return uri.toString(); }
public Observable<Token> postOauthToken(@NonNull String authCode) {
konifar/annict-android
app/src/main/java/com/konifar/annict/api/AnnictClient.java
// Path: app/src/main/java/com/konifar/annict/model/Programs.java // @Parcel // public class Programs { // // @SerializedName("programs") // public List<Program> list; // } // // Path: app/src/main/java/com/konifar/annict/model/Record.java // @Parcel // @Table // public class Record { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public long id; // // @Column // @SerializedName("comment") // public String comment; // // @Nullable // @Column // @SerializedName("rating") // public Long rating; // // @Column // @SerializedName("is_modified") // public boolean isModified; // // @Column // @SerializedName("likes_count") // public int likesCount; // // @Column // @SerializedName("comments_count") // public int commentsCount; // // @Column // @SerializedName("created_at") // public Date createdAt; // // @Column(indexed = true) // @SerializedName("user") // public User user; // // @Column(indexed = true) // @SerializedName("work") // public Work work; // // @Column(indexed = true) // @SerializedName("episode") // public Work episode; // // public Record() { // // // } // } // // Path: app/src/main/java/com/konifar/annict/model/Token.java // public class Token { // // @SerializedName("access_token") // public String accessToken; // // @SerializedName("token_type") // public String tokenType; // // @SerializedName("expires_in") // public long expiresIn; // // @SerializedName("scope") // public String scope; // // @SerializedName("created_at") // public long createdAt; // } // // Path: app/src/main/java/com/konifar/annict/model/Works.java // @Parcel // public class Works { // // @SerializedName("works") // public List<Work> list; // }
import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.konifar.annict.BuildConfig; import com.konifar.annict.model.Programs; import com.konifar.annict.model.Record; import com.konifar.annict.model.Token; import com.konifar.annict.model.Works; import android.net.Uri; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import javax.inject.Inject; import javax.inject.Singleton; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.PUT; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Observable;
Uri uri = Uri.parse(BASE_URI + "/oauth/authorize") .buildUpon() .appendQueryParameter("client_id", BuildConfig.ANNICT_APPLICATION_ID) .appendQueryParameter("response_type", "code") .appendQueryParameter("redirect_uri", OAUTH_REDIRECT_URI) .build(); return uri.toString(); } public Observable<Token> postOauthToken(@NonNull String authCode) { return service.postOauthToken(BuildConfig.ANNICT_APPLICATION_ID, BuildConfig.ANNICT_SECRET_KEY, "authorization_code", OAUTH_REDIRECT_URI, authCode); } public interface AnnictService { /** * https://annict.wikihub.io/wiki/api/authentication */ @POST("/oauth/token") Observable<Token> postOauthToken( @Query("client_id") String clientId, @Query("client_secret") String clientSecret, @Query("grant_type") String grantType, @Query("redirect_uri") String scope, @Query("code") String code ); /** * https://annict.wikihub.io/wiki/api/me-programs */ @GET("/v1/me/programs")
// Path: app/src/main/java/com/konifar/annict/model/Programs.java // @Parcel // public class Programs { // // @SerializedName("programs") // public List<Program> list; // } // // Path: app/src/main/java/com/konifar/annict/model/Record.java // @Parcel // @Table // public class Record { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public long id; // // @Column // @SerializedName("comment") // public String comment; // // @Nullable // @Column // @SerializedName("rating") // public Long rating; // // @Column // @SerializedName("is_modified") // public boolean isModified; // // @Column // @SerializedName("likes_count") // public int likesCount; // // @Column // @SerializedName("comments_count") // public int commentsCount; // // @Column // @SerializedName("created_at") // public Date createdAt; // // @Column(indexed = true) // @SerializedName("user") // public User user; // // @Column(indexed = true) // @SerializedName("work") // public Work work; // // @Column(indexed = true) // @SerializedName("episode") // public Work episode; // // public Record() { // // // } // } // // Path: app/src/main/java/com/konifar/annict/model/Token.java // public class Token { // // @SerializedName("access_token") // public String accessToken; // // @SerializedName("token_type") // public String tokenType; // // @SerializedName("expires_in") // public long expiresIn; // // @SerializedName("scope") // public String scope; // // @SerializedName("created_at") // public long createdAt; // } // // Path: app/src/main/java/com/konifar/annict/model/Works.java // @Parcel // public class Works { // // @SerializedName("works") // public List<Work> list; // } // Path: app/src/main/java/com/konifar/annict/api/AnnictClient.java import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.konifar.annict.BuildConfig; import com.konifar.annict.model.Programs; import com.konifar.annict.model.Record; import com.konifar.annict.model.Token; import com.konifar.annict.model.Works; import android.net.Uri; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import javax.inject.Inject; import javax.inject.Singleton; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.PUT; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Observable; Uri uri = Uri.parse(BASE_URI + "/oauth/authorize") .buildUpon() .appendQueryParameter("client_id", BuildConfig.ANNICT_APPLICATION_ID) .appendQueryParameter("response_type", "code") .appendQueryParameter("redirect_uri", OAUTH_REDIRECT_URI) .build(); return uri.toString(); } public Observable<Token> postOauthToken(@NonNull String authCode) { return service.postOauthToken(BuildConfig.ANNICT_APPLICATION_ID, BuildConfig.ANNICT_SECRET_KEY, "authorization_code", OAUTH_REDIRECT_URI, authCode); } public interface AnnictService { /** * https://annict.wikihub.io/wiki/api/authentication */ @POST("/oauth/token") Observable<Token> postOauthToken( @Query("client_id") String clientId, @Query("client_secret") String clientSecret, @Query("grant_type") String grantType, @Query("redirect_uri") String scope, @Query("code") String code ); /** * https://annict.wikihub.io/wiki/api/me-programs */ @GET("/v1/me/programs")
Observable<Programs> getMeProgarms(
konifar/annict-android
app/src/main/java/com/konifar/annict/api/AnnictClient.java
// Path: app/src/main/java/com/konifar/annict/model/Programs.java // @Parcel // public class Programs { // // @SerializedName("programs") // public List<Program> list; // } // // Path: app/src/main/java/com/konifar/annict/model/Record.java // @Parcel // @Table // public class Record { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public long id; // // @Column // @SerializedName("comment") // public String comment; // // @Nullable // @Column // @SerializedName("rating") // public Long rating; // // @Column // @SerializedName("is_modified") // public boolean isModified; // // @Column // @SerializedName("likes_count") // public int likesCount; // // @Column // @SerializedName("comments_count") // public int commentsCount; // // @Column // @SerializedName("created_at") // public Date createdAt; // // @Column(indexed = true) // @SerializedName("user") // public User user; // // @Column(indexed = true) // @SerializedName("work") // public Work work; // // @Column(indexed = true) // @SerializedName("episode") // public Work episode; // // public Record() { // // // } // } // // Path: app/src/main/java/com/konifar/annict/model/Token.java // public class Token { // // @SerializedName("access_token") // public String accessToken; // // @SerializedName("token_type") // public String tokenType; // // @SerializedName("expires_in") // public long expiresIn; // // @SerializedName("scope") // public String scope; // // @SerializedName("created_at") // public long createdAt; // } // // Path: app/src/main/java/com/konifar/annict/model/Works.java // @Parcel // public class Works { // // @SerializedName("works") // public List<Work> list; // }
import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.konifar.annict.BuildConfig; import com.konifar.annict.model.Programs; import com.konifar.annict.model.Record; import com.konifar.annict.model.Token; import com.konifar.annict.model.Works; import android.net.Uri; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import javax.inject.Inject; import javax.inject.Singleton; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.PUT; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Observable;
/** * https://annict.wikihub.io/wiki/api/authentication */ @POST("/oauth/token") Observable<Token> postOauthToken( @Query("client_id") String clientId, @Query("client_secret") String clientSecret, @Query("grant_type") String grantType, @Query("redirect_uri") String scope, @Query("code") String code ); /** * https://annict.wikihub.io/wiki/api/me-programs */ @GET("/v1/me/programs") Observable<Programs> getMeProgarms( @Query("fields") @Nullable String fields, @Query("filter_ids") @Nullable String filterIds, @Query("filter_channel_ids") @Nullable String filterChannelIds, @Query("filter_work_ids") @Nullable String filterWorkIds, @Query("filter_started_at_gt") @Nullable String filterStartedAtGt, @Query("filter_started_at_lt") @Nullable String filterStartedAtLt, @Query("filter_unwatched") @Nullable Boolean filterUnwatched, @Query("filter_rebroadcast") @Nullable Boolean filterRebroadcast, @Query("page") int page, @Query("per_page") int perPage, @Query("sort_id") @Nullable String sortId, @Query("sort_started_at") @Nullable String sortStartedAt ); /** * https://annict.wikihub.io/wiki/api/me-works */ @GET("/v1/me/works")
// Path: app/src/main/java/com/konifar/annict/model/Programs.java // @Parcel // public class Programs { // // @SerializedName("programs") // public List<Program> list; // } // // Path: app/src/main/java/com/konifar/annict/model/Record.java // @Parcel // @Table // public class Record { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public long id; // // @Column // @SerializedName("comment") // public String comment; // // @Nullable // @Column // @SerializedName("rating") // public Long rating; // // @Column // @SerializedName("is_modified") // public boolean isModified; // // @Column // @SerializedName("likes_count") // public int likesCount; // // @Column // @SerializedName("comments_count") // public int commentsCount; // // @Column // @SerializedName("created_at") // public Date createdAt; // // @Column(indexed = true) // @SerializedName("user") // public User user; // // @Column(indexed = true) // @SerializedName("work") // public Work work; // // @Column(indexed = true) // @SerializedName("episode") // public Work episode; // // public Record() { // // // } // } // // Path: app/src/main/java/com/konifar/annict/model/Token.java // public class Token { // // @SerializedName("access_token") // public String accessToken; // // @SerializedName("token_type") // public String tokenType; // // @SerializedName("expires_in") // public long expiresIn; // // @SerializedName("scope") // public String scope; // // @SerializedName("created_at") // public long createdAt; // } // // Path: app/src/main/java/com/konifar/annict/model/Works.java // @Parcel // public class Works { // // @SerializedName("works") // public List<Work> list; // } // Path: app/src/main/java/com/konifar/annict/api/AnnictClient.java import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.konifar.annict.BuildConfig; import com.konifar.annict.model.Programs; import com.konifar.annict.model.Record; import com.konifar.annict.model.Token; import com.konifar.annict.model.Works; import android.net.Uri; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import javax.inject.Inject; import javax.inject.Singleton; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.PUT; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Observable; /** * https://annict.wikihub.io/wiki/api/authentication */ @POST("/oauth/token") Observable<Token> postOauthToken( @Query("client_id") String clientId, @Query("client_secret") String clientSecret, @Query("grant_type") String grantType, @Query("redirect_uri") String scope, @Query("code") String code ); /** * https://annict.wikihub.io/wiki/api/me-programs */ @GET("/v1/me/programs") Observable<Programs> getMeProgarms( @Query("fields") @Nullable String fields, @Query("filter_ids") @Nullable String filterIds, @Query("filter_channel_ids") @Nullable String filterChannelIds, @Query("filter_work_ids") @Nullable String filterWorkIds, @Query("filter_started_at_gt") @Nullable String filterStartedAtGt, @Query("filter_started_at_lt") @Nullable String filterStartedAtLt, @Query("filter_unwatched") @Nullable Boolean filterUnwatched, @Query("filter_rebroadcast") @Nullable Boolean filterRebroadcast, @Query("page") int page, @Query("per_page") int perPage, @Query("sort_id") @Nullable String sortId, @Query("sort_started_at") @Nullable String sortStartedAt ); /** * https://annict.wikihub.io/wiki/api/me-works */ @GET("/v1/me/works")
Observable<Works> getMeWorks(
konifar/annict-android
app/src/main/java/com/konifar/annict/api/AnnictClient.java
// Path: app/src/main/java/com/konifar/annict/model/Programs.java // @Parcel // public class Programs { // // @SerializedName("programs") // public List<Program> list; // } // // Path: app/src/main/java/com/konifar/annict/model/Record.java // @Parcel // @Table // public class Record { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public long id; // // @Column // @SerializedName("comment") // public String comment; // // @Nullable // @Column // @SerializedName("rating") // public Long rating; // // @Column // @SerializedName("is_modified") // public boolean isModified; // // @Column // @SerializedName("likes_count") // public int likesCount; // // @Column // @SerializedName("comments_count") // public int commentsCount; // // @Column // @SerializedName("created_at") // public Date createdAt; // // @Column(indexed = true) // @SerializedName("user") // public User user; // // @Column(indexed = true) // @SerializedName("work") // public Work work; // // @Column(indexed = true) // @SerializedName("episode") // public Work episode; // // public Record() { // // // } // } // // Path: app/src/main/java/com/konifar/annict/model/Token.java // public class Token { // // @SerializedName("access_token") // public String accessToken; // // @SerializedName("token_type") // public String tokenType; // // @SerializedName("expires_in") // public long expiresIn; // // @SerializedName("scope") // public String scope; // // @SerializedName("created_at") // public long createdAt; // } // // Path: app/src/main/java/com/konifar/annict/model/Works.java // @Parcel // public class Works { // // @SerializedName("works") // public List<Work> list; // }
import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.konifar.annict.BuildConfig; import com.konifar.annict.model.Programs; import com.konifar.annict.model.Record; import com.konifar.annict.model.Token; import com.konifar.annict.model.Works; import android.net.Uri; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import javax.inject.Inject; import javax.inject.Singleton; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.PUT; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Observable;
@Query("sort_watchers_count") @Nullable String sortWatchersCount ); /** * https://annict.wikihub.io/wiki/api/me-statuses */ @POST("/v1/me/statuses") Observable<Void> postMeStatuses( @Query("work_id") long workId, @Query("kind") @NonNull String kind ); /** * https://annict.wikihub.io/wiki/api/works */ @GET("/v1/works") Observable<Works> getWorks( @Query("fields") @Nullable String fields, @Query("filter_ids") @Nullable String filterIds, @Query("filter_season") @Nullable String filterSeason, @Query("filter_title") @Nullable String filterTitle, @Query("page") int page, @Query("per_page") int perPage, @Query("sort_id") @Nullable String sortId, @Query("sort_reason") @Nullable String sortReason, @Query("sort_watchers_count") @Nullable String sortWatchersCount ); /** * https://annict.wikihub.io/wiki/api/me-records */ @POST("/v1/me/records")
// Path: app/src/main/java/com/konifar/annict/model/Programs.java // @Parcel // public class Programs { // // @SerializedName("programs") // public List<Program> list; // } // // Path: app/src/main/java/com/konifar/annict/model/Record.java // @Parcel // @Table // public class Record { // // @PrimaryKey(auto = false) // @Column(indexed = true) // @SerializedName("id") // public long id; // // @Column // @SerializedName("comment") // public String comment; // // @Nullable // @Column // @SerializedName("rating") // public Long rating; // // @Column // @SerializedName("is_modified") // public boolean isModified; // // @Column // @SerializedName("likes_count") // public int likesCount; // // @Column // @SerializedName("comments_count") // public int commentsCount; // // @Column // @SerializedName("created_at") // public Date createdAt; // // @Column(indexed = true) // @SerializedName("user") // public User user; // // @Column(indexed = true) // @SerializedName("work") // public Work work; // // @Column(indexed = true) // @SerializedName("episode") // public Work episode; // // public Record() { // // // } // } // // Path: app/src/main/java/com/konifar/annict/model/Token.java // public class Token { // // @SerializedName("access_token") // public String accessToken; // // @SerializedName("token_type") // public String tokenType; // // @SerializedName("expires_in") // public long expiresIn; // // @SerializedName("scope") // public String scope; // // @SerializedName("created_at") // public long createdAt; // } // // Path: app/src/main/java/com/konifar/annict/model/Works.java // @Parcel // public class Works { // // @SerializedName("works") // public List<Work> list; // } // Path: app/src/main/java/com/konifar/annict/api/AnnictClient.java import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.konifar.annict.BuildConfig; import com.konifar.annict.model.Programs; import com.konifar.annict.model.Record; import com.konifar.annict.model.Token; import com.konifar.annict.model.Works; import android.net.Uri; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import javax.inject.Inject; import javax.inject.Singleton; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.PUT; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Observable; @Query("sort_watchers_count") @Nullable String sortWatchersCount ); /** * https://annict.wikihub.io/wiki/api/me-statuses */ @POST("/v1/me/statuses") Observable<Void> postMeStatuses( @Query("work_id") long workId, @Query("kind") @NonNull String kind ); /** * https://annict.wikihub.io/wiki/api/works */ @GET("/v1/works") Observable<Works> getWorks( @Query("fields") @Nullable String fields, @Query("filter_ids") @Nullable String filterIds, @Query("filter_season") @Nullable String filterSeason, @Query("filter_title") @Nullable String filterTitle, @Query("page") int page, @Query("per_page") int perPage, @Query("sort_id") @Nullable String sortId, @Query("sort_reason") @Nullable String sortReason, @Query("sort_watchers_count") @Nullable String sortWatchersCount ); /** * https://annict.wikihub.io/wiki/api/me-records */ @POST("/v1/me/records")
Observable<Record> postMeRecords(