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
Devskiller/friendly-id
friendly-id-samples/friendly-id-contracts/src/test/java/com/devskiller/friendly_id/sample/contracts/MvcTest.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-jackson-datatype/src/main/java/com/devskiller/friendly_id/jackson/FriendlyIdModule.java // public class FriendlyIdModule extends SimpleModule { // // private FriendlyIdAnnotationIntrospector introspector; // // public FriendlyIdModule() { // introspector = new FriendlyIdAnnotationIntrospector(); // addDeserializer(UUID.class, new FriendlyIdDeserializer()); // addSerializer(UUID.class, new FriendlyIdSerializer()); // } // // @Override // public void setupModule(SetupContext context) { // context.insertAnnotationIntrospector(introspector); // } // }
import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.jackson.FriendlyIdModule; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; import io.restassured.module.mockmvc.RestAssuredMockMvc; import org.junit.Before; import org.springframework.core.convert.converter.Converter; import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.hateoas.server.EntityLinks; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.test.web.servlet.setup.StandaloneMockMvcBuilder; import java.util.UUID; import static org.mockito.Mockito.mock; import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
package com.devskiller.friendly_id.sample.contracts; public class MvcTest { protected StandaloneMockMvcBuilder mockMvcBuilder; @Before public void setup() { mockMvcBuilder = standaloneSetup(new FooController(mock(EntityLinks.class))); DefaultFormattingConversionService service = new DefaultFormattingConversionService(); service.addConverter(new StringToUuidConverter()); mockMvcBuilder.setMessageConverters(jackson2HttpMessageConverter()).setConversionService(service); RestAssuredMockMvc.standaloneSetup(mockMvcBuilder); } public static class StringToUuidConverter implements Converter<String, UUID> { @Override public UUID convert(String id) {
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-jackson-datatype/src/main/java/com/devskiller/friendly_id/jackson/FriendlyIdModule.java // public class FriendlyIdModule extends SimpleModule { // // private FriendlyIdAnnotationIntrospector introspector; // // public FriendlyIdModule() { // introspector = new FriendlyIdAnnotationIntrospector(); // addDeserializer(UUID.class, new FriendlyIdDeserializer()); // addSerializer(UUID.class, new FriendlyIdSerializer()); // } // // @Override // public void setupModule(SetupContext context) { // context.insertAnnotationIntrospector(introspector); // } // } // Path: friendly-id-samples/friendly-id-contracts/src/test/java/com/devskiller/friendly_id/sample/contracts/MvcTest.java import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.jackson.FriendlyIdModule; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; import io.restassured.module.mockmvc.RestAssuredMockMvc; import org.junit.Before; import org.springframework.core.convert.converter.Converter; import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.hateoas.server.EntityLinks; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.test.web.servlet.setup.StandaloneMockMvcBuilder; import java.util.UUID; import static org.mockito.Mockito.mock; import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup; package com.devskiller.friendly_id.sample.contracts; public class MvcTest { protected StandaloneMockMvcBuilder mockMvcBuilder; @Before public void setup() { mockMvcBuilder = standaloneSetup(new FooController(mock(EntityLinks.class))); DefaultFormattingConversionService service = new DefaultFormattingConversionService(); service.addConverter(new StringToUuidConverter()); mockMvcBuilder.setMessageConverters(jackson2HttpMessageConverter()).setConversionService(service); RestAssuredMockMvc.standaloneSetup(mockMvcBuilder); } public static class StringToUuidConverter implements Converter<String, UUID> { @Override public UUID convert(String id) {
return FriendlyId.toUuid(id);
Devskiller/friendly-id
friendly-id-samples/friendly-id-contracts/src/test/java/com/devskiller/friendly_id/sample/contracts/MvcTest.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-jackson-datatype/src/main/java/com/devskiller/friendly_id/jackson/FriendlyIdModule.java // public class FriendlyIdModule extends SimpleModule { // // private FriendlyIdAnnotationIntrospector introspector; // // public FriendlyIdModule() { // introspector = new FriendlyIdAnnotationIntrospector(); // addDeserializer(UUID.class, new FriendlyIdDeserializer()); // addSerializer(UUID.class, new FriendlyIdSerializer()); // } // // @Override // public void setupModule(SetupContext context) { // context.insertAnnotationIntrospector(introspector); // } // }
import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.jackson.FriendlyIdModule; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; import io.restassured.module.mockmvc.RestAssuredMockMvc; import org.junit.Before; import org.springframework.core.convert.converter.Converter; import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.hateoas.server.EntityLinks; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.test.web.servlet.setup.StandaloneMockMvcBuilder; import java.util.UUID; import static org.mockito.Mockito.mock; import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
package com.devskiller.friendly_id.sample.contracts; public class MvcTest { protected StandaloneMockMvcBuilder mockMvcBuilder; @Before public void setup() { mockMvcBuilder = standaloneSetup(new FooController(mock(EntityLinks.class))); DefaultFormattingConversionService service = new DefaultFormattingConversionService(); service.addConverter(new StringToUuidConverter()); mockMvcBuilder.setMessageConverters(jackson2HttpMessageConverter()).setConversionService(service); RestAssuredMockMvc.standaloneSetup(mockMvcBuilder); } public static class StringToUuidConverter implements Converter<String, UUID> { @Override public UUID convert(String id) { return FriendlyId.toUuid(id); } } private MappingJackson2HttpMessageConverter jackson2HttpMessageConverter() { MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); Jackson2ObjectMapperBuilder builder = this.jacksonBuilder(); converter.setObjectMapper(builder.build()); return converter; } protected Jackson2ObjectMapperBuilder jacksonBuilder() { Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-jackson-datatype/src/main/java/com/devskiller/friendly_id/jackson/FriendlyIdModule.java // public class FriendlyIdModule extends SimpleModule { // // private FriendlyIdAnnotationIntrospector introspector; // // public FriendlyIdModule() { // introspector = new FriendlyIdAnnotationIntrospector(); // addDeserializer(UUID.class, new FriendlyIdDeserializer()); // addSerializer(UUID.class, new FriendlyIdSerializer()); // } // // @Override // public void setupModule(SetupContext context) { // context.insertAnnotationIntrospector(introspector); // } // } // Path: friendly-id-samples/friendly-id-contracts/src/test/java/com/devskiller/friendly_id/sample/contracts/MvcTest.java import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.jackson.FriendlyIdModule; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; import io.restassured.module.mockmvc.RestAssuredMockMvc; import org.junit.Before; import org.springframework.core.convert.converter.Converter; import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.hateoas.server.EntityLinks; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.test.web.servlet.setup.StandaloneMockMvcBuilder; import java.util.UUID; import static org.mockito.Mockito.mock; import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup; package com.devskiller.friendly_id.sample.contracts; public class MvcTest { protected StandaloneMockMvcBuilder mockMvcBuilder; @Before public void setup() { mockMvcBuilder = standaloneSetup(new FooController(mock(EntityLinks.class))); DefaultFormattingConversionService service = new DefaultFormattingConversionService(); service.addConverter(new StringToUuidConverter()); mockMvcBuilder.setMessageConverters(jackson2HttpMessageConverter()).setConversionService(service); RestAssuredMockMvc.standaloneSetup(mockMvcBuilder); } public static class StringToUuidConverter implements Converter<String, UUID> { @Override public UUID convert(String id) { return FriendlyId.toUuid(id); } } private MappingJackson2HttpMessageConverter jackson2HttpMessageConverter() { MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); Jackson2ObjectMapperBuilder builder = this.jacksonBuilder(); converter.setObjectMapper(builder.build()); return converter; } protected Jackson2ObjectMapperBuilder jacksonBuilder() { Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.modules(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES), new JavaTimeModule(), new FriendlyIdModule());
Devskiller/friendly-id
friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/BarResourceAssembler.java
// Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Bar.java // @Data // @AllArgsConstructor // public class Bar { // // private UUID id; // private String name; // // private Foo foo; // // } // // Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // }
import com.devskiller.friendly_id.sample.hateos.domain.Bar; import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderFactory; import static com.devskiller.friendly_id.FriendlyId.toFriendlyId;
package com.devskiller.friendly_id.sample.hateos; public class BarResourceAssembler extends RepresentationModelAssemblerSupport<Bar, BarResource> { public BarResourceAssembler() { super(BarController.class, BarResource.class); } @Override public BarResource toModel(Bar entity) { BarResource resource = new BarResource(entity.getName()); WebMvcLinkBuilderFactory factory = new WebMvcLinkBuilderFactory(); resource.add(factory.linkTo(FooController.class).withRel("foos"));
// Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Bar.java // @Data // @AllArgsConstructor // public class Bar { // // private UUID id; // private String name; // // private Foo foo; // // } // // Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/BarResourceAssembler.java import com.devskiller.friendly_id.sample.hateos.domain.Bar; import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderFactory; import static com.devskiller.friendly_id.FriendlyId.toFriendlyId; package com.devskiller.friendly_id.sample.hateos; public class BarResourceAssembler extends RepresentationModelAssemblerSupport<Bar, BarResource> { public BarResourceAssembler() { super(BarController.class, BarResource.class); } @Override public BarResource toModel(Bar entity) { BarResource resource = new BarResource(entity.getName()); WebMvcLinkBuilderFactory factory = new WebMvcLinkBuilderFactory(); resource.add(factory.linkTo(FooController.class).withRel("foos"));
resource.add(factory.linkTo(BarController.class, toFriendlyId(entity.getFoo().getId())).slash(toFriendlyId(entity.getId())).withSelfRel());
Devskiller/friendly-id
friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/FooController.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // }
import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.sample.contracts.domain.Foo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.hateoas.server.EntityLinks; import org.springframework.hateoas.server.ExposesResourceFor; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.lang.invoke.MethodHandles; import java.util.UUID;
package com.devskiller.friendly_id.sample.contracts; @RestController @ExposesResourceFor(FooResource.class) @RequestMapping("/foos") public class FooController { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private final EntityLinks entityLinks; private final FooResourceAssembler assembler; public FooController(EntityLinks entityLinks) { this.entityLinks = entityLinks; this.assembler = new FooResourceAssembler(); } @GetMapping("/{id}") public FooResource get(@PathVariable UUID id) { log.info("Get {}", id);
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // } // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/FooController.java import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.sample.contracts.domain.Foo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.hateoas.server.EntityLinks; import org.springframework.hateoas.server.ExposesResourceFor; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.lang.invoke.MethodHandles; import java.util.UUID; package com.devskiller.friendly_id.sample.contracts; @RestController @ExposesResourceFor(FooResource.class) @RequestMapping("/foos") public class FooController { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private final EntityLinks entityLinks; private final FooResourceAssembler assembler; public FooController(EntityLinks entityLinks) { this.entityLinks = entityLinks; this.assembler = new FooResourceAssembler(); } @GetMapping("/{id}") public FooResource get(@PathVariable UUID id) { log.info("Get {}", id);
Foo foo = new Foo(id, "Foo");
Devskiller/friendly-id
friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/FooController.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // }
import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.sample.contracts.domain.Foo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.hateoas.server.EntityLinks; import org.springframework.hateoas.server.ExposesResourceFor; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.lang.invoke.MethodHandles; import java.util.UUID;
package com.devskiller.friendly_id.sample.contracts; @RestController @ExposesResourceFor(FooResource.class) @RequestMapping("/foos") public class FooController { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private final EntityLinks entityLinks; private final FooResourceAssembler assembler; public FooController(EntityLinks entityLinks) { this.entityLinks = entityLinks; this.assembler = new FooResourceAssembler(); } @GetMapping("/{id}") public FooResource get(@PathVariable UUID id) { log.info("Get {}", id); Foo foo = new Foo(id, "Foo"); return assembler.toModel(foo); } @PutMapping("/{id}") public HttpEntity<FooResource> update(@PathVariable UUID id, @RequestBody FooResource fooResource) { log.info("Update {} : {}", id, fooResource); Foo entity = new Foo(fooResource.getUuid(), fooResource.getName()); return ResponseEntity.ok(assembler.toModel(entity)); } @PostMapping public HttpEntity<FooResource> create(@RequestBody FooResource fooResource) { HttpHeaders headers = new HttpHeaders(); Foo entity = new Foo(fooResource.getUuid(), "Foo"); // ...
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // } // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/FooController.java import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.sample.contracts.domain.Foo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.hateoas.server.EntityLinks; import org.springframework.hateoas.server.ExposesResourceFor; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.lang.invoke.MethodHandles; import java.util.UUID; package com.devskiller.friendly_id.sample.contracts; @RestController @ExposesResourceFor(FooResource.class) @RequestMapping("/foos") public class FooController { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private final EntityLinks entityLinks; private final FooResourceAssembler assembler; public FooController(EntityLinks entityLinks) { this.entityLinks = entityLinks; this.assembler = new FooResourceAssembler(); } @GetMapping("/{id}") public FooResource get(@PathVariable UUID id) { log.info("Get {}", id); Foo foo = new Foo(id, "Foo"); return assembler.toModel(foo); } @PutMapping("/{id}") public HttpEntity<FooResource> update(@PathVariable UUID id, @RequestBody FooResource fooResource) { log.info("Update {} : {}", id, fooResource); Foo entity = new Foo(fooResource.getUuid(), fooResource.getName()); return ResponseEntity.ok(assembler.toModel(entity)); } @PostMapping public HttpEntity<FooResource> create(@RequestBody FooResource fooResource) { HttpHeaders headers = new HttpHeaders(); Foo entity = new Foo(fooResource.getUuid(), "Foo"); // ...
headers.setLocation(entityLinks.linkToItemResource(FooResource.class, FriendlyId.toFriendlyId(entity.getId())).toUri());
Devskiller/friendly-id
friendly-id-jackson-datatype/src/main/java/com/devskiller/friendly_id/jackson/FriendlyIdDeserializer.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // }
import java.io.IOException; import java.util.UUID; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.deser.std.UUIDDeserializer; import com.devskiller.friendly_id.FriendlyId;
package com.devskiller.friendly_id.jackson; public class FriendlyIdDeserializer extends UUIDDeserializer { @Override public UUID deserialize(JsonParser parser, DeserializationContext deserializationContext) throws IOException { JsonToken token = parser.getCurrentToken(); if (token == JsonToken.VALUE_STRING) { String string = parser.getValueAsString().trim(); if (looksLikeUuid(string)) { return super.deserialize(parser, deserializationContext); } else {
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // Path: friendly-id-jackson-datatype/src/main/java/com/devskiller/friendly_id/jackson/FriendlyIdDeserializer.java import java.io.IOException; import java.util.UUID; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.deser.std.UUIDDeserializer; import com.devskiller.friendly_id.FriendlyId; package com.devskiller.friendly_id.jackson; public class FriendlyIdDeserializer extends UUIDDeserializer { @Override public UUID deserialize(JsonParser parser, DeserializationContext deserializationContext) throws IOException { JsonToken token = parser.getCurrentToken(); if (token == JsonToken.VALUE_STRING) { String string = parser.getValueAsString().trim(); if (looksLikeUuid(string)) { return super.deserialize(parser, deserializationContext); } else {
return FriendlyId.toUuid(string);
Devskiller/friendly-id
friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/FooResourceAssembler.java
// Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Bar.java // @Data // @AllArgsConstructor // public class Bar { // // private UUID id; // private String name; // // private Foo foo; // // } // // Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // } // // Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // }
import com.devskiller.friendly_id.sample.hateos.domain.Bar; import com.devskiller.friendly_id.sample.hateos.domain.Foo; import org.springframework.hateoas.CollectionModel; import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderFactory; import java.util.Arrays; import java.util.List; import java.util.UUID; import static com.devskiller.friendly_id.FriendlyId.toFriendlyId;
package com.devskiller.friendly_id.sample.hateos; public class FooResourceAssembler extends RepresentationModelAssemblerSupport<Foo, FooResource> { public FooResourceAssembler() { super(FooController.class, FooResource.class); } @Override public FooResource toModel(Foo entity) { BarResourceAssembler barResourceAssembler = new BarResourceAssembler();
// Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Bar.java // @Data // @AllArgsConstructor // public class Bar { // // private UUID id; // private String name; // // private Foo foo; // // } // // Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // } // // Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/FooResourceAssembler.java import com.devskiller.friendly_id.sample.hateos.domain.Bar; import com.devskiller.friendly_id.sample.hateos.domain.Foo; import org.springframework.hateoas.CollectionModel; import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderFactory; import java.util.Arrays; import java.util.List; import java.util.UUID; import static com.devskiller.friendly_id.FriendlyId.toFriendlyId; package com.devskiller.friendly_id.sample.hateos; public class FooResourceAssembler extends RepresentationModelAssemblerSupport<Foo, FooResource> { public FooResourceAssembler() { super(FooController.class, FooResource.class); } @Override public FooResource toModel(Foo entity) { BarResourceAssembler barResourceAssembler = new BarResourceAssembler();
List<Bar> bars = Arrays.asList(new Bar(UUID.randomUUID(), "bar one", entity),
Devskiller/friendly-id
friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/FooResourceAssembler.java
// Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Bar.java // @Data // @AllArgsConstructor // public class Bar { // // private UUID id; // private String name; // // private Foo foo; // // } // // Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // } // // Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // }
import com.devskiller.friendly_id.sample.hateos.domain.Bar; import com.devskiller.friendly_id.sample.hateos.domain.Foo; import org.springframework.hateoas.CollectionModel; import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderFactory; import java.util.Arrays; import java.util.List; import java.util.UUID; import static com.devskiller.friendly_id.FriendlyId.toFriendlyId;
package com.devskiller.friendly_id.sample.hateos; public class FooResourceAssembler extends RepresentationModelAssemblerSupport<Foo, FooResource> { public FooResourceAssembler() { super(FooController.class, FooResource.class); } @Override public FooResource toModel(Foo entity) { BarResourceAssembler barResourceAssembler = new BarResourceAssembler(); List<Bar> bars = Arrays.asList(new Bar(UUID.randomUUID(), "bar one", entity), new Bar(UUID.randomUUID(), "bar two", entity)); CollectionModel<BarResource> barResources = barResourceAssembler.toCollectionModel(bars); WebMvcLinkBuilderFactory factory = new WebMvcLinkBuilderFactory(); FooResource resource = new FooResource(entity.getId(), entity.getName(), barResources);
// Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Bar.java // @Data // @AllArgsConstructor // public class Bar { // // private UUID id; // private String name; // // private Foo foo; // // } // // Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // } // // Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/FooResourceAssembler.java import com.devskiller.friendly_id.sample.hateos.domain.Bar; import com.devskiller.friendly_id.sample.hateos.domain.Foo; import org.springframework.hateoas.CollectionModel; import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderFactory; import java.util.Arrays; import java.util.List; import java.util.UUID; import static com.devskiller.friendly_id.FriendlyId.toFriendlyId; package com.devskiller.friendly_id.sample.hateos; public class FooResourceAssembler extends RepresentationModelAssemblerSupport<Foo, FooResource> { public FooResourceAssembler() { super(FooController.class, FooResource.class); } @Override public FooResource toModel(Foo entity) { BarResourceAssembler barResourceAssembler = new BarResourceAssembler(); List<Bar> bars = Arrays.asList(new Bar(UUID.randomUUID(), "bar one", entity), new Bar(UUID.randomUUID(), "bar two", entity)); CollectionModel<BarResource> barResources = barResourceAssembler.toCollectionModel(bars); WebMvcLinkBuilderFactory factory = new WebMvcLinkBuilderFactory(); FooResource resource = new FooResource(entity.getId(), entity.getName(), barResources);
resource.add(factory.linkTo(FooController.class).slash(toFriendlyId(entity.getId())).withSelfRel());
Devskiller/friendly-id
friendly-id-jackson-datatype/src/test/java/com/devskiller/friendly_id/spring/FieldWithoutFriendlyIdTest.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-jackson-datatype/src/test/java/com/devskiller/friendly_id/spring/ObjectMapperConfiguration.java // protected static ObjectMapper mapper(Module... modules) { // ObjectMapper mapper = new ObjectMapper(); // mapper.registerModule(new FriendlyIdModule()); // mapper.registerModules(modules); // return mapper; // }
import java.util.UUID; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; import org.junit.Test; import com.devskiller.friendly_id.FriendlyId; import static com.devskiller.friendly_id.spring.ObjectMapperConfiguration.mapper; import static org.assertj.core.api.Assertions.assertThat;
package com.devskiller.friendly_id.spring; public class FieldWithoutFriendlyIdTest { private UUID uuid = UUID.fromString("f088ce5b-9279-4cc3-946a-c15ad740dd6d");
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-jackson-datatype/src/test/java/com/devskiller/friendly_id/spring/ObjectMapperConfiguration.java // protected static ObjectMapper mapper(Module... modules) { // ObjectMapper mapper = new ObjectMapper(); // mapper.registerModule(new FriendlyIdModule()); // mapper.registerModules(modules); // return mapper; // } // Path: friendly-id-jackson-datatype/src/test/java/com/devskiller/friendly_id/spring/FieldWithoutFriendlyIdTest.java import java.util.UUID; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; import org.junit.Test; import com.devskiller.friendly_id.FriendlyId; import static com.devskiller.friendly_id.spring.ObjectMapperConfiguration.mapper; import static org.assertj.core.api.Assertions.assertThat; package com.devskiller.friendly_id.spring; public class FieldWithoutFriendlyIdTest { private UUID uuid = UUID.fromString("f088ce5b-9279-4cc3-946a-c15ad740dd6d");
private ObjectMapper mapper = mapper();
Devskiller/friendly-id
friendly-id/src/test/java/com/devskiller/friendly_id/BigIntegerPairingTest.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/BigIntegerPairing.java // static BigInteger pair(BigInteger hi, BigInteger lo) { // BigInteger unsignedLo = toUnsigned.apply(lo); // BigInteger unsignedHi = toUnsigned.apply(hi); // return unsignedLo.add(unsignedHi.multiply(HALF)); // } // // Path: friendly-id/src/main/java/com/devskiller/friendly_id/BigIntegerPairing.java // static BigInteger[] unpair(BigInteger value) { // BigInteger[] parts = value.divideAndRemainder(HALF); // BigInteger signedHi = toSigned.apply(parts[0]); // BigInteger signedLo = toSigned.apply(parts[1]); // return new BigInteger[]{signedHi, signedLo}; // }
import java.math.BigInteger; import java.util.Arrays; import io.vavr.Tuple2; import org.junit.Test; import static com.devskiller.friendly_id.BigIntegerPairing.pair; import static com.devskiller.friendly_id.BigIntegerPairing.unpair; import static io.vavr.test.Property.def; import static java.math.BigInteger.valueOf; import static org.assertj.core.api.Assertions.assertThat;
package com.devskiller.friendly_id; public class BigIntegerPairingTest { @Test public void shouldPairTwoLongs() { long x = 1; long y = 2;
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/BigIntegerPairing.java // static BigInteger pair(BigInteger hi, BigInteger lo) { // BigInteger unsignedLo = toUnsigned.apply(lo); // BigInteger unsignedHi = toUnsigned.apply(hi); // return unsignedLo.add(unsignedHi.multiply(HALF)); // } // // Path: friendly-id/src/main/java/com/devskiller/friendly_id/BigIntegerPairing.java // static BigInteger[] unpair(BigInteger value) { // BigInteger[] parts = value.divideAndRemainder(HALF); // BigInteger signedHi = toSigned.apply(parts[0]); // BigInteger signedLo = toSigned.apply(parts[1]); // return new BigInteger[]{signedHi, signedLo}; // } // Path: friendly-id/src/test/java/com/devskiller/friendly_id/BigIntegerPairingTest.java import java.math.BigInteger; import java.util.Arrays; import io.vavr.Tuple2; import org.junit.Test; import static com.devskiller.friendly_id.BigIntegerPairing.pair; import static com.devskiller.friendly_id.BigIntegerPairing.unpair; import static io.vavr.test.Property.def; import static java.math.BigInteger.valueOf; import static org.assertj.core.api.Assertions.assertThat; package com.devskiller.friendly_id; public class BigIntegerPairingTest { @Test public void shouldPairTwoLongs() { long x = 1; long y = 2;
BigInteger z = pair(valueOf(1), valueOf(2));
Devskiller/friendly-id
friendly-id/src/test/java/com/devskiller/friendly_id/BigIntegerPairingTest.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/BigIntegerPairing.java // static BigInteger pair(BigInteger hi, BigInteger lo) { // BigInteger unsignedLo = toUnsigned.apply(lo); // BigInteger unsignedHi = toUnsigned.apply(hi); // return unsignedLo.add(unsignedHi.multiply(HALF)); // } // // Path: friendly-id/src/main/java/com/devskiller/friendly_id/BigIntegerPairing.java // static BigInteger[] unpair(BigInteger value) { // BigInteger[] parts = value.divideAndRemainder(HALF); // BigInteger signedHi = toSigned.apply(parts[0]); // BigInteger signedLo = toSigned.apply(parts[1]); // return new BigInteger[]{signedHi, signedLo}; // }
import java.math.BigInteger; import java.util.Arrays; import io.vavr.Tuple2; import org.junit.Test; import static com.devskiller.friendly_id.BigIntegerPairing.pair; import static com.devskiller.friendly_id.BigIntegerPairing.unpair; import static io.vavr.test.Property.def; import static java.math.BigInteger.valueOf; import static org.assertj.core.api.Assertions.assertThat;
package com.devskiller.friendly_id; public class BigIntegerPairingTest { @Test public void shouldPairTwoLongs() { long x = 1; long y = 2; BigInteger z = pair(valueOf(1), valueOf(2));
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/BigIntegerPairing.java // static BigInteger pair(BigInteger hi, BigInteger lo) { // BigInteger unsignedLo = toUnsigned.apply(lo); // BigInteger unsignedHi = toUnsigned.apply(hi); // return unsignedLo.add(unsignedHi.multiply(HALF)); // } // // Path: friendly-id/src/main/java/com/devskiller/friendly_id/BigIntegerPairing.java // static BigInteger[] unpair(BigInteger value) { // BigInteger[] parts = value.divideAndRemainder(HALF); // BigInteger signedHi = toSigned.apply(parts[0]); // BigInteger signedLo = toSigned.apply(parts[1]); // return new BigInteger[]{signedHi, signedLo}; // } // Path: friendly-id/src/test/java/com/devskiller/friendly_id/BigIntegerPairingTest.java import java.math.BigInteger; import java.util.Arrays; import io.vavr.Tuple2; import org.junit.Test; import static com.devskiller.friendly_id.BigIntegerPairing.pair; import static com.devskiller.friendly_id.BigIntegerPairing.unpair; import static io.vavr.test.Property.def; import static java.math.BigInteger.valueOf; import static org.assertj.core.api.Assertions.assertThat; package com.devskiller.friendly_id; public class BigIntegerPairingTest { @Test public void shouldPairTwoLongs() { long x = 1; long y = 2; BigInteger z = pair(valueOf(1), valueOf(2));
assertThat(unpair(z)).contains(valueOf(x), valueOf(y));
Devskiller/friendly-id
friendly-id-spring-boot/src/main/java/com/devskiller/friendly_id/spring/FriendlyIdConfiguration.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-jackson-datatype/src/main/java/com/devskiller/friendly_id/jackson/FriendlyIdModule.java // public class FriendlyIdModule extends SimpleModule { // // private FriendlyIdAnnotationIntrospector introspector; // // public FriendlyIdModule() { // introspector = new FriendlyIdAnnotationIntrospector(); // addDeserializer(UUID.class, new FriendlyIdDeserializer()); // addSerializer(UUID.class, new FriendlyIdSerializer()); // } // // @Override // public void setupModule(SetupContext context) { // context.insertAnnotationIntrospector(introspector); // } // }
import java.util.UUID; import com.fasterxml.jackson.databind.Module; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.convert.converter.Converter; import org.springframework.format.FormatterRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.jackson.FriendlyIdModule;
package com.devskiller.friendly_id.spring; @Configuration public class FriendlyIdConfiguration implements WebMvcConfigurer { @Override public void addFormatters(FormatterRegistry registry) { registry.addConverter(new StringToUuidConverter()); registry.addConverter(new UuidToStringConverter()); } @Bean public Module friendlyIdModule() {
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-jackson-datatype/src/main/java/com/devskiller/friendly_id/jackson/FriendlyIdModule.java // public class FriendlyIdModule extends SimpleModule { // // private FriendlyIdAnnotationIntrospector introspector; // // public FriendlyIdModule() { // introspector = new FriendlyIdAnnotationIntrospector(); // addDeserializer(UUID.class, new FriendlyIdDeserializer()); // addSerializer(UUID.class, new FriendlyIdSerializer()); // } // // @Override // public void setupModule(SetupContext context) { // context.insertAnnotationIntrospector(introspector); // } // } // Path: friendly-id-spring-boot/src/main/java/com/devskiller/friendly_id/spring/FriendlyIdConfiguration.java import java.util.UUID; import com.fasterxml.jackson.databind.Module; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.convert.converter.Converter; import org.springframework.format.FormatterRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.jackson.FriendlyIdModule; package com.devskiller.friendly_id.spring; @Configuration public class FriendlyIdConfiguration implements WebMvcConfigurer { @Override public void addFormatters(FormatterRegistry registry) { registry.addConverter(new StringToUuidConverter()); registry.addConverter(new UuidToStringConverter()); } @Bean public Module friendlyIdModule() {
return new FriendlyIdModule();
Devskiller/friendly-id
friendly-id-spring-boot/src/main/java/com/devskiller/friendly_id/spring/FriendlyIdConfiguration.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-jackson-datatype/src/main/java/com/devskiller/friendly_id/jackson/FriendlyIdModule.java // public class FriendlyIdModule extends SimpleModule { // // private FriendlyIdAnnotationIntrospector introspector; // // public FriendlyIdModule() { // introspector = new FriendlyIdAnnotationIntrospector(); // addDeserializer(UUID.class, new FriendlyIdDeserializer()); // addSerializer(UUID.class, new FriendlyIdSerializer()); // } // // @Override // public void setupModule(SetupContext context) { // context.insertAnnotationIntrospector(introspector); // } // }
import java.util.UUID; import com.fasterxml.jackson.databind.Module; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.convert.converter.Converter; import org.springframework.format.FormatterRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.jackson.FriendlyIdModule;
package com.devskiller.friendly_id.spring; @Configuration public class FriendlyIdConfiguration implements WebMvcConfigurer { @Override public void addFormatters(FormatterRegistry registry) { registry.addConverter(new StringToUuidConverter()); registry.addConverter(new UuidToStringConverter()); } @Bean public Module friendlyIdModule() { return new FriendlyIdModule(); } //FIXME: make this public public static class StringToUuidConverter implements Converter<String, UUID> { @Override public UUID convert(String id) {
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-jackson-datatype/src/main/java/com/devskiller/friendly_id/jackson/FriendlyIdModule.java // public class FriendlyIdModule extends SimpleModule { // // private FriendlyIdAnnotationIntrospector introspector; // // public FriendlyIdModule() { // introspector = new FriendlyIdAnnotationIntrospector(); // addDeserializer(UUID.class, new FriendlyIdDeserializer()); // addSerializer(UUID.class, new FriendlyIdSerializer()); // } // // @Override // public void setupModule(SetupContext context) { // context.insertAnnotationIntrospector(introspector); // } // } // Path: friendly-id-spring-boot/src/main/java/com/devskiller/friendly_id/spring/FriendlyIdConfiguration.java import java.util.UUID; import com.fasterxml.jackson.databind.Module; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.convert.converter.Converter; import org.springframework.format.FormatterRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.jackson.FriendlyIdModule; package com.devskiller.friendly_id.spring; @Configuration public class FriendlyIdConfiguration implements WebMvcConfigurer { @Override public void addFormatters(FormatterRegistry registry) { registry.addConverter(new StringToUuidConverter()); registry.addConverter(new UuidToStringConverter()); } @Bean public Module friendlyIdModule() { return new FriendlyIdModule(); } //FIXME: make this public public static class StringToUuidConverter implements Converter<String, UUID> { @Override public UUID convert(String id) {
return FriendlyId.toUuid(id);
Devskiller/friendly-id
friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/BarResourceAssembler.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/domain/Bar.java // @Data // @AllArgsConstructor // public class Bar { // // private UUID id; // private String name; // // private Foo foo; // // } // // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // }
import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.sample.contracts.domain.Bar; import com.devskiller.friendly_id.sample.contracts.domain.Foo; import org.springframework.hateoas.server.LinkRelationProvider; import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderFactory;
package com.devskiller.friendly_id.sample.contracts; public class BarResourceAssembler extends RepresentationModelAssemblerSupport<Bar, BarResource> { LinkRelationProvider relProvider; public BarResourceAssembler() { super(BarController.class, BarResource.class); } public BarResourceAssembler(LinkRelationProvider relProvider) { super(BarController.class, BarResource.class); this.relProvider = relProvider; } @Override public BarResource toModel(Bar entity) { BarResource resource = new BarResource(entity.getName()); WebMvcLinkBuilderFactory factory = new WebMvcLinkBuilderFactory();
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/domain/Bar.java // @Data // @AllArgsConstructor // public class Bar { // // private UUID id; // private String name; // // private Foo foo; // // } // // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // } // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/BarResourceAssembler.java import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.sample.contracts.domain.Bar; import com.devskiller.friendly_id.sample.contracts.domain.Foo; import org.springframework.hateoas.server.LinkRelationProvider; import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderFactory; package com.devskiller.friendly_id.sample.contracts; public class BarResourceAssembler extends RepresentationModelAssemblerSupport<Bar, BarResource> { LinkRelationProvider relProvider; public BarResourceAssembler() { super(BarController.class, BarResource.class); } public BarResourceAssembler(LinkRelationProvider relProvider) { super(BarController.class, BarResource.class); this.relProvider = relProvider; } @Override public BarResource toModel(Bar entity) { BarResource resource = new BarResource(entity.getName()); WebMvcLinkBuilderFactory factory = new WebMvcLinkBuilderFactory();
resource.add(factory.linkTo(FooController.class, FriendlyId.toFriendlyId(entity.getFoo().getId()))
Devskiller/friendly-id
friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/BarResourceAssembler.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/domain/Bar.java // @Data // @AllArgsConstructor // public class Bar { // // private UUID id; // private String name; // // private Foo foo; // // } // // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // }
import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.sample.contracts.domain.Bar; import com.devskiller.friendly_id.sample.contracts.domain.Foo; import org.springframework.hateoas.server.LinkRelationProvider; import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderFactory;
package com.devskiller.friendly_id.sample.contracts; public class BarResourceAssembler extends RepresentationModelAssemblerSupport<Bar, BarResource> { LinkRelationProvider relProvider; public BarResourceAssembler() { super(BarController.class, BarResource.class); } public BarResourceAssembler(LinkRelationProvider relProvider) { super(BarController.class, BarResource.class); this.relProvider = relProvider; } @Override public BarResource toModel(Bar entity) { BarResource resource = new BarResource(entity.getName()); WebMvcLinkBuilderFactory factory = new WebMvcLinkBuilderFactory(); resource.add(factory.linkTo(FooController.class, FriendlyId.toFriendlyId(entity.getFoo().getId()))
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/domain/Bar.java // @Data // @AllArgsConstructor // public class Bar { // // private UUID id; // private String name; // // private Foo foo; // // } // // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // } // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/BarResourceAssembler.java import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.sample.contracts.domain.Bar; import com.devskiller.friendly_id.sample.contracts.domain.Foo; import org.springframework.hateoas.server.LinkRelationProvider; import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderFactory; package com.devskiller.friendly_id.sample.contracts; public class BarResourceAssembler extends RepresentationModelAssemblerSupport<Bar, BarResource> { LinkRelationProvider relProvider; public BarResourceAssembler() { super(BarController.class, BarResource.class); } public BarResourceAssembler(LinkRelationProvider relProvider) { super(BarController.class, BarResource.class); this.relProvider = relProvider; } @Override public BarResource toModel(Bar entity) { BarResource resource = new BarResource(entity.getName()); WebMvcLinkBuilderFactory factory = new WebMvcLinkBuilderFactory(); resource.add(factory.linkTo(FooController.class, FriendlyId.toFriendlyId(entity.getFoo().getId()))
.withRel(relProvider.getCollectionResourceRelFor(Foo.class)));
Devskiller/friendly-id
friendly-id-jackson-datatype/src/main/java/com/devskiller/friendly_id/jackson/FriendlyIdSerializer.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // }
import java.io.IOException; import java.util.UUID; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; import com.devskiller.friendly_id.FriendlyId;
package com.devskiller.friendly_id.jackson; public class FriendlyIdSerializer extends StdSerializer<UUID> { public FriendlyIdSerializer() { super(UUID.class); } @Override public void serialize(UUID uuid, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // Path: friendly-id-jackson-datatype/src/main/java/com/devskiller/friendly_id/jackson/FriendlyIdSerializer.java import java.io.IOException; import java.util.UUID; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; import com.devskiller.friendly_id.FriendlyId; package com.devskiller.friendly_id.jackson; public class FriendlyIdSerializer extends StdSerializer<UUID> { public FriendlyIdSerializer() { super(UUID.class); } @Override public void serialize(UUID uuid, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeString(FriendlyId.toFriendlyId(uuid));
Devskiller/friendly-id
friendly-id-jackson-datatype/src/test/java/com/devskiller/friendly_id/spring/FriendlyIdDeserializerTest.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-jackson-datatype/src/test/java/com/devskiller/friendly_id/spring/ObjectMapperConfiguration.java // protected static ObjectMapper mapper(Module... modules) { // ObjectMapper mapper = new ObjectMapper(); // mapper.registerModule(new FriendlyIdModule()); // mapper.registerModules(modules); // return mapper; // }
import java.util.UUID; import org.junit.Test; import com.devskiller.friendly_id.FriendlyId; import static com.devskiller.friendly_id.spring.ObjectMapperConfiguration.mapper; import static org.assertj.core.api.Assertions.assertThat;
package com.devskiller.friendly_id.spring; public class FriendlyIdDeserializerTest { @Test public void shouldSerializeFriendlyId() throws Exception { UUID uuid = UUID.randomUUID();
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-jackson-datatype/src/test/java/com/devskiller/friendly_id/spring/ObjectMapperConfiguration.java // protected static ObjectMapper mapper(Module... modules) { // ObjectMapper mapper = new ObjectMapper(); // mapper.registerModule(new FriendlyIdModule()); // mapper.registerModules(modules); // return mapper; // } // Path: friendly-id-jackson-datatype/src/test/java/com/devskiller/friendly_id/spring/FriendlyIdDeserializerTest.java import java.util.UUID; import org.junit.Test; import com.devskiller.friendly_id.FriendlyId; import static com.devskiller.friendly_id.spring.ObjectMapperConfiguration.mapper; import static org.assertj.core.api.Assertions.assertThat; package com.devskiller.friendly_id.spring; public class FriendlyIdDeserializerTest { @Test public void shouldSerializeFriendlyId() throws Exception { UUID uuid = UUID.randomUUID();
String json = mapper().writeValueAsString(uuid);
Devskiller/friendly-id
friendly-id-jackson-datatype/src/test/java/com/devskiller/friendly_id/spring/FriendlyIdDeserializerTest.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-jackson-datatype/src/test/java/com/devskiller/friendly_id/spring/ObjectMapperConfiguration.java // protected static ObjectMapper mapper(Module... modules) { // ObjectMapper mapper = new ObjectMapper(); // mapper.registerModule(new FriendlyIdModule()); // mapper.registerModules(modules); // return mapper; // }
import java.util.UUID; import org.junit.Test; import com.devskiller.friendly_id.FriendlyId; import static com.devskiller.friendly_id.spring.ObjectMapperConfiguration.mapper; import static org.assertj.core.api.Assertions.assertThat;
package com.devskiller.friendly_id.spring; public class FriendlyIdDeserializerTest { @Test public void shouldSerializeFriendlyId() throws Exception { UUID uuid = UUID.randomUUID(); String json = mapper().writeValueAsString(uuid); System.out.println(json);
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-jackson-datatype/src/test/java/com/devskiller/friendly_id/spring/ObjectMapperConfiguration.java // protected static ObjectMapper mapper(Module... modules) { // ObjectMapper mapper = new ObjectMapper(); // mapper.registerModule(new FriendlyIdModule()); // mapper.registerModules(modules); // return mapper; // } // Path: friendly-id-jackson-datatype/src/test/java/com/devskiller/friendly_id/spring/FriendlyIdDeserializerTest.java import java.util.UUID; import org.junit.Test; import com.devskiller.friendly_id.FriendlyId; import static com.devskiller.friendly_id.spring.ObjectMapperConfiguration.mapper; import static org.assertj.core.api.Assertions.assertThat; package com.devskiller.friendly_id.spring; public class FriendlyIdDeserializerTest { @Test public void shouldSerializeFriendlyId() throws Exception { UUID uuid = UUID.randomUUID(); String json = mapper().writeValueAsString(uuid); System.out.println(json);
assertThat(json).contains(FriendlyId.toFriendlyId(uuid));
Devskiller/friendly-id
friendly-id/src/test/java/com/devskiller/friendly_id/FriendlyIdTest.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // Path: friendly-id/src/test/java/com/devskiller/friendly_id/IdUtil.java // static boolean areEqualIgnoringLeadingZeros(String code1, String code2) { // return areEqual(removeLeadingZeros(code1), removeLeadingZeros(code2)); // }
import io.vavr.test.Arbitrary; import org.junit.Test; import static com.devskiller.friendly_id.FriendlyId.toFriendlyId; import static com.devskiller.friendly_id.FriendlyId.toUuid; import static com.devskiller.friendly_id.IdUtil.areEqualIgnoringLeadingZeros; import static io.vavr.test.Property.def; import static org.assertj.core.util.Objects.areEqual;
package com.devskiller.friendly_id; public class FriendlyIdTest { @Test public void shouldCreateValidIdsThatConformToUuidType4() { def("areEqual(FriendlyId.toUuid(FriendlyId.toFriendlyId(uuid))), uuid)") .forAll(Arbitrary.integer())
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // Path: friendly-id/src/test/java/com/devskiller/friendly_id/IdUtil.java // static boolean areEqualIgnoringLeadingZeros(String code1, String code2) { // return areEqual(removeLeadingZeros(code1), removeLeadingZeros(code2)); // } // Path: friendly-id/src/test/java/com/devskiller/friendly_id/FriendlyIdTest.java import io.vavr.test.Arbitrary; import org.junit.Test; import static com.devskiller.friendly_id.FriendlyId.toFriendlyId; import static com.devskiller.friendly_id.FriendlyId.toUuid; import static com.devskiller.friendly_id.IdUtil.areEqualIgnoringLeadingZeros; import static io.vavr.test.Property.def; import static org.assertj.core.util.Objects.areEqual; package com.devskiller.friendly_id; public class FriendlyIdTest { @Test public void shouldCreateValidIdsThatConformToUuidType4() { def("areEqual(FriendlyId.toUuid(FriendlyId.toFriendlyId(uuid))), uuid)") .forAll(Arbitrary.integer())
.suchThat(ignored -> toUuid(FriendlyId.createFriendlyId()).version() == 4)
Devskiller/friendly-id
friendly-id/src/test/java/com/devskiller/friendly_id/FriendlyIdTest.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // Path: friendly-id/src/test/java/com/devskiller/friendly_id/IdUtil.java // static boolean areEqualIgnoringLeadingZeros(String code1, String code2) { // return areEqual(removeLeadingZeros(code1), removeLeadingZeros(code2)); // }
import io.vavr.test.Arbitrary; import org.junit.Test; import static com.devskiller.friendly_id.FriendlyId.toFriendlyId; import static com.devskiller.friendly_id.FriendlyId.toUuid; import static com.devskiller.friendly_id.IdUtil.areEqualIgnoringLeadingZeros; import static io.vavr.test.Property.def; import static org.assertj.core.util.Objects.areEqual;
package com.devskiller.friendly_id; public class FriendlyIdTest { @Test public void shouldCreateValidIdsThatConformToUuidType4() { def("areEqual(FriendlyId.toUuid(FriendlyId.toFriendlyId(uuid))), uuid)") .forAll(Arbitrary.integer()) .suchThat(ignored -> toUuid(FriendlyId.createFriendlyId()).version() == 4) .check(-1, 100_000) .assertIsSatisfied(); } @Test public void encodingUuidShouldBeReversible() { def("areEqual(FriendlyId.toUuid(FriendlyId.toFriendlyId(uuid))), uuid)") .forAll(DataProvider.UUIDS)
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // Path: friendly-id/src/test/java/com/devskiller/friendly_id/IdUtil.java // static boolean areEqualIgnoringLeadingZeros(String code1, String code2) { // return areEqual(removeLeadingZeros(code1), removeLeadingZeros(code2)); // } // Path: friendly-id/src/test/java/com/devskiller/friendly_id/FriendlyIdTest.java import io.vavr.test.Arbitrary; import org.junit.Test; import static com.devskiller.friendly_id.FriendlyId.toFriendlyId; import static com.devskiller.friendly_id.FriendlyId.toUuid; import static com.devskiller.friendly_id.IdUtil.areEqualIgnoringLeadingZeros; import static io.vavr.test.Property.def; import static org.assertj.core.util.Objects.areEqual; package com.devskiller.friendly_id; public class FriendlyIdTest { @Test public void shouldCreateValidIdsThatConformToUuidType4() { def("areEqual(FriendlyId.toUuid(FriendlyId.toFriendlyId(uuid))), uuid)") .forAll(Arbitrary.integer()) .suchThat(ignored -> toUuid(FriendlyId.createFriendlyId()).version() == 4) .check(-1, 100_000) .assertIsSatisfied(); } @Test public void encodingUuidShouldBeReversible() { def("areEqual(FriendlyId.toUuid(FriendlyId.toFriendlyId(uuid))), uuid)") .forAll(DataProvider.UUIDS)
.suchThat(uuid -> areEqual(toUuid(toFriendlyId(uuid)), uuid))
Devskiller/friendly-id
friendly-id/src/test/java/com/devskiller/friendly_id/FriendlyIdTest.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // Path: friendly-id/src/test/java/com/devskiller/friendly_id/IdUtil.java // static boolean areEqualIgnoringLeadingZeros(String code1, String code2) { // return areEqual(removeLeadingZeros(code1), removeLeadingZeros(code2)); // }
import io.vavr.test.Arbitrary; import org.junit.Test; import static com.devskiller.friendly_id.FriendlyId.toFriendlyId; import static com.devskiller.friendly_id.FriendlyId.toUuid; import static com.devskiller.friendly_id.IdUtil.areEqualIgnoringLeadingZeros; import static io.vavr.test.Property.def; import static org.assertj.core.util.Objects.areEqual;
package com.devskiller.friendly_id; public class FriendlyIdTest { @Test public void shouldCreateValidIdsThatConformToUuidType4() { def("areEqual(FriendlyId.toUuid(FriendlyId.toFriendlyId(uuid))), uuid)") .forAll(Arbitrary.integer()) .suchThat(ignored -> toUuid(FriendlyId.createFriendlyId()).version() == 4) .check(-1, 100_000) .assertIsSatisfied(); } @Test public void encodingUuidShouldBeReversible() { def("areEqual(FriendlyId.toUuid(FriendlyId.toFriendlyId(uuid))), uuid)") .forAll(DataProvider.UUIDS) .suchThat(uuid -> areEqual(toUuid(toFriendlyId(uuid)), uuid)) .check(-1, 100_000) .assertIsSatisfied(); } @Test public void decodingIdShouldBeReversible() { def("areEqualIgnoringLeadingZeros(Url62.toFriendlyId(Url62.toUuid(id)), id)") .forAll(DataProvider.FRIENDLY_IDS)
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // Path: friendly-id/src/test/java/com/devskiller/friendly_id/IdUtil.java // static boolean areEqualIgnoringLeadingZeros(String code1, String code2) { // return areEqual(removeLeadingZeros(code1), removeLeadingZeros(code2)); // } // Path: friendly-id/src/test/java/com/devskiller/friendly_id/FriendlyIdTest.java import io.vavr.test.Arbitrary; import org.junit.Test; import static com.devskiller.friendly_id.FriendlyId.toFriendlyId; import static com.devskiller.friendly_id.FriendlyId.toUuid; import static com.devskiller.friendly_id.IdUtil.areEqualIgnoringLeadingZeros; import static io.vavr.test.Property.def; import static org.assertj.core.util.Objects.areEqual; package com.devskiller.friendly_id; public class FriendlyIdTest { @Test public void shouldCreateValidIdsThatConformToUuidType4() { def("areEqual(FriendlyId.toUuid(FriendlyId.toFriendlyId(uuid))), uuid)") .forAll(Arbitrary.integer()) .suchThat(ignored -> toUuid(FriendlyId.createFriendlyId()).version() == 4) .check(-1, 100_000) .assertIsSatisfied(); } @Test public void encodingUuidShouldBeReversible() { def("areEqual(FriendlyId.toUuid(FriendlyId.toFriendlyId(uuid))), uuid)") .forAll(DataProvider.UUIDS) .suchThat(uuid -> areEqual(toUuid(toFriendlyId(uuid)), uuid)) .check(-1, 100_000) .assertIsSatisfied(); } @Test public void decodingIdShouldBeReversible() { def("areEqualIgnoringLeadingZeros(Url62.toFriendlyId(Url62.toUuid(id)), id)") .forAll(DataProvider.FRIENDLY_IDS)
.suchThat(id -> areEqualIgnoringLeadingZeros(toFriendlyId(toUuid(id)), id))
Devskiller/friendly-id
friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/FooResourceAssembler.java
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // }
import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.sample.contracts.domain.Foo; import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderFactory;
package com.devskiller.friendly_id.sample.contracts; public class FooResourceAssembler extends RepresentationModelAssemblerSupport<Foo, FooResource> { public FooResourceAssembler() { super(FooController.class, FooResource.class); } @Override public FooResource toModel(Foo entity) { WebMvcLinkBuilderFactory factory = new WebMvcLinkBuilderFactory(); FooResource resource = new FooResource(entity.getId(), entity.getName());
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java // public class FriendlyId { // // /** // * Create FriendlyId id // * // * @return Friendly Id encoded UUID // */ // public static String createFriendlyId() { // return Url62.encode(UUID.randomUUID()); // } // // /** // * Encode UUID to FriendlyId id // * // * @param uuid UUID to be encoded // * @return Friendly Id encoded UUID // */ // public static String toFriendlyId(UUID uuid) { // return Url62.encode(uuid); // } // // /** // * Decode Friendly Id to UUID // * // * @param friendlyId encoded UUID // * @return decoded UUID // */ // public static UUID toUuid(String friendlyId) { // return Url62.decode(friendlyId); // } // // } // // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // } // Path: friendly-id-samples/friendly-id-contracts/src/main/java/com/devskiller/friendly_id/sample/contracts/FooResourceAssembler.java import com.devskiller.friendly_id.FriendlyId; import com.devskiller.friendly_id.sample.contracts.domain.Foo; import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderFactory; package com.devskiller.friendly_id.sample.contracts; public class FooResourceAssembler extends RepresentationModelAssemblerSupport<Foo, FooResource> { public FooResourceAssembler() { super(FooController.class, FooResource.class); } @Override public FooResource toModel(Foo entity) { WebMvcLinkBuilderFactory factory = new WebMvcLinkBuilderFactory(); FooResource resource = new FooResource(entity.getId(), entity.getName());
resource.add(factory.linkTo(FooController.class).slash(FriendlyId.toFriendlyId(entity.getId())).withSelfRel());
Devskiller/friendly-id
friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/BarController.java
// Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Bar.java // @Data // @AllArgsConstructor // public class Bar { // // private UUID id; // private String name; // // private Foo foo; // // } // // Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // }
import com.devskiller.friendly_id.sample.hateos.domain.Bar; import com.devskiller.friendly_id.sample.hateos.domain.Foo; import org.springframework.hateoas.server.ExposesResourceFor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.UUID;
package com.devskiller.friendly_id.sample.hateos; @RestController @ExposesResourceFor(BarResource.class) @RequestMapping("/foos/{fooId}/bars") public class BarController { private final BarResourceAssembler assembler; public BarController(BarResourceAssembler assembler) { this.assembler = assembler; } @GetMapping("/{id}") public BarResource getBar(@PathVariable UUID fooId, @PathVariable UUID id) {
// Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Bar.java // @Data // @AllArgsConstructor // public class Bar { // // private UUID id; // private String name; // // private Foo foo; // // } // // Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // } // Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/BarController.java import com.devskiller.friendly_id.sample.hateos.domain.Bar; import com.devskiller.friendly_id.sample.hateos.domain.Foo; import org.springframework.hateoas.server.ExposesResourceFor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.UUID; package com.devskiller.friendly_id.sample.hateos; @RestController @ExposesResourceFor(BarResource.class) @RequestMapping("/foos/{fooId}/bars") public class BarController { private final BarResourceAssembler assembler; public BarController(BarResourceAssembler assembler) { this.assembler = assembler; } @GetMapping("/{id}") public BarResource getBar(@PathVariable UUID fooId, @PathVariable UUID id) {
return assembler.toModel(new Bar(id, "Bar", new Foo(fooId, "Root Foo")));
Devskiller/friendly-id
friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/BarController.java
// Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Bar.java // @Data // @AllArgsConstructor // public class Bar { // // private UUID id; // private String name; // // private Foo foo; // // } // // Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // }
import com.devskiller.friendly_id.sample.hateos.domain.Bar; import com.devskiller.friendly_id.sample.hateos.domain.Foo; import org.springframework.hateoas.server.ExposesResourceFor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.UUID;
package com.devskiller.friendly_id.sample.hateos; @RestController @ExposesResourceFor(BarResource.class) @RequestMapping("/foos/{fooId}/bars") public class BarController { private final BarResourceAssembler assembler; public BarController(BarResourceAssembler assembler) { this.assembler = assembler; } @GetMapping("/{id}") public BarResource getBar(@PathVariable UUID fooId, @PathVariable UUID id) {
// Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Bar.java // @Data // @AllArgsConstructor // public class Bar { // // private UUID id; // private String name; // // private Foo foo; // // } // // Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Foo.java // @Data // @AllArgsConstructor // public class Foo { // // private UUID id; // private String name; // // } // Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/BarController.java import com.devskiller.friendly_id.sample.hateos.domain.Bar; import com.devskiller.friendly_id.sample.hateos.domain.Foo; import org.springframework.hateoas.server.ExposesResourceFor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.UUID; package com.devskiller.friendly_id.sample.hateos; @RestController @ExposesResourceFor(BarResource.class) @RequestMapping("/foos/{fooId}/bars") public class BarController { private final BarResourceAssembler assembler; public BarController(BarResourceAssembler assembler) { this.assembler = assembler; } @GetMapping("/{id}") public BarResource getBar(@PathVariable UUID fooId, @PathVariable UUID id) {
return assembler.toModel(new Bar(id, "Bar", new Foo(fooId, "Root Foo")));
novucs/factions-top
hook/vault/src/main/java/net/novucs/ftop/hook/VaultEconomyHook.java
// Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionEconomyEvent.java // public class FactionEconomyEvent extends EconomyEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String factionId; // // public FactionEconomyEvent(String factionId, double oldBalance, double newBalance) { // super(oldBalance, newBalance); // this.factionId = factionId; // } // // public String getFactionId() { // return factionId; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/PlayerEconomyEvent.java // public class PlayerEconomyEvent extends EconomyEvent { // // private static final HandlerList handlers = new HandlerList(); // private final Player player; // // public PlayerEconomyEvent(Player player, double oldBalance, double newBalance) { // super(oldBalance, newBalance); // this.player = player; // } // // public Player getPlayer() { // return player; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // }
import net.milkbowl.vault.economy.Economy; import net.novucs.ftop.hook.event.FactionEconomyEvent; import net.novucs.ftop.hook.event.PlayerEconomyEvent; import org.bukkit.entity.Player; import org.bukkit.event.*; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.scheduler.BukkitRunnable; import java.util.*;
tickPlayers(); } // Tick factions if enabled. if (factionEnabled) { tickFactions(); } } private void tickPlayers() { Double oldBalance; Double newBalance; UUID playerId; // Iterate through every player on the server. for (Player player : plugin.getServer().getOnlinePlayers()) { // Get their previous and current balances. playerId = player.getUniqueId(); oldBalance = playerBalances.get(playerId); newBalance = economy.getBalance(player); // Add new balance if player is not already added to the cache. if (oldBalance == null) { playerBalances.put(playerId, newBalance); continue; } // Call PlayerEconomyEvent if their balance has changed. if (oldBalance.doubleValue() != newBalance.doubleValue()) { playerBalances.put(playerId, newBalance);
// Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionEconomyEvent.java // public class FactionEconomyEvent extends EconomyEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String factionId; // // public FactionEconomyEvent(String factionId, double oldBalance, double newBalance) { // super(oldBalance, newBalance); // this.factionId = factionId; // } // // public String getFactionId() { // return factionId; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/PlayerEconomyEvent.java // public class PlayerEconomyEvent extends EconomyEvent { // // private static final HandlerList handlers = new HandlerList(); // private final Player player; // // public PlayerEconomyEvent(Player player, double oldBalance, double newBalance) { // super(oldBalance, newBalance); // this.player = player; // } // // public Player getPlayer() { // return player; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // Path: hook/vault/src/main/java/net/novucs/ftop/hook/VaultEconomyHook.java import net.milkbowl.vault.economy.Economy; import net.novucs.ftop.hook.event.FactionEconomyEvent; import net.novucs.ftop.hook.event.PlayerEconomyEvent; import org.bukkit.entity.Player; import org.bukkit.event.*; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.scheduler.BukkitRunnable; import java.util.*; tickPlayers(); } // Tick factions if enabled. if (factionEnabled) { tickFactions(); } } private void tickPlayers() { Double oldBalance; Double newBalance; UUID playerId; // Iterate through every player on the server. for (Player player : plugin.getServer().getOnlinePlayers()) { // Get their previous and current balances. playerId = player.getUniqueId(); oldBalance = playerBalances.get(playerId); newBalance = economy.getBalance(player); // Add new balance if player is not already added to the cache. if (oldBalance == null) { playerBalances.put(playerId, newBalance); continue; } // Call PlayerEconomyEvent if their balance has changed. if (oldBalance.doubleValue() != newBalance.doubleValue()) { playerBalances.put(playerId, newBalance);
callEvent(new PlayerEconomyEvent(player, oldBalance, newBalance));
novucs/factions-top
hook/vault/src/main/java/net/novucs/ftop/hook/VaultEconomyHook.java
// Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionEconomyEvent.java // public class FactionEconomyEvent extends EconomyEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String factionId; // // public FactionEconomyEvent(String factionId, double oldBalance, double newBalance) { // super(oldBalance, newBalance); // this.factionId = factionId; // } // // public String getFactionId() { // return factionId; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/PlayerEconomyEvent.java // public class PlayerEconomyEvent extends EconomyEvent { // // private static final HandlerList handlers = new HandlerList(); // private final Player player; // // public PlayerEconomyEvent(Player player, double oldBalance, double newBalance) { // super(oldBalance, newBalance); // this.player = player; // } // // public Player getPlayer() { // return player; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // }
import net.milkbowl.vault.economy.Economy; import net.novucs.ftop.hook.event.FactionEconomyEvent; import net.novucs.ftop.hook.event.PlayerEconomyEvent; import org.bukkit.entity.Player; import org.bukkit.event.*; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.scheduler.BukkitRunnable; import java.util.*;
continue; } // Call PlayerEconomyEvent if their balance has changed. if (oldBalance.doubleValue() != newBalance.doubleValue()) { playerBalances.put(playerId, newBalance); callEvent(new PlayerEconomyEvent(player, oldBalance, newBalance)); } } } private void tickFactions() { Double oldBalance; Double newBalance; // Iterate through every faction on the server. for (String factionId : factionIds) { // Get their previous and current balances. oldBalance = factionBalances.getOrDefault(factionId, 0d); newBalance = economy.getBalance("faction-" + factionId); // Add new balance if faction is not already added to the cache. if (oldBalance == null) { factionBalances.put(factionId, newBalance); continue; } // Call FactionEconomyEvent if their balance has changed. if (oldBalance.doubleValue() != newBalance.doubleValue()) { factionBalances.put(factionId, newBalance);
// Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionEconomyEvent.java // public class FactionEconomyEvent extends EconomyEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String factionId; // // public FactionEconomyEvent(String factionId, double oldBalance, double newBalance) { // super(oldBalance, newBalance); // this.factionId = factionId; // } // // public String getFactionId() { // return factionId; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/PlayerEconomyEvent.java // public class PlayerEconomyEvent extends EconomyEvent { // // private static final HandlerList handlers = new HandlerList(); // private final Player player; // // public PlayerEconomyEvent(Player player, double oldBalance, double newBalance) { // super(oldBalance, newBalance); // this.player = player; // } // // public Player getPlayer() { // return player; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // Path: hook/vault/src/main/java/net/novucs/ftop/hook/VaultEconomyHook.java import net.milkbowl.vault.economy.Economy; import net.novucs.ftop.hook.event.FactionEconomyEvent; import net.novucs.ftop.hook.event.PlayerEconomyEvent; import org.bukkit.entity.Player; import org.bukkit.event.*; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.scheduler.BukkitRunnable; import java.util.*; continue; } // Call PlayerEconomyEvent if their balance has changed. if (oldBalance.doubleValue() != newBalance.doubleValue()) { playerBalances.put(playerId, newBalance); callEvent(new PlayerEconomyEvent(player, oldBalance, newBalance)); } } } private void tickFactions() { Double oldBalance; Double newBalance; // Iterate through every faction on the server. for (String factionId : factionIds) { // Get their previous and current balances. oldBalance = factionBalances.getOrDefault(factionId, 0d); newBalance = economy.getBalance("faction-" + factionId); // Add new balance if faction is not already added to the cache. if (oldBalance == null) { factionBalances.put(factionId, newBalance); continue; } // Call FactionEconomyEvent if their balance has changed. if (oldBalance.doubleValue() != newBalance.doubleValue()) { factionBalances.put(factionId, newBalance);
callEvent(new FactionEconomyEvent(factionId, oldBalance, newBalance));
novucs/factions-top
hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/MVdWPlaceholderAPIHook.java
// Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/LastReplacer.java // public class LastReplacer implements PlaceholderReplacer { // // private final Supplier<String> lastReplacer; // // public LastReplacer(Supplier<String> lastReplacer) { // this.lastReplacer = lastReplacer; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return lastReplacer.get(); // } // } // // Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/PlayerReplacer.java // public class PlayerReplacer implements PlaceholderReplacer { // // private final Function<Player, String> playerReplacer; // // public PlayerReplacer(Function<Player, String> playerReplacer) { // this.playerReplacer = playerReplacer; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return playerReplacer.apply(event.getPlayer()); // } // } // // Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/RankReplacer.java // public class RankReplacer implements PlaceholderReplacer { // // private final Function<Integer, String> rankReplacer; // private final int rank; // // public RankReplacer(Function<Integer, String> rankReplacer, int rank) { // this.rankReplacer = rankReplacer; // this.rank = rank; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return rankReplacer.apply(rank); // } // }
import be.maximvdw.placeholderapi.PlaceholderAPI; import net.novucs.ftop.hook.replacer.LastReplacer; import net.novucs.ftop.hook.replacer.PlayerReplacer; import net.novucs.ftop.hook.replacer.RankReplacer; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import java.util.List; import java.util.function.Function; import java.util.function.Supplier;
package net.novucs.ftop.hook; public class MVdWPlaceholderAPIHook implements PlaceholderHook { private final Plugin plugin; private final Function<Player, String> playerReplacer; private final Function<Integer, String> rankReplacer; private final Supplier<String> lastReplacer; public MVdWPlaceholderAPIHook(Plugin plugin, Function<Player, String> playerReplacer, Function<Integer, String> rankReplacer, Supplier<String> lastReplacer) { this.plugin = plugin; this.playerReplacer = playerReplacer; this.rankReplacer = rankReplacer; this.lastReplacer = lastReplacer; } @Override public boolean initialize(List<Integer> enabledRanks) {
// Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/LastReplacer.java // public class LastReplacer implements PlaceholderReplacer { // // private final Supplier<String> lastReplacer; // // public LastReplacer(Supplier<String> lastReplacer) { // this.lastReplacer = lastReplacer; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return lastReplacer.get(); // } // } // // Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/PlayerReplacer.java // public class PlayerReplacer implements PlaceholderReplacer { // // private final Function<Player, String> playerReplacer; // // public PlayerReplacer(Function<Player, String> playerReplacer) { // this.playerReplacer = playerReplacer; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return playerReplacer.apply(event.getPlayer()); // } // } // // Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/RankReplacer.java // public class RankReplacer implements PlaceholderReplacer { // // private final Function<Integer, String> rankReplacer; // private final int rank; // // public RankReplacer(Function<Integer, String> rankReplacer, int rank) { // this.rankReplacer = rankReplacer; // this.rank = rank; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return rankReplacer.apply(rank); // } // } // Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/MVdWPlaceholderAPIHook.java import be.maximvdw.placeholderapi.PlaceholderAPI; import net.novucs.ftop.hook.replacer.LastReplacer; import net.novucs.ftop.hook.replacer.PlayerReplacer; import net.novucs.ftop.hook.replacer.RankReplacer; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import java.util.List; import java.util.function.Function; import java.util.function.Supplier; package net.novucs.ftop.hook; public class MVdWPlaceholderAPIHook implements PlaceholderHook { private final Plugin plugin; private final Function<Player, String> playerReplacer; private final Function<Integer, String> rankReplacer; private final Supplier<String> lastReplacer; public MVdWPlaceholderAPIHook(Plugin plugin, Function<Player, String> playerReplacer, Function<Integer, String> rankReplacer, Supplier<String> lastReplacer) { this.plugin = plugin; this.playerReplacer = playerReplacer; this.rankReplacer = rankReplacer; this.lastReplacer = lastReplacer; } @Override public boolean initialize(List<Integer> enabledRanks) {
LastReplacer lastReplacer = new LastReplacer(this.lastReplacer);
novucs/factions-top
hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/MVdWPlaceholderAPIHook.java
// Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/LastReplacer.java // public class LastReplacer implements PlaceholderReplacer { // // private final Supplier<String> lastReplacer; // // public LastReplacer(Supplier<String> lastReplacer) { // this.lastReplacer = lastReplacer; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return lastReplacer.get(); // } // } // // Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/PlayerReplacer.java // public class PlayerReplacer implements PlaceholderReplacer { // // private final Function<Player, String> playerReplacer; // // public PlayerReplacer(Function<Player, String> playerReplacer) { // this.playerReplacer = playerReplacer; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return playerReplacer.apply(event.getPlayer()); // } // } // // Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/RankReplacer.java // public class RankReplacer implements PlaceholderReplacer { // // private final Function<Integer, String> rankReplacer; // private final int rank; // // public RankReplacer(Function<Integer, String> rankReplacer, int rank) { // this.rankReplacer = rankReplacer; // this.rank = rank; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return rankReplacer.apply(rank); // } // }
import be.maximvdw.placeholderapi.PlaceholderAPI; import net.novucs.ftop.hook.replacer.LastReplacer; import net.novucs.ftop.hook.replacer.PlayerReplacer; import net.novucs.ftop.hook.replacer.RankReplacer; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import java.util.List; import java.util.function.Function; import java.util.function.Supplier;
package net.novucs.ftop.hook; public class MVdWPlaceholderAPIHook implements PlaceholderHook { private final Plugin plugin; private final Function<Player, String> playerReplacer; private final Function<Integer, String> rankReplacer; private final Supplier<String> lastReplacer; public MVdWPlaceholderAPIHook(Plugin plugin, Function<Player, String> playerReplacer, Function<Integer, String> rankReplacer, Supplier<String> lastReplacer) { this.plugin = plugin; this.playerReplacer = playerReplacer; this.rankReplacer = rankReplacer; this.lastReplacer = lastReplacer; } @Override public boolean initialize(List<Integer> enabledRanks) { LastReplacer lastReplacer = new LastReplacer(this.lastReplacer); boolean updated = PlaceholderAPI.registerPlaceholder(plugin, "factionstop_name:last", lastReplacer); for (int rank : enabledRanks) {
// Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/LastReplacer.java // public class LastReplacer implements PlaceholderReplacer { // // private final Supplier<String> lastReplacer; // // public LastReplacer(Supplier<String> lastReplacer) { // this.lastReplacer = lastReplacer; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return lastReplacer.get(); // } // } // // Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/PlayerReplacer.java // public class PlayerReplacer implements PlaceholderReplacer { // // private final Function<Player, String> playerReplacer; // // public PlayerReplacer(Function<Player, String> playerReplacer) { // this.playerReplacer = playerReplacer; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return playerReplacer.apply(event.getPlayer()); // } // } // // Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/RankReplacer.java // public class RankReplacer implements PlaceholderReplacer { // // private final Function<Integer, String> rankReplacer; // private final int rank; // // public RankReplacer(Function<Integer, String> rankReplacer, int rank) { // this.rankReplacer = rankReplacer; // this.rank = rank; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return rankReplacer.apply(rank); // } // } // Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/MVdWPlaceholderAPIHook.java import be.maximvdw.placeholderapi.PlaceholderAPI; import net.novucs.ftop.hook.replacer.LastReplacer; import net.novucs.ftop.hook.replacer.PlayerReplacer; import net.novucs.ftop.hook.replacer.RankReplacer; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import java.util.List; import java.util.function.Function; import java.util.function.Supplier; package net.novucs.ftop.hook; public class MVdWPlaceholderAPIHook implements PlaceholderHook { private final Plugin plugin; private final Function<Player, String> playerReplacer; private final Function<Integer, String> rankReplacer; private final Supplier<String> lastReplacer; public MVdWPlaceholderAPIHook(Plugin plugin, Function<Player, String> playerReplacer, Function<Integer, String> rankReplacer, Supplier<String> lastReplacer) { this.plugin = plugin; this.playerReplacer = playerReplacer; this.rankReplacer = rankReplacer; this.lastReplacer = lastReplacer; } @Override public boolean initialize(List<Integer> enabledRanks) { LastReplacer lastReplacer = new LastReplacer(this.lastReplacer); boolean updated = PlaceholderAPI.registerPlaceholder(plugin, "factionstop_name:last", lastReplacer); for (int rank : enabledRanks) {
RankReplacer replacer = new RankReplacer(rankReplacer, rank);
novucs/factions-top
hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/MVdWPlaceholderAPIHook.java
// Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/LastReplacer.java // public class LastReplacer implements PlaceholderReplacer { // // private final Supplier<String> lastReplacer; // // public LastReplacer(Supplier<String> lastReplacer) { // this.lastReplacer = lastReplacer; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return lastReplacer.get(); // } // } // // Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/PlayerReplacer.java // public class PlayerReplacer implements PlaceholderReplacer { // // private final Function<Player, String> playerReplacer; // // public PlayerReplacer(Function<Player, String> playerReplacer) { // this.playerReplacer = playerReplacer; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return playerReplacer.apply(event.getPlayer()); // } // } // // Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/RankReplacer.java // public class RankReplacer implements PlaceholderReplacer { // // private final Function<Integer, String> rankReplacer; // private final int rank; // // public RankReplacer(Function<Integer, String> rankReplacer, int rank) { // this.rankReplacer = rankReplacer; // this.rank = rank; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return rankReplacer.apply(rank); // } // }
import be.maximvdw.placeholderapi.PlaceholderAPI; import net.novucs.ftop.hook.replacer.LastReplacer; import net.novucs.ftop.hook.replacer.PlayerReplacer; import net.novucs.ftop.hook.replacer.RankReplacer; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import java.util.List; import java.util.function.Function; import java.util.function.Supplier;
package net.novucs.ftop.hook; public class MVdWPlaceholderAPIHook implements PlaceholderHook { private final Plugin plugin; private final Function<Player, String> playerReplacer; private final Function<Integer, String> rankReplacer; private final Supplier<String> lastReplacer; public MVdWPlaceholderAPIHook(Plugin plugin, Function<Player, String> playerReplacer, Function<Integer, String> rankReplacer, Supplier<String> lastReplacer) { this.plugin = plugin; this.playerReplacer = playerReplacer; this.rankReplacer = rankReplacer; this.lastReplacer = lastReplacer; } @Override public boolean initialize(List<Integer> enabledRanks) { LastReplacer lastReplacer = new LastReplacer(this.lastReplacer); boolean updated = PlaceholderAPI.registerPlaceholder(plugin, "factionstop_name:last", lastReplacer); for (int rank : enabledRanks) { RankReplacer replacer = new RankReplacer(rankReplacer, rank); if (PlaceholderAPI.registerPlaceholder(plugin, "factionstop_name:" + rank, replacer)) { updated = true; } }
// Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/LastReplacer.java // public class LastReplacer implements PlaceholderReplacer { // // private final Supplier<String> lastReplacer; // // public LastReplacer(Supplier<String> lastReplacer) { // this.lastReplacer = lastReplacer; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return lastReplacer.get(); // } // } // // Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/PlayerReplacer.java // public class PlayerReplacer implements PlaceholderReplacer { // // private final Function<Player, String> playerReplacer; // // public PlayerReplacer(Function<Player, String> playerReplacer) { // this.playerReplacer = playerReplacer; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return playerReplacer.apply(event.getPlayer()); // } // } // // Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/replacer/RankReplacer.java // public class RankReplacer implements PlaceholderReplacer { // // private final Function<Integer, String> rankReplacer; // private final int rank; // // public RankReplacer(Function<Integer, String> rankReplacer, int rank) { // this.rankReplacer = rankReplacer; // this.rank = rank; // } // // @Override // public String onPlaceholderReplace(PlaceholderReplaceEvent event) { // return rankReplacer.apply(rank); // } // } // Path: hook/mvdwplaceholderapi/src/main/java/net/novucs/ftop/hook/MVdWPlaceholderAPIHook.java import be.maximvdw.placeholderapi.PlaceholderAPI; import net.novucs.ftop.hook.replacer.LastReplacer; import net.novucs.ftop.hook.replacer.PlayerReplacer; import net.novucs.ftop.hook.replacer.RankReplacer; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import java.util.List; import java.util.function.Function; import java.util.function.Supplier; package net.novucs.ftop.hook; public class MVdWPlaceholderAPIHook implements PlaceholderHook { private final Plugin plugin; private final Function<Player, String> playerReplacer; private final Function<Integer, String> rankReplacer; private final Supplier<String> lastReplacer; public MVdWPlaceholderAPIHook(Plugin plugin, Function<Player, String> playerReplacer, Function<Integer, String> rankReplacer, Supplier<String> lastReplacer) { this.plugin = plugin; this.playerReplacer = playerReplacer; this.rankReplacer = rankReplacer; this.lastReplacer = lastReplacer; } @Override public boolean initialize(List<Integer> enabledRanks) { LastReplacer lastReplacer = new LastReplacer(this.lastReplacer); boolean updated = PlaceholderAPI.registerPlaceholder(plugin, "factionstop_name:last", lastReplacer); for (int rank : enabledRanks) { RankReplacer replacer = new RankReplacer(rankReplacer, rank); if (PlaceholderAPI.registerPlaceholder(plugin, "factionstop_name:" + rank, replacer)) { updated = true; } }
PlayerReplacer playerReplacer = new PlayerReplacer(this.playerReplacer);
novucs/factions-top
hook/factions-1-6/src/main/java/net/novucs/ftop/hook/Factions0106.java
// Path: hook/manager/src/main/java/net/novucs/ftop/entity/ChunkPos.java // public class ChunkPos { // // private final String world; // private final int x; // private final int z; // // public static ChunkPos of(Chunk chunk) { // return new ChunkPos(chunk.getWorld().getName(), chunk.getX(), chunk.getZ()); // } // // public static ChunkPos of(ChunkSnapshot snapshot) { // return new ChunkPos(snapshot.getWorldName(), snapshot.getX(), snapshot.getZ()); // } // // public static ChunkPos of(String world, int x, int z) { // return new ChunkPos(world, x, z); // } // // private ChunkPos(String world, int x, int z) { // this.world = world; // this.x = x; // this.z = z; // } // // public String getWorld() { // return world; // } // // public int getX() { // return x; // } // // public int getZ() { // return z; // } // // public Chunk getChunk(Server server) { // if (server.getWorld(world) == null) return null; // return server.getWorld(world).getChunkAt(x, z); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // ChunkPos chunkPos = (ChunkPos) o; // return x == chunkPos.x && // z == chunkPos.z && // Objects.equals(world, chunkPos.world); // } // // @Override // public int hashCode() { // return Objects.hash(world, x, z); // } // // @Override // public String toString() { // return "ChunkPos{" + // "world='" + world + '\'' + // ", x=" + x + // ", z=" + z + // '}'; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionDisbandEvent.java // public class FactionDisbandEvent extends FactionEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String name; // // public FactionDisbandEvent(String factionId, String name) { // super(factionId); // this.name = name; // } // // public String getName() { // return name; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionRenameEvent.java // public class FactionRenameEvent extends FactionEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String oldName; // private final String newName; // // public FactionRenameEvent(String factionId, String oldName, String newName) { // super(factionId); // this.oldName = oldName; // this.newName = newName; // } // // public String getOldName() { // return oldName; // } // // public String getNewName() { // return newName; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // }
import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.massivecraft.factions.*; import com.massivecraft.factions.event.*; import net.novucs.ftop.entity.ChunkPos; import net.novucs.ftop.hook.event.*; import net.novucs.ftop.hook.event.FactionDisbandEvent; import net.novucs.ftop.hook.event.FactionRenameEvent; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.plugin.Plugin; import java.lang.reflect.Field; import java.util.*; import java.util.stream.Collectors;
return Factions.getInstance().getFactionById(factionId) != null; } @Override public ChatColor getRelation(Player player, String factionId) { FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); Faction faction = Factions.getInstance().getFactionById(factionId); return fplayer.getFaction().getRelationTo(faction).getColor(); } @Override public String getOwnerName(String factionId) { Faction faction = Factions.getInstance().getFactionById(factionId); if (faction == null) { return null; } FPlayer owner = faction.getFPlayerAdmin(); return owner == null ? null : owner.getName(); } @Override public List<UUID> getMembers(String factionId) { return Factions.getInstance().getFactionById(factionId).getFPlayers().stream() .map(fplayer -> UUID.fromString(fplayer.getId())) .collect(Collectors.toList()); } @Override
// Path: hook/manager/src/main/java/net/novucs/ftop/entity/ChunkPos.java // public class ChunkPos { // // private final String world; // private final int x; // private final int z; // // public static ChunkPos of(Chunk chunk) { // return new ChunkPos(chunk.getWorld().getName(), chunk.getX(), chunk.getZ()); // } // // public static ChunkPos of(ChunkSnapshot snapshot) { // return new ChunkPos(snapshot.getWorldName(), snapshot.getX(), snapshot.getZ()); // } // // public static ChunkPos of(String world, int x, int z) { // return new ChunkPos(world, x, z); // } // // private ChunkPos(String world, int x, int z) { // this.world = world; // this.x = x; // this.z = z; // } // // public String getWorld() { // return world; // } // // public int getX() { // return x; // } // // public int getZ() { // return z; // } // // public Chunk getChunk(Server server) { // if (server.getWorld(world) == null) return null; // return server.getWorld(world).getChunkAt(x, z); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // ChunkPos chunkPos = (ChunkPos) o; // return x == chunkPos.x && // z == chunkPos.z && // Objects.equals(world, chunkPos.world); // } // // @Override // public int hashCode() { // return Objects.hash(world, x, z); // } // // @Override // public String toString() { // return "ChunkPos{" + // "world='" + world + '\'' + // ", x=" + x + // ", z=" + z + // '}'; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionDisbandEvent.java // public class FactionDisbandEvent extends FactionEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String name; // // public FactionDisbandEvent(String factionId, String name) { // super(factionId); // this.name = name; // } // // public String getName() { // return name; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionRenameEvent.java // public class FactionRenameEvent extends FactionEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String oldName; // private final String newName; // // public FactionRenameEvent(String factionId, String oldName, String newName) { // super(factionId); // this.oldName = oldName; // this.newName = newName; // } // // public String getOldName() { // return oldName; // } // // public String getNewName() { // return newName; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // Path: hook/factions-1-6/src/main/java/net/novucs/ftop/hook/Factions0106.java import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.massivecraft.factions.*; import com.massivecraft.factions.event.*; import net.novucs.ftop.entity.ChunkPos; import net.novucs.ftop.hook.event.*; import net.novucs.ftop.hook.event.FactionDisbandEvent; import net.novucs.ftop.hook.event.FactionRenameEvent; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.plugin.Plugin; import java.lang.reflect.Field; import java.util.*; import java.util.stream.Collectors; return Factions.getInstance().getFactionById(factionId) != null; } @Override public ChatColor getRelation(Player player, String factionId) { FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); Faction faction = Factions.getInstance().getFactionById(factionId); return fplayer.getFaction().getRelationTo(faction).getColor(); } @Override public String getOwnerName(String factionId) { Faction faction = Factions.getInstance().getFactionById(factionId); if (faction == null) { return null; } FPlayer owner = faction.getFPlayerAdmin(); return owner == null ? null : owner.getName(); } @Override public List<UUID> getMembers(String factionId) { return Factions.getInstance().getFactionById(factionId).getFPlayers().stream() .map(fplayer -> UUID.fromString(fplayer.getId())) .collect(Collectors.toList()); } @Override
public List<ChunkPos> getClaims() {
novucs/factions-top
hook/factions-1-6/src/main/java/net/novucs/ftop/hook/Factions0106.java
// Path: hook/manager/src/main/java/net/novucs/ftop/entity/ChunkPos.java // public class ChunkPos { // // private final String world; // private final int x; // private final int z; // // public static ChunkPos of(Chunk chunk) { // return new ChunkPos(chunk.getWorld().getName(), chunk.getX(), chunk.getZ()); // } // // public static ChunkPos of(ChunkSnapshot snapshot) { // return new ChunkPos(snapshot.getWorldName(), snapshot.getX(), snapshot.getZ()); // } // // public static ChunkPos of(String world, int x, int z) { // return new ChunkPos(world, x, z); // } // // private ChunkPos(String world, int x, int z) { // this.world = world; // this.x = x; // this.z = z; // } // // public String getWorld() { // return world; // } // // public int getX() { // return x; // } // // public int getZ() { // return z; // } // // public Chunk getChunk(Server server) { // if (server.getWorld(world) == null) return null; // return server.getWorld(world).getChunkAt(x, z); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // ChunkPos chunkPos = (ChunkPos) o; // return x == chunkPos.x && // z == chunkPos.z && // Objects.equals(world, chunkPos.world); // } // // @Override // public int hashCode() { // return Objects.hash(world, x, z); // } // // @Override // public String toString() { // return "ChunkPos{" + // "world='" + world + '\'' + // ", x=" + x + // ", z=" + z + // '}'; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionDisbandEvent.java // public class FactionDisbandEvent extends FactionEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String name; // // public FactionDisbandEvent(String factionId, String name) { // super(factionId); // this.name = name; // } // // public String getName() { // return name; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionRenameEvent.java // public class FactionRenameEvent extends FactionEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String oldName; // private final String newName; // // public FactionRenameEvent(String factionId, String oldName, String newName) { // super(factionId); // this.oldName = oldName; // this.newName = newName; // } // // public String getOldName() { // return oldName; // } // // public String getNewName() { // return newName; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // }
import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.massivecraft.factions.*; import com.massivecraft.factions.event.*; import net.novucs.ftop.entity.ChunkPos; import net.novucs.ftop.hook.event.*; import net.novucs.ftop.hook.event.FactionDisbandEvent; import net.novucs.ftop.hook.event.FactionRenameEvent; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.plugin.Plugin; import java.lang.reflect.Field; import java.util.*; import java.util.stream.Collectors;
Faction faction = Factions.getInstance().getFactionById(factionId); if (faction == null) { return null; } FPlayer owner = faction.getFPlayerAdmin(); return owner == null ? null : owner.getName(); } @Override public List<UUID> getMembers(String factionId) { return Factions.getInstance().getFactionById(factionId).getFPlayers().stream() .map(fplayer -> UUID.fromString(fplayer.getId())) .collect(Collectors.toList()); } @Override public List<ChunkPos> getClaims() { List<ChunkPos> target = new LinkedList<>(); target.addAll(getChunkPos(flocationIds.keySet())); return target; } @Override public Set<String> getFactionIds() { return factions.keySet(); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
// Path: hook/manager/src/main/java/net/novucs/ftop/entity/ChunkPos.java // public class ChunkPos { // // private final String world; // private final int x; // private final int z; // // public static ChunkPos of(Chunk chunk) { // return new ChunkPos(chunk.getWorld().getName(), chunk.getX(), chunk.getZ()); // } // // public static ChunkPos of(ChunkSnapshot snapshot) { // return new ChunkPos(snapshot.getWorldName(), snapshot.getX(), snapshot.getZ()); // } // // public static ChunkPos of(String world, int x, int z) { // return new ChunkPos(world, x, z); // } // // private ChunkPos(String world, int x, int z) { // this.world = world; // this.x = x; // this.z = z; // } // // public String getWorld() { // return world; // } // // public int getX() { // return x; // } // // public int getZ() { // return z; // } // // public Chunk getChunk(Server server) { // if (server.getWorld(world) == null) return null; // return server.getWorld(world).getChunkAt(x, z); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // ChunkPos chunkPos = (ChunkPos) o; // return x == chunkPos.x && // z == chunkPos.z && // Objects.equals(world, chunkPos.world); // } // // @Override // public int hashCode() { // return Objects.hash(world, x, z); // } // // @Override // public String toString() { // return "ChunkPos{" + // "world='" + world + '\'' + // ", x=" + x + // ", z=" + z + // '}'; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionDisbandEvent.java // public class FactionDisbandEvent extends FactionEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String name; // // public FactionDisbandEvent(String factionId, String name) { // super(factionId); // this.name = name; // } // // public String getName() { // return name; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionRenameEvent.java // public class FactionRenameEvent extends FactionEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String oldName; // private final String newName; // // public FactionRenameEvent(String factionId, String oldName, String newName) { // super(factionId); // this.oldName = oldName; // this.newName = newName; // } // // public String getOldName() { // return oldName; // } // // public String getNewName() { // return newName; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // Path: hook/factions-1-6/src/main/java/net/novucs/ftop/hook/Factions0106.java import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.massivecraft.factions.*; import com.massivecraft.factions.event.*; import net.novucs.ftop.entity.ChunkPos; import net.novucs.ftop.hook.event.*; import net.novucs.ftop.hook.event.FactionDisbandEvent; import net.novucs.ftop.hook.event.FactionRenameEvent; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.plugin.Plugin; import java.lang.reflect.Field; import java.util.*; import java.util.stream.Collectors; Faction faction = Factions.getInstance().getFactionById(factionId); if (faction == null) { return null; } FPlayer owner = faction.getFPlayerAdmin(); return owner == null ? null : owner.getName(); } @Override public List<UUID> getMembers(String factionId) { return Factions.getInstance().getFactionById(factionId).getFPlayers().stream() .map(fplayer -> UUID.fromString(fplayer.getId())) .collect(Collectors.toList()); } @Override public List<ChunkPos> getClaims() { List<ChunkPos> target = new LinkedList<>(); target.addAll(getChunkPos(flocationIds.keySet())); return target; } @Override public Set<String> getFactionIds() { return factions.keySet(); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onDisband(com.massivecraft.factions.event.FactionDisbandEvent event) {
novucs/factions-top
hook/factions-1-6/src/main/java/net/novucs/ftop/hook/Factions0106.java
// Path: hook/manager/src/main/java/net/novucs/ftop/entity/ChunkPos.java // public class ChunkPos { // // private final String world; // private final int x; // private final int z; // // public static ChunkPos of(Chunk chunk) { // return new ChunkPos(chunk.getWorld().getName(), chunk.getX(), chunk.getZ()); // } // // public static ChunkPos of(ChunkSnapshot snapshot) { // return new ChunkPos(snapshot.getWorldName(), snapshot.getX(), snapshot.getZ()); // } // // public static ChunkPos of(String world, int x, int z) { // return new ChunkPos(world, x, z); // } // // private ChunkPos(String world, int x, int z) { // this.world = world; // this.x = x; // this.z = z; // } // // public String getWorld() { // return world; // } // // public int getX() { // return x; // } // // public int getZ() { // return z; // } // // public Chunk getChunk(Server server) { // if (server.getWorld(world) == null) return null; // return server.getWorld(world).getChunkAt(x, z); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // ChunkPos chunkPos = (ChunkPos) o; // return x == chunkPos.x && // z == chunkPos.z && // Objects.equals(world, chunkPos.world); // } // // @Override // public int hashCode() { // return Objects.hash(world, x, z); // } // // @Override // public String toString() { // return "ChunkPos{" + // "world='" + world + '\'' + // ", x=" + x + // ", z=" + z + // '}'; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionDisbandEvent.java // public class FactionDisbandEvent extends FactionEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String name; // // public FactionDisbandEvent(String factionId, String name) { // super(factionId); // this.name = name; // } // // public String getName() { // return name; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionRenameEvent.java // public class FactionRenameEvent extends FactionEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String oldName; // private final String newName; // // public FactionRenameEvent(String factionId, String oldName, String newName) { // super(factionId); // this.oldName = oldName; // this.newName = newName; // } // // public String getOldName() { // return oldName; // } // // public String getNewName() { // return newName; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // }
import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.massivecraft.factions.*; import com.massivecraft.factions.event.*; import net.novucs.ftop.entity.ChunkPos; import net.novucs.ftop.hook.event.*; import net.novucs.ftop.hook.event.FactionDisbandEvent; import net.novucs.ftop.hook.event.FactionRenameEvent; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.plugin.Plugin; import java.lang.reflect.Field; import java.util.*; import java.util.stream.Collectors;
return owner == null ? null : owner.getName(); } @Override public List<UUID> getMembers(String factionId) { return Factions.getInstance().getFactionById(factionId).getFPlayers().stream() .map(fplayer -> UUID.fromString(fplayer.getId())) .collect(Collectors.toList()); } @Override public List<ChunkPos> getClaims() { List<ChunkPos> target = new LinkedList<>(); target.addAll(getChunkPos(flocationIds.keySet())); return target; } @Override public Set<String> getFactionIds() { return factions.keySet(); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onDisband(com.massivecraft.factions.event.FactionDisbandEvent event) { String factionId = event.getFaction().getId(); String factionName = event.getFaction().getTag(); callEvent(new FactionDisbandEvent(factionId, factionName)); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
// Path: hook/manager/src/main/java/net/novucs/ftop/entity/ChunkPos.java // public class ChunkPos { // // private final String world; // private final int x; // private final int z; // // public static ChunkPos of(Chunk chunk) { // return new ChunkPos(chunk.getWorld().getName(), chunk.getX(), chunk.getZ()); // } // // public static ChunkPos of(ChunkSnapshot snapshot) { // return new ChunkPos(snapshot.getWorldName(), snapshot.getX(), snapshot.getZ()); // } // // public static ChunkPos of(String world, int x, int z) { // return new ChunkPos(world, x, z); // } // // private ChunkPos(String world, int x, int z) { // this.world = world; // this.x = x; // this.z = z; // } // // public String getWorld() { // return world; // } // // public int getX() { // return x; // } // // public int getZ() { // return z; // } // // public Chunk getChunk(Server server) { // if (server.getWorld(world) == null) return null; // return server.getWorld(world).getChunkAt(x, z); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // ChunkPos chunkPos = (ChunkPos) o; // return x == chunkPos.x && // z == chunkPos.z && // Objects.equals(world, chunkPos.world); // } // // @Override // public int hashCode() { // return Objects.hash(world, x, z); // } // // @Override // public String toString() { // return "ChunkPos{" + // "world='" + world + '\'' + // ", x=" + x + // ", z=" + z + // '}'; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionDisbandEvent.java // public class FactionDisbandEvent extends FactionEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String name; // // public FactionDisbandEvent(String factionId, String name) { // super(factionId); // this.name = name; // } // // public String getName() { // return name; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionRenameEvent.java // public class FactionRenameEvent extends FactionEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String oldName; // private final String newName; // // public FactionRenameEvent(String factionId, String oldName, String newName) { // super(factionId); // this.oldName = oldName; // this.newName = newName; // } // // public String getOldName() { // return oldName; // } // // public String getNewName() { // return newName; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // Path: hook/factions-1-6/src/main/java/net/novucs/ftop/hook/Factions0106.java import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.massivecraft.factions.*; import com.massivecraft.factions.event.*; import net.novucs.ftop.entity.ChunkPos; import net.novucs.ftop.hook.event.*; import net.novucs.ftop.hook.event.FactionDisbandEvent; import net.novucs.ftop.hook.event.FactionRenameEvent; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.plugin.Plugin; import java.lang.reflect.Field; import java.util.*; import java.util.stream.Collectors; return owner == null ? null : owner.getName(); } @Override public List<UUID> getMembers(String factionId) { return Factions.getInstance().getFactionById(factionId).getFPlayers().stream() .map(fplayer -> UUID.fromString(fplayer.getId())) .collect(Collectors.toList()); } @Override public List<ChunkPos> getClaims() { List<ChunkPos> target = new LinkedList<>(); target.addAll(getChunkPos(flocationIds.keySet())); return target; } @Override public Set<String> getFactionIds() { return factions.keySet(); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onDisband(com.massivecraft.factions.event.FactionDisbandEvent event) { String factionId = event.getFaction().getId(); String factionName = event.getFaction().getTag(); callEvent(new FactionDisbandEvent(factionId, factionName)); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onRename(com.massivecraft.factions.event.FactionRenameEvent event) {
novucs/factions-top
core/src/main/java/net/novucs/ftop/entity/FactionWorth.java
// Path: hook/manager/src/main/java/net/novucs/ftop/WorthType.java // public enum WorthType { // // CHEST, // PLAYER_BALANCE, // FACTION_BALANCE, // SPAWNER, // BLOCK; // // private static final WorthType[] PLACED = {CHEST, SPAWNER, BLOCK}; // // public static WorthType[] getPlaced() { // return PLACED; // } // // public static boolean isPlaced(WorthType worthType) { // switch (worthType) { // case PLAYER_BALANCE: // case FACTION_BALANCE: // return false; // } // return true; // } // }
import net.novucs.ftop.WorthType; import org.bukkit.Material; import org.bukkit.entity.EntityType; import java.util.Collections; import java.util.EnumMap; import java.util.Map;
package net.novucs.ftop.entity; public class FactionWorth implements Comparable<FactionWorth> { private final String factionId;
// Path: hook/manager/src/main/java/net/novucs/ftop/WorthType.java // public enum WorthType { // // CHEST, // PLAYER_BALANCE, // FACTION_BALANCE, // SPAWNER, // BLOCK; // // private static final WorthType[] PLACED = {CHEST, SPAWNER, BLOCK}; // // public static WorthType[] getPlaced() { // return PLACED; // } // // public static boolean isPlaced(WorthType worthType) { // switch (worthType) { // case PLAYER_BALANCE: // case FACTION_BALANCE: // return false; // } // return true; // } // } // Path: core/src/main/java/net/novucs/ftop/entity/FactionWorth.java import net.novucs.ftop.WorthType; import org.bukkit.Material; import org.bukkit.entity.EntityType; import java.util.Collections; import java.util.EnumMap; import java.util.Map; package net.novucs.ftop.entity; public class FactionWorth implements Comparable<FactionWorth> { private final String factionId;
private final Map<WorthType, Double> worth = new EnumMap<>(WorthType.class);
novucs/factions-top
core/src/main/java/net/novucs/ftop/gui/element/button/GuiNextButton.java
// Path: core/src/main/java/net/novucs/ftop/gui/GuiContext.java // public class GuiContext { // // private final FactionsTopPlugin plugin; // private final Player player; // private final Inventory inventory; // private final int maxPage; // private final int thisPage; // private final TreeIterator<FactionWorth> worthIterator; // private final Map<String, String> placeholders; // private final List<GuiElement> slots = new ArrayList<>(); // private int currentRank; // private int slot; // // public GuiContext(FactionsTopPlugin plugin, Player player, Inventory inventory, int maxPage, int thisPage, // TreeIterator<FactionWorth> worthIterator, Map<String, String> placeholders) { // this.plugin = plugin; // this.player = player; // this.inventory = inventory; // this.maxPage = maxPage; // this.thisPage = thisPage; // this.worthIterator = worthIterator; // this.placeholders = placeholders; // } // // public FactionsTopPlugin getPlugin() { // return plugin; // } // // public Player getPlayer() { // return player; // } // // public Inventory getInventory() { // return inventory; // } // // public int getMaxPage() { // return maxPage; // } // // public int getThisPage() { // return thisPage; // } // // public TreeIterator<FactionWorth> getWorthIterator() { // return worthIterator; // } // // public Map<String, String> getPlaceholders() { // return placeholders; // } // // public List<GuiElement> getSlots() { // return slots; // } // // public boolean hasNextPage() { // return thisPage < maxPage; // } // // public boolean hasPrevPage() { // return thisPage > 1; // } // // public int getCurrentRank() { // return currentRank; // } // // public void setCurrentRank(int currentRank) { // this.currentRank = currentRank; // } // // public int getAndIncrementRank() { // return currentRank++; // } // // public int getSlot() { // return slot; // } // // public void setSlot(int slot) { // this.slot = slot; // } // // public int getAndIncrementSlot() { // return slot++; // } // }
import net.novucs.ftop.gui.GuiContext;
package net.novucs.ftop.gui.element.button; public class GuiNextButton extends GuiBiStateButton { public GuiNextButton(GuiButtonContent enabled, GuiButtonContent disabled) { super(enabled, disabled); } @Override
// Path: core/src/main/java/net/novucs/ftop/gui/GuiContext.java // public class GuiContext { // // private final FactionsTopPlugin plugin; // private final Player player; // private final Inventory inventory; // private final int maxPage; // private final int thisPage; // private final TreeIterator<FactionWorth> worthIterator; // private final Map<String, String> placeholders; // private final List<GuiElement> slots = new ArrayList<>(); // private int currentRank; // private int slot; // // public GuiContext(FactionsTopPlugin plugin, Player player, Inventory inventory, int maxPage, int thisPage, // TreeIterator<FactionWorth> worthIterator, Map<String, String> placeholders) { // this.plugin = plugin; // this.player = player; // this.inventory = inventory; // this.maxPage = maxPage; // this.thisPage = thisPage; // this.worthIterator = worthIterator; // this.placeholders = placeholders; // } // // public FactionsTopPlugin getPlugin() { // return plugin; // } // // public Player getPlayer() { // return player; // } // // public Inventory getInventory() { // return inventory; // } // // public int getMaxPage() { // return maxPage; // } // // public int getThisPage() { // return thisPage; // } // // public TreeIterator<FactionWorth> getWorthIterator() { // return worthIterator; // } // // public Map<String, String> getPlaceholders() { // return placeholders; // } // // public List<GuiElement> getSlots() { // return slots; // } // // public boolean hasNextPage() { // return thisPage < maxPage; // } // // public boolean hasPrevPage() { // return thisPage > 1; // } // // public int getCurrentRank() { // return currentRank; // } // // public void setCurrentRank(int currentRank) { // this.currentRank = currentRank; // } // // public int getAndIncrementRank() { // return currentRank++; // } // // public int getSlot() { // return slot; // } // // public void setSlot(int slot) { // this.slot = slot; // } // // public int getAndIncrementSlot() { // return slot++; // } // } // Path: core/src/main/java/net/novucs/ftop/gui/element/button/GuiNextButton.java import net.novucs.ftop.gui.GuiContext; package net.novucs.ftop.gui.element.button; public class GuiNextButton extends GuiBiStateButton { public GuiNextButton(GuiButtonContent enabled, GuiButtonContent disabled) { super(enabled, disabled); } @Override
public void render(GuiContext context) {
novucs/factions-top
hook/essentials/src/main/java/net/novucs/ftop/hook/EssentialsEconomyHook.java
// Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionEconomyEvent.java // public class FactionEconomyEvent extends EconomyEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String factionId; // // public FactionEconomyEvent(String factionId, double oldBalance, double newBalance) { // super(oldBalance, newBalance); // this.factionId = factionId; // } // // public String getFactionId() { // return factionId; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/PlayerEconomyEvent.java // public class PlayerEconomyEvent extends EconomyEvent { // // private static final HandlerList handlers = new HandlerList(); // private final Player player; // // public PlayerEconomyEvent(Player player, double oldBalance, double newBalance) { // super(oldBalance, newBalance); // this.player = player; // } // // public Player getPlayer() { // return player; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // }
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; import com.earth2me.essentials.api.UserDoesNotExistException; import net.ess3.api.Economy; import net.ess3.api.events.UserBalanceUpdateEvent; import net.novucs.ftop.hook.event.FactionEconomyEvent; import net.novucs.ftop.hook.event.PlayerEconomyEvent; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; import java.util.List; import java.util.UUID;
} @Override public double getTotalBalance(List<UUID> playerIds) { double balance = 0; for (UUID playerId : playerIds) { balance += getBalance(playerId); } return balance; } @Override public double getFactionBalance(String factionId) { try { return Economy.getMoneyExact("faction_" + factionId.replace("-", "_")).doubleValue(); } catch (UserDoesNotExistException e) { return 0; } } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onEconomyEvent(UserBalanceUpdateEvent event) { double oldBalance = event.getOldBalance().doubleValue(); double newBalance = event.getNewBalance().doubleValue(); Player player = event.getPlayer(); if (!player.isOnline() && player.getName().startsWith("faction_")) { String factionId = player.getName().substring(8).replace("_", "-"); if (factionsHook.isFaction(factionId)) { if (factionEnabled) {
// Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionEconomyEvent.java // public class FactionEconomyEvent extends EconomyEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String factionId; // // public FactionEconomyEvent(String factionId, double oldBalance, double newBalance) { // super(oldBalance, newBalance); // this.factionId = factionId; // } // // public String getFactionId() { // return factionId; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/PlayerEconomyEvent.java // public class PlayerEconomyEvent extends EconomyEvent { // // private static final HandlerList handlers = new HandlerList(); // private final Player player; // // public PlayerEconomyEvent(Player player, double oldBalance, double newBalance) { // super(oldBalance, newBalance); // this.player = player; // } // // public Player getPlayer() { // return player; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // Path: hook/essentials/src/main/java/net/novucs/ftop/hook/EssentialsEconomyHook.java import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; import com.earth2me.essentials.api.UserDoesNotExistException; import net.ess3.api.Economy; import net.ess3.api.events.UserBalanceUpdateEvent; import net.novucs.ftop.hook.event.FactionEconomyEvent; import net.novucs.ftop.hook.event.PlayerEconomyEvent; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; import java.util.List; import java.util.UUID; } @Override public double getTotalBalance(List<UUID> playerIds) { double balance = 0; for (UUID playerId : playerIds) { balance += getBalance(playerId); } return balance; } @Override public double getFactionBalance(String factionId) { try { return Economy.getMoneyExact("faction_" + factionId.replace("-", "_")).doubleValue(); } catch (UserDoesNotExistException e) { return 0; } } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onEconomyEvent(UserBalanceUpdateEvent event) { double oldBalance = event.getOldBalance().doubleValue(); double newBalance = event.getNewBalance().doubleValue(); Player player = event.getPlayer(); if (!player.isOnline() && player.getName().startsWith("faction_")) { String factionId = player.getName().substring(8).replace("_", "-"); if (factionsHook.isFaction(factionId)) { if (factionEnabled) {
callEvent(new FactionEconomyEvent(factionId, oldBalance, newBalance));
novucs/factions-top
hook/essentials/src/main/java/net/novucs/ftop/hook/EssentialsEconomyHook.java
// Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionEconomyEvent.java // public class FactionEconomyEvent extends EconomyEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String factionId; // // public FactionEconomyEvent(String factionId, double oldBalance, double newBalance) { // super(oldBalance, newBalance); // this.factionId = factionId; // } // // public String getFactionId() { // return factionId; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/PlayerEconomyEvent.java // public class PlayerEconomyEvent extends EconomyEvent { // // private static final HandlerList handlers = new HandlerList(); // private final Player player; // // public PlayerEconomyEvent(Player player, double oldBalance, double newBalance) { // super(oldBalance, newBalance); // this.player = player; // } // // public Player getPlayer() { // return player; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // }
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; import com.earth2me.essentials.api.UserDoesNotExistException; import net.ess3.api.Economy; import net.ess3.api.events.UserBalanceUpdateEvent; import net.novucs.ftop.hook.event.FactionEconomyEvent; import net.novucs.ftop.hook.event.PlayerEconomyEvent; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; import java.util.List; import java.util.UUID;
return Economy.getMoneyExact("faction_" + factionId.replace("-", "_")).doubleValue(); } catch (UserDoesNotExistException e) { return 0; } } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onEconomyEvent(UserBalanceUpdateEvent event) { double oldBalance = event.getOldBalance().doubleValue(); double newBalance = event.getNewBalance().doubleValue(); Player player = event.getPlayer(); if (!player.isOnline() && player.getName().startsWith("faction_")) { String factionId = player.getName().substring(8).replace("_", "-"); if (factionsHook.isFaction(factionId)) { if (factionEnabled) { callEvent(new FactionEconomyEvent(factionId, oldBalance, newBalance)); } return; } } try { if (Economy.isNPC(player.getName())) { return; } } catch (UserDoesNotExistException ignore) { } if (playerEnabled) {
// Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionEconomyEvent.java // public class FactionEconomyEvent extends EconomyEvent { // // private static final HandlerList handlers = new HandlerList(); // private final String factionId; // // public FactionEconomyEvent(String factionId, double oldBalance, double newBalance) { // super(oldBalance, newBalance); // this.factionId = factionId; // } // // public String getFactionId() { // return factionId; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/PlayerEconomyEvent.java // public class PlayerEconomyEvent extends EconomyEvent { // // private static final HandlerList handlers = new HandlerList(); // private final Player player; // // public PlayerEconomyEvent(Player player, double oldBalance, double newBalance) { // super(oldBalance, newBalance); // this.player = player; // } // // public Player getPlayer() { // return player; // } // // @Override // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // } // Path: hook/essentials/src/main/java/net/novucs/ftop/hook/EssentialsEconomyHook.java import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; import com.earth2me.essentials.api.UserDoesNotExistException; import net.ess3.api.Economy; import net.ess3.api.events.UserBalanceUpdateEvent; import net.novucs.ftop.hook.event.FactionEconomyEvent; import net.novucs.ftop.hook.event.PlayerEconomyEvent; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; import java.util.List; import java.util.UUID; return Economy.getMoneyExact("faction_" + factionId.replace("-", "_")).doubleValue(); } catch (UserDoesNotExistException e) { return 0; } } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onEconomyEvent(UserBalanceUpdateEvent event) { double oldBalance = event.getOldBalance().doubleValue(); double newBalance = event.getNewBalance().doubleValue(); Player player = event.getPlayer(); if (!player.isOnline() && player.getName().startsWith("faction_")) { String factionId = player.getName().substring(8).replace("_", "-"); if (factionsHook.isFaction(factionId)) { if (factionEnabled) { callEvent(new FactionEconomyEvent(factionId, oldBalance, newBalance)); } return; } } try { if (Economy.isNPC(player.getName())) { return; } } catch (UserDoesNotExistException ignore) { } if (playerEnabled) {
callEvent(new PlayerEconomyEvent(player, oldBalance, newBalance));
novucs/factions-top
core/src/main/java/net/novucs/ftop/gui/element/button/GuiBackButton.java
// Path: core/src/main/java/net/novucs/ftop/gui/GuiContext.java // public class GuiContext { // // private final FactionsTopPlugin plugin; // private final Player player; // private final Inventory inventory; // private final int maxPage; // private final int thisPage; // private final TreeIterator<FactionWorth> worthIterator; // private final Map<String, String> placeholders; // private final List<GuiElement> slots = new ArrayList<>(); // private int currentRank; // private int slot; // // public GuiContext(FactionsTopPlugin plugin, Player player, Inventory inventory, int maxPage, int thisPage, // TreeIterator<FactionWorth> worthIterator, Map<String, String> placeholders) { // this.plugin = plugin; // this.player = player; // this.inventory = inventory; // this.maxPage = maxPage; // this.thisPage = thisPage; // this.worthIterator = worthIterator; // this.placeholders = placeholders; // } // // public FactionsTopPlugin getPlugin() { // return plugin; // } // // public Player getPlayer() { // return player; // } // // public Inventory getInventory() { // return inventory; // } // // public int getMaxPage() { // return maxPage; // } // // public int getThisPage() { // return thisPage; // } // // public TreeIterator<FactionWorth> getWorthIterator() { // return worthIterator; // } // // public Map<String, String> getPlaceholders() { // return placeholders; // } // // public List<GuiElement> getSlots() { // return slots; // } // // public boolean hasNextPage() { // return thisPage < maxPage; // } // // public boolean hasPrevPage() { // return thisPage > 1; // } // // public int getCurrentRank() { // return currentRank; // } // // public void setCurrentRank(int currentRank) { // this.currentRank = currentRank; // } // // public int getAndIncrementRank() { // return currentRank++; // } // // public int getSlot() { // return slot; // } // // public void setSlot(int slot) { // this.slot = slot; // } // // public int getAndIncrementSlot() { // return slot++; // } // }
import net.novucs.ftop.gui.GuiContext;
package net.novucs.ftop.gui.element.button; public class GuiBackButton extends GuiBiStateButton { public GuiBackButton(GuiButtonContent enabled, GuiButtonContent disabled) { super(enabled, disabled); } @Override
// Path: core/src/main/java/net/novucs/ftop/gui/GuiContext.java // public class GuiContext { // // private final FactionsTopPlugin plugin; // private final Player player; // private final Inventory inventory; // private final int maxPage; // private final int thisPage; // private final TreeIterator<FactionWorth> worthIterator; // private final Map<String, String> placeholders; // private final List<GuiElement> slots = new ArrayList<>(); // private int currentRank; // private int slot; // // public GuiContext(FactionsTopPlugin plugin, Player player, Inventory inventory, int maxPage, int thisPage, // TreeIterator<FactionWorth> worthIterator, Map<String, String> placeholders) { // this.plugin = plugin; // this.player = player; // this.inventory = inventory; // this.maxPage = maxPage; // this.thisPage = thisPage; // this.worthIterator = worthIterator; // this.placeholders = placeholders; // } // // public FactionsTopPlugin getPlugin() { // return plugin; // } // // public Player getPlayer() { // return player; // } // // public Inventory getInventory() { // return inventory; // } // // public int getMaxPage() { // return maxPage; // } // // public int getThisPage() { // return thisPage; // } // // public TreeIterator<FactionWorth> getWorthIterator() { // return worthIterator; // } // // public Map<String, String> getPlaceholders() { // return placeholders; // } // // public List<GuiElement> getSlots() { // return slots; // } // // public boolean hasNextPage() { // return thisPage < maxPage; // } // // public boolean hasPrevPage() { // return thisPage > 1; // } // // public int getCurrentRank() { // return currentRank; // } // // public void setCurrentRank(int currentRank) { // this.currentRank = currentRank; // } // // public int getAndIncrementRank() { // return currentRank++; // } // // public int getSlot() { // return slot; // } // // public void setSlot(int slot) { // this.slot = slot; // } // // public int getAndIncrementSlot() { // return slot++; // } // } // Path: core/src/main/java/net/novucs/ftop/gui/element/button/GuiBackButton.java import net.novucs.ftop.gui.GuiContext; package net.novucs.ftop.gui.element.button; public class GuiBackButton extends GuiBiStateButton { public GuiBackButton(GuiButtonContent enabled, GuiButtonContent disabled) { super(enabled, disabled); } @Override
public void render(GuiContext context) {
novucs/factions-top
hook/epicspawners/src/main/java/net/novucs/ftop/hook/EpicSpawnersHook.java
// Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/API/EpicSpawnersAPI.java // public class EpicSpawnersAPI { // // public int getSpawnerMultiplier(Location location) { // throw new UnsupportedOperationException(); // } // // public ItemStack newSpawnerItem(EntityType type, int amount) { // throw new UnsupportedOperationException(); // } // // public EntityType getType(ItemStack stack) { // throw new UnsupportedOperationException(); // } // } // // Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/EpicSpawners.java // public class EpicSpawners extends JavaPlugin implements Listener { // // public EpicSpawnersAPI getApi() { // throw new UnsupportedOperationException(); // } // } // // Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/Spawners/SpawnerChangeEvent.java // public class SpawnerChangeEvent extends Event { // // public SpawnerChangeEvent(Location location, Player player, int multi, int oldMulti) { // throw new UnsupportedOperationException(); // } // // public Block getSpawner() { // throw new UnsupportedOperationException(); // } // // public int getCurrentMulti() { // throw new UnsupportedOperationException(); // } // // public int getOldMulti() { // throw new UnsupportedOperationException(); // } // // public Player getPlayer() { // throw new UnsupportedOperationException(); // } // // public HandlerList getHandlers() { // throw new UnsupportedOperationException(); // } // // public static HandlerList getHandlerList() { // throw new UnsupportedOperationException(); // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/SpawnerMultiplierChangeEvent.java // public class SpawnerMultiplierChangeEvent extends BlockEvent { // // private static final HandlerList HANDLERS = new HandlerList(); // private final CreatureSpawner spawner; // private final int oldMultiplier; // private final int newMultiplier; // // public SpawnerMultiplierChangeEvent(CreatureSpawner spawner, int oldMultiplier, int newMultiplier) { // super(spawner.getBlock()); // this.spawner = spawner; // this.oldMultiplier = oldMultiplier; // this.newMultiplier = newMultiplier; // } // // public CreatureSpawner getSpawner() { // return spawner; // } // // public int getOldMultiplier() { // return oldMultiplier; // } // // public int getNewMultiplier() { // return newMultiplier; // } // // @Override // public HandlerList getHandlers() { // return HANDLERS; // } // // public static HandlerList getHandlerList() { // return HANDLERS; // } // }
import com.songoda.epicspawners.API.EpicSpawnersAPI; import com.songoda.epicspawners.EpicSpawners; import com.songoda.epicspawners.Spawners.SpawnerChangeEvent; import net.novucs.ftop.hook.event.SpawnerMultiplierChangeEvent; import org.bukkit.ChatColor; import org.bukkit.block.CreatureSpawner; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin;
package net.novucs.ftop.hook; public class EpicSpawnersHook implements SpawnerStackerHook, Listener { private final Plugin plugin; private final CraftbukkitHook craftbukkitHook;
// Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/API/EpicSpawnersAPI.java // public class EpicSpawnersAPI { // // public int getSpawnerMultiplier(Location location) { // throw new UnsupportedOperationException(); // } // // public ItemStack newSpawnerItem(EntityType type, int amount) { // throw new UnsupportedOperationException(); // } // // public EntityType getType(ItemStack stack) { // throw new UnsupportedOperationException(); // } // } // // Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/EpicSpawners.java // public class EpicSpawners extends JavaPlugin implements Listener { // // public EpicSpawnersAPI getApi() { // throw new UnsupportedOperationException(); // } // } // // Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/Spawners/SpawnerChangeEvent.java // public class SpawnerChangeEvent extends Event { // // public SpawnerChangeEvent(Location location, Player player, int multi, int oldMulti) { // throw new UnsupportedOperationException(); // } // // public Block getSpawner() { // throw new UnsupportedOperationException(); // } // // public int getCurrentMulti() { // throw new UnsupportedOperationException(); // } // // public int getOldMulti() { // throw new UnsupportedOperationException(); // } // // public Player getPlayer() { // throw new UnsupportedOperationException(); // } // // public HandlerList getHandlers() { // throw new UnsupportedOperationException(); // } // // public static HandlerList getHandlerList() { // throw new UnsupportedOperationException(); // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/SpawnerMultiplierChangeEvent.java // public class SpawnerMultiplierChangeEvent extends BlockEvent { // // private static final HandlerList HANDLERS = new HandlerList(); // private final CreatureSpawner spawner; // private final int oldMultiplier; // private final int newMultiplier; // // public SpawnerMultiplierChangeEvent(CreatureSpawner spawner, int oldMultiplier, int newMultiplier) { // super(spawner.getBlock()); // this.spawner = spawner; // this.oldMultiplier = oldMultiplier; // this.newMultiplier = newMultiplier; // } // // public CreatureSpawner getSpawner() { // return spawner; // } // // public int getOldMultiplier() { // return oldMultiplier; // } // // public int getNewMultiplier() { // return newMultiplier; // } // // @Override // public HandlerList getHandlers() { // return HANDLERS; // } // // public static HandlerList getHandlerList() { // return HANDLERS; // } // } // Path: hook/epicspawners/src/main/java/net/novucs/ftop/hook/EpicSpawnersHook.java import com.songoda.epicspawners.API.EpicSpawnersAPI; import com.songoda.epicspawners.EpicSpawners; import com.songoda.epicspawners.Spawners.SpawnerChangeEvent; import net.novucs.ftop.hook.event.SpawnerMultiplierChangeEvent; import org.bukkit.ChatColor; import org.bukkit.block.CreatureSpawner; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; package net.novucs.ftop.hook; public class EpicSpawnersHook implements SpawnerStackerHook, Listener { private final Plugin plugin; private final CraftbukkitHook craftbukkitHook;
private EpicSpawnersAPI api;
novucs/factions-top
hook/epicspawners/src/main/java/net/novucs/ftop/hook/EpicSpawnersHook.java
// Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/API/EpicSpawnersAPI.java // public class EpicSpawnersAPI { // // public int getSpawnerMultiplier(Location location) { // throw new UnsupportedOperationException(); // } // // public ItemStack newSpawnerItem(EntityType type, int amount) { // throw new UnsupportedOperationException(); // } // // public EntityType getType(ItemStack stack) { // throw new UnsupportedOperationException(); // } // } // // Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/EpicSpawners.java // public class EpicSpawners extends JavaPlugin implements Listener { // // public EpicSpawnersAPI getApi() { // throw new UnsupportedOperationException(); // } // } // // Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/Spawners/SpawnerChangeEvent.java // public class SpawnerChangeEvent extends Event { // // public SpawnerChangeEvent(Location location, Player player, int multi, int oldMulti) { // throw new UnsupportedOperationException(); // } // // public Block getSpawner() { // throw new UnsupportedOperationException(); // } // // public int getCurrentMulti() { // throw new UnsupportedOperationException(); // } // // public int getOldMulti() { // throw new UnsupportedOperationException(); // } // // public Player getPlayer() { // throw new UnsupportedOperationException(); // } // // public HandlerList getHandlers() { // throw new UnsupportedOperationException(); // } // // public static HandlerList getHandlerList() { // throw new UnsupportedOperationException(); // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/SpawnerMultiplierChangeEvent.java // public class SpawnerMultiplierChangeEvent extends BlockEvent { // // private static final HandlerList HANDLERS = new HandlerList(); // private final CreatureSpawner spawner; // private final int oldMultiplier; // private final int newMultiplier; // // public SpawnerMultiplierChangeEvent(CreatureSpawner spawner, int oldMultiplier, int newMultiplier) { // super(spawner.getBlock()); // this.spawner = spawner; // this.oldMultiplier = oldMultiplier; // this.newMultiplier = newMultiplier; // } // // public CreatureSpawner getSpawner() { // return spawner; // } // // public int getOldMultiplier() { // return oldMultiplier; // } // // public int getNewMultiplier() { // return newMultiplier; // } // // @Override // public HandlerList getHandlers() { // return HANDLERS; // } // // public static HandlerList getHandlerList() { // return HANDLERS; // } // }
import com.songoda.epicspawners.API.EpicSpawnersAPI; import com.songoda.epicspawners.EpicSpawners; import com.songoda.epicspawners.Spawners.SpawnerChangeEvent; import net.novucs.ftop.hook.event.SpawnerMultiplierChangeEvent; import org.bukkit.ChatColor; import org.bukkit.block.CreatureSpawner; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin;
package net.novucs.ftop.hook; public class EpicSpawnersHook implements SpawnerStackerHook, Listener { private final Plugin plugin; private final CraftbukkitHook craftbukkitHook; private EpicSpawnersAPI api; public EpicSpawnersHook(Plugin plugin, CraftbukkitHook craftbukkitHook) { this.plugin = plugin; this.craftbukkitHook = craftbukkitHook; } public void initialize() {
// Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/API/EpicSpawnersAPI.java // public class EpicSpawnersAPI { // // public int getSpawnerMultiplier(Location location) { // throw new UnsupportedOperationException(); // } // // public ItemStack newSpawnerItem(EntityType type, int amount) { // throw new UnsupportedOperationException(); // } // // public EntityType getType(ItemStack stack) { // throw new UnsupportedOperationException(); // } // } // // Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/EpicSpawners.java // public class EpicSpawners extends JavaPlugin implements Listener { // // public EpicSpawnersAPI getApi() { // throw new UnsupportedOperationException(); // } // } // // Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/Spawners/SpawnerChangeEvent.java // public class SpawnerChangeEvent extends Event { // // public SpawnerChangeEvent(Location location, Player player, int multi, int oldMulti) { // throw new UnsupportedOperationException(); // } // // public Block getSpawner() { // throw new UnsupportedOperationException(); // } // // public int getCurrentMulti() { // throw new UnsupportedOperationException(); // } // // public int getOldMulti() { // throw new UnsupportedOperationException(); // } // // public Player getPlayer() { // throw new UnsupportedOperationException(); // } // // public HandlerList getHandlers() { // throw new UnsupportedOperationException(); // } // // public static HandlerList getHandlerList() { // throw new UnsupportedOperationException(); // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/SpawnerMultiplierChangeEvent.java // public class SpawnerMultiplierChangeEvent extends BlockEvent { // // private static final HandlerList HANDLERS = new HandlerList(); // private final CreatureSpawner spawner; // private final int oldMultiplier; // private final int newMultiplier; // // public SpawnerMultiplierChangeEvent(CreatureSpawner spawner, int oldMultiplier, int newMultiplier) { // super(spawner.getBlock()); // this.spawner = spawner; // this.oldMultiplier = oldMultiplier; // this.newMultiplier = newMultiplier; // } // // public CreatureSpawner getSpawner() { // return spawner; // } // // public int getOldMultiplier() { // return oldMultiplier; // } // // public int getNewMultiplier() { // return newMultiplier; // } // // @Override // public HandlerList getHandlers() { // return HANDLERS; // } // // public static HandlerList getHandlerList() { // return HANDLERS; // } // } // Path: hook/epicspawners/src/main/java/net/novucs/ftop/hook/EpicSpawnersHook.java import com.songoda.epicspawners.API.EpicSpawnersAPI; import com.songoda.epicspawners.EpicSpawners; import com.songoda.epicspawners.Spawners.SpawnerChangeEvent; import net.novucs.ftop.hook.event.SpawnerMultiplierChangeEvent; import org.bukkit.ChatColor; import org.bukkit.block.CreatureSpawner; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; package net.novucs.ftop.hook; public class EpicSpawnersHook implements SpawnerStackerHook, Listener { private final Plugin plugin; private final CraftbukkitHook craftbukkitHook; private EpicSpawnersAPI api; public EpicSpawnersHook(Plugin plugin, CraftbukkitHook craftbukkitHook) { this.plugin = plugin; this.craftbukkitHook = craftbukkitHook; } public void initialize() {
Plugin epicSpawnersPlugin = plugin.getServer().getPluginManager().getPlugin("EpicSpawners");
novucs/factions-top
hook/epicspawners/src/main/java/net/novucs/ftop/hook/EpicSpawnersHook.java
// Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/API/EpicSpawnersAPI.java // public class EpicSpawnersAPI { // // public int getSpawnerMultiplier(Location location) { // throw new UnsupportedOperationException(); // } // // public ItemStack newSpawnerItem(EntityType type, int amount) { // throw new UnsupportedOperationException(); // } // // public EntityType getType(ItemStack stack) { // throw new UnsupportedOperationException(); // } // } // // Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/EpicSpawners.java // public class EpicSpawners extends JavaPlugin implements Listener { // // public EpicSpawnersAPI getApi() { // throw new UnsupportedOperationException(); // } // } // // Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/Spawners/SpawnerChangeEvent.java // public class SpawnerChangeEvent extends Event { // // public SpawnerChangeEvent(Location location, Player player, int multi, int oldMulti) { // throw new UnsupportedOperationException(); // } // // public Block getSpawner() { // throw new UnsupportedOperationException(); // } // // public int getCurrentMulti() { // throw new UnsupportedOperationException(); // } // // public int getOldMulti() { // throw new UnsupportedOperationException(); // } // // public Player getPlayer() { // throw new UnsupportedOperationException(); // } // // public HandlerList getHandlers() { // throw new UnsupportedOperationException(); // } // // public static HandlerList getHandlerList() { // throw new UnsupportedOperationException(); // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/SpawnerMultiplierChangeEvent.java // public class SpawnerMultiplierChangeEvent extends BlockEvent { // // private static final HandlerList HANDLERS = new HandlerList(); // private final CreatureSpawner spawner; // private final int oldMultiplier; // private final int newMultiplier; // // public SpawnerMultiplierChangeEvent(CreatureSpawner spawner, int oldMultiplier, int newMultiplier) { // super(spawner.getBlock()); // this.spawner = spawner; // this.oldMultiplier = oldMultiplier; // this.newMultiplier = newMultiplier; // } // // public CreatureSpawner getSpawner() { // return spawner; // } // // public int getOldMultiplier() { // return oldMultiplier; // } // // public int getNewMultiplier() { // return newMultiplier; // } // // @Override // public HandlerList getHandlers() { // return HANDLERS; // } // // public static HandlerList getHandlerList() { // return HANDLERS; // } // }
import com.songoda.epicspawners.API.EpicSpawnersAPI; import com.songoda.epicspawners.EpicSpawners; import com.songoda.epicspawners.Spawners.SpawnerChangeEvent; import net.novucs.ftop.hook.event.SpawnerMultiplierChangeEvent; import org.bukkit.ChatColor; import org.bukkit.block.CreatureSpawner; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin;
@Override public int getStackSize(ItemStack spawner) { if (api == null || !spawner.hasItemMeta()) { return 1; } String[] args = spawner.getItemMeta().getDisplayName().split(" "); String lastArg = ChatColor.stripColor(args[args.length - 1]); if (lastArg.length() > 0) { lastArg = lastArg.substring(0, lastArg.length() - 1); } try { return Integer.parseInt(lastArg); } catch (NumberFormatException ex) { return 1; } } @Override public int getStackSize(CreatureSpawner spawner) { if (api == null) { return 1; } return api.getSpawnerMultiplier(spawner.getLocation()); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
// Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/API/EpicSpawnersAPI.java // public class EpicSpawnersAPI { // // public int getSpawnerMultiplier(Location location) { // throw new UnsupportedOperationException(); // } // // public ItemStack newSpawnerItem(EntityType type, int amount) { // throw new UnsupportedOperationException(); // } // // public EntityType getType(ItemStack stack) { // throw new UnsupportedOperationException(); // } // } // // Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/EpicSpawners.java // public class EpicSpawners extends JavaPlugin implements Listener { // // public EpicSpawnersAPI getApi() { // throw new UnsupportedOperationException(); // } // } // // Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/Spawners/SpawnerChangeEvent.java // public class SpawnerChangeEvent extends Event { // // public SpawnerChangeEvent(Location location, Player player, int multi, int oldMulti) { // throw new UnsupportedOperationException(); // } // // public Block getSpawner() { // throw new UnsupportedOperationException(); // } // // public int getCurrentMulti() { // throw new UnsupportedOperationException(); // } // // public int getOldMulti() { // throw new UnsupportedOperationException(); // } // // public Player getPlayer() { // throw new UnsupportedOperationException(); // } // // public HandlerList getHandlers() { // throw new UnsupportedOperationException(); // } // // public static HandlerList getHandlerList() { // throw new UnsupportedOperationException(); // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/SpawnerMultiplierChangeEvent.java // public class SpawnerMultiplierChangeEvent extends BlockEvent { // // private static final HandlerList HANDLERS = new HandlerList(); // private final CreatureSpawner spawner; // private final int oldMultiplier; // private final int newMultiplier; // // public SpawnerMultiplierChangeEvent(CreatureSpawner spawner, int oldMultiplier, int newMultiplier) { // super(spawner.getBlock()); // this.spawner = spawner; // this.oldMultiplier = oldMultiplier; // this.newMultiplier = newMultiplier; // } // // public CreatureSpawner getSpawner() { // return spawner; // } // // public int getOldMultiplier() { // return oldMultiplier; // } // // public int getNewMultiplier() { // return newMultiplier; // } // // @Override // public HandlerList getHandlers() { // return HANDLERS; // } // // public static HandlerList getHandlerList() { // return HANDLERS; // } // } // Path: hook/epicspawners/src/main/java/net/novucs/ftop/hook/EpicSpawnersHook.java import com.songoda.epicspawners.API.EpicSpawnersAPI; import com.songoda.epicspawners.EpicSpawners; import com.songoda.epicspawners.Spawners.SpawnerChangeEvent; import net.novucs.ftop.hook.event.SpawnerMultiplierChangeEvent; import org.bukkit.ChatColor; import org.bukkit.block.CreatureSpawner; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; @Override public int getStackSize(ItemStack spawner) { if (api == null || !spawner.hasItemMeta()) { return 1; } String[] args = spawner.getItemMeta().getDisplayName().split(" "); String lastArg = ChatColor.stripColor(args[args.length - 1]); if (lastArg.length() > 0) { lastArg = lastArg.substring(0, lastArg.length() - 1); } try { return Integer.parseInt(lastArg); } catch (NumberFormatException ex) { return 1; } } @Override public int getStackSize(CreatureSpawner spawner) { if (api == null) { return 1; } return api.getSpawnerMultiplier(spawner.getLocation()); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void updateWorth(SpawnerChangeEvent event) {
novucs/factions-top
hook/epicspawners/src/main/java/net/novucs/ftop/hook/EpicSpawnersHook.java
// Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/API/EpicSpawnersAPI.java // public class EpicSpawnersAPI { // // public int getSpawnerMultiplier(Location location) { // throw new UnsupportedOperationException(); // } // // public ItemStack newSpawnerItem(EntityType type, int amount) { // throw new UnsupportedOperationException(); // } // // public EntityType getType(ItemStack stack) { // throw new UnsupportedOperationException(); // } // } // // Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/EpicSpawners.java // public class EpicSpawners extends JavaPlugin implements Listener { // // public EpicSpawnersAPI getApi() { // throw new UnsupportedOperationException(); // } // } // // Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/Spawners/SpawnerChangeEvent.java // public class SpawnerChangeEvent extends Event { // // public SpawnerChangeEvent(Location location, Player player, int multi, int oldMulti) { // throw new UnsupportedOperationException(); // } // // public Block getSpawner() { // throw new UnsupportedOperationException(); // } // // public int getCurrentMulti() { // throw new UnsupportedOperationException(); // } // // public int getOldMulti() { // throw new UnsupportedOperationException(); // } // // public Player getPlayer() { // throw new UnsupportedOperationException(); // } // // public HandlerList getHandlers() { // throw new UnsupportedOperationException(); // } // // public static HandlerList getHandlerList() { // throw new UnsupportedOperationException(); // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/SpawnerMultiplierChangeEvent.java // public class SpawnerMultiplierChangeEvent extends BlockEvent { // // private static final HandlerList HANDLERS = new HandlerList(); // private final CreatureSpawner spawner; // private final int oldMultiplier; // private final int newMultiplier; // // public SpawnerMultiplierChangeEvent(CreatureSpawner spawner, int oldMultiplier, int newMultiplier) { // super(spawner.getBlock()); // this.spawner = spawner; // this.oldMultiplier = oldMultiplier; // this.newMultiplier = newMultiplier; // } // // public CreatureSpawner getSpawner() { // return spawner; // } // // public int getOldMultiplier() { // return oldMultiplier; // } // // public int getNewMultiplier() { // return newMultiplier; // } // // @Override // public HandlerList getHandlers() { // return HANDLERS; // } // // public static HandlerList getHandlerList() { // return HANDLERS; // } // }
import com.songoda.epicspawners.API.EpicSpawnersAPI; import com.songoda.epicspawners.EpicSpawners; import com.songoda.epicspawners.Spawners.SpawnerChangeEvent; import net.novucs.ftop.hook.event.SpawnerMultiplierChangeEvent; import org.bukkit.ChatColor; import org.bukkit.block.CreatureSpawner; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin;
} String[] args = spawner.getItemMeta().getDisplayName().split(" "); String lastArg = ChatColor.stripColor(args[args.length - 1]); if (lastArg.length() > 0) { lastArg = lastArg.substring(0, lastArg.length() - 1); } try { return Integer.parseInt(lastArg); } catch (NumberFormatException ex) { return 1; } } @Override public int getStackSize(CreatureSpawner spawner) { if (api == null) { return 1; } return api.getSpawnerMultiplier(spawner.getLocation()); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void updateWorth(SpawnerChangeEvent event) { CreatureSpawner spawner = (CreatureSpawner) event.getSpawner().getState(); int oldMultiplier = event.getOldMulti(); int newMultiplier = event.getCurrentMulti();
// Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/API/EpicSpawnersAPI.java // public class EpicSpawnersAPI { // // public int getSpawnerMultiplier(Location location) { // throw new UnsupportedOperationException(); // } // // public ItemStack newSpawnerItem(EntityType type, int amount) { // throw new UnsupportedOperationException(); // } // // public EntityType getType(ItemStack stack) { // throw new UnsupportedOperationException(); // } // } // // Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/EpicSpawners.java // public class EpicSpawners extends JavaPlugin implements Listener { // // public EpicSpawnersAPI getApi() { // throw new UnsupportedOperationException(); // } // } // // Path: hook/epicspawnersapi/src/main/java/com/songoda/epicspawners/Spawners/SpawnerChangeEvent.java // public class SpawnerChangeEvent extends Event { // // public SpawnerChangeEvent(Location location, Player player, int multi, int oldMulti) { // throw new UnsupportedOperationException(); // } // // public Block getSpawner() { // throw new UnsupportedOperationException(); // } // // public int getCurrentMulti() { // throw new UnsupportedOperationException(); // } // // public int getOldMulti() { // throw new UnsupportedOperationException(); // } // // public Player getPlayer() { // throw new UnsupportedOperationException(); // } // // public HandlerList getHandlers() { // throw new UnsupportedOperationException(); // } // // public static HandlerList getHandlerList() { // throw new UnsupportedOperationException(); // } // } // // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/SpawnerMultiplierChangeEvent.java // public class SpawnerMultiplierChangeEvent extends BlockEvent { // // private static final HandlerList HANDLERS = new HandlerList(); // private final CreatureSpawner spawner; // private final int oldMultiplier; // private final int newMultiplier; // // public SpawnerMultiplierChangeEvent(CreatureSpawner spawner, int oldMultiplier, int newMultiplier) { // super(spawner.getBlock()); // this.spawner = spawner; // this.oldMultiplier = oldMultiplier; // this.newMultiplier = newMultiplier; // } // // public CreatureSpawner getSpawner() { // return spawner; // } // // public int getOldMultiplier() { // return oldMultiplier; // } // // public int getNewMultiplier() { // return newMultiplier; // } // // @Override // public HandlerList getHandlers() { // return HANDLERS; // } // // public static HandlerList getHandlerList() { // return HANDLERS; // } // } // Path: hook/epicspawners/src/main/java/net/novucs/ftop/hook/EpicSpawnersHook.java import com.songoda.epicspawners.API.EpicSpawnersAPI; import com.songoda.epicspawners.EpicSpawners; import com.songoda.epicspawners.Spawners.SpawnerChangeEvent; import net.novucs.ftop.hook.event.SpawnerMultiplierChangeEvent; import org.bukkit.ChatColor; import org.bukkit.block.CreatureSpawner; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; } String[] args = spawner.getItemMeta().getDisplayName().split(" "); String lastArg = ChatColor.stripColor(args[args.length - 1]); if (lastArg.length() > 0) { lastArg = lastArg.substring(0, lastArg.length() - 1); } try { return Integer.parseInt(lastArg); } catch (NumberFormatException ex) { return 1; } } @Override public int getStackSize(CreatureSpawner spawner) { if (api == null) { return 1; } return api.getSpawnerMultiplier(spawner.getLocation()); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void updateWorth(SpawnerChangeEvent event) { CreatureSpawner spawner = (CreatureSpawner) event.getSpawner().getState(); int oldMultiplier = event.getOldMulti(); int newMultiplier = event.getCurrentMulti();
SpawnerMultiplierChangeEvent event1 = new SpawnerMultiplierChangeEvent(spawner, oldMultiplier, newMultiplier);
novucs/factions-top
core/src/main/java/net/novucs/ftop/entity/IdentityCache.java
// Path: hook/manager/src/main/java/net/novucs/ftop/WorthType.java // public enum WorthType { // // CHEST, // PLAYER_BALANCE, // FACTION_BALANCE, // SPAWNER, // BLOCK; // // private static final WorthType[] PLACED = {CHEST, SPAWNER, BLOCK}; // // public static WorthType[] getPlaced() { // return PLACED; // } // // public static boolean isPlaced(WorthType worthType) { // switch (worthType) { // case PLAYER_BALANCE: // case FACTION_BALANCE: // return false; // } // return true; // } // } // // Path: core/src/main/java/net/novucs/ftop/util/GenericUtils.java // public final class GenericUtils { // // private GenericUtils() { // } // // public static <E> List<E> castList(Class<? extends E> type, List<?> toCast) throws ClassCastException { // return toCast.stream().map(type::cast).collect(Collectors.toList()); // } // // public static Optional<List> getList(Map<?, ?> input, Object key) { // return getValue(List.class, input, key); // } // // public static Optional<Material> getMaterial(Map<?, ?> input, Object key) { // return getEnum(Material.class, input, key); // } // // public static <T extends Enum<T>> Optional<T> getEnum(Class<T> type, Map<?, ?> input, Object key) { // Optional<String> name = getString(input, key); // if (name.isPresent()) { // return parseEnum(type, name.get()); // } // return Optional.empty(); // } // // public static Optional<Boolean> getBoolean(Map<?, ?> input, Object key) { // return getValue(Boolean.class, input, key); // } // // public static Optional<Integer> getInt(Map<?, ?> input, Object key) { // return getValue(Integer.class, input, key); // } // // public static Optional<String> getString(Map<?, ?> input, Object key) { // return getValue(String.class, input, key); // } // // public static Optional<Map> getMap(Map<?, ?> input, Object key) { // return getValue(Map.class, input, key); // } // // public static <T> Optional<T> getValue(Class<T> clazz, Map<?, ?> input, Object key) { // Object target = input.get(key); // if (target == null || !clazz.isInstance(target)) { // return Optional.empty(); // } // return Optional.of((T) target); // } // // public static <T extends Enum<T>> Optional<T> parseEnum(Class<T> type, String name) { // name = name.toUpperCase().replaceAll("\\s+", "_").replaceAll("\\W", ""); // try { // return Optional.of(Enum.valueOf(type, name)); // } catch (IllegalArgumentException | NullPointerException e) { // return Optional.empty(); // } // } // }
import com.google.common.collect.BiMap; import com.google.common.collect.HashBasedTable; import com.google.common.collect.HashBiMap; import com.google.common.collect.Table; import net.novucs.ftop.WorthType; import net.novucs.ftop.util.GenericUtils; import org.bukkit.Material; import org.bukkit.entity.EntityType; import java.util.Arrays; import java.util.HashSet; import java.util.Optional; import java.util.Set;
return worth.get(new Key<>(name)); } public Integer getFactionMaterialId(String factionId, int materialId) { return factionMaterial.get(factionId, materialId); } public Integer getFactionSpawnerId(String factionId, int spawnerId) { return factionSpawner.get(factionId, spawnerId); } public Integer getFactionWorthId(String factionId, int worthId) { return factionWorth.get(factionId, worthId); } public Integer getBlockId(int worldId, int x, int y, int z) { return block.get(new Key<>(worldId, x, y, z)); } public Integer getSignId(int blockId) { return sign.get(new Key<>(blockId)); } public Optional<String> getWorldName(int worldId) { Key key = world.inverse().get(worldId); return key == null ? Optional.empty() : Optional.of((String) key.getObjects()[0]); } public Optional<Material> getMaterial(int materialId) { Key key = material.inverse().get(materialId);
// Path: hook/manager/src/main/java/net/novucs/ftop/WorthType.java // public enum WorthType { // // CHEST, // PLAYER_BALANCE, // FACTION_BALANCE, // SPAWNER, // BLOCK; // // private static final WorthType[] PLACED = {CHEST, SPAWNER, BLOCK}; // // public static WorthType[] getPlaced() { // return PLACED; // } // // public static boolean isPlaced(WorthType worthType) { // switch (worthType) { // case PLAYER_BALANCE: // case FACTION_BALANCE: // return false; // } // return true; // } // } // // Path: core/src/main/java/net/novucs/ftop/util/GenericUtils.java // public final class GenericUtils { // // private GenericUtils() { // } // // public static <E> List<E> castList(Class<? extends E> type, List<?> toCast) throws ClassCastException { // return toCast.stream().map(type::cast).collect(Collectors.toList()); // } // // public static Optional<List> getList(Map<?, ?> input, Object key) { // return getValue(List.class, input, key); // } // // public static Optional<Material> getMaterial(Map<?, ?> input, Object key) { // return getEnum(Material.class, input, key); // } // // public static <T extends Enum<T>> Optional<T> getEnum(Class<T> type, Map<?, ?> input, Object key) { // Optional<String> name = getString(input, key); // if (name.isPresent()) { // return parseEnum(type, name.get()); // } // return Optional.empty(); // } // // public static Optional<Boolean> getBoolean(Map<?, ?> input, Object key) { // return getValue(Boolean.class, input, key); // } // // public static Optional<Integer> getInt(Map<?, ?> input, Object key) { // return getValue(Integer.class, input, key); // } // // public static Optional<String> getString(Map<?, ?> input, Object key) { // return getValue(String.class, input, key); // } // // public static Optional<Map> getMap(Map<?, ?> input, Object key) { // return getValue(Map.class, input, key); // } // // public static <T> Optional<T> getValue(Class<T> clazz, Map<?, ?> input, Object key) { // Object target = input.get(key); // if (target == null || !clazz.isInstance(target)) { // return Optional.empty(); // } // return Optional.of((T) target); // } // // public static <T extends Enum<T>> Optional<T> parseEnum(Class<T> type, String name) { // name = name.toUpperCase().replaceAll("\\s+", "_").replaceAll("\\W", ""); // try { // return Optional.of(Enum.valueOf(type, name)); // } catch (IllegalArgumentException | NullPointerException e) { // return Optional.empty(); // } // } // } // Path: core/src/main/java/net/novucs/ftop/entity/IdentityCache.java import com.google.common.collect.BiMap; import com.google.common.collect.HashBasedTable; import com.google.common.collect.HashBiMap; import com.google.common.collect.Table; import net.novucs.ftop.WorthType; import net.novucs.ftop.util.GenericUtils; import org.bukkit.Material; import org.bukkit.entity.EntityType; import java.util.Arrays; import java.util.HashSet; import java.util.Optional; import java.util.Set; return worth.get(new Key<>(name)); } public Integer getFactionMaterialId(String factionId, int materialId) { return factionMaterial.get(factionId, materialId); } public Integer getFactionSpawnerId(String factionId, int spawnerId) { return factionSpawner.get(factionId, spawnerId); } public Integer getFactionWorthId(String factionId, int worthId) { return factionWorth.get(factionId, worthId); } public Integer getBlockId(int worldId, int x, int y, int z) { return block.get(new Key<>(worldId, x, y, z)); } public Integer getSignId(int blockId) { return sign.get(new Key<>(blockId)); } public Optional<String> getWorldName(int worldId) { Key key = world.inverse().get(worldId); return key == null ? Optional.empty() : Optional.of((String) key.getObjects()[0]); } public Optional<Material> getMaterial(int materialId) { Key key = material.inverse().get(materialId);
return key == null ? Optional.empty() : GenericUtils.parseEnum(Material.class, (String) key.getObjects()[0]);
novucs/factions-top
core/src/main/java/net/novucs/ftop/entity/IdentityCache.java
// Path: hook/manager/src/main/java/net/novucs/ftop/WorthType.java // public enum WorthType { // // CHEST, // PLAYER_BALANCE, // FACTION_BALANCE, // SPAWNER, // BLOCK; // // private static final WorthType[] PLACED = {CHEST, SPAWNER, BLOCK}; // // public static WorthType[] getPlaced() { // return PLACED; // } // // public static boolean isPlaced(WorthType worthType) { // switch (worthType) { // case PLAYER_BALANCE: // case FACTION_BALANCE: // return false; // } // return true; // } // } // // Path: core/src/main/java/net/novucs/ftop/util/GenericUtils.java // public final class GenericUtils { // // private GenericUtils() { // } // // public static <E> List<E> castList(Class<? extends E> type, List<?> toCast) throws ClassCastException { // return toCast.stream().map(type::cast).collect(Collectors.toList()); // } // // public static Optional<List> getList(Map<?, ?> input, Object key) { // return getValue(List.class, input, key); // } // // public static Optional<Material> getMaterial(Map<?, ?> input, Object key) { // return getEnum(Material.class, input, key); // } // // public static <T extends Enum<T>> Optional<T> getEnum(Class<T> type, Map<?, ?> input, Object key) { // Optional<String> name = getString(input, key); // if (name.isPresent()) { // return parseEnum(type, name.get()); // } // return Optional.empty(); // } // // public static Optional<Boolean> getBoolean(Map<?, ?> input, Object key) { // return getValue(Boolean.class, input, key); // } // // public static Optional<Integer> getInt(Map<?, ?> input, Object key) { // return getValue(Integer.class, input, key); // } // // public static Optional<String> getString(Map<?, ?> input, Object key) { // return getValue(String.class, input, key); // } // // public static Optional<Map> getMap(Map<?, ?> input, Object key) { // return getValue(Map.class, input, key); // } // // public static <T> Optional<T> getValue(Class<T> clazz, Map<?, ?> input, Object key) { // Object target = input.get(key); // if (target == null || !clazz.isInstance(target)) { // return Optional.empty(); // } // return Optional.of((T) target); // } // // public static <T extends Enum<T>> Optional<T> parseEnum(Class<T> type, String name) { // name = name.toUpperCase().replaceAll("\\s+", "_").replaceAll("\\W", ""); // try { // return Optional.of(Enum.valueOf(type, name)); // } catch (IllegalArgumentException | NullPointerException e) { // return Optional.empty(); // } // } // }
import com.google.common.collect.BiMap; import com.google.common.collect.HashBasedTable; import com.google.common.collect.HashBiMap; import com.google.common.collect.Table; import net.novucs.ftop.WorthType; import net.novucs.ftop.util.GenericUtils; import org.bukkit.Material; import org.bukkit.entity.EntityType; import java.util.Arrays; import java.util.HashSet; import java.util.Optional; import java.util.Set;
return factionSpawner.get(factionId, spawnerId); } public Integer getFactionWorthId(String factionId, int worthId) { return factionWorth.get(factionId, worthId); } public Integer getBlockId(int worldId, int x, int y, int z) { return block.get(new Key<>(worldId, x, y, z)); } public Integer getSignId(int blockId) { return sign.get(new Key<>(blockId)); } public Optional<String> getWorldName(int worldId) { Key key = world.inverse().get(worldId); return key == null ? Optional.empty() : Optional.of((String) key.getObjects()[0]); } public Optional<Material> getMaterial(int materialId) { Key key = material.inverse().get(materialId); return key == null ? Optional.empty() : GenericUtils.parseEnum(Material.class, (String) key.getObjects()[0]); } public Optional<EntityType> getSpawner(int spawnerId) { Key key = spawner.inverse().get(spawnerId); return key == null ? Optional.empty() : GenericUtils.parseEnum(EntityType.class, (String) key.getObjects()[0]); }
// Path: hook/manager/src/main/java/net/novucs/ftop/WorthType.java // public enum WorthType { // // CHEST, // PLAYER_BALANCE, // FACTION_BALANCE, // SPAWNER, // BLOCK; // // private static final WorthType[] PLACED = {CHEST, SPAWNER, BLOCK}; // // public static WorthType[] getPlaced() { // return PLACED; // } // // public static boolean isPlaced(WorthType worthType) { // switch (worthType) { // case PLAYER_BALANCE: // case FACTION_BALANCE: // return false; // } // return true; // } // } // // Path: core/src/main/java/net/novucs/ftop/util/GenericUtils.java // public final class GenericUtils { // // private GenericUtils() { // } // // public static <E> List<E> castList(Class<? extends E> type, List<?> toCast) throws ClassCastException { // return toCast.stream().map(type::cast).collect(Collectors.toList()); // } // // public static Optional<List> getList(Map<?, ?> input, Object key) { // return getValue(List.class, input, key); // } // // public static Optional<Material> getMaterial(Map<?, ?> input, Object key) { // return getEnum(Material.class, input, key); // } // // public static <T extends Enum<T>> Optional<T> getEnum(Class<T> type, Map<?, ?> input, Object key) { // Optional<String> name = getString(input, key); // if (name.isPresent()) { // return parseEnum(type, name.get()); // } // return Optional.empty(); // } // // public static Optional<Boolean> getBoolean(Map<?, ?> input, Object key) { // return getValue(Boolean.class, input, key); // } // // public static Optional<Integer> getInt(Map<?, ?> input, Object key) { // return getValue(Integer.class, input, key); // } // // public static Optional<String> getString(Map<?, ?> input, Object key) { // return getValue(String.class, input, key); // } // // public static Optional<Map> getMap(Map<?, ?> input, Object key) { // return getValue(Map.class, input, key); // } // // public static <T> Optional<T> getValue(Class<T> clazz, Map<?, ?> input, Object key) { // Object target = input.get(key); // if (target == null || !clazz.isInstance(target)) { // return Optional.empty(); // } // return Optional.of((T) target); // } // // public static <T extends Enum<T>> Optional<T> parseEnum(Class<T> type, String name) { // name = name.toUpperCase().replaceAll("\\s+", "_").replaceAll("\\W", ""); // try { // return Optional.of(Enum.valueOf(type, name)); // } catch (IllegalArgumentException | NullPointerException e) { // return Optional.empty(); // } // } // } // Path: core/src/main/java/net/novucs/ftop/entity/IdentityCache.java import com.google.common.collect.BiMap; import com.google.common.collect.HashBasedTable; import com.google.common.collect.HashBiMap; import com.google.common.collect.Table; import net.novucs.ftop.WorthType; import net.novucs.ftop.util.GenericUtils; import org.bukkit.Material; import org.bukkit.entity.EntityType; import java.util.Arrays; import java.util.HashSet; import java.util.Optional; import java.util.Set; return factionSpawner.get(factionId, spawnerId); } public Integer getFactionWorthId(String factionId, int worthId) { return factionWorth.get(factionId, worthId); } public Integer getBlockId(int worldId, int x, int y, int z) { return block.get(new Key<>(worldId, x, y, z)); } public Integer getSignId(int blockId) { return sign.get(new Key<>(blockId)); } public Optional<String> getWorldName(int worldId) { Key key = world.inverse().get(worldId); return key == null ? Optional.empty() : Optional.of((String) key.getObjects()[0]); } public Optional<Material> getMaterial(int materialId) { Key key = material.inverse().get(materialId); return key == null ? Optional.empty() : GenericUtils.parseEnum(Material.class, (String) key.getObjects()[0]); } public Optional<EntityType> getSpawner(int spawnerId) { Key key = spawner.inverse().get(spawnerId); return key == null ? Optional.empty() : GenericUtils.parseEnum(EntityType.class, (String) key.getObjects()[0]); }
public Optional<WorthType> getWorthType(int worthId) {
novucs/factions-top
hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionClaimEvent.java
// Path: hook/manager/src/main/java/net/novucs/ftop/entity/ChunkPos.java // public class ChunkPos { // // private final String world; // private final int x; // private final int z; // // public static ChunkPos of(Chunk chunk) { // return new ChunkPos(chunk.getWorld().getName(), chunk.getX(), chunk.getZ()); // } // // public static ChunkPos of(ChunkSnapshot snapshot) { // return new ChunkPos(snapshot.getWorldName(), snapshot.getX(), snapshot.getZ()); // } // // public static ChunkPos of(String world, int x, int z) { // return new ChunkPos(world, x, z); // } // // private ChunkPos(String world, int x, int z) { // this.world = world; // this.x = x; // this.z = z; // } // // public String getWorld() { // return world; // } // // public int getX() { // return x; // } // // public int getZ() { // return z; // } // // public Chunk getChunk(Server server) { // if (server.getWorld(world) == null) return null; // return server.getWorld(world).getChunkAt(x, z); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // ChunkPos chunkPos = (ChunkPos) o; // return x == chunkPos.x && // z == chunkPos.z && // Objects.equals(world, chunkPos.world); // } // // @Override // public int hashCode() { // return Objects.hash(world, x, z); // } // // @Override // public String toString() { // return "ChunkPos{" + // "world='" + world + '\'' + // ", x=" + x + // ", z=" + z + // '}'; // } // }
import com.google.common.collect.Multimap; import net.novucs.ftop.entity.ChunkPos; import org.bukkit.event.HandlerList;
package net.novucs.ftop.hook.event; public class FactionClaimEvent extends FactionEvent { private static final HandlerList handlers = new HandlerList();
// Path: hook/manager/src/main/java/net/novucs/ftop/entity/ChunkPos.java // public class ChunkPos { // // private final String world; // private final int x; // private final int z; // // public static ChunkPos of(Chunk chunk) { // return new ChunkPos(chunk.getWorld().getName(), chunk.getX(), chunk.getZ()); // } // // public static ChunkPos of(ChunkSnapshot snapshot) { // return new ChunkPos(snapshot.getWorldName(), snapshot.getX(), snapshot.getZ()); // } // // public static ChunkPos of(String world, int x, int z) { // return new ChunkPos(world, x, z); // } // // private ChunkPos(String world, int x, int z) { // this.world = world; // this.x = x; // this.z = z; // } // // public String getWorld() { // return world; // } // // public int getX() { // return x; // } // // public int getZ() { // return z; // } // // public Chunk getChunk(Server server) { // if (server.getWorld(world) == null) return null; // return server.getWorld(world).getChunkAt(x, z); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // ChunkPos chunkPos = (ChunkPos) o; // return x == chunkPos.x && // z == chunkPos.z && // Objects.equals(world, chunkPos.world); // } // // @Override // public int hashCode() { // return Objects.hash(world, x, z); // } // // @Override // public String toString() { // return "ChunkPos{" + // "world='" + world + '\'' + // ", x=" + x + // ", z=" + z + // '}'; // } // } // Path: hook/manager/src/main/java/net/novucs/ftop/hook/event/FactionClaimEvent.java import com.google.common.collect.Multimap; import net.novucs.ftop.entity.ChunkPos; import org.bukkit.event.HandlerList; package net.novucs.ftop.hook.event; public class FactionClaimEvent extends FactionEvent { private static final HandlerList handlers = new HandlerList();
private final Multimap<String, ChunkPos> claims;
novucs/factions-top
hook/manager/src/main/java/net/novucs/ftop/hook/FactionsHook.java
// Path: hook/manager/src/main/java/net/novucs/ftop/PluginService.java // public interface PluginService { // // /** // * Initializes the service. // */ // void initialize(); // // /** // * Terminates the service. // */ // void terminate(); // // } // // Path: hook/manager/src/main/java/net/novucs/ftop/entity/ChunkPos.java // public class ChunkPos { // // private final String world; // private final int x; // private final int z; // // public static ChunkPos of(Chunk chunk) { // return new ChunkPos(chunk.getWorld().getName(), chunk.getX(), chunk.getZ()); // } // // public static ChunkPos of(ChunkSnapshot snapshot) { // return new ChunkPos(snapshot.getWorldName(), snapshot.getX(), snapshot.getZ()); // } // // public static ChunkPos of(String world, int x, int z) { // return new ChunkPos(world, x, z); // } // // private ChunkPos(String world, int x, int z) { // this.world = world; // this.x = x; // this.z = z; // } // // public String getWorld() { // return world; // } // // public int getX() { // return x; // } // // public int getZ() { // return z; // } // // public Chunk getChunk(Server server) { // if (server.getWorld(world) == null) return null; // return server.getWorld(world).getChunkAt(x, z); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // ChunkPos chunkPos = (ChunkPos) o; // return x == chunkPos.x && // z == chunkPos.z && // Objects.equals(world, chunkPos.world); // } // // @Override // public int hashCode() { // return Objects.hash(world, x, z); // } // // @Override // public String toString() { // return "ChunkPos{" + // "world='" + world + '\'' + // ", x=" + x + // ", z=" + z + // '}'; // } // }
import net.novucs.ftop.PluginService; import net.novucs.ftop.entity.ChunkPos; import org.bukkit.ChatColor; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; import java.util.List; import java.util.Set; import java.util.UUID;
package net.novucs.ftop.hook; public abstract class FactionsHook implements Listener, PluginService { private final Plugin plugin; public FactionsHook(Plugin plugin) { this.plugin = plugin; } public Plugin getPlugin() { return plugin; } @Override public void initialize() { plugin.getServer().getPluginManager().registerEvents(this, plugin); } @Override public void terminate() { HandlerList.unregisterAll(this); }
// Path: hook/manager/src/main/java/net/novucs/ftop/PluginService.java // public interface PluginService { // // /** // * Initializes the service. // */ // void initialize(); // // /** // * Terminates the service. // */ // void terminate(); // // } // // Path: hook/manager/src/main/java/net/novucs/ftop/entity/ChunkPos.java // public class ChunkPos { // // private final String world; // private final int x; // private final int z; // // public static ChunkPos of(Chunk chunk) { // return new ChunkPos(chunk.getWorld().getName(), chunk.getX(), chunk.getZ()); // } // // public static ChunkPos of(ChunkSnapshot snapshot) { // return new ChunkPos(snapshot.getWorldName(), snapshot.getX(), snapshot.getZ()); // } // // public static ChunkPos of(String world, int x, int z) { // return new ChunkPos(world, x, z); // } // // private ChunkPos(String world, int x, int z) { // this.world = world; // this.x = x; // this.z = z; // } // // public String getWorld() { // return world; // } // // public int getX() { // return x; // } // // public int getZ() { // return z; // } // // public Chunk getChunk(Server server) { // if (server.getWorld(world) == null) return null; // return server.getWorld(world).getChunkAt(x, z); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // ChunkPos chunkPos = (ChunkPos) o; // return x == chunkPos.x && // z == chunkPos.z && // Objects.equals(world, chunkPos.world); // } // // @Override // public int hashCode() { // return Objects.hash(world, x, z); // } // // @Override // public String toString() { // return "ChunkPos{" + // "world='" + world + '\'' + // ", x=" + x + // ", z=" + z + // '}'; // } // } // Path: hook/manager/src/main/java/net/novucs/ftop/hook/FactionsHook.java import net.novucs.ftop.PluginService; import net.novucs.ftop.entity.ChunkPos; import org.bukkit.ChatColor; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; import java.util.List; import java.util.Set; import java.util.UUID; package net.novucs.ftop.hook; public abstract class FactionsHook implements Listener, PluginService { private final Plugin plugin; public FactionsHook(Plugin plugin) { this.plugin = plugin; } public Plugin getPlugin() { return plugin; } @Override public void initialize() { plugin.getServer().getPluginManager().registerEvents(this, plugin); } @Override public void terminate() { HandlerList.unregisterAll(this); }
public String getFactionAt(ChunkPos pos) {
hceylan/guava
guava-testlib/src/com/google/common/collect/testing/google/MapGenerators.java
// Path: guava-testlib/src/com/google/common/collect/testing/SampleElements.java // public class SampleElements<E> { // // TODO: rename e3, e4 => missing1, missing2 // public final E e0; // public final E e1; // public final E e2; // public final E e3; // public final E e4; // // public SampleElements(E e0, E e1, E e2, E e3, E e4) { // this.e0 = e0; // this.e1 = e1; // this.e2 = e2; // this.e3 = e3; // this.e4 = e4; // } // // public static class Strings extends SampleElements<String> { // public Strings() { // // elements aren't sorted, to better test SortedSet iteration ordering // super("b", "a", "c", "d", "e"); // } // // // for testing SortedSet and SortedMap methods // public static final String BEFORE_FIRST = "\0"; // public static final String BEFORE_FIRST_2 = "\0\0"; // public static final String MIN_ELEMENT = "a"; // public static final String AFTER_LAST = "z"; // public static final String AFTER_LAST_2 = "zz"; // } // // public static class Enums extends SampleElements<AnEnum> { // public Enums() { // // elements aren't sorted, to better test SortedSet iteration ordering // super(AnEnum.B, AnEnum.A, AnEnum.C, AnEnum.D, AnEnum.E); // } // } // // public static class Ints extends SampleElements<Integer> { // public Ints() { // // elements aren't sorted, to better test SortedSet iteration ordering // super(1, 0, 2, 3, 4); // } // } // // public static <K, V> SampleElements<Map.Entry<K, V>> mapEntries( // SampleElements<K> keys, SampleElements<V> values) { // return new SampleElements<Map.Entry<K, V>>( // Helpers.mapEntry(keys.e0, values.e0), // Helpers.mapEntry(keys.e1, values.e1), // Helpers.mapEntry(keys.e2, values.e2), // Helpers.mapEntry(keys.e3, values.e3), // Helpers.mapEntry(keys.e4, values.e4)); // } // // public static class Unhashables extends SampleElements<UnhashableObject> { // public Unhashables() { // super(new UnhashableObject(1), // new UnhashableObject(2), // new UnhashableObject(3), // new UnhashableObject(4), // new UnhashableObject(5)); // } // } // // public static class Colliders extends SampleElements<Object> { // public Colliders() { // super(new Collider(1), // new Collider(2), // new Collider(3), // new Collider(4), // new Collider(5)); // } // } // // private static class Collider { // final int value; // // Collider(int value) { // this.value = value; // } // // @Override public boolean equals(Object obj) { // return obj instanceof Collider && ((Collider) obj).value == value; // } // // @Override public int hashCode() { // return 1; // evil! // } // } // }
import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.annotations.GwtCompatible; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.testing.SampleElements; import com.google.common.collect.testing.TestCollectionGenerator; import com.google.common.collect.testing.TestListGenerator; import com.google.common.collect.testing.TestMapEntrySetGenerator; import com.google.common.collect.testing.TestStringMapGenerator; import com.google.common.collect.testing.TestStringSetGenerator; import com.google.common.collect.testing.TestUnhashableCollectionGenerator; import com.google.common.collect.testing.UnhashableObject;
/* * Copyright (C) 2009 The Guava Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.common.collect.testing.google; /** * Generators of different types of map and related collections, such as * keys, entries and values. * * @author Hayward Chan */ @GwtCompatible public class MapGenerators { public static class ImmutableMapGenerator extends TestStringMapGenerator { @Override protected Map<String, String> create(Entry<String, String>[] entries) { Builder<String, String> builder = ImmutableMap.builder(); for (Entry<String, String> entry : entries) { builder.put(entry.getKey(), entry.getValue()); } return builder.build(); } } public static class ImmutableMapKeySetGenerator extends TestStringSetGenerator { @Override protected Set<String> create(String[] elements) { Builder<String, Integer> builder = ImmutableMap.builder(); for (String key : elements) { builder.put(key, 4); } return builder.build().keySet(); } } public static class ImmutableMapValuesGenerator implements TestCollectionGenerator<String> { @Override
// Path: guava-testlib/src/com/google/common/collect/testing/SampleElements.java // public class SampleElements<E> { // // TODO: rename e3, e4 => missing1, missing2 // public final E e0; // public final E e1; // public final E e2; // public final E e3; // public final E e4; // // public SampleElements(E e0, E e1, E e2, E e3, E e4) { // this.e0 = e0; // this.e1 = e1; // this.e2 = e2; // this.e3 = e3; // this.e4 = e4; // } // // public static class Strings extends SampleElements<String> { // public Strings() { // // elements aren't sorted, to better test SortedSet iteration ordering // super("b", "a", "c", "d", "e"); // } // // // for testing SortedSet and SortedMap methods // public static final String BEFORE_FIRST = "\0"; // public static final String BEFORE_FIRST_2 = "\0\0"; // public static final String MIN_ELEMENT = "a"; // public static final String AFTER_LAST = "z"; // public static final String AFTER_LAST_2 = "zz"; // } // // public static class Enums extends SampleElements<AnEnum> { // public Enums() { // // elements aren't sorted, to better test SortedSet iteration ordering // super(AnEnum.B, AnEnum.A, AnEnum.C, AnEnum.D, AnEnum.E); // } // } // // public static class Ints extends SampleElements<Integer> { // public Ints() { // // elements aren't sorted, to better test SortedSet iteration ordering // super(1, 0, 2, 3, 4); // } // } // // public static <K, V> SampleElements<Map.Entry<K, V>> mapEntries( // SampleElements<K> keys, SampleElements<V> values) { // return new SampleElements<Map.Entry<K, V>>( // Helpers.mapEntry(keys.e0, values.e0), // Helpers.mapEntry(keys.e1, values.e1), // Helpers.mapEntry(keys.e2, values.e2), // Helpers.mapEntry(keys.e3, values.e3), // Helpers.mapEntry(keys.e4, values.e4)); // } // // public static class Unhashables extends SampleElements<UnhashableObject> { // public Unhashables() { // super(new UnhashableObject(1), // new UnhashableObject(2), // new UnhashableObject(3), // new UnhashableObject(4), // new UnhashableObject(5)); // } // } // // public static class Colliders extends SampleElements<Object> { // public Colliders() { // super(new Collider(1), // new Collider(2), // new Collider(3), // new Collider(4), // new Collider(5)); // } // } // // private static class Collider { // final int value; // // Collider(int value) { // this.value = value; // } // // @Override public boolean equals(Object obj) { // return obj instanceof Collider && ((Collider) obj).value == value; // } // // @Override public int hashCode() { // return 1; // evil! // } // } // } // Path: guava-testlib/src/com/google/common/collect/testing/google/MapGenerators.java import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.annotations.GwtCompatible; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.testing.SampleElements; import com.google.common.collect.testing.TestCollectionGenerator; import com.google.common.collect.testing.TestListGenerator; import com.google.common.collect.testing.TestMapEntrySetGenerator; import com.google.common.collect.testing.TestStringMapGenerator; import com.google.common.collect.testing.TestStringSetGenerator; import com.google.common.collect.testing.TestUnhashableCollectionGenerator; import com.google.common.collect.testing.UnhashableObject; /* * Copyright (C) 2009 The Guava Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.common.collect.testing.google; /** * Generators of different types of map and related collections, such as * keys, entries and values. * * @author Hayward Chan */ @GwtCompatible public class MapGenerators { public static class ImmutableMapGenerator extends TestStringMapGenerator { @Override protected Map<String, String> create(Entry<String, String>[] entries) { Builder<String, String> builder = ImmutableMap.builder(); for (Entry<String, String> entry : entries) { builder.put(entry.getKey(), entry.getValue()); } return builder.build(); } } public static class ImmutableMapKeySetGenerator extends TestStringSetGenerator { @Override protected Set<String> create(String[] elements) { Builder<String, Integer> builder = ImmutableMap.builder(); for (String key : elements) { builder.put(key, 4); } return builder.build().keySet(); } } public static class ImmutableMapValuesGenerator implements TestCollectionGenerator<String> { @Override
public SampleElements<String> samples() {
hceylan/guava
guava-testlib/src/com/google/common/collect/testing/TestsForMapsInJavaUtil.java
// Path: guava-testlib/src/com/google/common/collect/testing/features/CollectionFeature.java // @SuppressWarnings("unchecked") // public enum CollectionFeature implements Feature<Collection> { // /** // * The collection must not throw {@code NullPointerException} on calls // * such as {@code contains(null)} or {@code remove(null)}, but instead // * must return a simple {@code false}. // */ // ALLOWS_NULL_QUERIES, // // ALLOWS_NULL_VALUES (ALLOWS_NULL_QUERIES), // // /** // * Indicates that a collection disallows certain elements (other than // * {@code null}, whose validity as an element is indicated by the presence // * or absence of {@link #ALLOWS_NULL_VALUES}). // * From the documentation for {@link Collection}: // * <blockquote>"Some collection implementations have restrictions on the // * elements that they may contain. For example, some implementations // * prohibit null elements, and some have restrictions on the types of their // * elements."</blockquote> // */ // RESTRICTS_ELEMENTS, // // /** // * Indicates that a collection has a well-defined ordering of its elements. // * The ordering may depend on the element values, such as a {@link SortedSet}, // * or on the insertion ordering, such as a {@link LinkedHashSet}. All list // * tests automatically specify this feature. // */ // KNOWN_ORDER, // // /** // * Indicates that a collection has a different {@link Object#toString} // * representation than most collections. If not specified, the collection // * tests will examine the value returned by {@link Object#toString}. // */ // NON_STANDARD_TOSTRING, // // /** // * Indicates that the constructor or factory method of a collection, usually // * an immutable set, throws an {@link IllegalArgumentException} when presented // * with duplicate elements instead of collapsing them to a single element or // * including duplicate instances in the collection. // */ // REJECTS_DUPLICATES_AT_CREATION, // // SUPPORTS_ADD, // SUPPORTS_REMOVE, // SUPPORTS_ADD_ALL, // SUPPORTS_REMOVE_ALL, // SUPPORTS_RETAIN_ALL, // SUPPORTS_CLEAR, // FAILS_FAST_ON_CONCURRENT_MODIFICATION, // // /** // * Features supported by general-purpose collections - // * everything but {@link #RESTRICTS_ELEMENTS}. // * @see java.util.Collection the definition of general-purpose collections. // */ // GENERAL_PURPOSE( // SUPPORTS_ADD, // SUPPORTS_REMOVE, // SUPPORTS_ADD_ALL, // SUPPORTS_REMOVE_ALL, // SUPPORTS_RETAIN_ALL, // SUPPORTS_CLEAR), // // /** Features supported by collections where only removal is allowed. */ // REMOVE_OPERATIONS( // SUPPORTS_REMOVE, // SUPPORTS_REMOVE_ALL, // SUPPORTS_RETAIN_ALL, // SUPPORTS_CLEAR), // // SERIALIZABLE, SERIALIZABLE_INCLUDING_VIEWS(SERIALIZABLE), // // /** // * For documenting collections that support no optional features, such as // * {@link java.util.Collections#emptySet} // */ // NONE(); // // private final Set<Feature<? super Collection>> implied; // // CollectionFeature(Feature<? super Collection> ... implied) { // this.implied = Helpers.copyToSet(implied); // } // // @Override // public Set<Feature<? super Collection>> getImpliedFeatures() { // return implied; // } // // @Retention(RetentionPolicy.RUNTIME) // @Inherited // @TesterAnnotation // public @interface Require { // CollectionFeature[] value() default {}; // CollectionFeature[] absent() default {}; // } // }
import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import com.google.common.collect.testing.features.CollectionFeature; import com.google.common.collect.testing.features.CollectionSize; import com.google.common.collect.testing.features.MapFeature; import junit.framework.Test; import junit.framework.TestSuite; import java.io.Serializable; import java.lang.reflect.Method; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.EnumMap; import java.util.HashMap;
} protected Collection<Method> suppressForSingletonMap() { return Collections.emptySet(); } protected Collection<Method> suppressForHashMap() { return Collections.emptySet(); } protected Collection<Method> suppressForLinkedHashMap() { return Collections.emptySet(); } protected Collection<Method> suppressForTreeMap() { return Collections.emptySet(); } protected Collection<Method> suppressForEnumMap() { return Collections.emptySet(); } protected Collection<Method> suppressForConcurrentHashMap() { return Collections.emptySet(); } public Test testsForEmptyMap() { return MapTestSuiteBuilder .using(new TestStringMapGenerator() { @Override protected Map<String, String> create( Entry<String, String>[] entries) { return Collections.emptyMap(); } }) .named("emptyMap") .withFeatures(
// Path: guava-testlib/src/com/google/common/collect/testing/features/CollectionFeature.java // @SuppressWarnings("unchecked") // public enum CollectionFeature implements Feature<Collection> { // /** // * The collection must not throw {@code NullPointerException} on calls // * such as {@code contains(null)} or {@code remove(null)}, but instead // * must return a simple {@code false}. // */ // ALLOWS_NULL_QUERIES, // // ALLOWS_NULL_VALUES (ALLOWS_NULL_QUERIES), // // /** // * Indicates that a collection disallows certain elements (other than // * {@code null}, whose validity as an element is indicated by the presence // * or absence of {@link #ALLOWS_NULL_VALUES}). // * From the documentation for {@link Collection}: // * <blockquote>"Some collection implementations have restrictions on the // * elements that they may contain. For example, some implementations // * prohibit null elements, and some have restrictions on the types of their // * elements."</blockquote> // */ // RESTRICTS_ELEMENTS, // // /** // * Indicates that a collection has a well-defined ordering of its elements. // * The ordering may depend on the element values, such as a {@link SortedSet}, // * or on the insertion ordering, such as a {@link LinkedHashSet}. All list // * tests automatically specify this feature. // */ // KNOWN_ORDER, // // /** // * Indicates that a collection has a different {@link Object#toString} // * representation than most collections. If not specified, the collection // * tests will examine the value returned by {@link Object#toString}. // */ // NON_STANDARD_TOSTRING, // // /** // * Indicates that the constructor or factory method of a collection, usually // * an immutable set, throws an {@link IllegalArgumentException} when presented // * with duplicate elements instead of collapsing them to a single element or // * including duplicate instances in the collection. // */ // REJECTS_DUPLICATES_AT_CREATION, // // SUPPORTS_ADD, // SUPPORTS_REMOVE, // SUPPORTS_ADD_ALL, // SUPPORTS_REMOVE_ALL, // SUPPORTS_RETAIN_ALL, // SUPPORTS_CLEAR, // FAILS_FAST_ON_CONCURRENT_MODIFICATION, // // /** // * Features supported by general-purpose collections - // * everything but {@link #RESTRICTS_ELEMENTS}. // * @see java.util.Collection the definition of general-purpose collections. // */ // GENERAL_PURPOSE( // SUPPORTS_ADD, // SUPPORTS_REMOVE, // SUPPORTS_ADD_ALL, // SUPPORTS_REMOVE_ALL, // SUPPORTS_RETAIN_ALL, // SUPPORTS_CLEAR), // // /** Features supported by collections where only removal is allowed. */ // REMOVE_OPERATIONS( // SUPPORTS_REMOVE, // SUPPORTS_REMOVE_ALL, // SUPPORTS_RETAIN_ALL, // SUPPORTS_CLEAR), // // SERIALIZABLE, SERIALIZABLE_INCLUDING_VIEWS(SERIALIZABLE), // // /** // * For documenting collections that support no optional features, such as // * {@link java.util.Collections#emptySet} // */ // NONE(); // // private final Set<Feature<? super Collection>> implied; // // CollectionFeature(Feature<? super Collection> ... implied) { // this.implied = Helpers.copyToSet(implied); // } // // @Override // public Set<Feature<? super Collection>> getImpliedFeatures() { // return implied; // } // // @Retention(RetentionPolicy.RUNTIME) // @Inherited // @TesterAnnotation // public @interface Require { // CollectionFeature[] value() default {}; // CollectionFeature[] absent() default {}; // } // } // Path: guava-testlib/src/com/google/common/collect/testing/TestsForMapsInJavaUtil.java import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import com.google.common.collect.testing.features.CollectionFeature; import com.google.common.collect.testing.features.CollectionSize; import com.google.common.collect.testing.features.MapFeature; import junit.framework.Test; import junit.framework.TestSuite; import java.io.Serializable; import java.lang.reflect.Method; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.EnumMap; import java.util.HashMap; } protected Collection<Method> suppressForSingletonMap() { return Collections.emptySet(); } protected Collection<Method> suppressForHashMap() { return Collections.emptySet(); } protected Collection<Method> suppressForLinkedHashMap() { return Collections.emptySet(); } protected Collection<Method> suppressForTreeMap() { return Collections.emptySet(); } protected Collection<Method> suppressForEnumMap() { return Collections.emptySet(); } protected Collection<Method> suppressForConcurrentHashMap() { return Collections.emptySet(); } public Test testsForEmptyMap() { return MapTestSuiteBuilder .using(new TestStringMapGenerator() { @Override protected Map<String, String> create( Entry<String, String>[] entries) { return Collections.emptyMap(); } }) .named("emptyMap") .withFeatures(
CollectionFeature.SERIALIZABLE,
hceylan/guava
guava-testlib/src/com/google/common/collect/testing/MapTestSuiteBuilder.java
// Path: guava-testlib/src/com/google/common/collect/testing/features/CollectionFeature.java // @SuppressWarnings("unchecked") // public enum CollectionFeature implements Feature<Collection> { // /** // * The collection must not throw {@code NullPointerException} on calls // * such as {@code contains(null)} or {@code remove(null)}, but instead // * must return a simple {@code false}. // */ // ALLOWS_NULL_QUERIES, // // ALLOWS_NULL_VALUES (ALLOWS_NULL_QUERIES), // // /** // * Indicates that a collection disallows certain elements (other than // * {@code null}, whose validity as an element is indicated by the presence // * or absence of {@link #ALLOWS_NULL_VALUES}). // * From the documentation for {@link Collection}: // * <blockquote>"Some collection implementations have restrictions on the // * elements that they may contain. For example, some implementations // * prohibit null elements, and some have restrictions on the types of their // * elements."</blockquote> // */ // RESTRICTS_ELEMENTS, // // /** // * Indicates that a collection has a well-defined ordering of its elements. // * The ordering may depend on the element values, such as a {@link SortedSet}, // * or on the insertion ordering, such as a {@link LinkedHashSet}. All list // * tests automatically specify this feature. // */ // KNOWN_ORDER, // // /** // * Indicates that a collection has a different {@link Object#toString} // * representation than most collections. If not specified, the collection // * tests will examine the value returned by {@link Object#toString}. // */ // NON_STANDARD_TOSTRING, // // /** // * Indicates that the constructor or factory method of a collection, usually // * an immutable set, throws an {@link IllegalArgumentException} when presented // * with duplicate elements instead of collapsing them to a single element or // * including duplicate instances in the collection. // */ // REJECTS_DUPLICATES_AT_CREATION, // // SUPPORTS_ADD, // SUPPORTS_REMOVE, // SUPPORTS_ADD_ALL, // SUPPORTS_REMOVE_ALL, // SUPPORTS_RETAIN_ALL, // SUPPORTS_CLEAR, // FAILS_FAST_ON_CONCURRENT_MODIFICATION, // // /** // * Features supported by general-purpose collections - // * everything but {@link #RESTRICTS_ELEMENTS}. // * @see java.util.Collection the definition of general-purpose collections. // */ // GENERAL_PURPOSE( // SUPPORTS_ADD, // SUPPORTS_REMOVE, // SUPPORTS_ADD_ALL, // SUPPORTS_REMOVE_ALL, // SUPPORTS_RETAIN_ALL, // SUPPORTS_CLEAR), // // /** Features supported by collections where only removal is allowed. */ // REMOVE_OPERATIONS( // SUPPORTS_REMOVE, // SUPPORTS_REMOVE_ALL, // SUPPORTS_RETAIN_ALL, // SUPPORTS_CLEAR), // // SERIALIZABLE, SERIALIZABLE_INCLUDING_VIEWS(SERIALIZABLE), // // /** // * For documenting collections that support no optional features, such as // * {@link java.util.Collections#emptySet} // */ // NONE(); // // private final Set<Feature<? super Collection>> implied; // // CollectionFeature(Feature<? super Collection> ... implied) { // this.implied = Helpers.copyToSet(implied); // } // // @Override // public Set<Feature<? super Collection>> getImpliedFeatures() { // return implied; // } // // @Retention(RetentionPolicy.RUNTIME) // @Inherited // @TesterAnnotation // public @interface Require { // CollectionFeature[] value() default {}; // CollectionFeature[] absent() default {}; // } // }
import com.google.common.collect.testing.features.CollectionFeature; import com.google.common.collect.testing.features.CollectionSize; import com.google.common.collect.testing.features.Feature; import com.google.common.collect.testing.features.MapFeature; import com.google.common.collect.testing.testers.MapClearTester; import com.google.common.collect.testing.testers.MapContainsKeyTester; import com.google.common.collect.testing.testers.MapContainsValueTester; import com.google.common.collect.testing.testers.MapCreationTester; import com.google.common.collect.testing.testers.MapEqualsTester; import com.google.common.collect.testing.testers.MapGetTester; import com.google.common.collect.testing.testers.MapHashCodeTester; import com.google.common.collect.testing.testers.MapIsEmptyTester; import com.google.common.collect.testing.testers.MapPutAllTester; import com.google.common.collect.testing.testers.MapPutTester; import com.google.common.collect.testing.testers.MapRemoveTester; import com.google.common.collect.testing.testers.MapSerializationTester; import com.google.common.collect.testing.testers.MapSizeTester; import com.google.common.testing.SerializableTester; import junit.framework.TestSuite; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set;
@Override protected List<Class<? extends AbstractTester>> getTesters() { return Arrays.<Class<? extends AbstractTester>>asList( MapClearTester.class, MapContainsKeyTester.class, MapContainsValueTester.class, MapCreationTester.class, MapEqualsTester.class, MapGetTester.class, MapHashCodeTester.class, MapIsEmptyTester.class, MapPutTester.class, MapPutAllTester.class, MapRemoveTester.class, MapSerializationTester.class, MapSizeTester.class ); } @Override protected List<TestSuite> createDerivedSuites( FeatureSpecificTestSuiteBuilder< ?, ? extends OneSizeTestContainerGenerator<Map<K, V>, Map.Entry<K, V>>> parentBuilder) { // TODO: Once invariant support is added, supply invariants to each of the // derived suites, to check that mutations to the derived collections are // reflected in the underlying map. List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
// Path: guava-testlib/src/com/google/common/collect/testing/features/CollectionFeature.java // @SuppressWarnings("unchecked") // public enum CollectionFeature implements Feature<Collection> { // /** // * The collection must not throw {@code NullPointerException} on calls // * such as {@code contains(null)} or {@code remove(null)}, but instead // * must return a simple {@code false}. // */ // ALLOWS_NULL_QUERIES, // // ALLOWS_NULL_VALUES (ALLOWS_NULL_QUERIES), // // /** // * Indicates that a collection disallows certain elements (other than // * {@code null}, whose validity as an element is indicated by the presence // * or absence of {@link #ALLOWS_NULL_VALUES}). // * From the documentation for {@link Collection}: // * <blockquote>"Some collection implementations have restrictions on the // * elements that they may contain. For example, some implementations // * prohibit null elements, and some have restrictions on the types of their // * elements."</blockquote> // */ // RESTRICTS_ELEMENTS, // // /** // * Indicates that a collection has a well-defined ordering of its elements. // * The ordering may depend on the element values, such as a {@link SortedSet}, // * or on the insertion ordering, such as a {@link LinkedHashSet}. All list // * tests automatically specify this feature. // */ // KNOWN_ORDER, // // /** // * Indicates that a collection has a different {@link Object#toString} // * representation than most collections. If not specified, the collection // * tests will examine the value returned by {@link Object#toString}. // */ // NON_STANDARD_TOSTRING, // // /** // * Indicates that the constructor or factory method of a collection, usually // * an immutable set, throws an {@link IllegalArgumentException} when presented // * with duplicate elements instead of collapsing them to a single element or // * including duplicate instances in the collection. // */ // REJECTS_DUPLICATES_AT_CREATION, // // SUPPORTS_ADD, // SUPPORTS_REMOVE, // SUPPORTS_ADD_ALL, // SUPPORTS_REMOVE_ALL, // SUPPORTS_RETAIN_ALL, // SUPPORTS_CLEAR, // FAILS_FAST_ON_CONCURRENT_MODIFICATION, // // /** // * Features supported by general-purpose collections - // * everything but {@link #RESTRICTS_ELEMENTS}. // * @see java.util.Collection the definition of general-purpose collections. // */ // GENERAL_PURPOSE( // SUPPORTS_ADD, // SUPPORTS_REMOVE, // SUPPORTS_ADD_ALL, // SUPPORTS_REMOVE_ALL, // SUPPORTS_RETAIN_ALL, // SUPPORTS_CLEAR), // // /** Features supported by collections where only removal is allowed. */ // REMOVE_OPERATIONS( // SUPPORTS_REMOVE, // SUPPORTS_REMOVE_ALL, // SUPPORTS_RETAIN_ALL, // SUPPORTS_CLEAR), // // SERIALIZABLE, SERIALIZABLE_INCLUDING_VIEWS(SERIALIZABLE), // // /** // * For documenting collections that support no optional features, such as // * {@link java.util.Collections#emptySet} // */ // NONE(); // // private final Set<Feature<? super Collection>> implied; // // CollectionFeature(Feature<? super Collection> ... implied) { // this.implied = Helpers.copyToSet(implied); // } // // @Override // public Set<Feature<? super Collection>> getImpliedFeatures() { // return implied; // } // // @Retention(RetentionPolicy.RUNTIME) // @Inherited // @TesterAnnotation // public @interface Require { // CollectionFeature[] value() default {}; // CollectionFeature[] absent() default {}; // } // } // Path: guava-testlib/src/com/google/common/collect/testing/MapTestSuiteBuilder.java import com.google.common.collect.testing.features.CollectionFeature; import com.google.common.collect.testing.features.CollectionSize; import com.google.common.collect.testing.features.Feature; import com.google.common.collect.testing.features.MapFeature; import com.google.common.collect.testing.testers.MapClearTester; import com.google.common.collect.testing.testers.MapContainsKeyTester; import com.google.common.collect.testing.testers.MapContainsValueTester; import com.google.common.collect.testing.testers.MapCreationTester; import com.google.common.collect.testing.testers.MapEqualsTester; import com.google.common.collect.testing.testers.MapGetTester; import com.google.common.collect.testing.testers.MapHashCodeTester; import com.google.common.collect.testing.testers.MapIsEmptyTester; import com.google.common.collect.testing.testers.MapPutAllTester; import com.google.common.collect.testing.testers.MapPutTester; import com.google.common.collect.testing.testers.MapRemoveTester; import com.google.common.collect.testing.testers.MapSerializationTester; import com.google.common.collect.testing.testers.MapSizeTester; import com.google.common.testing.SerializableTester; import junit.framework.TestSuite; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @Override protected List<Class<? extends AbstractTester>> getTesters() { return Arrays.<Class<? extends AbstractTester>>asList( MapClearTester.class, MapContainsKeyTester.class, MapContainsValueTester.class, MapCreationTester.class, MapEqualsTester.class, MapGetTester.class, MapHashCodeTester.class, MapIsEmptyTester.class, MapPutTester.class, MapPutAllTester.class, MapRemoveTester.class, MapSerializationTester.class, MapSizeTester.class ); } @Override protected List<TestSuite> createDerivedSuites( FeatureSpecificTestSuiteBuilder< ?, ? extends OneSizeTestContainerGenerator<Map<K, V>, Map.Entry<K, V>>> parentBuilder) { // TODO: Once invariant support is added, supply invariants to each of the // derived suites, to check that mutations to the derived collections are // reflected in the underlying map. List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
if (parentBuilder.getFeatures().contains(CollectionFeature.SERIALIZABLE)) {
hceylan/guava
guava/src/com/google/common/collect/MapMakerInternalMap.java
// Path: guava/src/com/google/common/collect/MapMaker.java // enum RemovalCause { // /** // * The entry was manually removed by the user. This can result from the user invoking // * {@link Map#remove}, {@link ConcurrentMap#remove}, or {@link java.util.Iterator#remove}. // */ // EXPLICIT { // @Override // boolean wasEvicted() { // return false; // } // }, // // /** // * The entry itself was not actually removed, but its value was replaced by the user. This can // * result from the user invoking {@link Map#put}, {@link Map#putAll}, // * {@link ConcurrentMap#replace(Object, Object)}, or // * {@link ConcurrentMap#replace(Object, Object, Object)}. // */ // REPLACED { // @Override // boolean wasEvicted() { // return false; // } // }, // // /** // * The entry was removed automatically because its key or value was garbage-collected. This // * can occur when using {@link #softKeys}, {@link #softValues}, {@link #weakKeys}, or {@link // * #weakValues}. // */ // COLLECTED { // @Override // boolean wasEvicted() { // return true; // } // }, // // /** // * The entry's expiration timestamp has passed. This can occur when using {@link // * #expireAfterWrite} or {@link #expireAfterAccess}. // */ // EXPIRED { // @Override // boolean wasEvicted() { // return true; // } // }, // // /** // * The entry was evicted due to size constraints. This can occur when using {@link // * #maximumSize}. // */ // SIZE { // @Override // boolean wasEvicted() { // return true; // } // }; // // /** // * Returns {@code true} if there was an automatic removal due to eviction (the cause is neither // * {@link #EXPLICIT} nor {@link #REPLACED}). // */ // abstract boolean wasEvicted(); // } // // Path: guava/src/com/google/common/collect/MapMaker.java // interface RemovalListener<K, V> { // /** // * Notifies the listener that a removal occurred at some point in the past. // */ // void onRemoval(RemovalNotification<K, V> notification); // } // // Path: guava/src/com/google/common/collect/MapMaker.java // static final class RemovalNotification<K, V> extends ImmutableEntry<K, V> { // private static final long serialVersionUID = 0; // // private final RemovalCause cause; // // RemovalNotification(@Nullable K key, @Nullable V value, RemovalCause cause) { // super(key, value); // this.cause = cause; // } // // /** // * Returns the cause for which the entry was removed. // */ // public RemovalCause getCause() { // return cause; // } // // /** // * Returns {@code true} if there was an automatic removal due to eviction (the cause is neither // * {@link RemovalCause#EXPLICIT} nor {@link RemovalCause#REPLACED}). // */ // public boolean wasEvicted() { // return cause.wasEvicted(); // } // }
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Equivalence; import com.google.common.base.Equivalences; import com.google.common.base.Ticker; import com.google.common.collect.GenericMapMaker.NullListener; import com.google.common.collect.MapMaker.RemovalCause; import com.google.common.collect.MapMaker.RemovalListener; import com.google.common.collect.MapMaker.RemovalNotification; import com.google.common.primitives.Ints; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; import java.lang.ref.SoftReference; import java.lang.ref.WeakReference; import java.util.AbstractCollection; import java.util.AbstractMap; import java.util.AbstractQueue; import java.util.AbstractSet; import java.util.Collection; import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; import java.util.Queue; import java.util.Set; import java.util.concurrent.CancellationException; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReferenceArray; import java.util.concurrent.locks.ReentrantLock; import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy;
// might overflow, but that's okay (see isExpired()) entry.setExpirationTime(map.ticker.read() + expirationNanos); } /** * Cleanup expired entries when the lock is available. */ void tryExpireEntries() { if (tryLock()) { try { expireEntries(); } finally { unlock(); // don't call postWriteCleanup as we're in a read } } } @GuardedBy("Segment.this") void expireEntries() { drainRecencyQueue(); if (expirationQueue.isEmpty()) { // There's no point in calling nanoTime() if we have no entries to // expire. return; } long now = map.ticker.read(); ReferenceEntry<K, V> e; while ((e = expirationQueue.peek()) != null && map.isExpired(e, now)) {
// Path: guava/src/com/google/common/collect/MapMaker.java // enum RemovalCause { // /** // * The entry was manually removed by the user. This can result from the user invoking // * {@link Map#remove}, {@link ConcurrentMap#remove}, or {@link java.util.Iterator#remove}. // */ // EXPLICIT { // @Override // boolean wasEvicted() { // return false; // } // }, // // /** // * The entry itself was not actually removed, but its value was replaced by the user. This can // * result from the user invoking {@link Map#put}, {@link Map#putAll}, // * {@link ConcurrentMap#replace(Object, Object)}, or // * {@link ConcurrentMap#replace(Object, Object, Object)}. // */ // REPLACED { // @Override // boolean wasEvicted() { // return false; // } // }, // // /** // * The entry was removed automatically because its key or value was garbage-collected. This // * can occur when using {@link #softKeys}, {@link #softValues}, {@link #weakKeys}, or {@link // * #weakValues}. // */ // COLLECTED { // @Override // boolean wasEvicted() { // return true; // } // }, // // /** // * The entry's expiration timestamp has passed. This can occur when using {@link // * #expireAfterWrite} or {@link #expireAfterAccess}. // */ // EXPIRED { // @Override // boolean wasEvicted() { // return true; // } // }, // // /** // * The entry was evicted due to size constraints. This can occur when using {@link // * #maximumSize}. // */ // SIZE { // @Override // boolean wasEvicted() { // return true; // } // }; // // /** // * Returns {@code true} if there was an automatic removal due to eviction (the cause is neither // * {@link #EXPLICIT} nor {@link #REPLACED}). // */ // abstract boolean wasEvicted(); // } // // Path: guava/src/com/google/common/collect/MapMaker.java // interface RemovalListener<K, V> { // /** // * Notifies the listener that a removal occurred at some point in the past. // */ // void onRemoval(RemovalNotification<K, V> notification); // } // // Path: guava/src/com/google/common/collect/MapMaker.java // static final class RemovalNotification<K, V> extends ImmutableEntry<K, V> { // private static final long serialVersionUID = 0; // // private final RemovalCause cause; // // RemovalNotification(@Nullable K key, @Nullable V value, RemovalCause cause) { // super(key, value); // this.cause = cause; // } // // /** // * Returns the cause for which the entry was removed. // */ // public RemovalCause getCause() { // return cause; // } // // /** // * Returns {@code true} if there was an automatic removal due to eviction (the cause is neither // * {@link RemovalCause#EXPLICIT} nor {@link RemovalCause#REPLACED}). // */ // public boolean wasEvicted() { // return cause.wasEvicted(); // } // } // Path: guava/src/com/google/common/collect/MapMakerInternalMap.java import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Equivalence; import com.google.common.base.Equivalences; import com.google.common.base.Ticker; import com.google.common.collect.GenericMapMaker.NullListener; import com.google.common.collect.MapMaker.RemovalCause; import com.google.common.collect.MapMaker.RemovalListener; import com.google.common.collect.MapMaker.RemovalNotification; import com.google.common.primitives.Ints; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; import java.lang.ref.SoftReference; import java.lang.ref.WeakReference; import java.util.AbstractCollection; import java.util.AbstractMap; import java.util.AbstractQueue; import java.util.AbstractSet; import java.util.Collection; import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; import java.util.Queue; import java.util.Set; import java.util.concurrent.CancellationException; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReferenceArray; import java.util.concurrent.locks.ReentrantLock; import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy; // might overflow, but that's okay (see isExpired()) entry.setExpirationTime(map.ticker.read() + expirationNanos); } /** * Cleanup expired entries when the lock is available. */ void tryExpireEntries() { if (tryLock()) { try { expireEntries(); } finally { unlock(); // don't call postWriteCleanup as we're in a read } } } @GuardedBy("Segment.this") void expireEntries() { drainRecencyQueue(); if (expirationQueue.isEmpty()) { // There's no point in calling nanoTime() if we have no entries to // expire. return; } long now = map.ticker.read(); ReferenceEntry<K, V> e; while ((e = expirationQueue.peek()) != null && map.isExpired(e, now)) {
if (!removeEntry(e, e.getHash(), RemovalCause.EXPIRED)) {
k3b/ToGoZip
libK3bAndroidZip/src/main/java/de/k3b/android/MediaUtil.java
// Path: libK3b/src/main/java/de/k3b/io/FileNameUtil.java // public class FileNameUtil { // // /** // * converts baseName to a valid filename by replacing illegal chars. // * If it has no file-extension then defaultExtension is added // * // * @param defaultExtension the new extension, excluding the dot. null means no extension. // */ // public static String createFileName(String baseName, String defaultExtension) { // StringBuilder result = new StringBuilder(baseName); // // // remove trailing "." // int len = result.length(); // while ((len > 0) && (result.charAt(len - 1) == '.')) { // result.deleteCharAt(len - 1); // len--; // } // // // remove leading "." // while ((len > 0) && (result.charAt(0) == '.')) { // result.deleteCharAt(0); // len--; // } // // // add extension if there is none // if ((defaultExtension != null) && (result.indexOf(".") < 0)) { // result.append(".").append(defaultExtension); // } // // // replace illegal chars with "_" // replace(result, "_", "/", "\\", ":", " ", "?", "*", "&", "%", ">", "<", "|", "'", "\"", "__"); // return result.toString(); // } // // /** // * converts baseName to a valid filename by replacing illegal chars. // */ // public static String createFileNameWitoutExtension(String fileNameCandidate) { // if (fileNameCandidate != null) { // // remove illegal chars or file extension // return FileNameUtil.createFileName(FileUtils.replaceExtension(fileNameCandidate, ""), null); // } // return null; // } // // public static String getWithoutWildcard(String path) { // if ((path == null) || (path.length() == 0)) return null; // if (path.endsWith("%")) { // // remove sql wildcard at end of name // return path.substring(0, path.length() - 1); // } // return path; // } // // /** // * converts filePath to a valid path by removing potential sql-wildcards and android specigic "//" // */ // public static String fixPath(String filePath) { // String path = FileNameUtil.getWithoutWildcard(FileUtils.fixPath(filePath)); // return path; // } // // /** replaces all occurences of illegalValues in result by replacement */ // private static void replace(StringBuilder result, String replacement, String ... illegalValues) { // for (String illegalValue : illegalValues) { // int found = result.indexOf(illegalValue); // while (found >= 0) { // result.replace(found, found+illegalValue.length(), replacement); // found = result.indexOf(illegalValue); // } // } // } // // // /** // * so that files are comparable // */ // public static String getCanonicalPath(File zipRelPath) { // File canonicalFile = FileUtils.tryGetCanonicalFile(zipRelPath); // if (canonicalFile != null) { // return FileUtils.fixPath(canonicalFile.getAbsolutePath()); // } // return null; // } // // /** // * @return either srcFile without leading relativeToPath or null if srcFile is not relative to relativeToPath // */ // public static String makePathRelative(String relativeToPath, File srcFile) { // String result = null; // if (!StringUtils.isNullOrEmpty(relativeToPath)) { // String srcPath = getCanonicalPath(srcFile); // boolean match = srcPath.toLowerCase().startsWith(relativeToPath); // if (match) { // result = srcPath.substring(relativeToPath.length() + 1); // } // } // return result; // } // }
import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.provider.MediaStore; import android.webkit.MimeTypeMap; import de.k3b.io.FileNameUtil;
/* Input: URI -- something like content://com.example.app.provider/table2/dataset1 Output: PATH -- something like /sdcard/DCIM/123242-image.jpg */ public static String convertMediaUriToPath(Context context, Uri uri) { return getString(context, uri, MediaStore.Images.Media.DATA); } /* Input: URI -- something like content://com.example.app.provider/table2/dataset1 Output: 0 or date */ public static long getDateModified(Context context, Uri uri) { return getLong(context, uri, MediaStore.Images.Media.DATE_MODIFIED); } /* Input: URI -- something like content://com.example.app.provider/table2/dataset1 Output: null or filename (with or without path) */ public static String getFileName(Context context, Uri uri, String mimeType) { String baseName = getString(context, uri, MediaStore.Images.Media.DISPLAY_NAME); if ((baseName == null) || (baseName.length() == 0)) { baseName = uri.getLastPathSegment(); // "content://com.mediatek.calendarimporter/1282" becomes "calendarimporter_1282" } String defaultFileExtension = (mimeType != null) ? MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType) : null;
// Path: libK3b/src/main/java/de/k3b/io/FileNameUtil.java // public class FileNameUtil { // // /** // * converts baseName to a valid filename by replacing illegal chars. // * If it has no file-extension then defaultExtension is added // * // * @param defaultExtension the new extension, excluding the dot. null means no extension. // */ // public static String createFileName(String baseName, String defaultExtension) { // StringBuilder result = new StringBuilder(baseName); // // // remove trailing "." // int len = result.length(); // while ((len > 0) && (result.charAt(len - 1) == '.')) { // result.deleteCharAt(len - 1); // len--; // } // // // remove leading "." // while ((len > 0) && (result.charAt(0) == '.')) { // result.deleteCharAt(0); // len--; // } // // // add extension if there is none // if ((defaultExtension != null) && (result.indexOf(".") < 0)) { // result.append(".").append(defaultExtension); // } // // // replace illegal chars with "_" // replace(result, "_", "/", "\\", ":", " ", "?", "*", "&", "%", ">", "<", "|", "'", "\"", "__"); // return result.toString(); // } // // /** // * converts baseName to a valid filename by replacing illegal chars. // */ // public static String createFileNameWitoutExtension(String fileNameCandidate) { // if (fileNameCandidate != null) { // // remove illegal chars or file extension // return FileNameUtil.createFileName(FileUtils.replaceExtension(fileNameCandidate, ""), null); // } // return null; // } // // public static String getWithoutWildcard(String path) { // if ((path == null) || (path.length() == 0)) return null; // if (path.endsWith("%")) { // // remove sql wildcard at end of name // return path.substring(0, path.length() - 1); // } // return path; // } // // /** // * converts filePath to a valid path by removing potential sql-wildcards and android specigic "//" // */ // public static String fixPath(String filePath) { // String path = FileNameUtil.getWithoutWildcard(FileUtils.fixPath(filePath)); // return path; // } // // /** replaces all occurences of illegalValues in result by replacement */ // private static void replace(StringBuilder result, String replacement, String ... illegalValues) { // for (String illegalValue : illegalValues) { // int found = result.indexOf(illegalValue); // while (found >= 0) { // result.replace(found, found+illegalValue.length(), replacement); // found = result.indexOf(illegalValue); // } // } // } // // // /** // * so that files are comparable // */ // public static String getCanonicalPath(File zipRelPath) { // File canonicalFile = FileUtils.tryGetCanonicalFile(zipRelPath); // if (canonicalFile != null) { // return FileUtils.fixPath(canonicalFile.getAbsolutePath()); // } // return null; // } // // /** // * @return either srcFile without leading relativeToPath or null if srcFile is not relative to relativeToPath // */ // public static String makePathRelative(String relativeToPath, File srcFile) { // String result = null; // if (!StringUtils.isNullOrEmpty(relativeToPath)) { // String srcPath = getCanonicalPath(srcFile); // boolean match = srcPath.toLowerCase().startsWith(relativeToPath); // if (match) { // result = srcPath.substring(relativeToPath.length() + 1); // } // } // return result; // } // } // Path: libK3bAndroidZip/src/main/java/de/k3b/android/MediaUtil.java import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.provider.MediaStore; import android.webkit.MimeTypeMap; import de.k3b.io.FileNameUtil; /* Input: URI -- something like content://com.example.app.provider/table2/dataset1 Output: PATH -- something like /sdcard/DCIM/123242-image.jpg */ public static String convertMediaUriToPath(Context context, Uri uri) { return getString(context, uri, MediaStore.Images.Media.DATA); } /* Input: URI -- something like content://com.example.app.provider/table2/dataset1 Output: 0 or date */ public static long getDateModified(Context context, Uri uri) { return getLong(context, uri, MediaStore.Images.Media.DATE_MODIFIED); } /* Input: URI -- something like content://com.example.app.provider/table2/dataset1 Output: null or filename (with or without path) */ public static String getFileName(Context context, Uri uri, String mimeType) { String baseName = getString(context, uri, MediaStore.Images.Media.DISPLAY_NAME); if ((baseName == null) || (baseName.length() == 0)) { baseName = uri.getLastPathSegment(); // "content://com.mediatek.calendarimporter/1282" becomes "calendarimporter_1282" } String defaultFileExtension = (mimeType != null) ? MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType) : null;
return FileNameUtil.createFileName(baseName, defaultFileExtension);
k3b/ToGoZip
app/src/main/java/de/k3b/android/widget/LocalizedActivity.java
// Path: libK3bAndroidZip/src/main/java/de/k3b/android/zip/Global.java // public class Global { // /** document tree supported since andrid-5.0. For older devices use folder picker */ // public static final boolean USE_DOCUMENT_PROVIDER = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP); // // /** #6: local settings: which language should the gui use */ // public static final String PREF_KEY_USER_LOCALE = "user_locale"; // // public static final String LOG_CONTEXT = "toGoZip"; // /** // * true: addToCompressQue several Log.d(...) to show what is going on. // * debugEnabled is updated by the SettingsActivity // */ // public static boolean debugEnabled = false; // // /** Remember initial language settings. This allows setting "switch back to device language" after changing app locale */ // public static Locale systemLocale = Locale.getDefault(); // // /** if not null added files will be logged in this zip-entry-text-file */ // public static boolean isWriteLogFile2Zip = false; // }
import de.k3b.android.zip.Global; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; import java.util.Locale;
/* * Copyright (c) 2015-2017 by k3b. * * This file is part of AndroFotoFinder and of ToGoZip. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/> */ package de.k3b.android.widget; /** * An activity that can change the locale (language) of its content. * * Inspired by http://stackoverflow.com/questions/13181847/change-the-locale-at-runtime * * Created by k3b on 07.01.2016. */ public abstract class LocalizedActivity extends Activity { /** if myLocale != Locale.Default : activity must be recreated in on resume */ private Locale myLocale = null; @Override protected void onCreate(Bundle savedInstanceState) { fixLocale(this); super.onCreate(savedInstanceState); } @Override protected void onResume() { super.onResume(); // Locale has changed by other Activity ? if ((myLocale != null) && !(myLocale.getLanguage().equals(Locale.getDefault().getLanguage()))) { myLocale = null; recreate(LocalizedActivity.this); } } /** * Set Activity-s locale to SharedPreferences-setting. * Must be called before */ public static void fixLocale(Context context) { final SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(context);
// Path: libK3bAndroidZip/src/main/java/de/k3b/android/zip/Global.java // public class Global { // /** document tree supported since andrid-5.0. For older devices use folder picker */ // public static final boolean USE_DOCUMENT_PROVIDER = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP); // // /** #6: local settings: which language should the gui use */ // public static final String PREF_KEY_USER_LOCALE = "user_locale"; // // public static final String LOG_CONTEXT = "toGoZip"; // /** // * true: addToCompressQue several Log.d(...) to show what is going on. // * debugEnabled is updated by the SettingsActivity // */ // public static boolean debugEnabled = false; // // /** Remember initial language settings. This allows setting "switch back to device language" after changing app locale */ // public static Locale systemLocale = Locale.getDefault(); // // /** if not null added files will be logged in this zip-entry-text-file */ // public static boolean isWriteLogFile2Zip = false; // } // Path: app/src/main/java/de/k3b/android/widget/LocalizedActivity.java import de.k3b.android.zip.Global; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; import java.util.Locale; /* * Copyright (c) 2015-2017 by k3b. * * This file is part of AndroFotoFinder and of ToGoZip. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/> */ package de.k3b.android.widget; /** * An activity that can change the locale (language) of its content. * * Inspired by http://stackoverflow.com/questions/13181847/change-the-locale-at-runtime * * Created by k3b on 07.01.2016. */ public abstract class LocalizedActivity extends Activity { /** if myLocale != Locale.Default : activity must be recreated in on resume */ private Locale myLocale = null; @Override protected void onCreate(Bundle savedInstanceState) { fixLocale(this); super.onCreate(savedInstanceState); } @Override protected void onResume() { super.onResume(); // Locale has changed by other Activity ? if ((myLocale != null) && !(myLocale.getLanguage().equals(Locale.getDefault().getLanguage()))) { myLocale = null; recreate(LocalizedActivity.this); } } /** * Set Activity-s locale to SharedPreferences-setting. * Must be called before */ public static void fixLocale(Context context) { final SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(context);
String language = prefs.getString(Global.PREF_KEY_USER_LOCALE, "");
k3b/ToGoZip
libK3b/src/test/java/de/k3b/translations/TranslationStatisticsTests.java
// Path: libK3b/src/main/java/de/k3b/io/DateUtil.java // public class DateUtil { // // cannot use Locale.ROOT because it requires api-9. this is api-7 // public static final DateFormat IsoDateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US); // public static final DateFormat IsoDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US); // public static final DateFormat IsoDateFormat2 = new SimpleDateFormat("yyyyMMdd", Locale.US); // // public static final TimeZone UTC = TimeZone.getTimeZone("UTC"); // // static { // DateUtil.IsoDateTimeFormat.setTimeZone(UTC); // DateUtil.IsoDateFormat.setTimeZone(UTC); // DateUtil.IsoDateFormat2.setTimeZone(UTC); // TimeZone.setDefault(UTC); // } // // public static Date parseIsoDate(String dateString) { // if (dateString == null) return null; // Date result = IsoDateTimeParser.parse(dateString); // if (result == null) { // result = parseDateTime(dateString, IsoDateTimeFormat, IsoDateFormat, IsoDateFormat2); // } // return result; // } // // private static Date parseDateTime(String dateString, DateFormat... formatCandidates) { // Date result = null; // if (dateString != null) { // for (DateFormat formatCandidate : formatCandidates) { // try { // result = formatCandidate.parse(dateString); // if (result != null) break; // } catch (ParseException e) { // } // } // } // return result; // } // // public static String toIsoDateTimeString(Date date) { // if (date == null) return null; // return IsoDateTimeFormat.format(date); // } // // public static String toIsoDateString(Date date) { // if (date == null) return null; // return IsoDateFormat.format(date); // } // }
import org.junit.Assert; import org.junit.Test; import java.io.File; import java.util.Date; import de.k3b.io.DateUtil;
/* * Copyright (c) 2018 by k3b. * * This file is part of #APhotoManager (https://github.com/k3b/APhotoManager/) * and #toGoZip (https://github.com/k3b/ToGoZip/). * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/> */ package de.k3b.translations; /** * (c) 2018-2021 by k3b * * For details see comments/values in translation-history.ini */ public class TranslationStatisticsTests { @Test public void shouldMatchFastlane() { Assert.assertEquals(true, TranslationStatistics.getFastlanePattern("en-US").matcher("en-US").matches()); } @Test public void shouldMatchString_de() { Assert.assertEquals(true, TranslationStatistics.PATTERN_ANDROID_RES_STRING_LOCALE.matcher("values-de").matches()); } @Test public void dumpAsMD() { final TranslationStatistics translationStatistics = new TranslationStatistics();
// Path: libK3b/src/main/java/de/k3b/io/DateUtil.java // public class DateUtil { // // cannot use Locale.ROOT because it requires api-9. this is api-7 // public static final DateFormat IsoDateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US); // public static final DateFormat IsoDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US); // public static final DateFormat IsoDateFormat2 = new SimpleDateFormat("yyyyMMdd", Locale.US); // // public static final TimeZone UTC = TimeZone.getTimeZone("UTC"); // // static { // DateUtil.IsoDateTimeFormat.setTimeZone(UTC); // DateUtil.IsoDateFormat.setTimeZone(UTC); // DateUtil.IsoDateFormat2.setTimeZone(UTC); // TimeZone.setDefault(UTC); // } // // public static Date parseIsoDate(String dateString) { // if (dateString == null) return null; // Date result = IsoDateTimeParser.parse(dateString); // if (result == null) { // result = parseDateTime(dateString, IsoDateTimeFormat, IsoDateFormat, IsoDateFormat2); // } // return result; // } // // private static Date parseDateTime(String dateString, DateFormat... formatCandidates) { // Date result = null; // if (dateString != null) { // for (DateFormat formatCandidate : formatCandidates) { // try { // result = formatCandidate.parse(dateString); // if (result != null) break; // } catch (ParseException e) { // } // } // } // return result; // } // // public static String toIsoDateTimeString(Date date) { // if (date == null) return null; // return IsoDateTimeFormat.format(date); // } // // public static String toIsoDateString(Date date) { // if (date == null) return null; // return IsoDateFormat.format(date); // } // } // Path: libK3b/src/test/java/de/k3b/translations/TranslationStatisticsTests.java import org.junit.Assert; import org.junit.Test; import java.io.File; import java.util.Date; import de.k3b.io.DateUtil; /* * Copyright (c) 2018 by k3b. * * This file is part of #APhotoManager (https://github.com/k3b/APhotoManager/) * and #toGoZip (https://github.com/k3b/ToGoZip/). * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/> */ package de.k3b.translations; /** * (c) 2018-2021 by k3b * * For details see comments/values in translation-history.ini */ public class TranslationStatisticsTests { @Test public void shouldMatchFastlane() { Assert.assertEquals(true, TranslationStatistics.getFastlanePattern("en-US").matcher("en-US").matches()); } @Test public void shouldMatchString_de() { Assert.assertEquals(true, TranslationStatistics.PATTERN_ANDROID_RES_STRING_LOCALE.matcher("values-de").matches()); } @Test public void dumpAsMD() { final TranslationStatistics translationStatistics = new TranslationStatistics();
System.out.println("<!-- generated on " + DateUtil.toIsoDateString(new Date()) +
k3b/ToGoZip
libK3bZip/src/main/java/de/k3b/zip/FileCompressItem.java
// Path: libK3b/src/main/java/de/k3b/io/FileNameUtil.java // public class FileNameUtil { // // /** // * converts baseName to a valid filename by replacing illegal chars. // * If it has no file-extension then defaultExtension is added // * // * @param defaultExtension the new extension, excluding the dot. null means no extension. // */ // public static String createFileName(String baseName, String defaultExtension) { // StringBuilder result = new StringBuilder(baseName); // // // remove trailing "." // int len = result.length(); // while ((len > 0) && (result.charAt(len - 1) == '.')) { // result.deleteCharAt(len - 1); // len--; // } // // // remove leading "." // while ((len > 0) && (result.charAt(0) == '.')) { // result.deleteCharAt(0); // len--; // } // // // add extension if there is none // if ((defaultExtension != null) && (result.indexOf(".") < 0)) { // result.append(".").append(defaultExtension); // } // // // replace illegal chars with "_" // replace(result, "_", "/", "\\", ":", " ", "?", "*", "&", "%", ">", "<", "|", "'", "\"", "__"); // return result.toString(); // } // // /** // * converts baseName to a valid filename by replacing illegal chars. // */ // public static String createFileNameWitoutExtension(String fileNameCandidate) { // if (fileNameCandidate != null) { // // remove illegal chars or file extension // return FileNameUtil.createFileName(FileUtils.replaceExtension(fileNameCandidate, ""), null); // } // return null; // } // // public static String getWithoutWildcard(String path) { // if ((path == null) || (path.length() == 0)) return null; // if (path.endsWith("%")) { // // remove sql wildcard at end of name // return path.substring(0, path.length() - 1); // } // return path; // } // // /** // * converts filePath to a valid path by removing potential sql-wildcards and android specigic "//" // */ // public static String fixPath(String filePath) { // String path = FileNameUtil.getWithoutWildcard(FileUtils.fixPath(filePath)); // return path; // } // // /** replaces all occurences of illegalValues in result by replacement */ // private static void replace(StringBuilder result, String replacement, String ... illegalValues) { // for (String illegalValue : illegalValues) { // int found = result.indexOf(illegalValue); // while (found >= 0) { // result.replace(found, found+illegalValue.length(), replacement); // found = result.indexOf(illegalValue); // } // } // } // // // /** // * so that files are comparable // */ // public static String getCanonicalPath(File zipRelPath) { // File canonicalFile = FileUtils.tryGetCanonicalFile(zipRelPath); // if (canonicalFile != null) { // return FileUtils.fixPath(canonicalFile.getAbsolutePath()); // } // return null; // } // // /** // * @return either srcFile without leading relativeToPath or null if srcFile is not relative to relativeToPath // */ // public static String makePathRelative(String relativeToPath, File srcFile) { // String result = null; // if (!StringUtils.isNullOrEmpty(relativeToPath)) { // String srcPath = getCanonicalPath(srcFile); // boolean match = srcPath.toLowerCase().startsWith(relativeToPath); // if (match) { // result = srcPath.substring(relativeToPath.length() + 1); // } // } // return result; // } // }
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import de.k3b.io.FileNameUtil;
/* * Copyright (C) 2014-2019 k3b * * This file is part of de.k3b.android.toGoZip (https://github.com/k3b/ToGoZip/) . * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/> */ package de.k3b.zip; /** * One android independant, java.io.File based dto-item that should be compressed.<br/> * <p/> * Author k3b */ public class FileCompressItem extends CompressItem { private static final Logger logger = LoggerFactory.getLogger(LibZipGlobal.LOG_TAG); private static final String DBG_CONTEXT = "FileCompressItem:"; /** source file to be compressed */ private File file; /** if not null file adds will be relative to this path if file is below this path */ private static String zipRelPath = null; /** * * @param outDirInZipForNoneRelPath directory with trailing "/" (without filename) where * the entry goes to if outside FileCompressItem.zipRelPath. * null==root dir. * @param srcFile full path to source file * @param zipEntryComment */ public FileCompressItem(String outDirInZipForNoneRelPath, File srcFile, String zipEntryComment) { String zipEntryName = calculateZipEntryName(outDirInZipForNoneRelPath, srcFile, FileCompressItem.zipRelPath); setFile(srcFile); setZipEntryFileName(zipEntryName); setZipEntryComment(zipEntryComment); } /** * Calculates the path within the zip file. * * Scope: package to allow unittesting. * * @param outDirInZipForNoneRelPath directory with trailing "/" (without filename) where * the entry goes to if outside zipRelPath. * null==root dir. * @param srcFile full path to source file * @param zipRelPath if not empty paths are caclulated relative to this directory. * Must have trailing "/" and be lower case. * @return */ static String calculateZipEntryName(String outDirInZipForNoneRelPath, File srcFile, String zipRelPath) {
// Path: libK3b/src/main/java/de/k3b/io/FileNameUtil.java // public class FileNameUtil { // // /** // * converts baseName to a valid filename by replacing illegal chars. // * If it has no file-extension then defaultExtension is added // * // * @param defaultExtension the new extension, excluding the dot. null means no extension. // */ // public static String createFileName(String baseName, String defaultExtension) { // StringBuilder result = new StringBuilder(baseName); // // // remove trailing "." // int len = result.length(); // while ((len > 0) && (result.charAt(len - 1) == '.')) { // result.deleteCharAt(len - 1); // len--; // } // // // remove leading "." // while ((len > 0) && (result.charAt(0) == '.')) { // result.deleteCharAt(0); // len--; // } // // // add extension if there is none // if ((defaultExtension != null) && (result.indexOf(".") < 0)) { // result.append(".").append(defaultExtension); // } // // // replace illegal chars with "_" // replace(result, "_", "/", "\\", ":", " ", "?", "*", "&", "%", ">", "<", "|", "'", "\"", "__"); // return result.toString(); // } // // /** // * converts baseName to a valid filename by replacing illegal chars. // */ // public static String createFileNameWitoutExtension(String fileNameCandidate) { // if (fileNameCandidate != null) { // // remove illegal chars or file extension // return FileNameUtil.createFileName(FileUtils.replaceExtension(fileNameCandidate, ""), null); // } // return null; // } // // public static String getWithoutWildcard(String path) { // if ((path == null) || (path.length() == 0)) return null; // if (path.endsWith("%")) { // // remove sql wildcard at end of name // return path.substring(0, path.length() - 1); // } // return path; // } // // /** // * converts filePath to a valid path by removing potential sql-wildcards and android specigic "//" // */ // public static String fixPath(String filePath) { // String path = FileNameUtil.getWithoutWildcard(FileUtils.fixPath(filePath)); // return path; // } // // /** replaces all occurences of illegalValues in result by replacement */ // private static void replace(StringBuilder result, String replacement, String ... illegalValues) { // for (String illegalValue : illegalValues) { // int found = result.indexOf(illegalValue); // while (found >= 0) { // result.replace(found, found+illegalValue.length(), replacement); // found = result.indexOf(illegalValue); // } // } // } // // // /** // * so that files are comparable // */ // public static String getCanonicalPath(File zipRelPath) { // File canonicalFile = FileUtils.tryGetCanonicalFile(zipRelPath); // if (canonicalFile != null) { // return FileUtils.fixPath(canonicalFile.getAbsolutePath()); // } // return null; // } // // /** // * @return either srcFile without leading relativeToPath or null if srcFile is not relative to relativeToPath // */ // public static String makePathRelative(String relativeToPath, File srcFile) { // String result = null; // if (!StringUtils.isNullOrEmpty(relativeToPath)) { // String srcPath = getCanonicalPath(srcFile); // boolean match = srcPath.toLowerCase().startsWith(relativeToPath); // if (match) { // result = srcPath.substring(relativeToPath.length() + 1); // } // } // return result; // } // } // Path: libK3bZip/src/main/java/de/k3b/zip/FileCompressItem.java import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import de.k3b.io.FileNameUtil; /* * Copyright (C) 2014-2019 k3b * * This file is part of de.k3b.android.toGoZip (https://github.com/k3b/ToGoZip/) . * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/> */ package de.k3b.zip; /** * One android independant, java.io.File based dto-item that should be compressed.<br/> * <p/> * Author k3b */ public class FileCompressItem extends CompressItem { private static final Logger logger = LoggerFactory.getLogger(LibZipGlobal.LOG_TAG); private static final String DBG_CONTEXT = "FileCompressItem:"; /** source file to be compressed */ private File file; /** if not null file adds will be relative to this path if file is below this path */ private static String zipRelPath = null; /** * * @param outDirInZipForNoneRelPath directory with trailing "/" (without filename) where * the entry goes to if outside FileCompressItem.zipRelPath. * null==root dir. * @param srcFile full path to source file * @param zipEntryComment */ public FileCompressItem(String outDirInZipForNoneRelPath, File srcFile, String zipEntryComment) { String zipEntryName = calculateZipEntryName(outDirInZipForNoneRelPath, srcFile, FileCompressItem.zipRelPath); setFile(srcFile); setZipEntryFileName(zipEntryName); setZipEntryComment(zipEntryComment); } /** * Calculates the path within the zip file. * * Scope: package to allow unittesting. * * @param outDirInZipForNoneRelPath directory with trailing "/" (without filename) where * the entry goes to if outside zipRelPath. * null==root dir. * @param srcFile full path to source file * @param zipRelPath if not empty paths are caclulated relative to this directory. * Must have trailing "/" and be lower case. * @return */ static String calculateZipEntryName(String outDirInZipForNoneRelPath, File srcFile, String zipRelPath) {
String result = FileNameUtil.makePathRelative(zipRelPath, srcFile);
vecnatechnologies/dbDiff
core/src/main/java/com/vecna/dbDiff/business/catalogSchema/impl/DelegatingByDriverCatalogSchemaResolverImpl.java
// Path: core/src/main/java/com/vecna/dbDiff/business/catalogSchema/CatalogSchemaResolver.java // public interface CatalogSchemaResolver { // /** // * Resolve the catalog/schema // * @param jdbcDriver driver // * @param jdbcUrl url // * @return catalog/schema // */ // public CatalogSchema resolveCatalogSchema(String jdbcDriver, String jdbcUrl); // } // // Path: core/src/main/java/com/vecna/dbDiff/model/CatalogSchema.java // public class CatalogSchema { // /** // * Default schema // */ // public static final String DEFAULT_SCHEMA = "public"; // // /** // * Default catalog // */ // public static final String DEFAULT_CATALOG = null; // // /** // * @return default catalog/schema. // */ // public static CatalogSchema defaultCatalogSchema() { // return new CatalogSchema(DEFAULT_CATALOG, DEFAULT_SCHEMA); // } // // private final String m_catalog; // private final String m_schema; // // /** // * Construct a new {@link CatalogSchema}. // * @param catalog catalog. // * @param schema schema. // */ // public CatalogSchema(String catalog, String schema) { // m_catalog = catalog; // m_schema = schema; // } // // /** // * @return the catalog. // */ // public String getCatalog() { // return m_catalog; // } // // /** // * @return the schema. // */ // public String getSchema() { // return m_schema; // } // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } else if (getClass() != obj.getClass()) { // return false; // } else { // CatalogSchema other = (CatalogSchema) obj; // return Objects.equals(getCatalog(), other.getCatalog()) && Objects.equals(getSchema(), other.getSchema()); // } // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), getCatalog(), getSchema()); // } // // @Override // public String toString() { // return "[" + m_catalog + "." + m_schema + "]"; // } // }
import java.util.Map; import com.vecna.dbDiff.business.catalogSchema.CatalogSchemaResolver; import com.vecna.dbDiff.model.CatalogSchema;
/** * Copyright 2011 Vecna Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.vecna.dbDiff.business.catalogSchema.impl; /** * Delegates to another {@link CatalogSchemaResolver} based on the jdbc driver (i.e. the db type). * @author ogolberg@vecna.com */ class DelegatingByDriverCatalogSchemaResolverImpl implements CatalogSchemaResolver { private final Map<String, CatalogSchemaResolver> m_resolverMap; @Override
// Path: core/src/main/java/com/vecna/dbDiff/business/catalogSchema/CatalogSchemaResolver.java // public interface CatalogSchemaResolver { // /** // * Resolve the catalog/schema // * @param jdbcDriver driver // * @param jdbcUrl url // * @return catalog/schema // */ // public CatalogSchema resolveCatalogSchema(String jdbcDriver, String jdbcUrl); // } // // Path: core/src/main/java/com/vecna/dbDiff/model/CatalogSchema.java // public class CatalogSchema { // /** // * Default schema // */ // public static final String DEFAULT_SCHEMA = "public"; // // /** // * Default catalog // */ // public static final String DEFAULT_CATALOG = null; // // /** // * @return default catalog/schema. // */ // public static CatalogSchema defaultCatalogSchema() { // return new CatalogSchema(DEFAULT_CATALOG, DEFAULT_SCHEMA); // } // // private final String m_catalog; // private final String m_schema; // // /** // * Construct a new {@link CatalogSchema}. // * @param catalog catalog. // * @param schema schema. // */ // public CatalogSchema(String catalog, String schema) { // m_catalog = catalog; // m_schema = schema; // } // // /** // * @return the catalog. // */ // public String getCatalog() { // return m_catalog; // } // // /** // * @return the schema. // */ // public String getSchema() { // return m_schema; // } // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } else if (getClass() != obj.getClass()) { // return false; // } else { // CatalogSchema other = (CatalogSchema) obj; // return Objects.equals(getCatalog(), other.getCatalog()) && Objects.equals(getSchema(), other.getSchema()); // } // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), getCatalog(), getSchema()); // } // // @Override // public String toString() { // return "[" + m_catalog + "." + m_schema + "]"; // } // } // Path: core/src/main/java/com/vecna/dbDiff/business/catalogSchema/impl/DelegatingByDriverCatalogSchemaResolverImpl.java import java.util.Map; import com.vecna.dbDiff.business.catalogSchema.CatalogSchemaResolver; import com.vecna.dbDiff.model.CatalogSchema; /** * Copyright 2011 Vecna Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.vecna.dbDiff.business.catalogSchema.impl; /** * Delegates to another {@link CatalogSchemaResolver} based on the jdbc driver (i.e. the db type). * @author ogolberg@vecna.com */ class DelegatingByDriverCatalogSchemaResolverImpl implements CatalogSchemaResolver { private final Map<String, CatalogSchemaResolver> m_resolverMap; @Override
public CatalogSchema resolveCatalogSchema(String jdbcDriver, String jdbcUrl) {
vecnatechnologies/dbDiff
hibernate/src/main/java/com/vecna/dbDiff/hibernate/NoopSqlTypeMapper.java
// Path: core/src/main/java/com/vecna/dbDiff/model/db/Column.java // public class Column extends NamedSchemaItem implements Comparable<Column> { // private final String m_table; // // // Column properties // private String m_default; // private Boolean m_isNullable; // private Integer m_columnSize; // private Integer m_ordinal; // private ColumnType m_columnType; // // /** // * Construct a new Column. // * @param catalogSchema catalog/schema. // * @param name column name. // * @param table name of the table that contains the column. // */ // public Column(CatalogSchema catalogSchema, String name, String table) { // super(catalogSchema, name); // m_table = table; // } // // /** // * Create a new Column. // * @param catalog catalog. // * @param schema schema. // * @param name column name. // * @param table name of the table that contains the column. // */ // public Column(String catalog, String schema, String name, String table) { // super(catalog, schema, name); // m_table = table; // } // // /** // * Get the table. // * @return Returns the table // */ // public String getTable() { // return m_table; // } // // /** // * Set the default. // * @param defaultVal The default to set // */ // public void setDefault(String defaultVal) { // m_default = defaultVal; // } // // /** // * Get the default. // * @return Returns the default // */ // public String getDefault() { // return m_default; // } // /** // * Set the isNullable. // * @param isNullable The isNullable to set // */ // public void setIsNullable(Boolean isNullable) { // m_isNullable = isNullable; // } // /** // * Get the isNullable. // * @return Returns the isNullable // */ // public Boolean getIsNullable() { // return m_isNullable; // } // /** // * Set the size of the column. For char or date types this is the maximum number of characters, for numeric or decimal types // * this is precision. // * @param columnSize The columnSize to set // */ // public void setColumnSize(Integer columnSize) { // m_columnSize = columnSize; // } // /** // * Get the size of the column. For char or date types this is the maximum number of characters, for numeric or decimal types // * this is precision. // * @return Returns the columnSize // */ // public Integer getColumnSize() { // return m_columnSize; // } // /** // * Set the ordinal. // * @param ordinal The ordinal to set // */ // public void setOrdinal(Integer ordinal) { // m_ordinal = ordinal; // } // /** // * Get the ordinal. // * @return Returns the ordinal // */ // public Integer getOrdinal() { // return m_ordinal; // } // // /** // * Get the type, corresponds to java.sql.Types // * @return Returns the type // */ // public int getType() { // return m_columnType.getType(); // } // // /** // * @return the type name (e.g. float4, bigint, varchar(255)) // */ // public String getTypeName() { // return m_columnType.getTypeCode(); // } // // /** // * @return the column type object // */ // public ColumnType getColumnType() { // return m_columnType; // } // // /** // * set the column type // * @param columnType the value to set // */ // public void setColumnType(ColumnType columnType) { // m_columnType = columnType; // } // // /** // * {@inheritDoc} // */ // @Override // public boolean equals(Object o) { // if (!(o instanceof Column)) { // return false; // } // Column other = (Column)o; // return getOrdinal().equals(other.getOrdinal()) && getName().equals(other.getName()); // } // // @Override // public int hashCode() { // return Objects.hash(m_ordinal, getName()); // } // // /** // * {@inheritDoc} // */ // @Override // public int compareTo(Column o) { // int ordComp = getOrdinal().compareTo(o.getOrdinal()); // if (ordComp == 0) { // return getName().compareTo(o.getName()); // } // return ordComp; // } // }
import com.vecna.dbDiff.model.db.Column;
/** * Copyright 2011 Vecna Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.vecna.dbDiff.hibernate; /** * This implementation of {@link HibernateSqlTypeMapper} does not modify the column types. * @author ogolberg@vecna.com */ public class NoopSqlTypeMapper implements HibernateSqlTypeMapper { /** * {@inheritDoc} */ @Override
// Path: core/src/main/java/com/vecna/dbDiff/model/db/Column.java // public class Column extends NamedSchemaItem implements Comparable<Column> { // private final String m_table; // // // Column properties // private String m_default; // private Boolean m_isNullable; // private Integer m_columnSize; // private Integer m_ordinal; // private ColumnType m_columnType; // // /** // * Construct a new Column. // * @param catalogSchema catalog/schema. // * @param name column name. // * @param table name of the table that contains the column. // */ // public Column(CatalogSchema catalogSchema, String name, String table) { // super(catalogSchema, name); // m_table = table; // } // // /** // * Create a new Column. // * @param catalog catalog. // * @param schema schema. // * @param name column name. // * @param table name of the table that contains the column. // */ // public Column(String catalog, String schema, String name, String table) { // super(catalog, schema, name); // m_table = table; // } // // /** // * Get the table. // * @return Returns the table // */ // public String getTable() { // return m_table; // } // // /** // * Set the default. // * @param defaultVal The default to set // */ // public void setDefault(String defaultVal) { // m_default = defaultVal; // } // // /** // * Get the default. // * @return Returns the default // */ // public String getDefault() { // return m_default; // } // /** // * Set the isNullable. // * @param isNullable The isNullable to set // */ // public void setIsNullable(Boolean isNullable) { // m_isNullable = isNullable; // } // /** // * Get the isNullable. // * @return Returns the isNullable // */ // public Boolean getIsNullable() { // return m_isNullable; // } // /** // * Set the size of the column. For char or date types this is the maximum number of characters, for numeric or decimal types // * this is precision. // * @param columnSize The columnSize to set // */ // public void setColumnSize(Integer columnSize) { // m_columnSize = columnSize; // } // /** // * Get the size of the column. For char or date types this is the maximum number of characters, for numeric or decimal types // * this is precision. // * @return Returns the columnSize // */ // public Integer getColumnSize() { // return m_columnSize; // } // /** // * Set the ordinal. // * @param ordinal The ordinal to set // */ // public void setOrdinal(Integer ordinal) { // m_ordinal = ordinal; // } // /** // * Get the ordinal. // * @return Returns the ordinal // */ // public Integer getOrdinal() { // return m_ordinal; // } // // /** // * Get the type, corresponds to java.sql.Types // * @return Returns the type // */ // public int getType() { // return m_columnType.getType(); // } // // /** // * @return the type name (e.g. float4, bigint, varchar(255)) // */ // public String getTypeName() { // return m_columnType.getTypeCode(); // } // // /** // * @return the column type object // */ // public ColumnType getColumnType() { // return m_columnType; // } // // /** // * set the column type // * @param columnType the value to set // */ // public void setColumnType(ColumnType columnType) { // m_columnType = columnType; // } // // /** // * {@inheritDoc} // */ // @Override // public boolean equals(Object o) { // if (!(o instanceof Column)) { // return false; // } // Column other = (Column)o; // return getOrdinal().equals(other.getOrdinal()) && getName().equals(other.getName()); // } // // @Override // public int hashCode() { // return Objects.hash(m_ordinal, getName()); // } // // /** // * {@inheritDoc} // */ // @Override // public int compareTo(Column o) { // int ordComp = getOrdinal().compareTo(o.getOrdinal()); // if (ordComp == 0) { // return getName().compareTo(o.getName()); // } // return ordComp; // } // } // Path: hibernate/src/main/java/com/vecna/dbDiff/hibernate/NoopSqlTypeMapper.java import com.vecna.dbDiff.model.db.Column; /** * Copyright 2011 Vecna Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.vecna.dbDiff.hibernate; /** * This implementation of {@link HibernateSqlTypeMapper} does not modify the column types. * @author ogolberg@vecna.com */ public class NoopSqlTypeMapper implements HibernateSqlTypeMapper { /** * {@inheritDoc} */ @Override
public void mapType(Column column) {
vecnatechnologies/dbDiff
core/src/main/java/com/vecna/dbDiff/model/db/Column.java
// Path: core/src/main/java/com/vecna/dbDiff/model/CatalogSchema.java // public class CatalogSchema { // /** // * Default schema // */ // public static final String DEFAULT_SCHEMA = "public"; // // /** // * Default catalog // */ // public static final String DEFAULT_CATALOG = null; // // /** // * @return default catalog/schema. // */ // public static CatalogSchema defaultCatalogSchema() { // return new CatalogSchema(DEFAULT_CATALOG, DEFAULT_SCHEMA); // } // // private final String m_catalog; // private final String m_schema; // // /** // * Construct a new {@link CatalogSchema}. // * @param catalog catalog. // * @param schema schema. // */ // public CatalogSchema(String catalog, String schema) { // m_catalog = catalog; // m_schema = schema; // } // // /** // * @return the catalog. // */ // public String getCatalog() { // return m_catalog; // } // // /** // * @return the schema. // */ // public String getSchema() { // return m_schema; // } // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } else if (getClass() != obj.getClass()) { // return false; // } else { // CatalogSchema other = (CatalogSchema) obj; // return Objects.equals(getCatalog(), other.getCatalog()) && Objects.equals(getSchema(), other.getSchema()); // } // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), getCatalog(), getSchema()); // } // // @Override // public String toString() { // return "[" + m_catalog + "." + m_schema + "]"; // } // } // // Path: core/src/main/java/com/vecna/dbDiff/model/ColumnType.java // public class ColumnType { // private final int m_type; // private final String m_typeCode; // // /** // * @param type an integer description of the data type in SQL // * @param typeCode a String description of the data type in Java // */ // public ColumnType(final int type, final String typeCode) { // m_type = type; // m_typeCode = typeCode; // } // // /** // * // * {@inheritDoc} // */ // @Override // public boolean equals(Object t) { // if (t == null || getClass() != t.getClass()) { // return false; // } else { // ColumnType other = (ColumnType) t; // return m_type == other.getType() && Objects.equals(m_typeCode, other.getTypeCode()); // } // } // // /** // * // * {@inheritDoc} // */ // @Override // public int hashCode() { // return Objects.hash(m_type, m_typeCode); // } // // /** // * @return an integer that defines a data type, the sql description // */ // public int getType() { // return m_type; // } // // /** // * @return a String that describes a data type, the Java description // */ // public String getTypeCode() { // return m_typeCode; // } // } // // Path: core/src/main/java/com/vecna/dbDiff/model/relationalDb/NamedSchemaItem.java // public abstract class NamedSchemaItem { // private final CatalogSchema m_catalogSchema; // private final String m_name; // // /** // * Create a new instance. // * @param catalogSchema catalog/schema. // * @param name name. // */ // public NamedSchemaItem(CatalogSchema catalogSchema, String name) { // m_catalogSchema = catalogSchema; // m_name = name; // } // // /** // * Create a new instance. // * @param catalog catalog. // * @param schema schema. // * @param name name. // */ // public NamedSchemaItem(String catalog, String schema, String name) { // this(new CatalogSchema(catalog, schema), name); // } // // /** // * @return catalog/schema. // */ // public CatalogSchema getCatalogSchema() { // return m_catalogSchema; // } // // /** // * @return name. // */ // public String getName() { // return m_name; // } // }
import java.util.Objects; import com.vecna.dbDiff.model.CatalogSchema; import com.vecna.dbDiff.model.ColumnType; import com.vecna.dbDiff.model.relationalDb.NamedSchemaItem;
/** * Copyright 2011 Vecna Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.vecna.dbDiff.model.db; /** * A model of a DB Table's column * @author dlopuch@vecna.com */ public class Column extends NamedSchemaItem implements Comparable<Column> { private final String m_table; // Column properties private String m_default; private Boolean m_isNullable; private Integer m_columnSize; private Integer m_ordinal;
// Path: core/src/main/java/com/vecna/dbDiff/model/CatalogSchema.java // public class CatalogSchema { // /** // * Default schema // */ // public static final String DEFAULT_SCHEMA = "public"; // // /** // * Default catalog // */ // public static final String DEFAULT_CATALOG = null; // // /** // * @return default catalog/schema. // */ // public static CatalogSchema defaultCatalogSchema() { // return new CatalogSchema(DEFAULT_CATALOG, DEFAULT_SCHEMA); // } // // private final String m_catalog; // private final String m_schema; // // /** // * Construct a new {@link CatalogSchema}. // * @param catalog catalog. // * @param schema schema. // */ // public CatalogSchema(String catalog, String schema) { // m_catalog = catalog; // m_schema = schema; // } // // /** // * @return the catalog. // */ // public String getCatalog() { // return m_catalog; // } // // /** // * @return the schema. // */ // public String getSchema() { // return m_schema; // } // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } else if (getClass() != obj.getClass()) { // return false; // } else { // CatalogSchema other = (CatalogSchema) obj; // return Objects.equals(getCatalog(), other.getCatalog()) && Objects.equals(getSchema(), other.getSchema()); // } // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), getCatalog(), getSchema()); // } // // @Override // public String toString() { // return "[" + m_catalog + "." + m_schema + "]"; // } // } // // Path: core/src/main/java/com/vecna/dbDiff/model/ColumnType.java // public class ColumnType { // private final int m_type; // private final String m_typeCode; // // /** // * @param type an integer description of the data type in SQL // * @param typeCode a String description of the data type in Java // */ // public ColumnType(final int type, final String typeCode) { // m_type = type; // m_typeCode = typeCode; // } // // /** // * // * {@inheritDoc} // */ // @Override // public boolean equals(Object t) { // if (t == null || getClass() != t.getClass()) { // return false; // } else { // ColumnType other = (ColumnType) t; // return m_type == other.getType() && Objects.equals(m_typeCode, other.getTypeCode()); // } // } // // /** // * // * {@inheritDoc} // */ // @Override // public int hashCode() { // return Objects.hash(m_type, m_typeCode); // } // // /** // * @return an integer that defines a data type, the sql description // */ // public int getType() { // return m_type; // } // // /** // * @return a String that describes a data type, the Java description // */ // public String getTypeCode() { // return m_typeCode; // } // } // // Path: core/src/main/java/com/vecna/dbDiff/model/relationalDb/NamedSchemaItem.java // public abstract class NamedSchemaItem { // private final CatalogSchema m_catalogSchema; // private final String m_name; // // /** // * Create a new instance. // * @param catalogSchema catalog/schema. // * @param name name. // */ // public NamedSchemaItem(CatalogSchema catalogSchema, String name) { // m_catalogSchema = catalogSchema; // m_name = name; // } // // /** // * Create a new instance. // * @param catalog catalog. // * @param schema schema. // * @param name name. // */ // public NamedSchemaItem(String catalog, String schema, String name) { // this(new CatalogSchema(catalog, schema), name); // } // // /** // * @return catalog/schema. // */ // public CatalogSchema getCatalogSchema() { // return m_catalogSchema; // } // // /** // * @return name. // */ // public String getName() { // return m_name; // } // } // Path: core/src/main/java/com/vecna/dbDiff/model/db/Column.java import java.util.Objects; import com.vecna.dbDiff.model.CatalogSchema; import com.vecna.dbDiff.model.ColumnType; import com.vecna.dbDiff.model.relationalDb.NamedSchemaItem; /** * Copyright 2011 Vecna Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.vecna.dbDiff.model.db; /** * A model of a DB Table's column * @author dlopuch@vecna.com */ public class Column extends NamedSchemaItem implements Comparable<Column> { private final String m_table; // Column properties private String m_default; private Boolean m_isNullable; private Integer m_columnSize; private Integer m_ordinal;
private ColumnType m_columnType;
vecnatechnologies/dbDiff
core/src/main/java/com/vecna/dbDiff/model/db/Column.java
// Path: core/src/main/java/com/vecna/dbDiff/model/CatalogSchema.java // public class CatalogSchema { // /** // * Default schema // */ // public static final String DEFAULT_SCHEMA = "public"; // // /** // * Default catalog // */ // public static final String DEFAULT_CATALOG = null; // // /** // * @return default catalog/schema. // */ // public static CatalogSchema defaultCatalogSchema() { // return new CatalogSchema(DEFAULT_CATALOG, DEFAULT_SCHEMA); // } // // private final String m_catalog; // private final String m_schema; // // /** // * Construct a new {@link CatalogSchema}. // * @param catalog catalog. // * @param schema schema. // */ // public CatalogSchema(String catalog, String schema) { // m_catalog = catalog; // m_schema = schema; // } // // /** // * @return the catalog. // */ // public String getCatalog() { // return m_catalog; // } // // /** // * @return the schema. // */ // public String getSchema() { // return m_schema; // } // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } else if (getClass() != obj.getClass()) { // return false; // } else { // CatalogSchema other = (CatalogSchema) obj; // return Objects.equals(getCatalog(), other.getCatalog()) && Objects.equals(getSchema(), other.getSchema()); // } // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), getCatalog(), getSchema()); // } // // @Override // public String toString() { // return "[" + m_catalog + "." + m_schema + "]"; // } // } // // Path: core/src/main/java/com/vecna/dbDiff/model/ColumnType.java // public class ColumnType { // private final int m_type; // private final String m_typeCode; // // /** // * @param type an integer description of the data type in SQL // * @param typeCode a String description of the data type in Java // */ // public ColumnType(final int type, final String typeCode) { // m_type = type; // m_typeCode = typeCode; // } // // /** // * // * {@inheritDoc} // */ // @Override // public boolean equals(Object t) { // if (t == null || getClass() != t.getClass()) { // return false; // } else { // ColumnType other = (ColumnType) t; // return m_type == other.getType() && Objects.equals(m_typeCode, other.getTypeCode()); // } // } // // /** // * // * {@inheritDoc} // */ // @Override // public int hashCode() { // return Objects.hash(m_type, m_typeCode); // } // // /** // * @return an integer that defines a data type, the sql description // */ // public int getType() { // return m_type; // } // // /** // * @return a String that describes a data type, the Java description // */ // public String getTypeCode() { // return m_typeCode; // } // } // // Path: core/src/main/java/com/vecna/dbDiff/model/relationalDb/NamedSchemaItem.java // public abstract class NamedSchemaItem { // private final CatalogSchema m_catalogSchema; // private final String m_name; // // /** // * Create a new instance. // * @param catalogSchema catalog/schema. // * @param name name. // */ // public NamedSchemaItem(CatalogSchema catalogSchema, String name) { // m_catalogSchema = catalogSchema; // m_name = name; // } // // /** // * Create a new instance. // * @param catalog catalog. // * @param schema schema. // * @param name name. // */ // public NamedSchemaItem(String catalog, String schema, String name) { // this(new CatalogSchema(catalog, schema), name); // } // // /** // * @return catalog/schema. // */ // public CatalogSchema getCatalogSchema() { // return m_catalogSchema; // } // // /** // * @return name. // */ // public String getName() { // return m_name; // } // }
import java.util.Objects; import com.vecna.dbDiff.model.CatalogSchema; import com.vecna.dbDiff.model.ColumnType; import com.vecna.dbDiff.model.relationalDb.NamedSchemaItem;
/** * Copyright 2011 Vecna Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.vecna.dbDiff.model.db; /** * A model of a DB Table's column * @author dlopuch@vecna.com */ public class Column extends NamedSchemaItem implements Comparable<Column> { private final String m_table; // Column properties private String m_default; private Boolean m_isNullable; private Integer m_columnSize; private Integer m_ordinal; private ColumnType m_columnType; /** * Construct a new Column. * @param catalogSchema catalog/schema. * @param name column name. * @param table name of the table that contains the column. */
// Path: core/src/main/java/com/vecna/dbDiff/model/CatalogSchema.java // public class CatalogSchema { // /** // * Default schema // */ // public static final String DEFAULT_SCHEMA = "public"; // // /** // * Default catalog // */ // public static final String DEFAULT_CATALOG = null; // // /** // * @return default catalog/schema. // */ // public static CatalogSchema defaultCatalogSchema() { // return new CatalogSchema(DEFAULT_CATALOG, DEFAULT_SCHEMA); // } // // private final String m_catalog; // private final String m_schema; // // /** // * Construct a new {@link CatalogSchema}. // * @param catalog catalog. // * @param schema schema. // */ // public CatalogSchema(String catalog, String schema) { // m_catalog = catalog; // m_schema = schema; // } // // /** // * @return the catalog. // */ // public String getCatalog() { // return m_catalog; // } // // /** // * @return the schema. // */ // public String getSchema() { // return m_schema; // } // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } else if (getClass() != obj.getClass()) { // return false; // } else { // CatalogSchema other = (CatalogSchema) obj; // return Objects.equals(getCatalog(), other.getCatalog()) && Objects.equals(getSchema(), other.getSchema()); // } // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), getCatalog(), getSchema()); // } // // @Override // public String toString() { // return "[" + m_catalog + "." + m_schema + "]"; // } // } // // Path: core/src/main/java/com/vecna/dbDiff/model/ColumnType.java // public class ColumnType { // private final int m_type; // private final String m_typeCode; // // /** // * @param type an integer description of the data type in SQL // * @param typeCode a String description of the data type in Java // */ // public ColumnType(final int type, final String typeCode) { // m_type = type; // m_typeCode = typeCode; // } // // /** // * // * {@inheritDoc} // */ // @Override // public boolean equals(Object t) { // if (t == null || getClass() != t.getClass()) { // return false; // } else { // ColumnType other = (ColumnType) t; // return m_type == other.getType() && Objects.equals(m_typeCode, other.getTypeCode()); // } // } // // /** // * // * {@inheritDoc} // */ // @Override // public int hashCode() { // return Objects.hash(m_type, m_typeCode); // } // // /** // * @return an integer that defines a data type, the sql description // */ // public int getType() { // return m_type; // } // // /** // * @return a String that describes a data type, the Java description // */ // public String getTypeCode() { // return m_typeCode; // } // } // // Path: core/src/main/java/com/vecna/dbDiff/model/relationalDb/NamedSchemaItem.java // public abstract class NamedSchemaItem { // private final CatalogSchema m_catalogSchema; // private final String m_name; // // /** // * Create a new instance. // * @param catalogSchema catalog/schema. // * @param name name. // */ // public NamedSchemaItem(CatalogSchema catalogSchema, String name) { // m_catalogSchema = catalogSchema; // m_name = name; // } // // /** // * Create a new instance. // * @param catalog catalog. // * @param schema schema. // * @param name name. // */ // public NamedSchemaItem(String catalog, String schema, String name) { // this(new CatalogSchema(catalog, schema), name); // } // // /** // * @return catalog/schema. // */ // public CatalogSchema getCatalogSchema() { // return m_catalogSchema; // } // // /** // * @return name. // */ // public String getName() { // return m_name; // } // } // Path: core/src/main/java/com/vecna/dbDiff/model/db/Column.java import java.util.Objects; import com.vecna.dbDiff.model.CatalogSchema; import com.vecna.dbDiff.model.ColumnType; import com.vecna.dbDiff.model.relationalDb.NamedSchemaItem; /** * Copyright 2011 Vecna Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.vecna.dbDiff.model.db; /** * A model of a DB Table's column * @author dlopuch@vecna.com */ public class Column extends NamedSchemaItem implements Comparable<Column> { private final String m_table; // Column properties private String m_default; private Boolean m_isNullable; private Integer m_columnSize; private Integer m_ordinal; private ColumnType m_columnType; /** * Construct a new Column. * @param catalogSchema catalog/schema. * @param name column name. * @param table name of the table that contains the column. */
public Column(CatalogSchema catalogSchema, String name, String table) {
vecnatechnologies/dbDiff
core/src/main/java/com/vecna/dbDiff/business/catalogSchema/impl/SQLServerCatalogSchemaResolver.java
// Path: core/src/main/java/com/vecna/dbDiff/business/catalogSchema/CatalogSchemaResolver.java // public interface CatalogSchemaResolver { // /** // * Resolve the catalog/schema // * @param jdbcDriver driver // * @param jdbcUrl url // * @return catalog/schema // */ // public CatalogSchema resolveCatalogSchema(String jdbcDriver, String jdbcUrl); // } // // Path: core/src/main/java/com/vecna/dbDiff/model/CatalogSchema.java // public class CatalogSchema { // /** // * Default schema // */ // public static final String DEFAULT_SCHEMA = "public"; // // /** // * Default catalog // */ // public static final String DEFAULT_CATALOG = null; // // /** // * @return default catalog/schema. // */ // public static CatalogSchema defaultCatalogSchema() { // return new CatalogSchema(DEFAULT_CATALOG, DEFAULT_SCHEMA); // } // // private final String m_catalog; // private final String m_schema; // // /** // * Construct a new {@link CatalogSchema}. // * @param catalog catalog. // * @param schema schema. // */ // public CatalogSchema(String catalog, String schema) { // m_catalog = catalog; // m_schema = schema; // } // // /** // * @return the catalog. // */ // public String getCatalog() { // return m_catalog; // } // // /** // * @return the schema. // */ // public String getSchema() { // return m_schema; // } // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } else if (getClass() != obj.getClass()) { // return false; // } else { // CatalogSchema other = (CatalogSchema) obj; // return Objects.equals(getCatalog(), other.getCatalog()) && Objects.equals(getSchema(), other.getSchema()); // } // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), getCatalog(), getSchema()); // } // // @Override // public String toString() { // return "[" + m_catalog + "." + m_schema + "]"; // } // }
import java.util.regex.Matcher; import java.util.regex.Pattern; import com.vecna.dbDiff.business.catalogSchema.CatalogSchemaResolver; import com.vecna.dbDiff.model.CatalogSchema;
/** * Copyright 2011 Vecna Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.vecna.dbDiff.business.catalogSchema.impl; /** * SQL Server catalog/schema resolver. Defaults to dbo/database name. * Database name is parsed from the jdbc url. * @author ogolberg@vecna.com */ class SQLServerCatalogSchemaResolver implements CatalogSchemaResolver { @Override
// Path: core/src/main/java/com/vecna/dbDiff/business/catalogSchema/CatalogSchemaResolver.java // public interface CatalogSchemaResolver { // /** // * Resolve the catalog/schema // * @param jdbcDriver driver // * @param jdbcUrl url // * @return catalog/schema // */ // public CatalogSchema resolveCatalogSchema(String jdbcDriver, String jdbcUrl); // } // // Path: core/src/main/java/com/vecna/dbDiff/model/CatalogSchema.java // public class CatalogSchema { // /** // * Default schema // */ // public static final String DEFAULT_SCHEMA = "public"; // // /** // * Default catalog // */ // public static final String DEFAULT_CATALOG = null; // // /** // * @return default catalog/schema. // */ // public static CatalogSchema defaultCatalogSchema() { // return new CatalogSchema(DEFAULT_CATALOG, DEFAULT_SCHEMA); // } // // private final String m_catalog; // private final String m_schema; // // /** // * Construct a new {@link CatalogSchema}. // * @param catalog catalog. // * @param schema schema. // */ // public CatalogSchema(String catalog, String schema) { // m_catalog = catalog; // m_schema = schema; // } // // /** // * @return the catalog. // */ // public String getCatalog() { // return m_catalog; // } // // /** // * @return the schema. // */ // public String getSchema() { // return m_schema; // } // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } else if (getClass() != obj.getClass()) { // return false; // } else { // CatalogSchema other = (CatalogSchema) obj; // return Objects.equals(getCatalog(), other.getCatalog()) && Objects.equals(getSchema(), other.getSchema()); // } // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), getCatalog(), getSchema()); // } // // @Override // public String toString() { // return "[" + m_catalog + "." + m_schema + "]"; // } // } // Path: core/src/main/java/com/vecna/dbDiff/business/catalogSchema/impl/SQLServerCatalogSchemaResolver.java import java.util.regex.Matcher; import java.util.regex.Pattern; import com.vecna.dbDiff.business.catalogSchema.CatalogSchemaResolver; import com.vecna.dbDiff.model.CatalogSchema; /** * Copyright 2011 Vecna Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.vecna.dbDiff.business.catalogSchema.impl; /** * SQL Server catalog/schema resolver. Defaults to dbo/database name. * Database name is parsed from the jdbc url. * @author ogolberg@vecna.com */ class SQLServerCatalogSchemaResolver implements CatalogSchemaResolver { @Override
public CatalogSchema resolveCatalogSchema(String jdbcDriver, String jdbcUrl) {
vecnatechnologies/dbDiff
core/src/test/java/com/vecna/dbDiff/model/ColumnTypeTest.java
// Path: core/src/main/java/com/vecna/dbDiff/model/ColumnType.java // public class ColumnType { // private final int m_type; // private final String m_typeCode; // // /** // * @param type an integer description of the data type in SQL // * @param typeCode a String description of the data type in Java // */ // public ColumnType(final int type, final String typeCode) { // m_type = type; // m_typeCode = typeCode; // } // // /** // * // * {@inheritDoc} // */ // @Override // public boolean equals(Object t) { // if (t == null || getClass() != t.getClass()) { // return false; // } else { // ColumnType other = (ColumnType) t; // return m_type == other.getType() && Objects.equals(m_typeCode, other.getTypeCode()); // } // } // // /** // * // * {@inheritDoc} // */ // @Override // public int hashCode() { // return Objects.hash(m_type, m_typeCode); // } // // /** // * @return an integer that defines a data type, the sql description // */ // public int getType() { // return m_type; // } // // /** // * @return a String that describes a data type, the Java description // */ // public String getTypeCode() { // return m_typeCode; // } // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotSame; import java.util.HashMap; import java.util.Map; import org.junit.Test; import com.vecna.dbDiff.model.ColumnType;
/** * Copyright 2011 Vecna Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.vecna.dbDiff.model; /** * @author greg.zheng@vecna.com */ public class ColumnTypeTest { /** * Test null type name */ @Test public void testNullTypeName() {
// Path: core/src/main/java/com/vecna/dbDiff/model/ColumnType.java // public class ColumnType { // private final int m_type; // private final String m_typeCode; // // /** // * @param type an integer description of the data type in SQL // * @param typeCode a String description of the data type in Java // */ // public ColumnType(final int type, final String typeCode) { // m_type = type; // m_typeCode = typeCode; // } // // /** // * // * {@inheritDoc} // */ // @Override // public boolean equals(Object t) { // if (t == null || getClass() != t.getClass()) { // return false; // } else { // ColumnType other = (ColumnType) t; // return m_type == other.getType() && Objects.equals(m_typeCode, other.getTypeCode()); // } // } // // /** // * // * {@inheritDoc} // */ // @Override // public int hashCode() { // return Objects.hash(m_type, m_typeCode); // } // // /** // * @return an integer that defines a data type, the sql description // */ // public int getType() { // return m_type; // } // // /** // * @return a String that describes a data type, the Java description // */ // public String getTypeCode() { // return m_typeCode; // } // } // Path: core/src/test/java/com/vecna/dbDiff/model/ColumnTypeTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotSame; import java.util.HashMap; import java.util.Map; import org.junit.Test; import com.vecna.dbDiff.model.ColumnType; /** * Copyright 2011 Vecna Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.vecna.dbDiff.model; /** * @author greg.zheng@vecna.com */ public class ColumnTypeTest { /** * Test null type name */ @Test public void testNullTypeName() {
ColumnType typeBool = new ColumnType(-7, null);
vecnatechnologies/dbDiff
core/src/main/java/com/vecna/dbDiff/model/db/ForeignKey.java
// Path: core/src/main/java/com/vecna/dbDiff/model/CatalogSchema.java // public class CatalogSchema { // /** // * Default schema // */ // public static final String DEFAULT_SCHEMA = "public"; // // /** // * Default catalog // */ // public static final String DEFAULT_CATALOG = null; // // /** // * @return default catalog/schema. // */ // public static CatalogSchema defaultCatalogSchema() { // return new CatalogSchema(DEFAULT_CATALOG, DEFAULT_SCHEMA); // } // // private final String m_catalog; // private final String m_schema; // // /** // * Construct a new {@link CatalogSchema}. // * @param catalog catalog. // * @param schema schema. // */ // public CatalogSchema(String catalog, String schema) { // m_catalog = catalog; // m_schema = schema; // } // // /** // * @return the catalog. // */ // public String getCatalog() { // return m_catalog; // } // // /** // * @return the schema. // */ // public String getSchema() { // return m_schema; // } // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } else if (getClass() != obj.getClass()) { // return false; // } else { // CatalogSchema other = (CatalogSchema) obj; // return Objects.equals(getCatalog(), other.getCatalog()) && Objects.equals(getSchema(), other.getSchema()); // } // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), getCatalog(), getSchema()); // } // // @Override // public String toString() { // return "[" + m_catalog + "." + m_schema + "]"; // } // }
import com.google.common.base.Objects; import com.vecna.dbDiff.model.CatalogSchema;
/** * Copyright 2011 Vecna Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.vecna.dbDiff.model.db; /** * A model of a database foreign key * @author dlopuch@vecna.com */ public class ForeignKey { //Constraint name private String m_fkName; private String m_keySeq; //Table and column the FK belongs to, ResultSet 5-8
// Path: core/src/main/java/com/vecna/dbDiff/model/CatalogSchema.java // public class CatalogSchema { // /** // * Default schema // */ // public static final String DEFAULT_SCHEMA = "public"; // // /** // * Default catalog // */ // public static final String DEFAULT_CATALOG = null; // // /** // * @return default catalog/schema. // */ // public static CatalogSchema defaultCatalogSchema() { // return new CatalogSchema(DEFAULT_CATALOG, DEFAULT_SCHEMA); // } // // private final String m_catalog; // private final String m_schema; // // /** // * Construct a new {@link CatalogSchema}. // * @param catalog catalog. // * @param schema schema. // */ // public CatalogSchema(String catalog, String schema) { // m_catalog = catalog; // m_schema = schema; // } // // /** // * @return the catalog. // */ // public String getCatalog() { // return m_catalog; // } // // /** // * @return the schema. // */ // public String getSchema() { // return m_schema; // } // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } else if (getClass() != obj.getClass()) { // return false; // } else { // CatalogSchema other = (CatalogSchema) obj; // return Objects.equals(getCatalog(), other.getCatalog()) && Objects.equals(getSchema(), other.getSchema()); // } // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), getCatalog(), getSchema()); // } // // @Override // public String toString() { // return "[" + m_catalog + "." + m_schema + "]"; // } // } // Path: core/src/main/java/com/vecna/dbDiff/model/db/ForeignKey.java import com.google.common.base.Objects; import com.vecna.dbDiff.model.CatalogSchema; /** * Copyright 2011 Vecna Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.vecna.dbDiff.model.db; /** * A model of a database foreign key * @author dlopuch@vecna.com */ public class ForeignKey { //Constraint name private String m_fkName; private String m_keySeq; //Table and column the FK belongs to, ResultSet 5-8
private CatalogSchema m_fkCatalogSchema;
vecnatechnologies/dbDiff
core/src/main/java/com/vecna/dbDiff/business/catalogSchema/impl/DefaultCatalogSchemaResolverFactory.java
// Path: core/src/main/java/com/vecna/dbDiff/business/catalogSchema/CatalogSchemaResolver.java // public interface CatalogSchemaResolver { // /** // * Resolve the catalog/schema // * @param jdbcDriver driver // * @param jdbcUrl url // * @return catalog/schema // */ // public CatalogSchema resolveCatalogSchema(String jdbcDriver, String jdbcUrl); // } // // Path: core/src/main/java/com/vecna/dbDiff/model/CatalogSchema.java // public class CatalogSchema { // /** // * Default schema // */ // public static final String DEFAULT_SCHEMA = "public"; // // /** // * Default catalog // */ // public static final String DEFAULT_CATALOG = null; // // /** // * @return default catalog/schema. // */ // public static CatalogSchema defaultCatalogSchema() { // return new CatalogSchema(DEFAULT_CATALOG, DEFAULT_SCHEMA); // } // // private final String m_catalog; // private final String m_schema; // // /** // * Construct a new {@link CatalogSchema}. // * @param catalog catalog. // * @param schema schema. // */ // public CatalogSchema(String catalog, String schema) { // m_catalog = catalog; // m_schema = schema; // } // // /** // * @return the catalog. // */ // public String getCatalog() { // return m_catalog; // } // // /** // * @return the schema. // */ // public String getSchema() { // return m_schema; // } // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } else if (getClass() != obj.getClass()) { // return false; // } else { // CatalogSchema other = (CatalogSchema) obj; // return Objects.equals(getCatalog(), other.getCatalog()) && Objects.equals(getSchema(), other.getSchema()); // } // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), getCatalog(), getSchema()); // } // // @Override // public String toString() { // return "[" + m_catalog + "." + m_schema + "]"; // } // }
import com.google.common.collect.ImmutableMap; import com.vecna.dbDiff.business.catalogSchema.CatalogSchemaResolver; import com.vecna.dbDiff.model.CatalogSchema;
/** * Copyright 2011 Vecna Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.vecna.dbDiff.business.catalogSchema.impl; /** * This abstract factory wires up the default catalog/schema resolver. * @author ogolberg@vecna.com */ public class DefaultCatalogSchemaResolverFactory { /** * Creates the default catalog/schema resolver * @return default catalog/schema resolver */ public static CatalogSchemaResolver getCatalogSchemaResolver() { return new DelegatingByDriverCatalogSchemaResolverImpl(ImmutableMap.of("org.postgresql.Driver",
// Path: core/src/main/java/com/vecna/dbDiff/business/catalogSchema/CatalogSchemaResolver.java // public interface CatalogSchemaResolver { // /** // * Resolve the catalog/schema // * @param jdbcDriver driver // * @param jdbcUrl url // * @return catalog/schema // */ // public CatalogSchema resolveCatalogSchema(String jdbcDriver, String jdbcUrl); // } // // Path: core/src/main/java/com/vecna/dbDiff/model/CatalogSchema.java // public class CatalogSchema { // /** // * Default schema // */ // public static final String DEFAULT_SCHEMA = "public"; // // /** // * Default catalog // */ // public static final String DEFAULT_CATALOG = null; // // /** // * @return default catalog/schema. // */ // public static CatalogSchema defaultCatalogSchema() { // return new CatalogSchema(DEFAULT_CATALOG, DEFAULT_SCHEMA); // } // // private final String m_catalog; // private final String m_schema; // // /** // * Construct a new {@link CatalogSchema}. // * @param catalog catalog. // * @param schema schema. // */ // public CatalogSchema(String catalog, String schema) { // m_catalog = catalog; // m_schema = schema; // } // // /** // * @return the catalog. // */ // public String getCatalog() { // return m_catalog; // } // // /** // * @return the schema. // */ // public String getSchema() { // return m_schema; // } // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } else if (getClass() != obj.getClass()) { // return false; // } else { // CatalogSchema other = (CatalogSchema) obj; // return Objects.equals(getCatalog(), other.getCatalog()) && Objects.equals(getSchema(), other.getSchema()); // } // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), getCatalog(), getSchema()); // } // // @Override // public String toString() { // return "[" + m_catalog + "." + m_schema + "]"; // } // } // Path: core/src/main/java/com/vecna/dbDiff/business/catalogSchema/impl/DefaultCatalogSchemaResolverFactory.java import com.google.common.collect.ImmutableMap; import com.vecna.dbDiff.business.catalogSchema.CatalogSchemaResolver; import com.vecna.dbDiff.model.CatalogSchema; /** * Copyright 2011 Vecna Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.vecna.dbDiff.business.catalogSchema.impl; /** * This abstract factory wires up the default catalog/schema resolver. * @author ogolberg@vecna.com */ public class DefaultCatalogSchemaResolverFactory { /** * Creates the default catalog/schema resolver * @return default catalog/schema resolver */ public static CatalogSchemaResolver getCatalogSchemaResolver() { return new DelegatingByDriverCatalogSchemaResolverImpl(ImmutableMap.of("org.postgresql.Driver",
new SimpleCatalogSchemaResolver(CatalogSchema
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsListCallbackImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetTransactionListInteractor.java // public interface GetTransactionListInteractor { // // void execute(String path, GetTransactionsListCallback callback) throws CustomException; // // interface GetTransactionsListCallback { // void onGetTransactionsListOK(List<Transaction> transactionList); // // void onGetTransactionListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsListModelDataMapper.java // @ActivityScope // public class TransactionsListModelDataMapper { // // private static final String GBP = "GBP"; // // @Inject // TransactionsListModelDataMapper() { // // } // // /** // * Transforms a List {@link Transaction} into an TreeMap of {@link Transaction} // * to maintain the order from A to Z sorted. // */ // public TreeMap<String, List<Transaction>> transform(List<Transaction> transactionList) { // if (transactionList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // TreeMap<String, List<Transaction>> map = new TreeMap<>(); // for (Transaction transaction : transactionList) { // String key = transaction.getSkuIdentifier(); // if (map.containsKey(key)) { // map.get(key).add(transaction); // } else { // List<Transaction> transactions = new ArrayList<>(); // transactions.add(transaction); // map.put(key, transactions); // } // } // return map; // } // // public List<ProductUI> transform(Map<String, List<Transaction>> transactionsDictionary) { // if (transactionsDictionary == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // ProductUI productUI; // List<ProductUI> productUIs = new ArrayList<>(); // for (Map.Entry<String, List<Transaction>> entry : transactionsDictionary.entrySet()) { // productUI = new ProductUI(entry.getKey(), entry.getValue(), GBP); // productUIs.add(productUI); // } // return productUIs; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/TransactionsPresenter.java // public interface TransactionsPresenter { // void startReading(String path) throws CustomException; // // void setView(View view); // // void saveProducts(List<Transaction> transactionList, Map<String, List<Transaction>> transactionsMap) // throws CustomException; // // void resetView(); // // interface View { // void saveProducts(Map<String, List<Transaction>> transactionsMap, List<Transaction> transactionList); // // void errorSavingProducts(String error); // // void productsSavedSuccessfully(String msg); // // void errorGettingTransactions(String error); // // void showProductsList(List<ProductUI> productUIs); // // void showEmptyState(); // // boolean isReady(); // } // }
import com.raulh82vlc.TransactionsViewer.domain.interactors.GetTransactionListInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsListModelDataMapper; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.ui.presentation.TransactionsPresenter; import java.util.List;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors_response; /** * Get Transactions List Callback communicating towards its view * * @author Raul Hernandez Lopez. */ public class GetTransactionsListCallbackImpl implements GetTransactionListInteractor.GetTransactionsListCallback { private final TransactionsPresenter.View mView;
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetTransactionListInteractor.java // public interface GetTransactionListInteractor { // // void execute(String path, GetTransactionsListCallback callback) throws CustomException; // // interface GetTransactionsListCallback { // void onGetTransactionsListOK(List<Transaction> transactionList); // // void onGetTransactionListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsListModelDataMapper.java // @ActivityScope // public class TransactionsListModelDataMapper { // // private static final String GBP = "GBP"; // // @Inject // TransactionsListModelDataMapper() { // // } // // /** // * Transforms a List {@link Transaction} into an TreeMap of {@link Transaction} // * to maintain the order from A to Z sorted. // */ // public TreeMap<String, List<Transaction>> transform(List<Transaction> transactionList) { // if (transactionList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // TreeMap<String, List<Transaction>> map = new TreeMap<>(); // for (Transaction transaction : transactionList) { // String key = transaction.getSkuIdentifier(); // if (map.containsKey(key)) { // map.get(key).add(transaction); // } else { // List<Transaction> transactions = new ArrayList<>(); // transactions.add(transaction); // map.put(key, transactions); // } // } // return map; // } // // public List<ProductUI> transform(Map<String, List<Transaction>> transactionsDictionary) { // if (transactionsDictionary == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // ProductUI productUI; // List<ProductUI> productUIs = new ArrayList<>(); // for (Map.Entry<String, List<Transaction>> entry : transactionsDictionary.entrySet()) { // productUI = new ProductUI(entry.getKey(), entry.getValue(), GBP); // productUIs.add(productUI); // } // return productUIs; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/TransactionsPresenter.java // public interface TransactionsPresenter { // void startReading(String path) throws CustomException; // // void setView(View view); // // void saveProducts(List<Transaction> transactionList, Map<String, List<Transaction>> transactionsMap) // throws CustomException; // // void resetView(); // // interface View { // void saveProducts(Map<String, List<Transaction>> transactionsMap, List<Transaction> transactionList); // // void errorSavingProducts(String error); // // void productsSavedSuccessfully(String msg); // // void errorGettingTransactions(String error); // // void showProductsList(List<ProductUI> productUIs); // // void showEmptyState(); // // boolean isReady(); // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsListCallbackImpl.java import com.raulh82vlc.TransactionsViewer.domain.interactors.GetTransactionListInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsListModelDataMapper; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.ui.presentation.TransactionsPresenter; import java.util.List; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors_response; /** * Get Transactions List Callback communicating towards its view * * @author Raul Hernandez Lopez. */ public class GetTransactionsListCallbackImpl implements GetTransactionListInteractor.GetTransactionsListCallback { private final TransactionsPresenter.View mView;
private final TransactionsListModelDataMapper transactionsListModelDataMapper;
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsListCallbackImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetTransactionListInteractor.java // public interface GetTransactionListInteractor { // // void execute(String path, GetTransactionsListCallback callback) throws CustomException; // // interface GetTransactionsListCallback { // void onGetTransactionsListOK(List<Transaction> transactionList); // // void onGetTransactionListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsListModelDataMapper.java // @ActivityScope // public class TransactionsListModelDataMapper { // // private static final String GBP = "GBP"; // // @Inject // TransactionsListModelDataMapper() { // // } // // /** // * Transforms a List {@link Transaction} into an TreeMap of {@link Transaction} // * to maintain the order from A to Z sorted. // */ // public TreeMap<String, List<Transaction>> transform(List<Transaction> transactionList) { // if (transactionList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // TreeMap<String, List<Transaction>> map = new TreeMap<>(); // for (Transaction transaction : transactionList) { // String key = transaction.getSkuIdentifier(); // if (map.containsKey(key)) { // map.get(key).add(transaction); // } else { // List<Transaction> transactions = new ArrayList<>(); // transactions.add(transaction); // map.put(key, transactions); // } // } // return map; // } // // public List<ProductUI> transform(Map<String, List<Transaction>> transactionsDictionary) { // if (transactionsDictionary == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // ProductUI productUI; // List<ProductUI> productUIs = new ArrayList<>(); // for (Map.Entry<String, List<Transaction>> entry : transactionsDictionary.entrySet()) { // productUI = new ProductUI(entry.getKey(), entry.getValue(), GBP); // productUIs.add(productUI); // } // return productUIs; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/TransactionsPresenter.java // public interface TransactionsPresenter { // void startReading(String path) throws CustomException; // // void setView(View view); // // void saveProducts(List<Transaction> transactionList, Map<String, List<Transaction>> transactionsMap) // throws CustomException; // // void resetView(); // // interface View { // void saveProducts(Map<String, List<Transaction>> transactionsMap, List<Transaction> transactionList); // // void errorSavingProducts(String error); // // void productsSavedSuccessfully(String msg); // // void errorGettingTransactions(String error); // // void showProductsList(List<ProductUI> productUIs); // // void showEmptyState(); // // boolean isReady(); // } // }
import com.raulh82vlc.TransactionsViewer.domain.interactors.GetTransactionListInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsListModelDataMapper; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.ui.presentation.TransactionsPresenter; import java.util.List;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors_response; /** * Get Transactions List Callback communicating towards its view * * @author Raul Hernandez Lopez. */ public class GetTransactionsListCallbackImpl implements GetTransactionListInteractor.GetTransactionsListCallback { private final TransactionsPresenter.View mView; private final TransactionsListModelDataMapper transactionsListModelDataMapper; public GetTransactionsListCallbackImpl(TransactionsPresenter.View view, TransactionsListModelDataMapper transactionsListModelDataMapper) { mView = view; this.transactionsListModelDataMapper = transactionsListModelDataMapper; } @Override
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetTransactionListInteractor.java // public interface GetTransactionListInteractor { // // void execute(String path, GetTransactionsListCallback callback) throws CustomException; // // interface GetTransactionsListCallback { // void onGetTransactionsListOK(List<Transaction> transactionList); // // void onGetTransactionListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsListModelDataMapper.java // @ActivityScope // public class TransactionsListModelDataMapper { // // private static final String GBP = "GBP"; // // @Inject // TransactionsListModelDataMapper() { // // } // // /** // * Transforms a List {@link Transaction} into an TreeMap of {@link Transaction} // * to maintain the order from A to Z sorted. // */ // public TreeMap<String, List<Transaction>> transform(List<Transaction> transactionList) { // if (transactionList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // TreeMap<String, List<Transaction>> map = new TreeMap<>(); // for (Transaction transaction : transactionList) { // String key = transaction.getSkuIdentifier(); // if (map.containsKey(key)) { // map.get(key).add(transaction); // } else { // List<Transaction> transactions = new ArrayList<>(); // transactions.add(transaction); // map.put(key, transactions); // } // } // return map; // } // // public List<ProductUI> transform(Map<String, List<Transaction>> transactionsDictionary) { // if (transactionsDictionary == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // ProductUI productUI; // List<ProductUI> productUIs = new ArrayList<>(); // for (Map.Entry<String, List<Transaction>> entry : transactionsDictionary.entrySet()) { // productUI = new ProductUI(entry.getKey(), entry.getValue(), GBP); // productUIs.add(productUI); // } // return productUIs; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/TransactionsPresenter.java // public interface TransactionsPresenter { // void startReading(String path) throws CustomException; // // void setView(View view); // // void saveProducts(List<Transaction> transactionList, Map<String, List<Transaction>> transactionsMap) // throws CustomException; // // void resetView(); // // interface View { // void saveProducts(Map<String, List<Transaction>> transactionsMap, List<Transaction> transactionList); // // void errorSavingProducts(String error); // // void productsSavedSuccessfully(String msg); // // void errorGettingTransactions(String error); // // void showProductsList(List<ProductUI> productUIs); // // void showEmptyState(); // // boolean isReady(); // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsListCallbackImpl.java import com.raulh82vlc.TransactionsViewer.domain.interactors.GetTransactionListInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsListModelDataMapper; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.ui.presentation.TransactionsPresenter; import java.util.List; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors_response; /** * Get Transactions List Callback communicating towards its view * * @author Raul Hernandez Lopez. */ public class GetTransactionsListCallbackImpl implements GetTransactionListInteractor.GetTransactionsListCallback { private final TransactionsPresenter.View mView; private final TransactionsListModelDataMapper transactionsListModelDataMapper; public GetTransactionsListCallbackImpl(TransactionsPresenter.View view, TransactionsListModelDataMapper transactionsListModelDataMapper) { mView = view; this.transactionsListModelDataMapper = transactionsListModelDataMapper; } @Override
public void onGetTransactionsListOK(List<Transaction> transactionList) {
raulh82vlc/Transactions-Viewer
domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/SavedTransactionListInteractorImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import java.util.Map; import javax.inject.Inject;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Saved Transactions List Interactor enables repository saving a well as interaction with presenter * @author Raul Hernandez Lopez */ public class SavedTransactionListInteractorImpl implements SavedTransactionsListInteractor, Interactor { private InteractorExecutor executor;
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // } // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/SavedTransactionListInteractorImpl.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import java.util.Map; import javax.inject.Inject; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Saved Transactions List Interactor enables repository saving a well as interaction with presenter * @author Raul Hernandez Lopez */ public class SavedTransactionListInteractorImpl implements SavedTransactionsListInteractor, Interactor { private InteractorExecutor executor;
private MainThread mainThread;
raulh82vlc/Transactions-Viewer
domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/SavedTransactionListInteractorImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import java.util.Map; import javax.inject.Inject;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Saved Transactions List Interactor enables repository saving a well as interaction with presenter * @author Raul Hernandez Lopez */ public class SavedTransactionListInteractorImpl implements SavedTransactionsListInteractor, Interactor { private InteractorExecutor executor; private MainThread mainThread;
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // } // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/SavedTransactionListInteractorImpl.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import java.util.Map; import javax.inject.Inject; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Saved Transactions List Interactor enables repository saving a well as interaction with presenter * @author Raul Hernandez Lopez */ public class SavedTransactionListInteractorImpl implements SavedTransactionsListInteractor, Interactor { private InteractorExecutor executor; private MainThread mainThread;
private DataRepository<Rate, Transaction> repository;
raulh82vlc/Transactions-Viewer
domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/SavedTransactionListInteractorImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import java.util.Map; import javax.inject.Inject;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Saved Transactions List Interactor enables repository saving a well as interaction with presenter * @author Raul Hernandez Lopez */ public class SavedTransactionListInteractorImpl implements SavedTransactionsListInteractor, Interactor { private InteractorExecutor executor; private MainThread mainThread;
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // } // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/SavedTransactionListInteractorImpl.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import java.util.Map; import javax.inject.Inject; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Saved Transactions List Interactor enables repository saving a well as interaction with presenter * @author Raul Hernandez Lopez */ public class SavedTransactionListInteractorImpl implements SavedTransactionsListInteractor, Interactor { private InteractorExecutor executor; private MainThread mainThread;
private DataRepository<Rate, Transaction> repository;
raulh82vlc/Transactions-Viewer
domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/SavedTransactionListInteractorImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import java.util.Map; import javax.inject.Inject;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Saved Transactions List Interactor enables repository saving a well as interaction with presenter * @author Raul Hernandez Lopez */ public class SavedTransactionListInteractorImpl implements SavedTransactionsListInteractor, Interactor { private InteractorExecutor executor; private MainThread mainThread;
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // } // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/SavedTransactionListInteractorImpl.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import java.util.Map; import javax.inject.Inject; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Saved Transactions List Interactor enables repository saving a well as interaction with presenter * @author Raul Hernandez Lopez */ public class SavedTransactionListInteractorImpl implements SavedTransactionsListInteractor, Interactor { private InteractorExecutor executor; private MainThread mainThread;
private DataRepository<Rate, Transaction> repository;
raulh82vlc/Transactions-Viewer
domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/SavedTransactionListInteractorImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import java.util.Map; import javax.inject.Inject;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Saved Transactions List Interactor enables repository saving a well as interaction with presenter * @author Raul Hernandez Lopez */ public class SavedTransactionListInteractorImpl implements SavedTransactionsListInteractor, Interactor { private InteractorExecutor executor; private MainThread mainThread; private DataRepository<Rate, Transaction> repository; private Map<String, List<Transaction>> map; private SavedTransactionsCallback callback; @Inject SavedTransactionListInteractorImpl(InteractorExecutor executor, MainThread mainThread, DataRepository repository) { this.executor = executor; this.mainThread = mainThread; this.repository = repository; } @Override public void executeSaveTransactions(Map<String, List<Transaction>> transactionDictionary,
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // } // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/SavedTransactionListInteractorImpl.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import java.util.Map; import javax.inject.Inject; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Saved Transactions List Interactor enables repository saving a well as interaction with presenter * @author Raul Hernandez Lopez */ public class SavedTransactionListInteractorImpl implements SavedTransactionsListInteractor, Interactor { private InteractorExecutor executor; private MainThread mainThread; private DataRepository<Rate, Transaction> repository; private Map<String, List<Transaction>> map; private SavedTransactionsCallback callback; @Inject SavedTransactionListInteractorImpl(InteractorExecutor executor, MainThread mainThread, DataRepository repository) { this.executor = executor; this.mainThread = mainThread; this.repository = repository; } @Override public void executeSaveTransactions(Map<String, List<Transaction>> transactionDictionary,
SavedTransactionsCallback savedTransactionsCallback) throws CustomException {
raulh82vlc/Transactions-Viewer
domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractor.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import java.util.List;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Get Rates List Use case * * @author Raul Hernandez Lopez */ public interface GetRatesListInteractor { void execute(String path, GetRatesListCallback callback) throws CustomException; interface GetRatesListCallback {
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractor.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import java.util.List; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Get Rates List Use case * * @author Raul Hernandez Lopez */ public interface GetRatesListInteractor { void execute(String path, GetRatesListCallback callback) throws CustomException; interface GetRatesListCallback {
void onGetRatesListOK(List<Rate> rateList);
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenterImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java // public interface ComputeTransactionsInteractor { // // void execute(String skuFromProduct, // GetTransactionsComputedCallback getTransactionsComputedCallback, // String toCurrency, // String pathTransactions, String pathRates) throws CustomException; // // // interface GetTransactionsComputedCallback { // void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount); // // void onGetTransactionListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java // @ActivityScope // public class TransactionsRatedDataMapper { // // @Inject // TransactionsRatedDataMapper() { // // } // // public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) { // if (transactionList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // // List<TransactionUI> transactionUIDomList = new ArrayList<>(); // for (TransactionRatedDomain transactionRated : transactionList) { // transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(), // transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(), // transactionRated.getAmountPerTransactionCurrent().toString())); // } // return transactionUIDomList; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImpl.java // public class GetTransactionsComputedCallbackImpl implements // ComputeTransactionsInteractor.GetTransactionsComputedCallback { // // private final ComputingTransactionsPresenter.View mView; // private final TransactionsRatedDataMapper transactionsRatedDataMapper; // // public GetTransactionsComputedCallbackImpl(ComputingTransactionsPresenter.View view, // TransactionsRatedDataMapper transactionsRatedDataMapper) { // mView = view; // this.transactionsRatedDataMapper = transactionsRatedDataMapper; // } // // @Override // public void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount) { // if (mView.isReady()) { // mView.computedRatesForTransactions(transactionsRatedDataMapper.transformToUI(transactionList), totalAmount); // mView.visibilityChangesAfterSuccessfulComputedRates(); // } // } // // @Override // public void onGetTransactionListKO(String error) { // if (mView.isReady()) { // mView.errorComputingRates(error); // mView.visibilityChangesAfterErrorComputedRates(); // } // } // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper; import com.raulh82vlc.TransactionsViewer.domain.interactors_response.GetTransactionsComputedCallbackImpl; import javax.inject.Inject;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.presentation; /** * Implementation of {@link ComputingTransactionsPresenter} * * @author Raul Hernandez Lopez. */ public class ComputingTransactionsPresenterImpl implements ComputingTransactionsPresenter { private final ComputeTransactionsInteractor interactor;
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java // public interface ComputeTransactionsInteractor { // // void execute(String skuFromProduct, // GetTransactionsComputedCallback getTransactionsComputedCallback, // String toCurrency, // String pathTransactions, String pathRates) throws CustomException; // // // interface GetTransactionsComputedCallback { // void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount); // // void onGetTransactionListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java // @ActivityScope // public class TransactionsRatedDataMapper { // // @Inject // TransactionsRatedDataMapper() { // // } // // public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) { // if (transactionList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // // List<TransactionUI> transactionUIDomList = new ArrayList<>(); // for (TransactionRatedDomain transactionRated : transactionList) { // transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(), // transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(), // transactionRated.getAmountPerTransactionCurrent().toString())); // } // return transactionUIDomList; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImpl.java // public class GetTransactionsComputedCallbackImpl implements // ComputeTransactionsInteractor.GetTransactionsComputedCallback { // // private final ComputingTransactionsPresenter.View mView; // private final TransactionsRatedDataMapper transactionsRatedDataMapper; // // public GetTransactionsComputedCallbackImpl(ComputingTransactionsPresenter.View view, // TransactionsRatedDataMapper transactionsRatedDataMapper) { // mView = view; // this.transactionsRatedDataMapper = transactionsRatedDataMapper; // } // // @Override // public void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount) { // if (mView.isReady()) { // mView.computedRatesForTransactions(transactionsRatedDataMapper.transformToUI(transactionList), totalAmount); // mView.visibilityChangesAfterSuccessfulComputedRates(); // } // } // // @Override // public void onGetTransactionListKO(String error) { // if (mView.isReady()) { // mView.errorComputingRates(error); // mView.visibilityChangesAfterErrorComputedRates(); // } // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenterImpl.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper; import com.raulh82vlc.TransactionsViewer.domain.interactors_response.GetTransactionsComputedCallbackImpl; import javax.inject.Inject; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.presentation; /** * Implementation of {@link ComputingTransactionsPresenter} * * @author Raul Hernandez Lopez. */ public class ComputingTransactionsPresenterImpl implements ComputingTransactionsPresenter { private final ComputeTransactionsInteractor interactor;
private final TransactionsRatedDataMapper transactionsRatedDataMapper;
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenterImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java // public interface ComputeTransactionsInteractor { // // void execute(String skuFromProduct, // GetTransactionsComputedCallback getTransactionsComputedCallback, // String toCurrency, // String pathTransactions, String pathRates) throws CustomException; // // // interface GetTransactionsComputedCallback { // void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount); // // void onGetTransactionListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java // @ActivityScope // public class TransactionsRatedDataMapper { // // @Inject // TransactionsRatedDataMapper() { // // } // // public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) { // if (transactionList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // // List<TransactionUI> transactionUIDomList = new ArrayList<>(); // for (TransactionRatedDomain transactionRated : transactionList) { // transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(), // transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(), // transactionRated.getAmountPerTransactionCurrent().toString())); // } // return transactionUIDomList; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImpl.java // public class GetTransactionsComputedCallbackImpl implements // ComputeTransactionsInteractor.GetTransactionsComputedCallback { // // private final ComputingTransactionsPresenter.View mView; // private final TransactionsRatedDataMapper transactionsRatedDataMapper; // // public GetTransactionsComputedCallbackImpl(ComputingTransactionsPresenter.View view, // TransactionsRatedDataMapper transactionsRatedDataMapper) { // mView = view; // this.transactionsRatedDataMapper = transactionsRatedDataMapper; // } // // @Override // public void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount) { // if (mView.isReady()) { // mView.computedRatesForTransactions(transactionsRatedDataMapper.transformToUI(transactionList), totalAmount); // mView.visibilityChangesAfterSuccessfulComputedRates(); // } // } // // @Override // public void onGetTransactionListKO(String error) { // if (mView.isReady()) { // mView.errorComputingRates(error); // mView.visibilityChangesAfterErrorComputedRates(); // } // } // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper; import com.raulh82vlc.TransactionsViewer.domain.interactors_response.GetTransactionsComputedCallbackImpl; import javax.inject.Inject;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.presentation; /** * Implementation of {@link ComputingTransactionsPresenter} * * @author Raul Hernandez Lopez. */ public class ComputingTransactionsPresenterImpl implements ComputingTransactionsPresenter { private final ComputeTransactionsInteractor interactor; private final TransactionsRatedDataMapper transactionsRatedDataMapper; private View view; @Inject ComputingTransactionsPresenterImpl(ComputeTransactionsInteractor computeTransactionsInteractor, TransactionsRatedDataMapper transactionsRatedDataMapper) { this.interactor = computeTransactionsInteractor; this.transactionsRatedDataMapper = transactionsRatedDataMapper; } @Override public void setView(View view) { if (view == null) { throw new IllegalArgumentException("The view should be instantiated"); } this.view = view; } @Override public void resetView() { view = null; } @Override public void computeRates(String skuFromProduct, String toCurrency, String pathTransactions,
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java // public interface ComputeTransactionsInteractor { // // void execute(String skuFromProduct, // GetTransactionsComputedCallback getTransactionsComputedCallback, // String toCurrency, // String pathTransactions, String pathRates) throws CustomException; // // // interface GetTransactionsComputedCallback { // void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount); // // void onGetTransactionListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java // @ActivityScope // public class TransactionsRatedDataMapper { // // @Inject // TransactionsRatedDataMapper() { // // } // // public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) { // if (transactionList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // // List<TransactionUI> transactionUIDomList = new ArrayList<>(); // for (TransactionRatedDomain transactionRated : transactionList) { // transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(), // transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(), // transactionRated.getAmountPerTransactionCurrent().toString())); // } // return transactionUIDomList; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImpl.java // public class GetTransactionsComputedCallbackImpl implements // ComputeTransactionsInteractor.GetTransactionsComputedCallback { // // private final ComputingTransactionsPresenter.View mView; // private final TransactionsRatedDataMapper transactionsRatedDataMapper; // // public GetTransactionsComputedCallbackImpl(ComputingTransactionsPresenter.View view, // TransactionsRatedDataMapper transactionsRatedDataMapper) { // mView = view; // this.transactionsRatedDataMapper = transactionsRatedDataMapper; // } // // @Override // public void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount) { // if (mView.isReady()) { // mView.computedRatesForTransactions(transactionsRatedDataMapper.transformToUI(transactionList), totalAmount); // mView.visibilityChangesAfterSuccessfulComputedRates(); // } // } // // @Override // public void onGetTransactionListKO(String error) { // if (mView.isReady()) { // mView.errorComputingRates(error); // mView.visibilityChangesAfterErrorComputedRates(); // } // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenterImpl.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper; import com.raulh82vlc.TransactionsViewer.domain.interactors_response.GetTransactionsComputedCallbackImpl; import javax.inject.Inject; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.presentation; /** * Implementation of {@link ComputingTransactionsPresenter} * * @author Raul Hernandez Lopez. */ public class ComputingTransactionsPresenterImpl implements ComputingTransactionsPresenter { private final ComputeTransactionsInteractor interactor; private final TransactionsRatedDataMapper transactionsRatedDataMapper; private View view; @Inject ComputingTransactionsPresenterImpl(ComputeTransactionsInteractor computeTransactionsInteractor, TransactionsRatedDataMapper transactionsRatedDataMapper) { this.interactor = computeTransactionsInteractor; this.transactionsRatedDataMapper = transactionsRatedDataMapper; } @Override public void setView(View view) { if (view == null) { throw new IllegalArgumentException("The view should be instantiated"); } this.view = view; } @Override public void resetView() { view = null; } @Override public void computeRates(String skuFromProduct, String toCurrency, String pathTransactions,
String pathRates) throws CustomException {
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenterImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java // public interface ComputeTransactionsInteractor { // // void execute(String skuFromProduct, // GetTransactionsComputedCallback getTransactionsComputedCallback, // String toCurrency, // String pathTransactions, String pathRates) throws CustomException; // // // interface GetTransactionsComputedCallback { // void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount); // // void onGetTransactionListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java // @ActivityScope // public class TransactionsRatedDataMapper { // // @Inject // TransactionsRatedDataMapper() { // // } // // public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) { // if (transactionList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // // List<TransactionUI> transactionUIDomList = new ArrayList<>(); // for (TransactionRatedDomain transactionRated : transactionList) { // transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(), // transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(), // transactionRated.getAmountPerTransactionCurrent().toString())); // } // return transactionUIDomList; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImpl.java // public class GetTransactionsComputedCallbackImpl implements // ComputeTransactionsInteractor.GetTransactionsComputedCallback { // // private final ComputingTransactionsPresenter.View mView; // private final TransactionsRatedDataMapper transactionsRatedDataMapper; // // public GetTransactionsComputedCallbackImpl(ComputingTransactionsPresenter.View view, // TransactionsRatedDataMapper transactionsRatedDataMapper) { // mView = view; // this.transactionsRatedDataMapper = transactionsRatedDataMapper; // } // // @Override // public void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount) { // if (mView.isReady()) { // mView.computedRatesForTransactions(transactionsRatedDataMapper.transformToUI(transactionList), totalAmount); // mView.visibilityChangesAfterSuccessfulComputedRates(); // } // } // // @Override // public void onGetTransactionListKO(String error) { // if (mView.isReady()) { // mView.errorComputingRates(error); // mView.visibilityChangesAfterErrorComputedRates(); // } // } // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper; import com.raulh82vlc.TransactionsViewer.domain.interactors_response.GetTransactionsComputedCallbackImpl; import javax.inject.Inject;
ComputingTransactionsPresenterImpl(ComputeTransactionsInteractor computeTransactionsInteractor, TransactionsRatedDataMapper transactionsRatedDataMapper) { this.interactor = computeTransactionsInteractor; this.transactionsRatedDataMapper = transactionsRatedDataMapper; } @Override public void setView(View view) { if (view == null) { throw new IllegalArgumentException("The view should be instantiated"); } this.view = view; } @Override public void resetView() { view = null; } @Override public void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates) throws CustomException { if (view != null) { view.startLoader(); startComputingRates(skuFromProduct, toCurrency, pathTransactions, pathRates); } } private void startComputingRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates) throws CustomException {
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/ComputeTransactionsInteractor.java // public interface ComputeTransactionsInteractor { // // void execute(String skuFromProduct, // GetTransactionsComputedCallback getTransactionsComputedCallback, // String toCurrency, // String pathTransactions, String pathRates) throws CustomException; // // // interface GetTransactionsComputedCallback { // void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount); // // void onGetTransactionListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/TransactionsRatedDataMapper.java // @ActivityScope // public class TransactionsRatedDataMapper { // // @Inject // TransactionsRatedDataMapper() { // // } // // public List<TransactionUI> transformToUI(List<TransactionRatedDomain> transactionList) { // if (transactionList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // // List<TransactionUI> transactionUIDomList = new ArrayList<>(); // for (TransactionRatedDomain transactionRated : transactionList) { // transactionUIDomList.add(new TransactionUI(transactionRated.getCurrencyPrev(), // transactionRated.getCurrencyCurrent(), transactionRated.getAmounPerTransactionPrev().toString(), // transactionRated.getAmountPerTransactionCurrent().toString())); // } // return transactionUIDomList; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetTransactionsComputedCallbackImpl.java // public class GetTransactionsComputedCallbackImpl implements // ComputeTransactionsInteractor.GetTransactionsComputedCallback { // // private final ComputingTransactionsPresenter.View mView; // private final TransactionsRatedDataMapper transactionsRatedDataMapper; // // public GetTransactionsComputedCallbackImpl(ComputingTransactionsPresenter.View view, // TransactionsRatedDataMapper transactionsRatedDataMapper) { // mView = view; // this.transactionsRatedDataMapper = transactionsRatedDataMapper; // } // // @Override // public void onGetTransactionsListOK(List<TransactionRatedDomain> transactionList, String totalAmount) { // if (mView.isReady()) { // mView.computedRatesForTransactions(transactionsRatedDataMapper.transformToUI(transactionList), totalAmount); // mView.visibilityChangesAfterSuccessfulComputedRates(); // } // } // // @Override // public void onGetTransactionListKO(String error) { // if (mView.isReady()) { // mView.errorComputingRates(error); // mView.visibilityChangesAfterErrorComputedRates(); // } // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenterImpl.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.interactors.ComputeTransactionsInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.TransactionsRatedDataMapper; import com.raulh82vlc.TransactionsViewer.domain.interactors_response.GetTransactionsComputedCallbackImpl; import javax.inject.Inject; ComputingTransactionsPresenterImpl(ComputeTransactionsInteractor computeTransactionsInteractor, TransactionsRatedDataMapper transactionsRatedDataMapper) { this.interactor = computeTransactionsInteractor; this.transactionsRatedDataMapper = transactionsRatedDataMapper; } @Override public void setView(View view) { if (view == null) { throw new IllegalArgumentException("The view should be instantiated"); } this.view = view; } @Override public void resetView() { view = null; } @Override public void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates) throws CustomException { if (view != null) { view.startLoader(); startComputingRates(skuFromProduct, toCurrency, pathTransactions, pathRates); } } private void startComputingRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates) throws CustomException {
interactor.execute(skuFromProduct, new GetTransactionsComputedCallbackImpl(view, transactionsRatedDataMapper),
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/datasources/json/JSONOperationsImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // }
import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.inject.Inject; import android.content.Context; import android.content.res.AssetManager; import android.util.Log; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.datasources.json; /** * Declared read operations from the JSON API interface * * @author Raul Hernandez Lopez */ public class JSONOperationsImpl implements JSONOperations<Rate, Transaction> { private static final String TAG = JSONOperationsImpl.class.getSimpleName(); private Gson mGson; @Inject JSONOperationsImpl() { if (mGson == null) { synchronized (this) { if (mGson == null) { mGson = new Gson(); } } } } @Override
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/datasources/json/JSONOperationsImpl.java import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.inject.Inject; import android.content.Context; import android.content.res.AssetManager; import android.util.Log; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.datasources.json; /** * Declared read operations from the JSON API interface * * @author Raul Hernandez Lopez */ public class JSONOperationsImpl implements JSONOperations<Rate, Transaction> { private static final String TAG = JSONOperationsImpl.class.getSimpleName(); private Gson mGson; @Inject JSONOperationsImpl() { if (mGson == null) { synchronized (this) { if (mGson == null) { mGson = new Gson(); } } } } @Override
public List<Rate> getRatesList(Context context, String path) throws CustomException {
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/AbstractActivityComponent.java
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ActivityModule.java // @Module // public class ActivityModule { // private final Activity activityContext; // // public ActivityModule(Activity activityContext) { // this.activityContext = activityContext; // } // // @Provides // @ActivityScope // Activity getActivityContext() { // return activityContext; // } // }
import android.app.Activity; import com.raulh82vlc.TransactionsViewer.di.modules.ActivityModule; import com.raulh82vlc.TransactionsViewer.di.scopes.ActivityScope; import dagger.Component;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.di.components; /** * Those components linked to the activity lifecycle or * to the activity context will depend or extend this one. * Those which are lifecycles or mainly common dependencies linked to activity context * would be the kind of dependencies were are talking about. * <p/> * Activity-level components should extend this component. * Fragment components may depend on this component. * * @author Raul Hernandez Lopez */ @ActivityScope @Component(dependencies = ApplicationComponent.class,
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ActivityModule.java // @Module // public class ActivityModule { // private final Activity activityContext; // // public ActivityModule(Activity activityContext) { // this.activityContext = activityContext; // } // // @Provides // @ActivityScope // Activity getActivityContext() { // return activityContext; // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/AbstractActivityComponent.java import android.app.Activity; import com.raulh82vlc.TransactionsViewer.di.modules.ActivityModule; import com.raulh82vlc.TransactionsViewer.di.scopes.ActivityScope; import dagger.Component; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.di.components; /** * Those components linked to the activity lifecycle or * to the activity context will depend or extend this one. * Those which are lifecycles or mainly common dependencies linked to activity context * would be the kind of dependencies were are talking about. * <p/> * Activity-level components should extend this component. * Fragment components may depend on this component. * * @author Raul Hernandez Lopez */ @ActivityScope @Component(dependencies = ApplicationComponent.class,
modules = ActivityModule.class)
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/JSONRepositoryImpl.java
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/datasources/json/JSONDataSourceImpl.java // public class JSONDataSourceImpl implements JSONDataSource<Rate, Transaction> { // // /** // * Vars declaration // */ // private Context mContext; // private JSONOperations<Rate, Transaction> mJSONOperations; // // @Inject // JSONDataSourceImpl(Context context, // JSONOperationsImpl jsonOperations) { // mContext = context; // if (mJSONOperations == null) { // synchronized (this) { // if (mJSONOperations == null) { // mJSONOperations = jsonOperations; // } // } // } // } // // @Override // public List<Rate> getRatesList(String path) throws CustomException { // return startToReadRatesFromFile(path); // } // // @Override // public List<Transaction> getTransactionsList(String path) throws CustomException { // return startToReadTransactionsFromFile(path); // } // // /** // * Starts to read from file the Transactions List // * // * @return List of transactions // * @throws CustomException // */ // private List<Transaction> startToReadTransactionsFromFile(String path) throws CustomException { // return mJSONOperations.getTransactionsList(mContext, path); // } // // /** // * Starts to read from file the Rates List // * // * @return List of rates // * @throws CustomException // */ // private List<Rate> startToReadRatesFromFile(String path) throws CustomException { // return mJSONOperations.getRatesList(mContext, path); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/datasources/JSONDataSource.java // public interface JSONDataSource<R, T> { // // /** // * Gets a Rates List from a JSON file // * // * @param path path of the file // */ // List<R> getRatesList(String path) throws CustomException; // // /** // * Gets a Transactions List from a JSON file // * // * @param path path of the file // */ // List<T> getTransactionsList(String path) throws CustomException; // }
import javax.inject.Inject; import com.raulh82vlc.TransactionsViewer.domain.datasources.json.JSONDataSourceImpl; import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.datasources.JSONDataSource; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.repository; /** * <p>Implements {@link DataRepository} and allows to have one or more Datasource * like {@link JSONDataSource} or one another on it</p> * * @author Raul Hernandez Lopez */ public class JSONRepositoryImpl implements DataRepository<Rate, Transaction> { private static final int SUPPORTED_SIMULTANEOUS_PATHS = 1;
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/datasources/json/JSONDataSourceImpl.java // public class JSONDataSourceImpl implements JSONDataSource<Rate, Transaction> { // // /** // * Vars declaration // */ // private Context mContext; // private JSONOperations<Rate, Transaction> mJSONOperations; // // @Inject // JSONDataSourceImpl(Context context, // JSONOperationsImpl jsonOperations) { // mContext = context; // if (mJSONOperations == null) { // synchronized (this) { // if (mJSONOperations == null) { // mJSONOperations = jsonOperations; // } // } // } // } // // @Override // public List<Rate> getRatesList(String path) throws CustomException { // return startToReadRatesFromFile(path); // } // // @Override // public List<Transaction> getTransactionsList(String path) throws CustomException { // return startToReadTransactionsFromFile(path); // } // // /** // * Starts to read from file the Transactions List // * // * @return List of transactions // * @throws CustomException // */ // private List<Transaction> startToReadTransactionsFromFile(String path) throws CustomException { // return mJSONOperations.getTransactionsList(mContext, path); // } // // /** // * Starts to read from file the Rates List // * // * @return List of rates // * @throws CustomException // */ // private List<Rate> startToReadRatesFromFile(String path) throws CustomException { // return mJSONOperations.getRatesList(mContext, path); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/datasources/JSONDataSource.java // public interface JSONDataSource<R, T> { // // /** // * Gets a Rates List from a JSON file // * // * @param path path of the file // */ // List<R> getRatesList(String path) throws CustomException; // // /** // * Gets a Transactions List from a JSON file // * // * @param path path of the file // */ // List<T> getTransactionsList(String path) throws CustomException; // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/JSONRepositoryImpl.java import javax.inject.Inject; import com.raulh82vlc.TransactionsViewer.domain.datasources.json.JSONDataSourceImpl; import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.datasources.JSONDataSource; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.repository; /** * <p>Implements {@link DataRepository} and allows to have one or more Datasource * like {@link JSONDataSource} or one another on it</p> * * @author Raul Hernandez Lopez */ public class JSONRepositoryImpl implements DataRepository<Rate, Transaction> { private static final int SUPPORTED_SIMULTANEOUS_PATHS = 1;
private JSONDataSource<Rate, Transaction> mJsonDataSource;
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/JSONRepositoryImpl.java
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/datasources/json/JSONDataSourceImpl.java // public class JSONDataSourceImpl implements JSONDataSource<Rate, Transaction> { // // /** // * Vars declaration // */ // private Context mContext; // private JSONOperations<Rate, Transaction> mJSONOperations; // // @Inject // JSONDataSourceImpl(Context context, // JSONOperationsImpl jsonOperations) { // mContext = context; // if (mJSONOperations == null) { // synchronized (this) { // if (mJSONOperations == null) { // mJSONOperations = jsonOperations; // } // } // } // } // // @Override // public List<Rate> getRatesList(String path) throws CustomException { // return startToReadRatesFromFile(path); // } // // @Override // public List<Transaction> getTransactionsList(String path) throws CustomException { // return startToReadTransactionsFromFile(path); // } // // /** // * Starts to read from file the Transactions List // * // * @return List of transactions // * @throws CustomException // */ // private List<Transaction> startToReadTransactionsFromFile(String path) throws CustomException { // return mJSONOperations.getTransactionsList(mContext, path); // } // // /** // * Starts to read from file the Rates List // * // * @return List of rates // * @throws CustomException // */ // private List<Rate> startToReadRatesFromFile(String path) throws CustomException { // return mJSONOperations.getRatesList(mContext, path); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/datasources/JSONDataSource.java // public interface JSONDataSource<R, T> { // // /** // * Gets a Rates List from a JSON file // * // * @param path path of the file // */ // List<R> getRatesList(String path) throws CustomException; // // /** // * Gets a Transactions List from a JSON file // * // * @param path path of the file // */ // List<T> getTransactionsList(String path) throws CustomException; // }
import javax.inject.Inject; import com.raulh82vlc.TransactionsViewer.domain.datasources.json.JSONDataSourceImpl; import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.datasources.JSONDataSource; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.repository; /** * <p>Implements {@link DataRepository} and allows to have one or more Datasource * like {@link JSONDataSource} or one another on it</p> * * @author Raul Hernandez Lopez */ public class JSONRepositoryImpl implements DataRepository<Rate, Transaction> { private static final int SUPPORTED_SIMULTANEOUS_PATHS = 1; private JSONDataSource<Rate, Transaction> mJsonDataSource; private List<Rate> mRates = new ArrayList<>(); private List<Transaction> mTransactions = new ArrayList<>(); private Set<String> dataPathListRates = new HashSet<>(SUPPORTED_SIMULTANEOUS_PATHS); private Set<String> dataPathListTransactions = new HashSet<>(SUPPORTED_SIMULTANEOUS_PATHS); private Map<String, List<Transaction>> mDictionaryOfTransactions; @Inject
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/datasources/json/JSONDataSourceImpl.java // public class JSONDataSourceImpl implements JSONDataSource<Rate, Transaction> { // // /** // * Vars declaration // */ // private Context mContext; // private JSONOperations<Rate, Transaction> mJSONOperations; // // @Inject // JSONDataSourceImpl(Context context, // JSONOperationsImpl jsonOperations) { // mContext = context; // if (mJSONOperations == null) { // synchronized (this) { // if (mJSONOperations == null) { // mJSONOperations = jsonOperations; // } // } // } // } // // @Override // public List<Rate> getRatesList(String path) throws CustomException { // return startToReadRatesFromFile(path); // } // // @Override // public List<Transaction> getTransactionsList(String path) throws CustomException { // return startToReadTransactionsFromFile(path); // } // // /** // * Starts to read from file the Transactions List // * // * @return List of transactions // * @throws CustomException // */ // private List<Transaction> startToReadTransactionsFromFile(String path) throws CustomException { // return mJSONOperations.getTransactionsList(mContext, path); // } // // /** // * Starts to read from file the Rates List // * // * @return List of rates // * @throws CustomException // */ // private List<Rate> startToReadRatesFromFile(String path) throws CustomException { // return mJSONOperations.getRatesList(mContext, path); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/datasources/JSONDataSource.java // public interface JSONDataSource<R, T> { // // /** // * Gets a Rates List from a JSON file // * // * @param path path of the file // */ // List<R> getRatesList(String path) throws CustomException; // // /** // * Gets a Transactions List from a JSON file // * // * @param path path of the file // */ // List<T> getTransactionsList(String path) throws CustomException; // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/JSONRepositoryImpl.java import javax.inject.Inject; import com.raulh82vlc.TransactionsViewer.domain.datasources.json.JSONDataSourceImpl; import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.datasources.JSONDataSource; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.repository; /** * <p>Implements {@link DataRepository} and allows to have one or more Datasource * like {@link JSONDataSource} or one another on it</p> * * @author Raul Hernandez Lopez */ public class JSONRepositoryImpl implements DataRepository<Rate, Transaction> { private static final int SUPPORTED_SIMULTANEOUS_PATHS = 1; private JSONDataSource<Rate, Transaction> mJsonDataSource; private List<Rate> mRates = new ArrayList<>(); private List<Transaction> mTransactions = new ArrayList<>(); private Set<String> dataPathListRates = new HashSet<>(SUPPORTED_SIMULTANEOUS_PATHS); private Set<String> dataPathListTransactions = new HashSet<>(SUPPORTED_SIMULTANEOUS_PATHS); private Map<String, List<Transaction>> mDictionaryOfTransactions; @Inject
JSONRepositoryImpl(JSONDataSourceImpl jsonDataSource) {
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/JSONRepositoryImpl.java
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/datasources/json/JSONDataSourceImpl.java // public class JSONDataSourceImpl implements JSONDataSource<Rate, Transaction> { // // /** // * Vars declaration // */ // private Context mContext; // private JSONOperations<Rate, Transaction> mJSONOperations; // // @Inject // JSONDataSourceImpl(Context context, // JSONOperationsImpl jsonOperations) { // mContext = context; // if (mJSONOperations == null) { // synchronized (this) { // if (mJSONOperations == null) { // mJSONOperations = jsonOperations; // } // } // } // } // // @Override // public List<Rate> getRatesList(String path) throws CustomException { // return startToReadRatesFromFile(path); // } // // @Override // public List<Transaction> getTransactionsList(String path) throws CustomException { // return startToReadTransactionsFromFile(path); // } // // /** // * Starts to read from file the Transactions List // * // * @return List of transactions // * @throws CustomException // */ // private List<Transaction> startToReadTransactionsFromFile(String path) throws CustomException { // return mJSONOperations.getTransactionsList(mContext, path); // } // // /** // * Starts to read from file the Rates List // * // * @return List of rates // * @throws CustomException // */ // private List<Rate> startToReadRatesFromFile(String path) throws CustomException { // return mJSONOperations.getRatesList(mContext, path); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/datasources/JSONDataSource.java // public interface JSONDataSource<R, T> { // // /** // * Gets a Rates List from a JSON file // * // * @param path path of the file // */ // List<R> getRatesList(String path) throws CustomException; // // /** // * Gets a Transactions List from a JSON file // * // * @param path path of the file // */ // List<T> getTransactionsList(String path) throws CustomException; // }
import javax.inject.Inject; import com.raulh82vlc.TransactionsViewer.domain.datasources.json.JSONDataSourceImpl; import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.datasources.JSONDataSource; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.repository; /** * <p>Implements {@link DataRepository} and allows to have one or more Datasource * like {@link JSONDataSource} or one another on it</p> * * @author Raul Hernandez Lopez */ public class JSONRepositoryImpl implements DataRepository<Rate, Transaction> { private static final int SUPPORTED_SIMULTANEOUS_PATHS = 1; private JSONDataSource<Rate, Transaction> mJsonDataSource; private List<Rate> mRates = new ArrayList<>(); private List<Transaction> mTransactions = new ArrayList<>(); private Set<String> dataPathListRates = new HashSet<>(SUPPORTED_SIMULTANEOUS_PATHS); private Set<String> dataPathListTransactions = new HashSet<>(SUPPORTED_SIMULTANEOUS_PATHS); private Map<String, List<Transaction>> mDictionaryOfTransactions; @Inject JSONRepositoryImpl(JSONDataSourceImpl jsonDataSource) { if (mJsonDataSource == null) { synchronized (JSONRepositoryImpl.class) { if (mJsonDataSource == null) { mJsonDataSource = jsonDataSource; } } } } @Override
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/datasources/json/JSONDataSourceImpl.java // public class JSONDataSourceImpl implements JSONDataSource<Rate, Transaction> { // // /** // * Vars declaration // */ // private Context mContext; // private JSONOperations<Rate, Transaction> mJSONOperations; // // @Inject // JSONDataSourceImpl(Context context, // JSONOperationsImpl jsonOperations) { // mContext = context; // if (mJSONOperations == null) { // synchronized (this) { // if (mJSONOperations == null) { // mJSONOperations = jsonOperations; // } // } // } // } // // @Override // public List<Rate> getRatesList(String path) throws CustomException { // return startToReadRatesFromFile(path); // } // // @Override // public List<Transaction> getTransactionsList(String path) throws CustomException { // return startToReadTransactionsFromFile(path); // } // // /** // * Starts to read from file the Transactions List // * // * @return List of transactions // * @throws CustomException // */ // private List<Transaction> startToReadTransactionsFromFile(String path) throws CustomException { // return mJSONOperations.getTransactionsList(mContext, path); // } // // /** // * Starts to read from file the Rates List // * // * @return List of rates // * @throws CustomException // */ // private List<Rate> startToReadRatesFromFile(String path) throws CustomException { // return mJSONOperations.getRatesList(mContext, path); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/datasources/JSONDataSource.java // public interface JSONDataSource<R, T> { // // /** // * Gets a Rates List from a JSON file // * // * @param path path of the file // */ // List<R> getRatesList(String path) throws CustomException; // // /** // * Gets a Transactions List from a JSON file // * // * @param path path of the file // */ // List<T> getTransactionsList(String path) throws CustomException; // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/JSONRepositoryImpl.java import javax.inject.Inject; import com.raulh82vlc.TransactionsViewer.domain.datasources.json.JSONDataSourceImpl; import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.datasources.JSONDataSource; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.repository; /** * <p>Implements {@link DataRepository} and allows to have one or more Datasource * like {@link JSONDataSource} or one another on it</p> * * @author Raul Hernandez Lopez */ public class JSONRepositoryImpl implements DataRepository<Rate, Transaction> { private static final int SUPPORTED_SIMULTANEOUS_PATHS = 1; private JSONDataSource<Rate, Transaction> mJsonDataSource; private List<Rate> mRates = new ArrayList<>(); private List<Transaction> mTransactions = new ArrayList<>(); private Set<String> dataPathListRates = new HashSet<>(SUPPORTED_SIMULTANEOUS_PATHS); private Set<String> dataPathListTransactions = new HashSet<>(SUPPORTED_SIMULTANEOUS_PATHS); private Map<String, List<Transaction>> mDictionaryOfTransactions; @Inject JSONRepositoryImpl(JSONDataSourceImpl jsonDataSource) { if (mJsonDataSource == null) { synchronized (JSONRepositoryImpl.class) { if (mJsonDataSource == null) { mJsonDataSource = jsonDataSource; } } } } @Override
public List<Rate> getRatesList(String datapath) throws CustomException {
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/activities/ProductsListActivity.java
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java // public class TransactionsViewerApp extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent component() { // return applicationComponent; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ProductsListComponent.java // @ActivityScope // @Component(dependencies = ApplicationComponent.class, // modules = { // ActivityModule.class, // ProductsListModule.class // }) // public interface ProductsListComponent extends AbstractActivityComponent { // void inject(ProductsListActivity productsListActivity); // // void inject(ProductsListFragment productsListFragment); // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ActivityModule.java // @Module // public class ActivityModule { // private final Activity activityContext; // // public ActivityModule(Activity activityContext) { // this.activityContext = activityContext; // } // // @Provides // @ActivityScope // Activity getActivityContext() { // return activityContext; // } // }
import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.ActionBar; import com.raulh82vlc.TransactionsViewer.R; import com.raulh82vlc.TransactionsViewer.TransactionsViewerApp; import com.raulh82vlc.TransactionsViewer.di.components.DaggerProductsListComponent; import com.raulh82vlc.TransactionsViewer.di.components.ProductsListComponent; import com.raulh82vlc.TransactionsViewer.di.modules.ActivityModule;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.activities; /** * <p>Products List Activity</p> * * @author Raul Hernandez Lopez */ public class ProductsListActivity extends BaseActivity { private ProductsListComponent mProductsListComponent; public ProductsListComponent component() { if (mProductsListComponent == null) { mProductsListComponent = DaggerProductsListComponent.builder()
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java // public class TransactionsViewerApp extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent component() { // return applicationComponent; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ProductsListComponent.java // @ActivityScope // @Component(dependencies = ApplicationComponent.class, // modules = { // ActivityModule.class, // ProductsListModule.class // }) // public interface ProductsListComponent extends AbstractActivityComponent { // void inject(ProductsListActivity productsListActivity); // // void inject(ProductsListFragment productsListFragment); // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ActivityModule.java // @Module // public class ActivityModule { // private final Activity activityContext; // // public ActivityModule(Activity activityContext) { // this.activityContext = activityContext; // } // // @Provides // @ActivityScope // Activity getActivityContext() { // return activityContext; // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/activities/ProductsListActivity.java import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.ActionBar; import com.raulh82vlc.TransactionsViewer.R; import com.raulh82vlc.TransactionsViewer.TransactionsViewerApp; import com.raulh82vlc.TransactionsViewer.di.components.DaggerProductsListComponent; import com.raulh82vlc.TransactionsViewer.di.components.ProductsListComponent; import com.raulh82vlc.TransactionsViewer.di.modules.ActivityModule; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.activities; /** * <p>Products List Activity</p> * * @author Raul Hernandez Lopez */ public class ProductsListActivity extends BaseActivity { private ProductsListComponent mProductsListComponent; public ProductsListComponent component() { if (mProductsListComponent == null) { mProductsListComponent = DaggerProductsListComponent.builder()
.applicationComponent(((TransactionsViewerApp) getApplication()).component())
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/activities/ProductsListActivity.java
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java // public class TransactionsViewerApp extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent component() { // return applicationComponent; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ProductsListComponent.java // @ActivityScope // @Component(dependencies = ApplicationComponent.class, // modules = { // ActivityModule.class, // ProductsListModule.class // }) // public interface ProductsListComponent extends AbstractActivityComponent { // void inject(ProductsListActivity productsListActivity); // // void inject(ProductsListFragment productsListFragment); // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ActivityModule.java // @Module // public class ActivityModule { // private final Activity activityContext; // // public ActivityModule(Activity activityContext) { // this.activityContext = activityContext; // } // // @Provides // @ActivityScope // Activity getActivityContext() { // return activityContext; // } // }
import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.ActionBar; import com.raulh82vlc.TransactionsViewer.R; import com.raulh82vlc.TransactionsViewer.TransactionsViewerApp; import com.raulh82vlc.TransactionsViewer.di.components.DaggerProductsListComponent; import com.raulh82vlc.TransactionsViewer.di.components.ProductsListComponent; import com.raulh82vlc.TransactionsViewer.di.modules.ActivityModule;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.activities; /** * <p>Products List Activity</p> * * @author Raul Hernandez Lopez */ public class ProductsListActivity extends BaseActivity { private ProductsListComponent mProductsListComponent; public ProductsListComponent component() { if (mProductsListComponent == null) { mProductsListComponent = DaggerProductsListComponent.builder() .applicationComponent(((TransactionsViewerApp) getApplication()).component())
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/TransactionsViewerApp.java // public class TransactionsViewerApp extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent component() { // return applicationComponent; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/components/ProductsListComponent.java // @ActivityScope // @Component(dependencies = ApplicationComponent.class, // modules = { // ActivityModule.class, // ProductsListModule.class // }) // public interface ProductsListComponent extends AbstractActivityComponent { // void inject(ProductsListActivity productsListActivity); // // void inject(ProductsListFragment productsListFragment); // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/di/modules/ActivityModule.java // @Module // public class ActivityModule { // private final Activity activityContext; // // public ActivityModule(Activity activityContext) { // this.activityContext = activityContext; // } // // @Provides // @ActivityScope // Activity getActivityContext() { // return activityContext; // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/activities/ProductsListActivity.java import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.ActionBar; import com.raulh82vlc.TransactionsViewer.R; import com.raulh82vlc.TransactionsViewer.TransactionsViewerApp; import com.raulh82vlc.TransactionsViewer.di.components.DaggerProductsListComponent; import com.raulh82vlc.TransactionsViewer.di.components.ProductsListComponent; import com.raulh82vlc.TransactionsViewer.di.modules.ActivityModule; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.activities; /** * <p>Products List Activity</p> * * @author Raul Hernandez Lopez */ public class ProductsListActivity extends BaseActivity { private ProductsListComponent mProductsListComponent; public ProductsListComponent component() { if (mProductsListComponent == null) { mProductsListComponent = DaggerProductsListComponent.builder() .applicationComponent(((TransactionsViewerApp) getApplication()).component())
.activityModule(new ActivityModule(this))
raulh82vlc/Transactions-Viewer
domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/ThreadsPoolExecutor.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import javax.inject.Inject;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.executors; /** * ThreadsPoolExecutor is the interactor's handler and has settings for the pool. * <p/> {@link ThreadPoolExecutor} is the Interactor executor implementation.<p/> * * @author Raul Hernandez Lopez */ public class ThreadsPoolExecutor implements InteractorExecutor { /** * Constants */ private static final int MAX_SIZE = 6; private static final int CORE_DEFAULT_SIZE = 3; private static final int TIME_OUT_TIME = 300; private static final TimeUnit TIME_UNITS = TimeUnit.SECONDS; /** * Local variables */ private ThreadPoolExecutor threadsPoolExecutor; @Inject ThreadsPoolExecutor() { BlockingQueue<Runnable> mWorkersQueue = new LinkedBlockingQueue<>(); threadsPoolExecutor = new ThreadPoolExecutor(CORE_DEFAULT_SIZE, MAX_SIZE, TIME_OUT_TIME, TIME_UNITS, mWorkersQueue); } @Override
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/ThreadsPoolExecutor.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import javax.inject.Inject; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.executors; /** * ThreadsPoolExecutor is the interactor's handler and has settings for the pool. * <p/> {@link ThreadPoolExecutor} is the Interactor executor implementation.<p/> * * @author Raul Hernandez Lopez */ public class ThreadsPoolExecutor implements InteractorExecutor { /** * Constants */ private static final int MAX_SIZE = 6; private static final int CORE_DEFAULT_SIZE = 3; private static final int TIME_OUT_TIME = 300; private static final TimeUnit TIME_UNITS = TimeUnit.SECONDS; /** * Local variables */ private ThreadPoolExecutor threadsPoolExecutor; @Inject ThreadsPoolExecutor() { BlockingQueue<Runnable> mWorkersQueue = new LinkedBlockingQueue<>(); threadsPoolExecutor = new ThreadPoolExecutor(CORE_DEFAULT_SIZE, MAX_SIZE, TIME_OUT_TIME, TIME_UNITS, mWorkersQueue); } @Override
public void run(final Interactor interactor) throws CustomException {
raulh82vlc/Transactions-Viewer
domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/SavedTransactionsListInteractor.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import java.util.List; import java.util.Map;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Save Transactions interactor */ public interface SavedTransactionsListInteractor { void executeSaveTransactions(Map<String, List<Transaction>> transactionList,
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/SavedTransactionsListInteractor.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import java.util.List; import java.util.Map; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Save Transactions interactor */ public interface SavedTransactionsListInteractor { void executeSaveTransactions(Map<String, List<Transaction>> transactionList,
SavedTransactionsCallback savedTransactionsCallback) throws CustomException;
raulh82vlc/Transactions-Viewer
android/src/test/java/com/raulh82vlc/TransactionsViewer/domain/repository/JSONRepositoryImplTest.java
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/datasources/json/JSONDataSourceImpl.java // public class JSONDataSourceImpl implements JSONDataSource<Rate, Transaction> { // // /** // * Vars declaration // */ // private Context mContext; // private JSONOperations<Rate, Transaction> mJSONOperations; // // @Inject // JSONDataSourceImpl(Context context, // JSONOperationsImpl jsonOperations) { // mContext = context; // if (mJSONOperations == null) { // synchronized (this) { // if (mJSONOperations == null) { // mJSONOperations = jsonOperations; // } // } // } // } // // @Override // public List<Rate> getRatesList(String path) throws CustomException { // return startToReadRatesFromFile(path); // } // // @Override // public List<Transaction> getTransactionsList(String path) throws CustomException { // return startToReadTransactionsFromFile(path); // } // // /** // * Starts to read from file the Transactions List // * // * @return List of transactions // * @throws CustomException // */ // private List<Transaction> startToReadTransactionsFromFile(String path) throws CustomException { // return mJSONOperations.getTransactionsList(mContext, path); // } // // /** // * Starts to read from file the Rates List // * // * @return List of rates // * @throws CustomException // */ // private List<Rate> startToReadRatesFromFile(String path) throws CustomException { // return mJSONOperations.getRatesList(mContext, path); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // }
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; import com.raulh82vlc.TransactionsViewer.domain.datasources.json.JSONDataSourceImpl; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import java.util.ArrayList; import java.util.List; import static junit.framework.Assert.assertEquals; import static org.mockito.Mockito.mock;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.repository; /** * <p>Checks the repository pattern behaviour adding rates or transactions</p> * * @author Raul Hernandez Lopez. */ public class JSONRepositoryImplTest { private static final String MY_PATH = "rates010.json"; @Mock
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/datasources/json/JSONDataSourceImpl.java // public class JSONDataSourceImpl implements JSONDataSource<Rate, Transaction> { // // /** // * Vars declaration // */ // private Context mContext; // private JSONOperations<Rate, Transaction> mJSONOperations; // // @Inject // JSONDataSourceImpl(Context context, // JSONOperationsImpl jsonOperations) { // mContext = context; // if (mJSONOperations == null) { // synchronized (this) { // if (mJSONOperations == null) { // mJSONOperations = jsonOperations; // } // } // } // } // // @Override // public List<Rate> getRatesList(String path) throws CustomException { // return startToReadRatesFromFile(path); // } // // @Override // public List<Transaction> getTransactionsList(String path) throws CustomException { // return startToReadTransactionsFromFile(path); // } // // /** // * Starts to read from file the Transactions List // * // * @return List of transactions // * @throws CustomException // */ // private List<Transaction> startToReadTransactionsFromFile(String path) throws CustomException { // return mJSONOperations.getTransactionsList(mContext, path); // } // // /** // * Starts to read from file the Rates List // * // * @return List of rates // * @throws CustomException // */ // private List<Rate> startToReadRatesFromFile(String path) throws CustomException { // return mJSONOperations.getRatesList(mContext, path); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // Path: android/src/test/java/com/raulh82vlc/TransactionsViewer/domain/repository/JSONRepositoryImplTest.java import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; import com.raulh82vlc.TransactionsViewer.domain.datasources.json.JSONDataSourceImpl; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import java.util.ArrayList; import java.util.List; import static junit.framework.Assert.assertEquals; import static org.mockito.Mockito.mock; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.repository; /** * <p>Checks the repository pattern behaviour adding rates or transactions</p> * * @author Raul Hernandez Lopez. */ public class JSONRepositoryImplTest { private static final String MY_PATH = "rates010.json"; @Mock
private JSONDataSourceImpl dataSource;
raulh82vlc/Transactions-Viewer
android/src/test/java/com/raulh82vlc/TransactionsViewer/domain/repository/JSONRepositoryImplTest.java
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/datasources/json/JSONDataSourceImpl.java // public class JSONDataSourceImpl implements JSONDataSource<Rate, Transaction> { // // /** // * Vars declaration // */ // private Context mContext; // private JSONOperations<Rate, Transaction> mJSONOperations; // // @Inject // JSONDataSourceImpl(Context context, // JSONOperationsImpl jsonOperations) { // mContext = context; // if (mJSONOperations == null) { // synchronized (this) { // if (mJSONOperations == null) { // mJSONOperations = jsonOperations; // } // } // } // } // // @Override // public List<Rate> getRatesList(String path) throws CustomException { // return startToReadRatesFromFile(path); // } // // @Override // public List<Transaction> getTransactionsList(String path) throws CustomException { // return startToReadTransactionsFromFile(path); // } // // /** // * Starts to read from file the Transactions List // * // * @return List of transactions // * @throws CustomException // */ // private List<Transaction> startToReadTransactionsFromFile(String path) throws CustomException { // return mJSONOperations.getTransactionsList(mContext, path); // } // // /** // * Starts to read from file the Rates List // * // * @return List of rates // * @throws CustomException // */ // private List<Rate> startToReadRatesFromFile(String path) throws CustomException { // return mJSONOperations.getRatesList(mContext, path); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // }
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; import com.raulh82vlc.TransactionsViewer.domain.datasources.json.JSONDataSourceImpl; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import java.util.ArrayList; import java.util.List; import static junit.framework.Assert.assertEquals; import static org.mockito.Mockito.mock;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.repository; /** * <p>Checks the repository pattern behaviour adding rates or transactions</p> * * @author Raul Hernandez Lopez. */ public class JSONRepositoryImplTest { private static final String MY_PATH = "rates010.json"; @Mock private JSONDataSourceImpl dataSource; private JSONRepositoryImpl repoUnderTest;
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/datasources/json/JSONDataSourceImpl.java // public class JSONDataSourceImpl implements JSONDataSource<Rate, Transaction> { // // /** // * Vars declaration // */ // private Context mContext; // private JSONOperations<Rate, Transaction> mJSONOperations; // // @Inject // JSONDataSourceImpl(Context context, // JSONOperationsImpl jsonOperations) { // mContext = context; // if (mJSONOperations == null) { // synchronized (this) { // if (mJSONOperations == null) { // mJSONOperations = jsonOperations; // } // } // } // } // // @Override // public List<Rate> getRatesList(String path) throws CustomException { // return startToReadRatesFromFile(path); // } // // @Override // public List<Transaction> getTransactionsList(String path) throws CustomException { // return startToReadTransactionsFromFile(path); // } // // /** // * Starts to read from file the Transactions List // * // * @return List of transactions // * @throws CustomException // */ // private List<Transaction> startToReadTransactionsFromFile(String path) throws CustomException { // return mJSONOperations.getTransactionsList(mContext, path); // } // // /** // * Starts to read from file the Rates List // * // * @return List of rates // * @throws CustomException // */ // private List<Rate> startToReadRatesFromFile(String path) throws CustomException { // return mJSONOperations.getRatesList(mContext, path); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // Path: android/src/test/java/com/raulh82vlc/TransactionsViewer/domain/repository/JSONRepositoryImplTest.java import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; import com.raulh82vlc.TransactionsViewer.domain.datasources.json.JSONDataSourceImpl; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import java.util.ArrayList; import java.util.List; import static junit.framework.Assert.assertEquals; import static org.mockito.Mockito.mock; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.repository; /** * <p>Checks the repository pattern behaviour adding rates or transactions</p> * * @author Raul Hernandez Lopez. */ public class JSONRepositoryImplTest { private static final String MY_PATH = "rates010.json"; @Mock private JSONDataSourceImpl dataSource; private JSONRepositoryImpl repoUnderTest;
private List<Rate> rates = new ArrayList<>();
raulh82vlc/Transactions-Viewer
android/src/test/java/com/raulh82vlc/TransactionsViewer/domain/repository/JSONRepositoryImplTest.java
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/datasources/json/JSONDataSourceImpl.java // public class JSONDataSourceImpl implements JSONDataSource<Rate, Transaction> { // // /** // * Vars declaration // */ // private Context mContext; // private JSONOperations<Rate, Transaction> mJSONOperations; // // @Inject // JSONDataSourceImpl(Context context, // JSONOperationsImpl jsonOperations) { // mContext = context; // if (mJSONOperations == null) { // synchronized (this) { // if (mJSONOperations == null) { // mJSONOperations = jsonOperations; // } // } // } // } // // @Override // public List<Rate> getRatesList(String path) throws CustomException { // return startToReadRatesFromFile(path); // } // // @Override // public List<Transaction> getTransactionsList(String path) throws CustomException { // return startToReadTransactionsFromFile(path); // } // // /** // * Starts to read from file the Transactions List // * // * @return List of transactions // * @throws CustomException // */ // private List<Transaction> startToReadTransactionsFromFile(String path) throws CustomException { // return mJSONOperations.getTransactionsList(mContext, path); // } // // /** // * Starts to read from file the Rates List // * // * @return List of rates // * @throws CustomException // */ // private List<Rate> startToReadRatesFromFile(String path) throws CustomException { // return mJSONOperations.getRatesList(mContext, path); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // }
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; import com.raulh82vlc.TransactionsViewer.domain.datasources.json.JSONDataSourceImpl; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import java.util.ArrayList; import java.util.List; import static junit.framework.Assert.assertEquals; import static org.mockito.Mockito.mock;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.repository; /** * <p>Checks the repository pattern behaviour adding rates or transactions</p> * * @author Raul Hernandez Lopez. */ public class JSONRepositoryImplTest { private static final String MY_PATH = "rates010.json"; @Mock private JSONDataSourceImpl dataSource; private JSONRepositoryImpl repoUnderTest; private List<Rate> rates = new ArrayList<>();
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/datasources/json/JSONDataSourceImpl.java // public class JSONDataSourceImpl implements JSONDataSource<Rate, Transaction> { // // /** // * Vars declaration // */ // private Context mContext; // private JSONOperations<Rate, Transaction> mJSONOperations; // // @Inject // JSONDataSourceImpl(Context context, // JSONOperationsImpl jsonOperations) { // mContext = context; // if (mJSONOperations == null) { // synchronized (this) { // if (mJSONOperations == null) { // mJSONOperations = jsonOperations; // } // } // } // } // // @Override // public List<Rate> getRatesList(String path) throws CustomException { // return startToReadRatesFromFile(path); // } // // @Override // public List<Transaction> getTransactionsList(String path) throws CustomException { // return startToReadTransactionsFromFile(path); // } // // /** // * Starts to read from file the Transactions List // * // * @return List of transactions // * @throws CustomException // */ // private List<Transaction> startToReadTransactionsFromFile(String path) throws CustomException { // return mJSONOperations.getTransactionsList(mContext, path); // } // // /** // * Starts to read from file the Rates List // * // * @return List of rates // * @throws CustomException // */ // private List<Rate> startToReadRatesFromFile(String path) throws CustomException { // return mJSONOperations.getRatesList(mContext, path); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // Path: android/src/test/java/com/raulh82vlc/TransactionsViewer/domain/repository/JSONRepositoryImplTest.java import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; import com.raulh82vlc.TransactionsViewer.domain.datasources.json.JSONDataSourceImpl; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import java.util.ArrayList; import java.util.List; import static junit.framework.Assert.assertEquals; import static org.mockito.Mockito.mock; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.repository; /** * <p>Checks the repository pattern behaviour adding rates or transactions</p> * * @author Raul Hernandez Lopez. */ public class JSONRepositoryImplTest { private static final String MY_PATH = "rates010.json"; @Mock private JSONDataSourceImpl dataSource; private JSONRepositoryImpl repoUnderTest; private List<Rate> rates = new ArrayList<>();
private List<Transaction> transactions = new ArrayList<>();
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/RatesListModelDataMapper.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/RateUI.java // public class RateUI implements Parcelable { // private String fromCurrency; // private String toCurrency; // private String rate; // // public RateUI(String fromCurrency, String toCurrency, String rate) { // this.fromCurrency = fromCurrency; // this.toCurrency = toCurrency; // this.rate = rate; // } // // private RateUI(Parcel in) { // fromCurrency = in.readString(); // toCurrency = in.readString(); // rate = in.readString(); // } // // public static final Creator<RateUI> CREATOR = new Creator<RateUI>() { // @Override // public RateUI createFromParcel(Parcel in) { // return new RateUI(in); // } // // @Override // public RateUI[] newArray(int size) { // return new RateUI[size]; // } // }; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(fromCurrency); // dest.writeString(toCurrency); // dest.writeString(rate); // } // }
import com.raulh82vlc.TransactionsViewer.di.scopes.ActivityScope; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.RateUI; import java.util.ArrayList; import java.util.List; import javax.inject.Inject;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors.mappers; /** * As a Mapper, means it is a converter between different domains * * @author Raul Hernandez Lopez */ @ActivityScope public class RatesListModelDataMapper { @Inject RatesListModelDataMapper() { } /** * Transforms a List of {@link Rate} into a List of Rates * * @param ratesList to be transformed. * @return Graph composed by a dictionary of rate to others */
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/RateUI.java // public class RateUI implements Parcelable { // private String fromCurrency; // private String toCurrency; // private String rate; // // public RateUI(String fromCurrency, String toCurrency, String rate) { // this.fromCurrency = fromCurrency; // this.toCurrency = toCurrency; // this.rate = rate; // } // // private RateUI(Parcel in) { // fromCurrency = in.readString(); // toCurrency = in.readString(); // rate = in.readString(); // } // // public static final Creator<RateUI> CREATOR = new Creator<RateUI>() { // @Override // public RateUI createFromParcel(Parcel in) { // return new RateUI(in); // } // // @Override // public RateUI[] newArray(int size) { // return new RateUI[size]; // } // }; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(fromCurrency); // dest.writeString(toCurrency); // dest.writeString(rate); // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/RatesListModelDataMapper.java import com.raulh82vlc.TransactionsViewer.di.scopes.ActivityScope; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.RateUI; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors.mappers; /** * As a Mapper, means it is a converter between different domains * * @author Raul Hernandez Lopez */ @ActivityScope public class RatesListModelDataMapper { @Inject RatesListModelDataMapper() { } /** * Transforms a List of {@link Rate} into a List of Rates * * @param ratesList to be transformed. * @return Graph composed by a dictionary of rate to others */
public List<RateUI> transform(List<Rate> ratesList) {
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/RatesListModelDataMapper.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/RateUI.java // public class RateUI implements Parcelable { // private String fromCurrency; // private String toCurrency; // private String rate; // // public RateUI(String fromCurrency, String toCurrency, String rate) { // this.fromCurrency = fromCurrency; // this.toCurrency = toCurrency; // this.rate = rate; // } // // private RateUI(Parcel in) { // fromCurrency = in.readString(); // toCurrency = in.readString(); // rate = in.readString(); // } // // public static final Creator<RateUI> CREATOR = new Creator<RateUI>() { // @Override // public RateUI createFromParcel(Parcel in) { // return new RateUI(in); // } // // @Override // public RateUI[] newArray(int size) { // return new RateUI[size]; // } // }; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(fromCurrency); // dest.writeString(toCurrency); // dest.writeString(rate); // } // }
import com.raulh82vlc.TransactionsViewer.di.scopes.ActivityScope; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.RateUI; import java.util.ArrayList; import java.util.List; import javax.inject.Inject;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors.mappers; /** * As a Mapper, means it is a converter between different domains * * @author Raul Hernandez Lopez */ @ActivityScope public class RatesListModelDataMapper { @Inject RatesListModelDataMapper() { } /** * Transforms a List of {@link Rate} into a List of Rates * * @param ratesList to be transformed. * @return Graph composed by a dictionary of rate to others */
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/RateUI.java // public class RateUI implements Parcelable { // private String fromCurrency; // private String toCurrency; // private String rate; // // public RateUI(String fromCurrency, String toCurrency, String rate) { // this.fromCurrency = fromCurrency; // this.toCurrency = toCurrency; // this.rate = rate; // } // // private RateUI(Parcel in) { // fromCurrency = in.readString(); // toCurrency = in.readString(); // rate = in.readString(); // } // // public static final Creator<RateUI> CREATOR = new Creator<RateUI>() { // @Override // public RateUI createFromParcel(Parcel in) { // return new RateUI(in); // } // // @Override // public RateUI[] newArray(int size) { // return new RateUI[size]; // } // }; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(fromCurrency); // dest.writeString(toCurrency); // dest.writeString(rate); // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/RatesListModelDataMapper.java import com.raulh82vlc.TransactionsViewer.di.scopes.ActivityScope; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.RateUI; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors.mappers; /** * As a Mapper, means it is a converter between different domains * * @author Raul Hernandez Lopez */ @ActivityScope public class RatesListModelDataMapper { @Inject RatesListModelDataMapper() { } /** * Transforms a List of {@link Rate} into a List of Rates * * @param ratesList to be transformed. * @return Graph composed by a dictionary of rate to others */
public List<RateUI> transform(List<Rate> ratesList) {
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionUI.java // public class TransactionUI implements Parcelable { // private String amounPerTransactionPrev; // private String amountPerTransactionCurrent; // private String currencyPrev; // private String currencyCurrent; // // public TransactionUI(String currencyPrev, String currencyCurrent, String amounPerTransactionPrev, // String amountPerTransactionCurrent) { // this.currencyPrev = currencyPrev; // this.currencyCurrent = currencyCurrent; // this.amounPerTransactionPrev = amounPerTransactionPrev; // this.amountPerTransactionCurrent = amountPerTransactionCurrent; // } // // private TransactionUI(Parcel in) { // currencyPrev = in.readString(); // currencyCurrent = in.readString(); // amounPerTransactionPrev = in.readString(); // amountPerTransactionCurrent = in.readString(); // } // // public static final Creator<TransactionUI> CREATOR = new Creator<TransactionUI>() { // @Override // public TransactionUI createFromParcel(Parcel in) { // return new TransactionUI(in); // } // // @Override // public TransactionUI[] newArray(int size) { // return new TransactionUI[size]; // } // }; // // public String getAmounPerTransactionPrev() { // return amounPerTransactionPrev; // } // // public String getAmountPerTransactionCurrent() { // return amountPerTransactionCurrent; // } // // public String getCurrencyPrev() { // return currencyPrev; // } // // public String getCurrencyCurrent() { // return currencyCurrent; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(currencyPrev); // dest.writeString(currencyCurrent); // dest.writeString(amounPerTransactionPrev); // dest.writeString(amountPerTransactionCurrent); // } // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.TransactionUI; import java.util.List;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.presentation; /** * <p>Presenter which asks a computing of rates given a list of rates as well as a list of transactions * and to a concrete Currency</p> * * @author Raul Hernandez Lopez. */ public interface ComputingTransactionsPresenter { void setView(View view); void resetView(); void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates)
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionUI.java // public class TransactionUI implements Parcelable { // private String amounPerTransactionPrev; // private String amountPerTransactionCurrent; // private String currencyPrev; // private String currencyCurrent; // // public TransactionUI(String currencyPrev, String currencyCurrent, String amounPerTransactionPrev, // String amountPerTransactionCurrent) { // this.currencyPrev = currencyPrev; // this.currencyCurrent = currencyCurrent; // this.amounPerTransactionPrev = amounPerTransactionPrev; // this.amountPerTransactionCurrent = amountPerTransactionCurrent; // } // // private TransactionUI(Parcel in) { // currencyPrev = in.readString(); // currencyCurrent = in.readString(); // amounPerTransactionPrev = in.readString(); // amountPerTransactionCurrent = in.readString(); // } // // public static final Creator<TransactionUI> CREATOR = new Creator<TransactionUI>() { // @Override // public TransactionUI createFromParcel(Parcel in) { // return new TransactionUI(in); // } // // @Override // public TransactionUI[] newArray(int size) { // return new TransactionUI[size]; // } // }; // // public String getAmounPerTransactionPrev() { // return amounPerTransactionPrev; // } // // public String getAmountPerTransactionCurrent() { // return amountPerTransactionCurrent; // } // // public String getCurrencyPrev() { // return currencyPrev; // } // // public String getCurrencyCurrent() { // return currencyCurrent; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(currencyPrev); // dest.writeString(currencyCurrent); // dest.writeString(amounPerTransactionPrev); // dest.writeString(amountPerTransactionCurrent); // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.TransactionUI; import java.util.List; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.presentation; /** * <p>Presenter which asks a computing of rates given a list of rates as well as a list of transactions * and to a concrete Currency</p> * * @author Raul Hernandez Lopez. */ public interface ComputingTransactionsPresenter { void setView(View view); void resetView(); void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates)
throws CustomException;
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionUI.java // public class TransactionUI implements Parcelable { // private String amounPerTransactionPrev; // private String amountPerTransactionCurrent; // private String currencyPrev; // private String currencyCurrent; // // public TransactionUI(String currencyPrev, String currencyCurrent, String amounPerTransactionPrev, // String amountPerTransactionCurrent) { // this.currencyPrev = currencyPrev; // this.currencyCurrent = currencyCurrent; // this.amounPerTransactionPrev = amounPerTransactionPrev; // this.amountPerTransactionCurrent = amountPerTransactionCurrent; // } // // private TransactionUI(Parcel in) { // currencyPrev = in.readString(); // currencyCurrent = in.readString(); // amounPerTransactionPrev = in.readString(); // amountPerTransactionCurrent = in.readString(); // } // // public static final Creator<TransactionUI> CREATOR = new Creator<TransactionUI>() { // @Override // public TransactionUI createFromParcel(Parcel in) { // return new TransactionUI(in); // } // // @Override // public TransactionUI[] newArray(int size) { // return new TransactionUI[size]; // } // }; // // public String getAmounPerTransactionPrev() { // return amounPerTransactionPrev; // } // // public String getAmountPerTransactionCurrent() { // return amountPerTransactionCurrent; // } // // public String getCurrencyPrev() { // return currencyPrev; // } // // public String getCurrencyCurrent() { // return currencyCurrent; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(currencyPrev); // dest.writeString(currencyCurrent); // dest.writeString(amounPerTransactionPrev); // dest.writeString(amountPerTransactionCurrent); // } // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.TransactionUI; import java.util.List;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.presentation; /** * <p>Presenter which asks a computing of rates given a list of rates as well as a list of transactions * and to a concrete Currency</p> * * @author Raul Hernandez Lopez. */ public interface ComputingTransactionsPresenter { void setView(View view); void resetView(); void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates) throws CustomException; interface View { void errorComputingRates(String error);
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/TransactionUI.java // public class TransactionUI implements Parcelable { // private String amounPerTransactionPrev; // private String amountPerTransactionCurrent; // private String currencyPrev; // private String currencyCurrent; // // public TransactionUI(String currencyPrev, String currencyCurrent, String amounPerTransactionPrev, // String amountPerTransactionCurrent) { // this.currencyPrev = currencyPrev; // this.currencyCurrent = currencyCurrent; // this.amounPerTransactionPrev = amounPerTransactionPrev; // this.amountPerTransactionCurrent = amountPerTransactionCurrent; // } // // private TransactionUI(Parcel in) { // currencyPrev = in.readString(); // currencyCurrent = in.readString(); // amounPerTransactionPrev = in.readString(); // amountPerTransactionCurrent = in.readString(); // } // // public static final Creator<TransactionUI> CREATOR = new Creator<TransactionUI>() { // @Override // public TransactionUI createFromParcel(Parcel in) { // return new TransactionUI(in); // } // // @Override // public TransactionUI[] newArray(int size) { // return new TransactionUI[size]; // } // }; // // public String getAmounPerTransactionPrev() { // return amounPerTransactionPrev; // } // // public String getAmountPerTransactionCurrent() { // return amountPerTransactionCurrent; // } // // public String getCurrencyPrev() { // return currencyPrev; // } // // public String getCurrencyCurrent() { // return currencyCurrent; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(currencyPrev); // dest.writeString(currencyCurrent); // dest.writeString(amounPerTransactionPrev); // dest.writeString(amountPerTransactionCurrent); // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/ComputingTransactionsPresenter.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.TransactionUI; import java.util.List; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.presentation; /** * <p>Presenter which asks a computing of rates given a list of rates as well as a list of transactions * and to a concrete Currency</p> * * @author Raul Hernandez Lopez. */ public interface ComputingTransactionsPresenter { void setView(View view); void resetView(); void computeRates(String skuFromProduct, String toCurrency, String pathTransactions, String pathRates) throws CustomException; interface View { void errorComputingRates(String error);
void computedRatesForTransactions(List<TransactionUI> transactions, String totalAmount);
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetRatesListCallbackImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractor.java // public interface GetRatesListInteractor { // // void execute(String path, GetRatesListCallback callback) throws CustomException; // // interface GetRatesListCallback { // void onGetRatesListOK(List<Rate> rateList); // // void onGetRatesListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/RatesListModelDataMapper.java // @ActivityScope // public class RatesListModelDataMapper { // // @Inject // RatesListModelDataMapper() { // // } // // /** // * Transforms a List of {@link Rate} into a List of Rates // * // * @param ratesList to be transformed. // * @return Graph composed by a dictionary of rate to others // */ // public List<RateUI> transform(List<Rate> ratesList) { // if (ratesList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // // int size = ratesList.size(); // List<RateUI> listOfRates = new ArrayList<>(size); // if (size > 0) { // listOfRates = new ArrayList<>(size); // for (Rate rate : ratesList) { // listOfRates.add(new RateUI(rate.getFromCurrency(), rate.getToCurrency(), rate.getRate())); // } // } // return listOfRates; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/RatesPresenter.java // public interface RatesPresenter { // // void startReading(String path) throws CustomException; // // void setView(View view); // // void resetView(); // // interface View { // void errorGettingRates(String error); // // void loadedRates(List<RateUI> listOfRates); // // boolean isReady(); // } // }
import com.raulh82vlc.TransactionsViewer.domain.interactors.GetRatesListInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.RatesListModelDataMapper; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.ui.presentation.RatesPresenter; import java.util.List;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors_response; /** * Get Rates list by means of its callback, communicating towards its view * * @author Raul Hernandez Lopez. */ public class GetRatesListCallbackImpl implements GetRatesListInteractor.GetRatesListCallback { private final RatesPresenter.View mView;
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractor.java // public interface GetRatesListInteractor { // // void execute(String path, GetRatesListCallback callback) throws CustomException; // // interface GetRatesListCallback { // void onGetRatesListOK(List<Rate> rateList); // // void onGetRatesListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/RatesListModelDataMapper.java // @ActivityScope // public class RatesListModelDataMapper { // // @Inject // RatesListModelDataMapper() { // // } // // /** // * Transforms a List of {@link Rate} into a List of Rates // * // * @param ratesList to be transformed. // * @return Graph composed by a dictionary of rate to others // */ // public List<RateUI> transform(List<Rate> ratesList) { // if (ratesList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // // int size = ratesList.size(); // List<RateUI> listOfRates = new ArrayList<>(size); // if (size > 0) { // listOfRates = new ArrayList<>(size); // for (Rate rate : ratesList) { // listOfRates.add(new RateUI(rate.getFromCurrency(), rate.getToCurrency(), rate.getRate())); // } // } // return listOfRates; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/RatesPresenter.java // public interface RatesPresenter { // // void startReading(String path) throws CustomException; // // void setView(View view); // // void resetView(); // // interface View { // void errorGettingRates(String error); // // void loadedRates(List<RateUI> listOfRates); // // boolean isReady(); // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetRatesListCallbackImpl.java import com.raulh82vlc.TransactionsViewer.domain.interactors.GetRatesListInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.RatesListModelDataMapper; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.ui.presentation.RatesPresenter; import java.util.List; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors_response; /** * Get Rates list by means of its callback, communicating towards its view * * @author Raul Hernandez Lopez. */ public class GetRatesListCallbackImpl implements GetRatesListInteractor.GetRatesListCallback { private final RatesPresenter.View mView;
private final RatesListModelDataMapper ratesListModelDataMapper;
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetRatesListCallbackImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractor.java // public interface GetRatesListInteractor { // // void execute(String path, GetRatesListCallback callback) throws CustomException; // // interface GetRatesListCallback { // void onGetRatesListOK(List<Rate> rateList); // // void onGetRatesListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/RatesListModelDataMapper.java // @ActivityScope // public class RatesListModelDataMapper { // // @Inject // RatesListModelDataMapper() { // // } // // /** // * Transforms a List of {@link Rate} into a List of Rates // * // * @param ratesList to be transformed. // * @return Graph composed by a dictionary of rate to others // */ // public List<RateUI> transform(List<Rate> ratesList) { // if (ratesList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // // int size = ratesList.size(); // List<RateUI> listOfRates = new ArrayList<>(size); // if (size > 0) { // listOfRates = new ArrayList<>(size); // for (Rate rate : ratesList) { // listOfRates.add(new RateUI(rate.getFromCurrency(), rate.getToCurrency(), rate.getRate())); // } // } // return listOfRates; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/RatesPresenter.java // public interface RatesPresenter { // // void startReading(String path) throws CustomException; // // void setView(View view); // // void resetView(); // // interface View { // void errorGettingRates(String error); // // void loadedRates(List<RateUI> listOfRates); // // boolean isReady(); // } // }
import com.raulh82vlc.TransactionsViewer.domain.interactors.GetRatesListInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.RatesListModelDataMapper; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.ui.presentation.RatesPresenter; import java.util.List;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors_response; /** * Get Rates list by means of its callback, communicating towards its view * * @author Raul Hernandez Lopez. */ public class GetRatesListCallbackImpl implements GetRatesListInteractor.GetRatesListCallback { private final RatesPresenter.View mView; private final RatesListModelDataMapper ratesListModelDataMapper; public GetRatesListCallbackImpl(RatesPresenter.View view, RatesListModelDataMapper ratesListModelDataMapper) { mView = view; this.ratesListModelDataMapper = ratesListModelDataMapper; } @Override
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractor.java // public interface GetRatesListInteractor { // // void execute(String path, GetRatesListCallback callback) throws CustomException; // // interface GetRatesListCallback { // void onGetRatesListOK(List<Rate> rateList); // // void onGetRatesListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/RatesListModelDataMapper.java // @ActivityScope // public class RatesListModelDataMapper { // // @Inject // RatesListModelDataMapper() { // // } // // /** // * Transforms a List of {@link Rate} into a List of Rates // * // * @param ratesList to be transformed. // * @return Graph composed by a dictionary of rate to others // */ // public List<RateUI> transform(List<Rate> ratesList) { // if (ratesList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // // int size = ratesList.size(); // List<RateUI> listOfRates = new ArrayList<>(size); // if (size > 0) { // listOfRates = new ArrayList<>(size); // for (Rate rate : ratesList) { // listOfRates.add(new RateUI(rate.getFromCurrency(), rate.getToCurrency(), rate.getRate())); // } // } // return listOfRates; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/RatesPresenter.java // public interface RatesPresenter { // // void startReading(String path) throws CustomException; // // void setView(View view); // // void resetView(); // // interface View { // void errorGettingRates(String error); // // void loadedRates(List<RateUI> listOfRates); // // boolean isReady(); // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetRatesListCallbackImpl.java import com.raulh82vlc.TransactionsViewer.domain.interactors.GetRatesListInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.RatesListModelDataMapper; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.ui.presentation.RatesPresenter; import java.util.List; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors_response; /** * Get Rates list by means of its callback, communicating towards its view * * @author Raul Hernandez Lopez. */ public class GetRatesListCallbackImpl implements GetRatesListInteractor.GetRatesListCallback { private final RatesPresenter.View mView; private final RatesListModelDataMapper ratesListModelDataMapper; public GetRatesListCallbackImpl(RatesPresenter.View view, RatesListModelDataMapper ratesListModelDataMapper) { mView = view; this.ratesListModelDataMapper = ratesListModelDataMapper; } @Override
public void onGetRatesListOK(List<Rate> rateList) {
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/RatesPresenter.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/RateUI.java // public class RateUI implements Parcelable { // private String fromCurrency; // private String toCurrency; // private String rate; // // public RateUI(String fromCurrency, String toCurrency, String rate) { // this.fromCurrency = fromCurrency; // this.toCurrency = toCurrency; // this.rate = rate; // } // // private RateUI(Parcel in) { // fromCurrency = in.readString(); // toCurrency = in.readString(); // rate = in.readString(); // } // // public static final Creator<RateUI> CREATOR = new Creator<RateUI>() { // @Override // public RateUI createFromParcel(Parcel in) { // return new RateUI(in); // } // // @Override // public RateUI[] newArray(int size) { // return new RateUI[size]; // } // }; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(fromCurrency); // dest.writeString(toCurrency); // dest.writeString(rate); // } // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.RateUI; import java.util.List;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.presentation; /** * Responsible of passing Rates List result to the View * * @author Raul Hernandez Lopez */ public interface RatesPresenter { void startReading(String path) throws CustomException; void setView(View view); void resetView(); interface View { void errorGettingRates(String error);
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/RateUI.java // public class RateUI implements Parcelable { // private String fromCurrency; // private String toCurrency; // private String rate; // // public RateUI(String fromCurrency, String toCurrency, String rate) { // this.fromCurrency = fromCurrency; // this.toCurrency = toCurrency; // this.rate = rate; // } // // private RateUI(Parcel in) { // fromCurrency = in.readString(); // toCurrency = in.readString(); // rate = in.readString(); // } // // public static final Creator<RateUI> CREATOR = new Creator<RateUI>() { // @Override // public RateUI createFromParcel(Parcel in) { // return new RateUI(in); // } // // @Override // public RateUI[] newArray(int size) { // return new RateUI[size]; // } // }; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(fromCurrency); // dest.writeString(toCurrency); // dest.writeString(rate); // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/RatesPresenter.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.models.RateUI; import java.util.List; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.presentation; /** * Responsible of passing Rates List result to the View * * @author Raul Hernandez Lopez */ public interface RatesPresenter { void startReading(String path) throws CustomException; void setView(View view); void resetView(); interface View { void errorGettingRates(String error);
void loadedRates(List<RateUI> listOfRates);
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/adapters/ProductsListAdapter.java
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/ProductUI.java // public class ProductUI implements Parcelable { // // private String sku; // private List<TransactionUI> transactions; // // public static final Creator<ProductUI> CREATOR = new Creator<ProductUI>() { // @Override // public ProductUI createFromParcel(Parcel in) { // return new ProductUI(in); // } // // @Override // public ProductUI[] newArray(int size) { // return new ProductUI[size]; // } // }; // // private ProductUI(Parcel in) { // sku = in.readString(); // if (transactions == null) { // transactions = new ArrayList<>(); // } // in.readList(transactions, Transaction.class.getClassLoader()); // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(sku); // dest.writeList(transactions); // } // // public ProductUI(String key, List<Transaction> values, String toCurrency) { // sku = key; // transactions = new ArrayList<>(values.size()); // for (Transaction transaction : values) { // transactions.add(new TransactionUI(transaction.getCurrency(), toCurrency, // transaction.getAmountPerTransaction(), "0")); // } // // } // // public List<TransactionUI> getTransactions() { // return transactions; // } // // public String getSku() { // return sku; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/viewholders/ViewHolder.java // public class ViewHolder extends RecyclerView.ViewHolder { // @InjectView(R.id.txt_title) // public TextView mTitle; // // @InjectView(R.id.txt_subtitle) // public TextView mSubtitle; // // public ViewHolder(View itemView) { // super(itemView); // ButterKnife.inject(this, itemView); // } // }
import android.os.Handler; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.raulh82vlc.TransactionsViewer.R; import com.raulh82vlc.TransactionsViewer.domain.models.ProductUI; import com.raulh82vlc.TransactionsViewer.ui.viewholders.ViewHolder; import java.util.ArrayList; import java.util.List;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.adapters; /** * Adapter for Products listing */ public class ProductsListAdapter extends RecyclerView.Adapter<ViewHolder> { private OnItemClickListener mOnItemClickListener;
// Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/ProductUI.java // public class ProductUI implements Parcelable { // // private String sku; // private List<TransactionUI> transactions; // // public static final Creator<ProductUI> CREATOR = new Creator<ProductUI>() { // @Override // public ProductUI createFromParcel(Parcel in) { // return new ProductUI(in); // } // // @Override // public ProductUI[] newArray(int size) { // return new ProductUI[size]; // } // }; // // private ProductUI(Parcel in) { // sku = in.readString(); // if (transactions == null) { // transactions = new ArrayList<>(); // } // in.readList(transactions, Transaction.class.getClassLoader()); // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(sku); // dest.writeList(transactions); // } // // public ProductUI(String key, List<Transaction> values, String toCurrency) { // sku = key; // transactions = new ArrayList<>(values.size()); // for (Transaction transaction : values) { // transactions.add(new TransactionUI(transaction.getCurrency(), toCurrency, // transaction.getAmountPerTransaction(), "0")); // } // // } // // public List<TransactionUI> getTransactions() { // return transactions; // } // // public String getSku() { // return sku; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/viewholders/ViewHolder.java // public class ViewHolder extends RecyclerView.ViewHolder { // @InjectView(R.id.txt_title) // public TextView mTitle; // // @InjectView(R.id.txt_subtitle) // public TextView mSubtitle; // // public ViewHolder(View itemView) { // super(itemView); // ButterKnife.inject(this, itemView); // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/adapters/ProductsListAdapter.java import android.os.Handler; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.raulh82vlc.TransactionsViewer.R; import com.raulh82vlc.TransactionsViewer.domain.models.ProductUI; import com.raulh82vlc.TransactionsViewer.ui.viewholders.ViewHolder; import java.util.ArrayList; import java.util.List; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.adapters; /** * Adapter for Products listing */ public class ProductsListAdapter extends RecyclerView.Adapter<ViewHolder> { private OnItemClickListener mOnItemClickListener;
private List<ProductUI> mProductUIs = new ArrayList<>();
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/RatesPresenterImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractor.java // public interface GetRatesListInteractor { // // void execute(String path, GetRatesListCallback callback) throws CustomException; // // interface GetRatesListCallback { // void onGetRatesListOK(List<Rate> rateList); // // void onGetRatesListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/RatesListModelDataMapper.java // @ActivityScope // public class RatesListModelDataMapper { // // @Inject // RatesListModelDataMapper() { // // } // // /** // * Transforms a List of {@link Rate} into a List of Rates // * // * @param ratesList to be transformed. // * @return Graph composed by a dictionary of rate to others // */ // public List<RateUI> transform(List<Rate> ratesList) { // if (ratesList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // // int size = ratesList.size(); // List<RateUI> listOfRates = new ArrayList<>(size); // if (size > 0) { // listOfRates = new ArrayList<>(size); // for (Rate rate : ratesList) { // listOfRates.add(new RateUI(rate.getFromCurrency(), rate.getToCurrency(), rate.getRate())); // } // } // return listOfRates; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetRatesListCallbackImpl.java // public class GetRatesListCallbackImpl implements GetRatesListInteractor.GetRatesListCallback { // // private final RatesPresenter.View mView; // private final RatesListModelDataMapper ratesListModelDataMapper; // // // public GetRatesListCallbackImpl(RatesPresenter.View view, // RatesListModelDataMapper ratesListModelDataMapper) { // mView = view; // this.ratesListModelDataMapper = ratesListModelDataMapper; // } // // @Override // public void onGetRatesListOK(List<Rate> rateList) { // if (mView.isReady()) { // mView.loadedRates(ratesListModelDataMapper.transform(rateList)); // } // } // // @Override // public void onGetRatesListKO(String error) { // if (mView.isReady()) { // mView.errorGettingRates(error); // } // } // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.interactors.GetRatesListInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.RatesListModelDataMapper; import com.raulh82vlc.TransactionsViewer.domain.interactors_response.GetRatesListCallbackImpl; import javax.inject.Inject;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.presentation; /** * Implementation of the {@link RatesPresenter} * * @author Raul Hernandez Lopez */ public class RatesPresenterImpl implements RatesPresenter { private final GetRatesListInteractor interactorGetRatesList;
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractor.java // public interface GetRatesListInteractor { // // void execute(String path, GetRatesListCallback callback) throws CustomException; // // interface GetRatesListCallback { // void onGetRatesListOK(List<Rate> rateList); // // void onGetRatesListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/RatesListModelDataMapper.java // @ActivityScope // public class RatesListModelDataMapper { // // @Inject // RatesListModelDataMapper() { // // } // // /** // * Transforms a List of {@link Rate} into a List of Rates // * // * @param ratesList to be transformed. // * @return Graph composed by a dictionary of rate to others // */ // public List<RateUI> transform(List<Rate> ratesList) { // if (ratesList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // // int size = ratesList.size(); // List<RateUI> listOfRates = new ArrayList<>(size); // if (size > 0) { // listOfRates = new ArrayList<>(size); // for (Rate rate : ratesList) { // listOfRates.add(new RateUI(rate.getFromCurrency(), rate.getToCurrency(), rate.getRate())); // } // } // return listOfRates; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetRatesListCallbackImpl.java // public class GetRatesListCallbackImpl implements GetRatesListInteractor.GetRatesListCallback { // // private final RatesPresenter.View mView; // private final RatesListModelDataMapper ratesListModelDataMapper; // // // public GetRatesListCallbackImpl(RatesPresenter.View view, // RatesListModelDataMapper ratesListModelDataMapper) { // mView = view; // this.ratesListModelDataMapper = ratesListModelDataMapper; // } // // @Override // public void onGetRatesListOK(List<Rate> rateList) { // if (mView.isReady()) { // mView.loadedRates(ratesListModelDataMapper.transform(rateList)); // } // } // // @Override // public void onGetRatesListKO(String error) { // if (mView.isReady()) { // mView.errorGettingRates(error); // } // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/RatesPresenterImpl.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.interactors.GetRatesListInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.RatesListModelDataMapper; import com.raulh82vlc.TransactionsViewer.domain.interactors_response.GetRatesListCallbackImpl; import javax.inject.Inject; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.presentation; /** * Implementation of the {@link RatesPresenter} * * @author Raul Hernandez Lopez */ public class RatesPresenterImpl implements RatesPresenter { private final GetRatesListInteractor interactorGetRatesList;
private final RatesListModelDataMapper ratesListModelDataMapper;
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/RatesPresenterImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractor.java // public interface GetRatesListInteractor { // // void execute(String path, GetRatesListCallback callback) throws CustomException; // // interface GetRatesListCallback { // void onGetRatesListOK(List<Rate> rateList); // // void onGetRatesListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/RatesListModelDataMapper.java // @ActivityScope // public class RatesListModelDataMapper { // // @Inject // RatesListModelDataMapper() { // // } // // /** // * Transforms a List of {@link Rate} into a List of Rates // * // * @param ratesList to be transformed. // * @return Graph composed by a dictionary of rate to others // */ // public List<RateUI> transform(List<Rate> ratesList) { // if (ratesList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // // int size = ratesList.size(); // List<RateUI> listOfRates = new ArrayList<>(size); // if (size > 0) { // listOfRates = new ArrayList<>(size); // for (Rate rate : ratesList) { // listOfRates.add(new RateUI(rate.getFromCurrency(), rate.getToCurrency(), rate.getRate())); // } // } // return listOfRates; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetRatesListCallbackImpl.java // public class GetRatesListCallbackImpl implements GetRatesListInteractor.GetRatesListCallback { // // private final RatesPresenter.View mView; // private final RatesListModelDataMapper ratesListModelDataMapper; // // // public GetRatesListCallbackImpl(RatesPresenter.View view, // RatesListModelDataMapper ratesListModelDataMapper) { // mView = view; // this.ratesListModelDataMapper = ratesListModelDataMapper; // } // // @Override // public void onGetRatesListOK(List<Rate> rateList) { // if (mView.isReady()) { // mView.loadedRates(ratesListModelDataMapper.transform(rateList)); // } // } // // @Override // public void onGetRatesListKO(String error) { // if (mView.isReady()) { // mView.errorGettingRates(error); // } // } // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.interactors.GetRatesListInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.RatesListModelDataMapper; import com.raulh82vlc.TransactionsViewer.domain.interactors_response.GetRatesListCallbackImpl; import javax.inject.Inject;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.presentation; /** * Implementation of the {@link RatesPresenter} * * @author Raul Hernandez Lopez */ public class RatesPresenterImpl implements RatesPresenter { private final GetRatesListInteractor interactorGetRatesList; private final RatesListModelDataMapper ratesListModelDataMapper; private View view; @Inject RatesPresenterImpl( GetRatesListInteractor interactorGetRatesList, RatesListModelDataMapper ratesListModelDataMapper) { this.interactorGetRatesList = interactorGetRatesList; this.ratesListModelDataMapper = ratesListModelDataMapper; } @Override public void setView(View view) { if (view == null) { throw new IllegalArgumentException("The view should be instantiated"); } this.view = view; } @Override public void resetView() { view = null; } @Override
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractor.java // public interface GetRatesListInteractor { // // void execute(String path, GetRatesListCallback callback) throws CustomException; // // interface GetRatesListCallback { // void onGetRatesListOK(List<Rate> rateList); // // void onGetRatesListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/RatesListModelDataMapper.java // @ActivityScope // public class RatesListModelDataMapper { // // @Inject // RatesListModelDataMapper() { // // } // // /** // * Transforms a List of {@link Rate} into a List of Rates // * // * @param ratesList to be transformed. // * @return Graph composed by a dictionary of rate to others // */ // public List<RateUI> transform(List<Rate> ratesList) { // if (ratesList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // // int size = ratesList.size(); // List<RateUI> listOfRates = new ArrayList<>(size); // if (size > 0) { // listOfRates = new ArrayList<>(size); // for (Rate rate : ratesList) { // listOfRates.add(new RateUI(rate.getFromCurrency(), rate.getToCurrency(), rate.getRate())); // } // } // return listOfRates; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetRatesListCallbackImpl.java // public class GetRatesListCallbackImpl implements GetRatesListInteractor.GetRatesListCallback { // // private final RatesPresenter.View mView; // private final RatesListModelDataMapper ratesListModelDataMapper; // // // public GetRatesListCallbackImpl(RatesPresenter.View view, // RatesListModelDataMapper ratesListModelDataMapper) { // mView = view; // this.ratesListModelDataMapper = ratesListModelDataMapper; // } // // @Override // public void onGetRatesListOK(List<Rate> rateList) { // if (mView.isReady()) { // mView.loadedRates(ratesListModelDataMapper.transform(rateList)); // } // } // // @Override // public void onGetRatesListKO(String error) { // if (mView.isReady()) { // mView.errorGettingRates(error); // } // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/RatesPresenterImpl.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.interactors.GetRatesListInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.RatesListModelDataMapper; import com.raulh82vlc.TransactionsViewer.domain.interactors_response.GetRatesListCallbackImpl; import javax.inject.Inject; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.ui.presentation; /** * Implementation of the {@link RatesPresenter} * * @author Raul Hernandez Lopez */ public class RatesPresenterImpl implements RatesPresenter { private final GetRatesListInteractor interactorGetRatesList; private final RatesListModelDataMapper ratesListModelDataMapper; private View view; @Inject RatesPresenterImpl( GetRatesListInteractor interactorGetRatesList, RatesListModelDataMapper ratesListModelDataMapper) { this.interactorGetRatesList = interactorGetRatesList; this.ratesListModelDataMapper = ratesListModelDataMapper; } @Override public void setView(View view) { if (view == null) { throw new IllegalArgumentException("The view should be instantiated"); } this.view = view; } @Override public void resetView() { view = null; } @Override
public void startReading(String path) throws CustomException {
raulh82vlc/Transactions-Viewer
android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/RatesPresenterImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractor.java // public interface GetRatesListInteractor { // // void execute(String path, GetRatesListCallback callback) throws CustomException; // // interface GetRatesListCallback { // void onGetRatesListOK(List<Rate> rateList); // // void onGetRatesListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/RatesListModelDataMapper.java // @ActivityScope // public class RatesListModelDataMapper { // // @Inject // RatesListModelDataMapper() { // // } // // /** // * Transforms a List of {@link Rate} into a List of Rates // * // * @param ratesList to be transformed. // * @return Graph composed by a dictionary of rate to others // */ // public List<RateUI> transform(List<Rate> ratesList) { // if (ratesList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // // int size = ratesList.size(); // List<RateUI> listOfRates = new ArrayList<>(size); // if (size > 0) { // listOfRates = new ArrayList<>(size); // for (Rate rate : ratesList) { // listOfRates.add(new RateUI(rate.getFromCurrency(), rate.getToCurrency(), rate.getRate())); // } // } // return listOfRates; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetRatesListCallbackImpl.java // public class GetRatesListCallbackImpl implements GetRatesListInteractor.GetRatesListCallback { // // private final RatesPresenter.View mView; // private final RatesListModelDataMapper ratesListModelDataMapper; // // // public GetRatesListCallbackImpl(RatesPresenter.View view, // RatesListModelDataMapper ratesListModelDataMapper) { // mView = view; // this.ratesListModelDataMapper = ratesListModelDataMapper; // } // // @Override // public void onGetRatesListOK(List<Rate> rateList) { // if (mView.isReady()) { // mView.loadedRates(ratesListModelDataMapper.transform(rateList)); // } // } // // @Override // public void onGetRatesListKO(String error) { // if (mView.isReady()) { // mView.errorGettingRates(error); // } // } // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.interactors.GetRatesListInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.RatesListModelDataMapper; import com.raulh82vlc.TransactionsViewer.domain.interactors_response.GetRatesListCallbackImpl; import javax.inject.Inject;
@Inject RatesPresenterImpl( GetRatesListInteractor interactorGetRatesList, RatesListModelDataMapper ratesListModelDataMapper) { this.interactorGetRatesList = interactorGetRatesList; this.ratesListModelDataMapper = ratesListModelDataMapper; } @Override public void setView(View view) { if (view == null) { throw new IllegalArgumentException("The view should be instantiated"); } this.view = view; } @Override public void resetView() { view = null; } @Override public void startReading(String path) throws CustomException { if (view != null) { startGettingRatesListFromJSON(path); } } private void startGettingRatesListFromJSON(String path) throws CustomException { interactorGetRatesList.execute(
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractor.java // public interface GetRatesListInteractor { // // void execute(String path, GetRatesListCallback callback) throws CustomException; // // interface GetRatesListCallback { // void onGetRatesListOK(List<Rate> rateList); // // void onGetRatesListKO(String error); // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/mappers/RatesListModelDataMapper.java // @ActivityScope // public class RatesListModelDataMapper { // // @Inject // RatesListModelDataMapper() { // // } // // /** // * Transforms a List of {@link Rate} into a List of Rates // * // * @param ratesList to be transformed. // * @return Graph composed by a dictionary of rate to others // */ // public List<RateUI> transform(List<Rate> ratesList) { // if (ratesList == null) { // throw new IllegalArgumentException("Cannot transform a null value"); // } // // int size = ratesList.size(); // List<RateUI> listOfRates = new ArrayList<>(size); // if (size > 0) { // listOfRates = new ArrayList<>(size); // for (Rate rate : ratesList) { // listOfRates.add(new RateUI(rate.getFromCurrency(), rate.getToCurrency(), rate.getRate())); // } // } // return listOfRates; // } // } // // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors_response/GetRatesListCallbackImpl.java // public class GetRatesListCallbackImpl implements GetRatesListInteractor.GetRatesListCallback { // // private final RatesPresenter.View mView; // private final RatesListModelDataMapper ratesListModelDataMapper; // // // public GetRatesListCallbackImpl(RatesPresenter.View view, // RatesListModelDataMapper ratesListModelDataMapper) { // mView = view; // this.ratesListModelDataMapper = ratesListModelDataMapper; // } // // @Override // public void onGetRatesListOK(List<Rate> rateList) { // if (mView.isReady()) { // mView.loadedRates(ratesListModelDataMapper.transform(rateList)); // } // } // // @Override // public void onGetRatesListKO(String error) { // if (mView.isReady()) { // mView.errorGettingRates(error); // } // } // } // Path: android/src/main/java/com/raulh82vlc/TransactionsViewer/ui/presentation/RatesPresenterImpl.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.interactors.GetRatesListInteractor; import com.raulh82vlc.TransactionsViewer.domain.interactors.mappers.RatesListModelDataMapper; import com.raulh82vlc.TransactionsViewer.domain.interactors_response.GetRatesListCallbackImpl; import javax.inject.Inject; @Inject RatesPresenterImpl( GetRatesListInteractor interactorGetRatesList, RatesListModelDataMapper ratesListModelDataMapper) { this.interactorGetRatesList = interactorGetRatesList; this.ratesListModelDataMapper = ratesListModelDataMapper; } @Override public void setView(View view) { if (view == null) { throw new IllegalArgumentException("The view should be instantiated"); } this.view = view; } @Override public void resetView() { view = null; } @Override public void startReading(String path) throws CustomException { if (view != null) { startGettingRatesListFromJSON(path); } } private void startGettingRatesListFromJSON(String path) throws CustomException { interactorGetRatesList.execute(
path, new GetRatesListCallbackImpl(view, ratesListModelDataMapper));
raulh82vlc/Transactions-Viewer
domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractorImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import javax.inject.Inject;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Implementation of the Get Rates List Interactor * * @author Raul Hernandez Lopez */ public class GetRatesListInteractorImpl implements GetRatesListInteractor, Interactor { private InteractorExecutor executor;
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // } // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractorImpl.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import javax.inject.Inject; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Implementation of the Get Rates List Interactor * * @author Raul Hernandez Lopez */ public class GetRatesListInteractorImpl implements GetRatesListInteractor, Interactor { private InteractorExecutor executor;
private MainThread mainThread;
raulh82vlc/Transactions-Viewer
domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractorImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import javax.inject.Inject;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Implementation of the Get Rates List Interactor * * @author Raul Hernandez Lopez */ public class GetRatesListInteractorImpl implements GetRatesListInteractor, Interactor { private InteractorExecutor executor; private MainThread mainThread;
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // } // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractorImpl.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import javax.inject.Inject; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Implementation of the Get Rates List Interactor * * @author Raul Hernandez Lopez */ public class GetRatesListInteractorImpl implements GetRatesListInteractor, Interactor { private InteractorExecutor executor; private MainThread mainThread;
private DataRepository<Rate, Transaction> repository;
raulh82vlc/Transactions-Viewer
domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractorImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import javax.inject.Inject;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Implementation of the Get Rates List Interactor * * @author Raul Hernandez Lopez */ public class GetRatesListInteractorImpl implements GetRatesListInteractor, Interactor { private InteractorExecutor executor; private MainThread mainThread;
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // } // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractorImpl.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import javax.inject.Inject; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Implementation of the Get Rates List Interactor * * @author Raul Hernandez Lopez */ public class GetRatesListInteractorImpl implements GetRatesListInteractor, Interactor { private InteractorExecutor executor; private MainThread mainThread;
private DataRepository<Rate, Transaction> repository;
raulh82vlc/Transactions-Viewer
domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractorImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import javax.inject.Inject;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Implementation of the Get Rates List Interactor * * @author Raul Hernandez Lopez */ public class GetRatesListInteractorImpl implements GetRatesListInteractor, Interactor { private InteractorExecutor executor; private MainThread mainThread;
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // } // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractorImpl.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import javax.inject.Inject; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Implementation of the Get Rates List Interactor * * @author Raul Hernandez Lopez */ public class GetRatesListInteractorImpl implements GetRatesListInteractor, Interactor { private InteractorExecutor executor; private MainThread mainThread;
private DataRepository<Rate, Transaction> repository;
raulh82vlc/Transactions-Viewer
domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractorImpl.java
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // }
import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import javax.inject.Inject;
/* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Implementation of the Get Rates List Interactor * * @author Raul Hernandez Lopez */ public class GetRatesListInteractorImpl implements GetRatesListInteractor, Interactor { private InteractorExecutor executor; private MainThread mainThread; private DataRepository<Rate, Transaction> repository; private GetRatesListCallback callback; private String path; @Inject GetRatesListInteractorImpl(InteractorExecutor executor, MainThread mainThread, DataRepository repository) { this.executor = executor; this.mainThread = mainThread; this.repository = repository; } @Override
// Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/exceptions/CustomException.java // public class CustomException extends Exception { // public CustomException(String detailMessage) { // super(detailMessage); // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/Interactor.java // public interface Interactor { // void run() throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/InteractorExecutor.java // public interface InteractorExecutor { // void run(Interactor interactor) throws CustomException; // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/executors/MainThread.java // public interface MainThread { // void post(final Runnable runnable); // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Rate.java // public class Rate { // @SerializedName("from") // private String fromCurrency; // @SerializedName("rate") // private String rate; // @SerializedName("to") // private String toCurrency; // // public String getFromCurrency() { // return fromCurrency; // } // // public String getRate() { // return rate; // } // // public String getToCurrency() { // return toCurrency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/models/Transaction.java // public class Transaction { // // @SerializedName("sku") // private String skuIdentifier; // // @SerializedName("amount") // private String amountPerTransaction; // // @SerializedName("currency") // private String currency; // // public String getSkuIdentifier() { // return skuIdentifier; // } // // public String getAmountPerTransaction() { // return amountPerTransaction; // } // // public String getCurrency() { // return currency; // } // } // // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/repository/DataRepository.java // public interface DataRepository<R, T> { // // /** // * to get Rates List // **/ // List<R> getRatesList(String path) throws CustomException; // // /** // * to get Transactions list // **/ // List<T> getTransactionsList(String path) throws CustomException; // // /** // * to get Transactions per product's SKU // **/ // List<T> getTransactionsPerSku(String mPathTransactions, String mSku); // // /** // * to save Transactions indexed per product's SKU // **/ // boolean saveTransactions(Map<String, List<T>> map); // } // Path: domain/src/main/java/com/raulh82vlc/TransactionsViewer/domain/interactors/GetRatesListInteractorImpl.java import com.raulh82vlc.TransactionsViewer.domain.exceptions.CustomException; import com.raulh82vlc.TransactionsViewer.domain.executors.Interactor; import com.raulh82vlc.TransactionsViewer.domain.executors.InteractorExecutor; import com.raulh82vlc.TransactionsViewer.domain.executors.MainThread; import com.raulh82vlc.TransactionsViewer.domain.models.Rate; import com.raulh82vlc.TransactionsViewer.domain.models.Transaction; import com.raulh82vlc.TransactionsViewer.domain.repository.DataRepository; import java.util.List; import javax.inject.Inject; /* * Copyright (C) 2017 Raul Hernandez Lopez @raulh82vlc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.raulh82vlc.TransactionsViewer.domain.interactors; /** * Implementation of the Get Rates List Interactor * * @author Raul Hernandez Lopez */ public class GetRatesListInteractorImpl implements GetRatesListInteractor, Interactor { private InteractorExecutor executor; private MainThread mainThread; private DataRepository<Rate, Transaction> repository; private GetRatesListCallback callback; private String path; @Inject GetRatesListInteractorImpl(InteractorExecutor executor, MainThread mainThread, DataRepository repository) { this.executor = executor; this.mainThread = mainThread; this.repository = repository; } @Override
public void execute(String path, GetRatesListCallback callback) throws CustomException {