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
|
---|---|---|---|---|---|---|
MrBW/resilient-transport-service | connote-service/src/test/java/de/codecentric/resilient/connote/service/ConnoteServiceTest.java | // Path: connote-service/src/main/java/de/codecentric/resilient/connote/entity/Connote.java
// @Entity
// public class Connote {
//
// @Id
// private Long connote;
//
// @Column(name = "created", nullable = false)
// private LocalDateTime created = LocalDateTime.now();
//
// public Connote(Long connote) {
//
// this.connote = connote;
// }
//
// public Connote() {
// }
//
// public Long getConnote() {
// return connote;
// }
//
// public void setConnote(Long connote) {
// this.connote = connote;
// }
//
// public LocalDateTime getCreated() {
// return created;
// }
//
// public void setCreated(LocalDateTime created) {
// this.created = created;
// }
//
// }
//
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/repository/ConnoteRepository.java
// public interface ConnoteRepository extends CrudRepository<Connote, Long> {
//
// @Override
// Connote save(Connote connote);
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class ConnoteDTO extends FallbackAbstractDTO {
//
// @JsonProperty(required = true)
// private Long connote;
//
// public void setConnote(Long connote) {
// this.connote = connote;
// }
//
// public Long getConnote() {
// return connote;
// }
//
// }
//
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/utils/RandomConnoteGenerator.java
// @Service
// @RefreshScope
// public class RandomConnoteGenerator {
//
// // Connote start range
// private DynamicLongProperty startRange =
// DynamicPropertyFactory.getInstance().getLongProperty("connote.range.start", 1000000);
//
// // Connote end range
// private DynamicLongProperty endRange = DynamicPropertyFactory.getInstance().getLongProperty("connote.range.end", 5000000);
//
// @Value("${connote.range.start}")
// private int connoteStart;
//
// @Value("${connote.range.end}")
// private int connoteEnd;
//
// public long randomNumber() {
// startRange.get();
// endRange.get();
// return RandomUtils.nextLong(connoteStart, connoteEnd);
//
// //return RandomUtils.nextLong(startRange.get(), endRange.get());
// }
// }
| import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
import de.codecentric.resilient.connote.entity.Connote;
import de.codecentric.resilient.connote.repository.ConnoteRepository;
import org.joda.time.LocalDateTime;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import de.codecentric.resilient.dto.ConnoteDTO;
import de.codecentric.resilient.connote.utils.RandomConnoteGenerator; | package de.codecentric.resilient.connote.service;
/**
* @author Benjamin Wilms (xd98870)
*/
@RunWith(MockitoJUnitRunner.class)
public class ConnoteServiceTest {
@Mock
private ConnoteRepository connoteRepositoryMock;
@Mock
private RandomConnoteGenerator randomConnoteGeneratorMock;
private ConnoteService connoteService;
@Before
public void setUp() throws Exception {
connoteService = new ConnoteService(connoteRepositoryMock, randomConnoteGeneratorMock);
}
@Test
public void nextConnote_Goodcase() throws Exception {
Long uniqueConnote = 1L;
Connote connoteToBeSaved = new Connote(uniqueConnote);
connoteToBeSaved.setCreated(new LocalDateTime(2017, 01, 02, 12, 03, 10));
when(randomConnoteGeneratorMock.randomNumber()).thenReturn(342L, uniqueConnote);
when(connoteRepositoryMock.findOne(342L)).thenReturn(new Connote(342L));
when(connoteRepositoryMock.findOne(uniqueConnote)).thenReturn(null);
when(connoteRepositoryMock.save(any(Connote.class))).thenReturn(connoteToBeSaved);
| // Path: connote-service/src/main/java/de/codecentric/resilient/connote/entity/Connote.java
// @Entity
// public class Connote {
//
// @Id
// private Long connote;
//
// @Column(name = "created", nullable = false)
// private LocalDateTime created = LocalDateTime.now();
//
// public Connote(Long connote) {
//
// this.connote = connote;
// }
//
// public Connote() {
// }
//
// public Long getConnote() {
// return connote;
// }
//
// public void setConnote(Long connote) {
// this.connote = connote;
// }
//
// public LocalDateTime getCreated() {
// return created;
// }
//
// public void setCreated(LocalDateTime created) {
// this.created = created;
// }
//
// }
//
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/repository/ConnoteRepository.java
// public interface ConnoteRepository extends CrudRepository<Connote, Long> {
//
// @Override
// Connote save(Connote connote);
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class ConnoteDTO extends FallbackAbstractDTO {
//
// @JsonProperty(required = true)
// private Long connote;
//
// public void setConnote(Long connote) {
// this.connote = connote;
// }
//
// public Long getConnote() {
// return connote;
// }
//
// }
//
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/utils/RandomConnoteGenerator.java
// @Service
// @RefreshScope
// public class RandomConnoteGenerator {
//
// // Connote start range
// private DynamicLongProperty startRange =
// DynamicPropertyFactory.getInstance().getLongProperty("connote.range.start", 1000000);
//
// // Connote end range
// private DynamicLongProperty endRange = DynamicPropertyFactory.getInstance().getLongProperty("connote.range.end", 5000000);
//
// @Value("${connote.range.start}")
// private int connoteStart;
//
// @Value("${connote.range.end}")
// private int connoteEnd;
//
// public long randomNumber() {
// startRange.get();
// endRange.get();
// return RandomUtils.nextLong(connoteStart, connoteEnd);
//
// //return RandomUtils.nextLong(startRange.get(), endRange.get());
// }
// }
// Path: connote-service/src/test/java/de/codecentric/resilient/connote/service/ConnoteServiceTest.java
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
import de.codecentric.resilient.connote.entity.Connote;
import de.codecentric.resilient.connote.repository.ConnoteRepository;
import org.joda.time.LocalDateTime;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import de.codecentric.resilient.dto.ConnoteDTO;
import de.codecentric.resilient.connote.utils.RandomConnoteGenerator;
package de.codecentric.resilient.connote.service;
/**
* @author Benjamin Wilms (xd98870)
*/
@RunWith(MockitoJUnitRunner.class)
public class ConnoteServiceTest {
@Mock
private ConnoteRepository connoteRepositoryMock;
@Mock
private RandomConnoteGenerator randomConnoteGeneratorMock;
private ConnoteService connoteService;
@Before
public void setUp() throws Exception {
connoteService = new ConnoteService(connoteRepositoryMock, randomConnoteGeneratorMock);
}
@Test
public void nextConnote_Goodcase() throws Exception {
Long uniqueConnote = 1L;
Connote connoteToBeSaved = new Connote(uniqueConnote);
connoteToBeSaved.setCreated(new LocalDateTime(2017, 01, 02, 12, 03, 10));
when(randomConnoteGeneratorMock.randomNumber()).thenReturn(342L, uniqueConnote);
when(connoteRepositoryMock.findOne(342L)).thenReturn(new Connote(342L));
when(connoteRepositoryMock.findOne(uniqueConnote)).thenReturn(null);
when(connoteRepositoryMock.save(any(Connote.class))).thenReturn(connoteToBeSaved);
| ConnoteDTO connote = connoteService.createConnote(); |
MrBW/resilient-transport-service | transport-api-gateway/src/main/java/de/codecentric/resilient/transport/api/gateway/commands/BookingCommand.java | // Path: service-library/src/main/java/de/codecentric/resilient/dto/BookingServiceRequestDTO.java
// public class BookingServiceRequestDTO {
//
// private CustomerResponseDTO customerDTO;
//
// private AddressResponseDTO senderAddress;
//
// private AddressResponseDTO receiverAddress;
//
// public CustomerResponseDTO getCustomerDTO() {
// return customerDTO;
// }
//
// public void setCustomerDTO(CustomerResponseDTO customerDTO) {
// this.customerDTO = customerDTO;
// }
//
// public AddressResponseDTO getSenderAddress() {
// return senderAddress;
// }
//
// public void setSenderAddress(AddressResponseDTO senderAddress) {
// this.senderAddress = senderAddress;
// }
//
// public AddressResponseDTO getReceiverAddress() {
// return receiverAddress;
// }
//
// public void setReceiverAddress(AddressResponseDTO receiverAddress) {
// this.receiverAddress = receiverAddress;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder("BookingServiceRequestDTO{");
// sb.append("customerDTO=").append(customerDTO);
// sb.append(", senderAddress=").append(senderAddress);
// sb.append(", receiverAddress=").append(receiverAddress);
// sb.append('}');
// return sb.toString();
// }
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/BookingServiceResponseDTO.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class BookingServiceResponseDTO extends FallbackAbstractDTO {
//
// @JsonProperty(required = true)
// private ConnoteDTO connoteDTO;
//
// @JsonProperty(required = true)
// private String status;
//
// @JsonProperty(required = true)
// private CustomerDTO customerDTO;
//
// @JsonProperty(required = true, value = "service-response-status")
// private List<ServiceResponseStatus> serviceResponseStatusList;
//
// public List<ServiceResponseStatus> getServiceResponseStatusList() {
// return serviceResponseStatusList;
// }
//
// public void setServiceResponseStatusList(List<ServiceResponseStatus> serviceResponseStatusList) {
// this.serviceResponseStatusList = serviceResponseStatusList;
// }
//
// public ConnoteDTO getConnoteDTO() {
// return connoteDTO;
// }
//
// public void setConnoteDTO(ConnoteDTO connoteDTO) {
// this.connoteDTO = connoteDTO;
// }
//
// public CustomerDTO getCustomerDTO() {
// return customerDTO;
// }
//
// public void setCustomerDTO(CustomerDTO customerDTO) {
// this.customerDTO = customerDTO;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
// }
| import com.netflix.hystrix.exception.HystrixRuntimeException;
import com.netflix.hystrix.exception.HystrixTimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.client.RestTemplate;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandKey;
import de.codecentric.resilient.dto.BookingServiceRequestDTO;
import de.codecentric.resilient.dto.BookingServiceResponseDTO; | package de.codecentric.resilient.transport.api.gateway.commands;
/**
* @author Benjamin Wilms
*/
public class BookingCommand extends HystrixCommand<BookingServiceResponseDTO> {
private static final Logger LOGGER = LoggerFactory.getLogger(BookingCommand.class);
| // Path: service-library/src/main/java/de/codecentric/resilient/dto/BookingServiceRequestDTO.java
// public class BookingServiceRequestDTO {
//
// private CustomerResponseDTO customerDTO;
//
// private AddressResponseDTO senderAddress;
//
// private AddressResponseDTO receiverAddress;
//
// public CustomerResponseDTO getCustomerDTO() {
// return customerDTO;
// }
//
// public void setCustomerDTO(CustomerResponseDTO customerDTO) {
// this.customerDTO = customerDTO;
// }
//
// public AddressResponseDTO getSenderAddress() {
// return senderAddress;
// }
//
// public void setSenderAddress(AddressResponseDTO senderAddress) {
// this.senderAddress = senderAddress;
// }
//
// public AddressResponseDTO getReceiverAddress() {
// return receiverAddress;
// }
//
// public void setReceiverAddress(AddressResponseDTO receiverAddress) {
// this.receiverAddress = receiverAddress;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder("BookingServiceRequestDTO{");
// sb.append("customerDTO=").append(customerDTO);
// sb.append(", senderAddress=").append(senderAddress);
// sb.append(", receiverAddress=").append(receiverAddress);
// sb.append('}');
// return sb.toString();
// }
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/BookingServiceResponseDTO.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class BookingServiceResponseDTO extends FallbackAbstractDTO {
//
// @JsonProperty(required = true)
// private ConnoteDTO connoteDTO;
//
// @JsonProperty(required = true)
// private String status;
//
// @JsonProperty(required = true)
// private CustomerDTO customerDTO;
//
// @JsonProperty(required = true, value = "service-response-status")
// private List<ServiceResponseStatus> serviceResponseStatusList;
//
// public List<ServiceResponseStatus> getServiceResponseStatusList() {
// return serviceResponseStatusList;
// }
//
// public void setServiceResponseStatusList(List<ServiceResponseStatus> serviceResponseStatusList) {
// this.serviceResponseStatusList = serviceResponseStatusList;
// }
//
// public ConnoteDTO getConnoteDTO() {
// return connoteDTO;
// }
//
// public void setConnoteDTO(ConnoteDTO connoteDTO) {
// this.connoteDTO = connoteDTO;
// }
//
// public CustomerDTO getCustomerDTO() {
// return customerDTO;
// }
//
// public void setCustomerDTO(CustomerDTO customerDTO) {
// this.customerDTO = customerDTO;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
// }
// Path: transport-api-gateway/src/main/java/de/codecentric/resilient/transport/api/gateway/commands/BookingCommand.java
import com.netflix.hystrix.exception.HystrixRuntimeException;
import com.netflix.hystrix.exception.HystrixTimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.client.RestTemplate;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandKey;
import de.codecentric.resilient.dto.BookingServiceRequestDTO;
import de.codecentric.resilient.dto.BookingServiceResponseDTO;
package de.codecentric.resilient.transport.api.gateway.commands;
/**
* @author Benjamin Wilms
*/
public class BookingCommand extends HystrixCommand<BookingServiceResponseDTO> {
private static final Logger LOGGER = LoggerFactory.getLogger(BookingCommand.class);
| private final BookingServiceRequestDTO bookingServiceRequestDTO; |
MrBW/resilient-transport-service | booking-service/src/main/java/de/codecentric/resilient/booking/rest/BookingController.java | // Path: booking-service/src/main/java/de/codecentric/resilient/booking/service/BookingService.java
// @Service
// public class BookingService {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(BookingService.class);
//
// private final BookingRepository bookingRepository;
//
// private final BookingMapper bookingMapper;
//
// private final RestTemplate restTemplate;
//
// private DynamicBooleanProperty secondServiceCallEnabled =
// DynamicPropertyFactory.getInstance().getBooleanProperty("second.service.call", false);
//
// @Autowired
// public BookingService(BookingRepository bookingRepository, BookingMapper bookingMapper, RestTemplate restTemplate) {
// this.bookingRepository = bookingRepository;
// this.bookingMapper = bookingMapper;
// this.restTemplate = restTemplate;
// }
//
// public BookingServiceResponseDTO createBooking(BookingServiceRequestDTO bookingRequestDTO) {
//
// BookingServiceResponseDTO bookingResponseDTO = new BookingServiceResponseDTO();
//
// // 1.) Create connote
// ConnoteDTO connoteDTO = receiveConnote();
//
// if (connoteDTO.isFallback()) {
// bookingResponseDTO.setErrorMsg("Connote error: " + connoteDTO.getErrorMsg());
// bookingResponseDTO.setStatus("ERROR");
// return bookingResponseDTO;
// }
//
// // 2. Save booking request
//
// Booking booking = bookingMapper.mapToBookingEntity(bookingRequestDTO, connoteDTO.getConnote());
// bookingRepository.save(booking);
//
// CustomerResponseDTO customerDTO = bookingRequestDTO.getCustomerDTO();
// bookingResponseDTO.setCustomerDTO(new CustomerDTO(customerDTO.getCustomerId(), customerDTO.getCustomerName()));
// bookingResponseDTO.setConnoteDTO(connoteDTO);
// bookingResponseDTO.setStatus("OK");
//
// return bookingResponseDTO;
//
// }
//
// private ConnoteDTO receiveConnote() {
// LOGGER.debug("Starting getConnote");
//
// return new ConnoteCommand(restTemplate, secondServiceCallEnabled.get()).execute();
// }
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/BookingServiceRequestDTO.java
// public class BookingServiceRequestDTO {
//
// private CustomerResponseDTO customerDTO;
//
// private AddressResponseDTO senderAddress;
//
// private AddressResponseDTO receiverAddress;
//
// public CustomerResponseDTO getCustomerDTO() {
// return customerDTO;
// }
//
// public void setCustomerDTO(CustomerResponseDTO customerDTO) {
// this.customerDTO = customerDTO;
// }
//
// public AddressResponseDTO getSenderAddress() {
// return senderAddress;
// }
//
// public void setSenderAddress(AddressResponseDTO senderAddress) {
// this.senderAddress = senderAddress;
// }
//
// public AddressResponseDTO getReceiverAddress() {
// return receiverAddress;
// }
//
// public void setReceiverAddress(AddressResponseDTO receiverAddress) {
// this.receiverAddress = receiverAddress;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder("BookingServiceRequestDTO{");
// sb.append("customerDTO=").append(customerDTO);
// sb.append(", senderAddress=").append(senderAddress);
// sb.append(", receiverAddress=").append(receiverAddress);
// sb.append('}');
// return sb.toString();
// }
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/BookingServiceResponseDTO.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class BookingServiceResponseDTO extends FallbackAbstractDTO {
//
// @JsonProperty(required = true)
// private ConnoteDTO connoteDTO;
//
// @JsonProperty(required = true)
// private String status;
//
// @JsonProperty(required = true)
// private CustomerDTO customerDTO;
//
// @JsonProperty(required = true, value = "service-response-status")
// private List<ServiceResponseStatus> serviceResponseStatusList;
//
// public List<ServiceResponseStatus> getServiceResponseStatusList() {
// return serviceResponseStatusList;
// }
//
// public void setServiceResponseStatusList(List<ServiceResponseStatus> serviceResponseStatusList) {
// this.serviceResponseStatusList = serviceResponseStatusList;
// }
//
// public ConnoteDTO getConnoteDTO() {
// return connoteDTO;
// }
//
// public void setConnoteDTO(ConnoteDTO connoteDTO) {
// this.connoteDTO = connoteDTO;
// }
//
// public CustomerDTO getCustomerDTO() {
// return customerDTO;
// }
//
// public void setCustomerDTO(CustomerDTO customerDTO) {
// this.customerDTO = customerDTO;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
// }
| import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Span;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import de.codecentric.resilient.booking.service.BookingService;
import de.codecentric.resilient.dto.BookingServiceRequestDTO;
import de.codecentric.resilient.dto.BookingServiceResponseDTO; | package de.codecentric.resilient.booking.rest;
/**
* @author Benjamin Wilms
*/
@RestController
@RequestMapping("rest/booking")
public class BookingController {
private static final Logger LOGGER = LoggerFactory.getLogger(BookingController.class);
| // Path: booking-service/src/main/java/de/codecentric/resilient/booking/service/BookingService.java
// @Service
// public class BookingService {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(BookingService.class);
//
// private final BookingRepository bookingRepository;
//
// private final BookingMapper bookingMapper;
//
// private final RestTemplate restTemplate;
//
// private DynamicBooleanProperty secondServiceCallEnabled =
// DynamicPropertyFactory.getInstance().getBooleanProperty("second.service.call", false);
//
// @Autowired
// public BookingService(BookingRepository bookingRepository, BookingMapper bookingMapper, RestTemplate restTemplate) {
// this.bookingRepository = bookingRepository;
// this.bookingMapper = bookingMapper;
// this.restTemplate = restTemplate;
// }
//
// public BookingServiceResponseDTO createBooking(BookingServiceRequestDTO bookingRequestDTO) {
//
// BookingServiceResponseDTO bookingResponseDTO = new BookingServiceResponseDTO();
//
// // 1.) Create connote
// ConnoteDTO connoteDTO = receiveConnote();
//
// if (connoteDTO.isFallback()) {
// bookingResponseDTO.setErrorMsg("Connote error: " + connoteDTO.getErrorMsg());
// bookingResponseDTO.setStatus("ERROR");
// return bookingResponseDTO;
// }
//
// // 2. Save booking request
//
// Booking booking = bookingMapper.mapToBookingEntity(bookingRequestDTO, connoteDTO.getConnote());
// bookingRepository.save(booking);
//
// CustomerResponseDTO customerDTO = bookingRequestDTO.getCustomerDTO();
// bookingResponseDTO.setCustomerDTO(new CustomerDTO(customerDTO.getCustomerId(), customerDTO.getCustomerName()));
// bookingResponseDTO.setConnoteDTO(connoteDTO);
// bookingResponseDTO.setStatus("OK");
//
// return bookingResponseDTO;
//
// }
//
// private ConnoteDTO receiveConnote() {
// LOGGER.debug("Starting getConnote");
//
// return new ConnoteCommand(restTemplate, secondServiceCallEnabled.get()).execute();
// }
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/BookingServiceRequestDTO.java
// public class BookingServiceRequestDTO {
//
// private CustomerResponseDTO customerDTO;
//
// private AddressResponseDTO senderAddress;
//
// private AddressResponseDTO receiverAddress;
//
// public CustomerResponseDTO getCustomerDTO() {
// return customerDTO;
// }
//
// public void setCustomerDTO(CustomerResponseDTO customerDTO) {
// this.customerDTO = customerDTO;
// }
//
// public AddressResponseDTO getSenderAddress() {
// return senderAddress;
// }
//
// public void setSenderAddress(AddressResponseDTO senderAddress) {
// this.senderAddress = senderAddress;
// }
//
// public AddressResponseDTO getReceiverAddress() {
// return receiverAddress;
// }
//
// public void setReceiverAddress(AddressResponseDTO receiverAddress) {
// this.receiverAddress = receiverAddress;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder("BookingServiceRequestDTO{");
// sb.append("customerDTO=").append(customerDTO);
// sb.append(", senderAddress=").append(senderAddress);
// sb.append(", receiverAddress=").append(receiverAddress);
// sb.append('}');
// return sb.toString();
// }
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/BookingServiceResponseDTO.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class BookingServiceResponseDTO extends FallbackAbstractDTO {
//
// @JsonProperty(required = true)
// private ConnoteDTO connoteDTO;
//
// @JsonProperty(required = true)
// private String status;
//
// @JsonProperty(required = true)
// private CustomerDTO customerDTO;
//
// @JsonProperty(required = true, value = "service-response-status")
// private List<ServiceResponseStatus> serviceResponseStatusList;
//
// public List<ServiceResponseStatus> getServiceResponseStatusList() {
// return serviceResponseStatusList;
// }
//
// public void setServiceResponseStatusList(List<ServiceResponseStatus> serviceResponseStatusList) {
// this.serviceResponseStatusList = serviceResponseStatusList;
// }
//
// public ConnoteDTO getConnoteDTO() {
// return connoteDTO;
// }
//
// public void setConnoteDTO(ConnoteDTO connoteDTO) {
// this.connoteDTO = connoteDTO;
// }
//
// public CustomerDTO getCustomerDTO() {
// return customerDTO;
// }
//
// public void setCustomerDTO(CustomerDTO customerDTO) {
// this.customerDTO = customerDTO;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
// }
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/rest/BookingController.java
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Span;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import de.codecentric.resilient.booking.service.BookingService;
import de.codecentric.resilient.dto.BookingServiceRequestDTO;
import de.codecentric.resilient.dto.BookingServiceResponseDTO;
package de.codecentric.resilient.booking.rest;
/**
* @author Benjamin Wilms
*/
@RestController
@RequestMapping("rest/booking")
public class BookingController {
private static final Logger LOGGER = LoggerFactory.getLogger(BookingController.class);
| private final BookingService bookingService; |
MrBW/resilient-transport-service | booking-service/src/main/java/de/codecentric/resilient/booking/rest/BookingController.java | // Path: booking-service/src/main/java/de/codecentric/resilient/booking/service/BookingService.java
// @Service
// public class BookingService {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(BookingService.class);
//
// private final BookingRepository bookingRepository;
//
// private final BookingMapper bookingMapper;
//
// private final RestTemplate restTemplate;
//
// private DynamicBooleanProperty secondServiceCallEnabled =
// DynamicPropertyFactory.getInstance().getBooleanProperty("second.service.call", false);
//
// @Autowired
// public BookingService(BookingRepository bookingRepository, BookingMapper bookingMapper, RestTemplate restTemplate) {
// this.bookingRepository = bookingRepository;
// this.bookingMapper = bookingMapper;
// this.restTemplate = restTemplate;
// }
//
// public BookingServiceResponseDTO createBooking(BookingServiceRequestDTO bookingRequestDTO) {
//
// BookingServiceResponseDTO bookingResponseDTO = new BookingServiceResponseDTO();
//
// // 1.) Create connote
// ConnoteDTO connoteDTO = receiveConnote();
//
// if (connoteDTO.isFallback()) {
// bookingResponseDTO.setErrorMsg("Connote error: " + connoteDTO.getErrorMsg());
// bookingResponseDTO.setStatus("ERROR");
// return bookingResponseDTO;
// }
//
// // 2. Save booking request
//
// Booking booking = bookingMapper.mapToBookingEntity(bookingRequestDTO, connoteDTO.getConnote());
// bookingRepository.save(booking);
//
// CustomerResponseDTO customerDTO = bookingRequestDTO.getCustomerDTO();
// bookingResponseDTO.setCustomerDTO(new CustomerDTO(customerDTO.getCustomerId(), customerDTO.getCustomerName()));
// bookingResponseDTO.setConnoteDTO(connoteDTO);
// bookingResponseDTO.setStatus("OK");
//
// return bookingResponseDTO;
//
// }
//
// private ConnoteDTO receiveConnote() {
// LOGGER.debug("Starting getConnote");
//
// return new ConnoteCommand(restTemplate, secondServiceCallEnabled.get()).execute();
// }
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/BookingServiceRequestDTO.java
// public class BookingServiceRequestDTO {
//
// private CustomerResponseDTO customerDTO;
//
// private AddressResponseDTO senderAddress;
//
// private AddressResponseDTO receiverAddress;
//
// public CustomerResponseDTO getCustomerDTO() {
// return customerDTO;
// }
//
// public void setCustomerDTO(CustomerResponseDTO customerDTO) {
// this.customerDTO = customerDTO;
// }
//
// public AddressResponseDTO getSenderAddress() {
// return senderAddress;
// }
//
// public void setSenderAddress(AddressResponseDTO senderAddress) {
// this.senderAddress = senderAddress;
// }
//
// public AddressResponseDTO getReceiverAddress() {
// return receiverAddress;
// }
//
// public void setReceiverAddress(AddressResponseDTO receiverAddress) {
// this.receiverAddress = receiverAddress;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder("BookingServiceRequestDTO{");
// sb.append("customerDTO=").append(customerDTO);
// sb.append(", senderAddress=").append(senderAddress);
// sb.append(", receiverAddress=").append(receiverAddress);
// sb.append('}');
// return sb.toString();
// }
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/BookingServiceResponseDTO.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class BookingServiceResponseDTO extends FallbackAbstractDTO {
//
// @JsonProperty(required = true)
// private ConnoteDTO connoteDTO;
//
// @JsonProperty(required = true)
// private String status;
//
// @JsonProperty(required = true)
// private CustomerDTO customerDTO;
//
// @JsonProperty(required = true, value = "service-response-status")
// private List<ServiceResponseStatus> serviceResponseStatusList;
//
// public List<ServiceResponseStatus> getServiceResponseStatusList() {
// return serviceResponseStatusList;
// }
//
// public void setServiceResponseStatusList(List<ServiceResponseStatus> serviceResponseStatusList) {
// this.serviceResponseStatusList = serviceResponseStatusList;
// }
//
// public ConnoteDTO getConnoteDTO() {
// return connoteDTO;
// }
//
// public void setConnoteDTO(ConnoteDTO connoteDTO) {
// this.connoteDTO = connoteDTO;
// }
//
// public CustomerDTO getCustomerDTO() {
// return customerDTO;
// }
//
// public void setCustomerDTO(CustomerDTO customerDTO) {
// this.customerDTO = customerDTO;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
// }
| import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Span;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import de.codecentric.resilient.booking.service.BookingService;
import de.codecentric.resilient.dto.BookingServiceRequestDTO;
import de.codecentric.resilient.dto.BookingServiceResponseDTO; | package de.codecentric.resilient.booking.rest;
/**
* @author Benjamin Wilms
*/
@RestController
@RequestMapping("rest/booking")
public class BookingController {
private static final Logger LOGGER = LoggerFactory.getLogger(BookingController.class);
private final BookingService bookingService;
private final Tracer tracer;
@Autowired
public BookingController(BookingService bookingService, Tracer tracer) {
this.bookingService = bookingService;
this.tracer = tracer;
}
@RequestMapping(value = "create", method = RequestMethod.POST)
@ResponseBody | // Path: booking-service/src/main/java/de/codecentric/resilient/booking/service/BookingService.java
// @Service
// public class BookingService {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(BookingService.class);
//
// private final BookingRepository bookingRepository;
//
// private final BookingMapper bookingMapper;
//
// private final RestTemplate restTemplate;
//
// private DynamicBooleanProperty secondServiceCallEnabled =
// DynamicPropertyFactory.getInstance().getBooleanProperty("second.service.call", false);
//
// @Autowired
// public BookingService(BookingRepository bookingRepository, BookingMapper bookingMapper, RestTemplate restTemplate) {
// this.bookingRepository = bookingRepository;
// this.bookingMapper = bookingMapper;
// this.restTemplate = restTemplate;
// }
//
// public BookingServiceResponseDTO createBooking(BookingServiceRequestDTO bookingRequestDTO) {
//
// BookingServiceResponseDTO bookingResponseDTO = new BookingServiceResponseDTO();
//
// // 1.) Create connote
// ConnoteDTO connoteDTO = receiveConnote();
//
// if (connoteDTO.isFallback()) {
// bookingResponseDTO.setErrorMsg("Connote error: " + connoteDTO.getErrorMsg());
// bookingResponseDTO.setStatus("ERROR");
// return bookingResponseDTO;
// }
//
// // 2. Save booking request
//
// Booking booking = bookingMapper.mapToBookingEntity(bookingRequestDTO, connoteDTO.getConnote());
// bookingRepository.save(booking);
//
// CustomerResponseDTO customerDTO = bookingRequestDTO.getCustomerDTO();
// bookingResponseDTO.setCustomerDTO(new CustomerDTO(customerDTO.getCustomerId(), customerDTO.getCustomerName()));
// bookingResponseDTO.setConnoteDTO(connoteDTO);
// bookingResponseDTO.setStatus("OK");
//
// return bookingResponseDTO;
//
// }
//
// private ConnoteDTO receiveConnote() {
// LOGGER.debug("Starting getConnote");
//
// return new ConnoteCommand(restTemplate, secondServiceCallEnabled.get()).execute();
// }
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/BookingServiceRequestDTO.java
// public class BookingServiceRequestDTO {
//
// private CustomerResponseDTO customerDTO;
//
// private AddressResponseDTO senderAddress;
//
// private AddressResponseDTO receiverAddress;
//
// public CustomerResponseDTO getCustomerDTO() {
// return customerDTO;
// }
//
// public void setCustomerDTO(CustomerResponseDTO customerDTO) {
// this.customerDTO = customerDTO;
// }
//
// public AddressResponseDTO getSenderAddress() {
// return senderAddress;
// }
//
// public void setSenderAddress(AddressResponseDTO senderAddress) {
// this.senderAddress = senderAddress;
// }
//
// public AddressResponseDTO getReceiverAddress() {
// return receiverAddress;
// }
//
// public void setReceiverAddress(AddressResponseDTO receiverAddress) {
// this.receiverAddress = receiverAddress;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder("BookingServiceRequestDTO{");
// sb.append("customerDTO=").append(customerDTO);
// sb.append(", senderAddress=").append(senderAddress);
// sb.append(", receiverAddress=").append(receiverAddress);
// sb.append('}');
// return sb.toString();
// }
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/BookingServiceResponseDTO.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class BookingServiceResponseDTO extends FallbackAbstractDTO {
//
// @JsonProperty(required = true)
// private ConnoteDTO connoteDTO;
//
// @JsonProperty(required = true)
// private String status;
//
// @JsonProperty(required = true)
// private CustomerDTO customerDTO;
//
// @JsonProperty(required = true, value = "service-response-status")
// private List<ServiceResponseStatus> serviceResponseStatusList;
//
// public List<ServiceResponseStatus> getServiceResponseStatusList() {
// return serviceResponseStatusList;
// }
//
// public void setServiceResponseStatusList(List<ServiceResponseStatus> serviceResponseStatusList) {
// this.serviceResponseStatusList = serviceResponseStatusList;
// }
//
// public ConnoteDTO getConnoteDTO() {
// return connoteDTO;
// }
//
// public void setConnoteDTO(ConnoteDTO connoteDTO) {
// this.connoteDTO = connoteDTO;
// }
//
// public CustomerDTO getCustomerDTO() {
// return customerDTO;
// }
//
// public void setCustomerDTO(CustomerDTO customerDTO) {
// this.customerDTO = customerDTO;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
// }
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/rest/BookingController.java
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Span;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import de.codecentric.resilient.booking.service.BookingService;
import de.codecentric.resilient.dto.BookingServiceRequestDTO;
import de.codecentric.resilient.dto.BookingServiceResponseDTO;
package de.codecentric.resilient.booking.rest;
/**
* @author Benjamin Wilms
*/
@RestController
@RequestMapping("rest/booking")
public class BookingController {
private static final Logger LOGGER = LoggerFactory.getLogger(BookingController.class);
private final BookingService bookingService;
private final Tracer tracer;
@Autowired
public BookingController(BookingService bookingService, Tracer tracer) {
this.bookingService = bookingService;
this.tracer = tracer;
}
@RequestMapping(value = "create", method = RequestMethod.POST)
@ResponseBody | public ResponseEntity<BookingServiceResponseDTO> create(@RequestBody BookingServiceRequestDTO bookingRequestDTO, |
MrBW/resilient-transport-service | booking-service/src/main/java/de/codecentric/resilient/booking/rest/BookingController.java | // Path: booking-service/src/main/java/de/codecentric/resilient/booking/service/BookingService.java
// @Service
// public class BookingService {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(BookingService.class);
//
// private final BookingRepository bookingRepository;
//
// private final BookingMapper bookingMapper;
//
// private final RestTemplate restTemplate;
//
// private DynamicBooleanProperty secondServiceCallEnabled =
// DynamicPropertyFactory.getInstance().getBooleanProperty("second.service.call", false);
//
// @Autowired
// public BookingService(BookingRepository bookingRepository, BookingMapper bookingMapper, RestTemplate restTemplate) {
// this.bookingRepository = bookingRepository;
// this.bookingMapper = bookingMapper;
// this.restTemplate = restTemplate;
// }
//
// public BookingServiceResponseDTO createBooking(BookingServiceRequestDTO bookingRequestDTO) {
//
// BookingServiceResponseDTO bookingResponseDTO = new BookingServiceResponseDTO();
//
// // 1.) Create connote
// ConnoteDTO connoteDTO = receiveConnote();
//
// if (connoteDTO.isFallback()) {
// bookingResponseDTO.setErrorMsg("Connote error: " + connoteDTO.getErrorMsg());
// bookingResponseDTO.setStatus("ERROR");
// return bookingResponseDTO;
// }
//
// // 2. Save booking request
//
// Booking booking = bookingMapper.mapToBookingEntity(bookingRequestDTO, connoteDTO.getConnote());
// bookingRepository.save(booking);
//
// CustomerResponseDTO customerDTO = bookingRequestDTO.getCustomerDTO();
// bookingResponseDTO.setCustomerDTO(new CustomerDTO(customerDTO.getCustomerId(), customerDTO.getCustomerName()));
// bookingResponseDTO.setConnoteDTO(connoteDTO);
// bookingResponseDTO.setStatus("OK");
//
// return bookingResponseDTO;
//
// }
//
// private ConnoteDTO receiveConnote() {
// LOGGER.debug("Starting getConnote");
//
// return new ConnoteCommand(restTemplate, secondServiceCallEnabled.get()).execute();
// }
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/BookingServiceRequestDTO.java
// public class BookingServiceRequestDTO {
//
// private CustomerResponseDTO customerDTO;
//
// private AddressResponseDTO senderAddress;
//
// private AddressResponseDTO receiverAddress;
//
// public CustomerResponseDTO getCustomerDTO() {
// return customerDTO;
// }
//
// public void setCustomerDTO(CustomerResponseDTO customerDTO) {
// this.customerDTO = customerDTO;
// }
//
// public AddressResponseDTO getSenderAddress() {
// return senderAddress;
// }
//
// public void setSenderAddress(AddressResponseDTO senderAddress) {
// this.senderAddress = senderAddress;
// }
//
// public AddressResponseDTO getReceiverAddress() {
// return receiverAddress;
// }
//
// public void setReceiverAddress(AddressResponseDTO receiverAddress) {
// this.receiverAddress = receiverAddress;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder("BookingServiceRequestDTO{");
// sb.append("customerDTO=").append(customerDTO);
// sb.append(", senderAddress=").append(senderAddress);
// sb.append(", receiverAddress=").append(receiverAddress);
// sb.append('}');
// return sb.toString();
// }
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/BookingServiceResponseDTO.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class BookingServiceResponseDTO extends FallbackAbstractDTO {
//
// @JsonProperty(required = true)
// private ConnoteDTO connoteDTO;
//
// @JsonProperty(required = true)
// private String status;
//
// @JsonProperty(required = true)
// private CustomerDTO customerDTO;
//
// @JsonProperty(required = true, value = "service-response-status")
// private List<ServiceResponseStatus> serviceResponseStatusList;
//
// public List<ServiceResponseStatus> getServiceResponseStatusList() {
// return serviceResponseStatusList;
// }
//
// public void setServiceResponseStatusList(List<ServiceResponseStatus> serviceResponseStatusList) {
// this.serviceResponseStatusList = serviceResponseStatusList;
// }
//
// public ConnoteDTO getConnoteDTO() {
// return connoteDTO;
// }
//
// public void setConnoteDTO(ConnoteDTO connoteDTO) {
// this.connoteDTO = connoteDTO;
// }
//
// public CustomerDTO getCustomerDTO() {
// return customerDTO;
// }
//
// public void setCustomerDTO(CustomerDTO customerDTO) {
// this.customerDTO = customerDTO;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
// }
| import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Span;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import de.codecentric.resilient.booking.service.BookingService;
import de.codecentric.resilient.dto.BookingServiceRequestDTO;
import de.codecentric.resilient.dto.BookingServiceResponseDTO; | package de.codecentric.resilient.booking.rest;
/**
* @author Benjamin Wilms
*/
@RestController
@RequestMapping("rest/booking")
public class BookingController {
private static final Logger LOGGER = LoggerFactory.getLogger(BookingController.class);
private final BookingService bookingService;
private final Tracer tracer;
@Autowired
public BookingController(BookingService bookingService, Tracer tracer) {
this.bookingService = bookingService;
this.tracer = tracer;
}
@RequestMapping(value = "create", method = RequestMethod.POST)
@ResponseBody | // Path: booking-service/src/main/java/de/codecentric/resilient/booking/service/BookingService.java
// @Service
// public class BookingService {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(BookingService.class);
//
// private final BookingRepository bookingRepository;
//
// private final BookingMapper bookingMapper;
//
// private final RestTemplate restTemplate;
//
// private DynamicBooleanProperty secondServiceCallEnabled =
// DynamicPropertyFactory.getInstance().getBooleanProperty("second.service.call", false);
//
// @Autowired
// public BookingService(BookingRepository bookingRepository, BookingMapper bookingMapper, RestTemplate restTemplate) {
// this.bookingRepository = bookingRepository;
// this.bookingMapper = bookingMapper;
// this.restTemplate = restTemplate;
// }
//
// public BookingServiceResponseDTO createBooking(BookingServiceRequestDTO bookingRequestDTO) {
//
// BookingServiceResponseDTO bookingResponseDTO = new BookingServiceResponseDTO();
//
// // 1.) Create connote
// ConnoteDTO connoteDTO = receiveConnote();
//
// if (connoteDTO.isFallback()) {
// bookingResponseDTO.setErrorMsg("Connote error: " + connoteDTO.getErrorMsg());
// bookingResponseDTO.setStatus("ERROR");
// return bookingResponseDTO;
// }
//
// // 2. Save booking request
//
// Booking booking = bookingMapper.mapToBookingEntity(bookingRequestDTO, connoteDTO.getConnote());
// bookingRepository.save(booking);
//
// CustomerResponseDTO customerDTO = bookingRequestDTO.getCustomerDTO();
// bookingResponseDTO.setCustomerDTO(new CustomerDTO(customerDTO.getCustomerId(), customerDTO.getCustomerName()));
// bookingResponseDTO.setConnoteDTO(connoteDTO);
// bookingResponseDTO.setStatus("OK");
//
// return bookingResponseDTO;
//
// }
//
// private ConnoteDTO receiveConnote() {
// LOGGER.debug("Starting getConnote");
//
// return new ConnoteCommand(restTemplate, secondServiceCallEnabled.get()).execute();
// }
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/BookingServiceRequestDTO.java
// public class BookingServiceRequestDTO {
//
// private CustomerResponseDTO customerDTO;
//
// private AddressResponseDTO senderAddress;
//
// private AddressResponseDTO receiverAddress;
//
// public CustomerResponseDTO getCustomerDTO() {
// return customerDTO;
// }
//
// public void setCustomerDTO(CustomerResponseDTO customerDTO) {
// this.customerDTO = customerDTO;
// }
//
// public AddressResponseDTO getSenderAddress() {
// return senderAddress;
// }
//
// public void setSenderAddress(AddressResponseDTO senderAddress) {
// this.senderAddress = senderAddress;
// }
//
// public AddressResponseDTO getReceiverAddress() {
// return receiverAddress;
// }
//
// public void setReceiverAddress(AddressResponseDTO receiverAddress) {
// this.receiverAddress = receiverAddress;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder("BookingServiceRequestDTO{");
// sb.append("customerDTO=").append(customerDTO);
// sb.append(", senderAddress=").append(senderAddress);
// sb.append(", receiverAddress=").append(receiverAddress);
// sb.append('}');
// return sb.toString();
// }
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/BookingServiceResponseDTO.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class BookingServiceResponseDTO extends FallbackAbstractDTO {
//
// @JsonProperty(required = true)
// private ConnoteDTO connoteDTO;
//
// @JsonProperty(required = true)
// private String status;
//
// @JsonProperty(required = true)
// private CustomerDTO customerDTO;
//
// @JsonProperty(required = true, value = "service-response-status")
// private List<ServiceResponseStatus> serviceResponseStatusList;
//
// public List<ServiceResponseStatus> getServiceResponseStatusList() {
// return serviceResponseStatusList;
// }
//
// public void setServiceResponseStatusList(List<ServiceResponseStatus> serviceResponseStatusList) {
// this.serviceResponseStatusList = serviceResponseStatusList;
// }
//
// public ConnoteDTO getConnoteDTO() {
// return connoteDTO;
// }
//
// public void setConnoteDTO(ConnoteDTO connoteDTO) {
// this.connoteDTO = connoteDTO;
// }
//
// public CustomerDTO getCustomerDTO() {
// return customerDTO;
// }
//
// public void setCustomerDTO(CustomerDTO customerDTO) {
// this.customerDTO = customerDTO;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
// }
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/rest/BookingController.java
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Span;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import de.codecentric.resilient.booking.service.BookingService;
import de.codecentric.resilient.dto.BookingServiceRequestDTO;
import de.codecentric.resilient.dto.BookingServiceResponseDTO;
package de.codecentric.resilient.booking.rest;
/**
* @author Benjamin Wilms
*/
@RestController
@RequestMapping("rest/booking")
public class BookingController {
private static final Logger LOGGER = LoggerFactory.getLogger(BookingController.class);
private final BookingService bookingService;
private final Tracer tracer;
@Autowired
public BookingController(BookingService bookingService, Tracer tracer) {
this.bookingService = bookingService;
this.tracer = tracer;
}
@RequestMapping(value = "create", method = RequestMethod.POST)
@ResponseBody | public ResponseEntity<BookingServiceResponseDTO> create(@RequestBody BookingServiceRequestDTO bookingRequestDTO, |
MrBW/resilient-transport-service | transport-api-gateway/src/main/java/de/codecentric/resilient/transport/api/gateway/commands/AddressCommand.java | // Path: service-library/src/main/java/de/codecentric/resilient/dto/AddressDTO.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class AddressDTO {
//
// @JsonProperty(required = true)
// private String country;
//
// @JsonProperty(required = true)
// private String city;
//
// @JsonProperty(required = true)
// private String postcode;
//
// @JsonProperty(required = true)
// private String street;
//
// @JsonProperty(required = true)
// private String streetNumber;
//
// public AddressDTO() {
// }
//
// public AddressDTO(String country, String city, String postcode, String street, String streetNumber) {
// this.country = country;
// this.city = city;
// this.postcode = postcode;
// this.street = street;
// this.streetNumber = streetNumber;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder("AddressDTO{");
// sb.append("country='").append(country).append('\'');
// sb.append(", city='").append(city).append('\'');
// sb.append(", postcode='").append(postcode).append('\'');
// sb.append(", street='").append(street).append('\'');
// sb.append(", streetNumber='").append(streetNumber).append('\'');
// sb.append('}');
// return sb.toString();
// }
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/AddressResponseDTO.java
// public class AddressResponseDTO extends FallbackAbstractDTO {
//
// @JsonProperty(required = true)
// private String country;
//
// @JsonProperty(required = true)
// private String city;
//
// @JsonProperty(required = true)
// private String postcode;
//
// @JsonProperty(required = true)
// private String street;
//
// @JsonProperty(required = true)
// private String streetNumber;
//
// public AddressResponseDTO() {
// }
//
// public AddressResponseDTO(String country, String city, String postcode, String street, String streetNumber) {
// this.country = country;
// this.city = city;
// this.postcode = postcode;
// this.street = street;
// this.streetNumber = streetNumber;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder("AddressDTO{");
// sb.append("country='").append(country).append('\'');
// sb.append(", city='").append(city).append('\'');
// sb.append(", postcode='").append(postcode).append('\'');
// sb.append(", street='").append(street).append('\'');
// sb.append(", streetNumber='").append(streetNumber).append('\'');
// sb.append('}');
// return sb.toString();
// }
// }
| import com.netflix.hystrix.exception.HystrixRuntimeException;
import com.netflix.hystrix.exception.HystrixTimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.client.RestTemplate;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandKey;
import de.codecentric.resilient.dto.AddressDTO;
import de.codecentric.resilient.dto.AddressResponseDTO; | package de.codecentric.resilient.transport.api.gateway.commands;
/**
* @author Benjamin Wilms (xd98870)
*/
public class AddressCommand extends HystrixCommand<AddressResponseDTO> {
private static final Logger LOGGER = LoggerFactory.getLogger(AddressCommand.class);
| // Path: service-library/src/main/java/de/codecentric/resilient/dto/AddressDTO.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class AddressDTO {
//
// @JsonProperty(required = true)
// private String country;
//
// @JsonProperty(required = true)
// private String city;
//
// @JsonProperty(required = true)
// private String postcode;
//
// @JsonProperty(required = true)
// private String street;
//
// @JsonProperty(required = true)
// private String streetNumber;
//
// public AddressDTO() {
// }
//
// public AddressDTO(String country, String city, String postcode, String street, String streetNumber) {
// this.country = country;
// this.city = city;
// this.postcode = postcode;
// this.street = street;
// this.streetNumber = streetNumber;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder("AddressDTO{");
// sb.append("country='").append(country).append('\'');
// sb.append(", city='").append(city).append('\'');
// sb.append(", postcode='").append(postcode).append('\'');
// sb.append(", street='").append(street).append('\'');
// sb.append(", streetNumber='").append(streetNumber).append('\'');
// sb.append('}');
// return sb.toString();
// }
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/AddressResponseDTO.java
// public class AddressResponseDTO extends FallbackAbstractDTO {
//
// @JsonProperty(required = true)
// private String country;
//
// @JsonProperty(required = true)
// private String city;
//
// @JsonProperty(required = true)
// private String postcode;
//
// @JsonProperty(required = true)
// private String street;
//
// @JsonProperty(required = true)
// private String streetNumber;
//
// public AddressResponseDTO() {
// }
//
// public AddressResponseDTO(String country, String city, String postcode, String street, String streetNumber) {
// this.country = country;
// this.city = city;
// this.postcode = postcode;
// this.street = street;
// this.streetNumber = streetNumber;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder("AddressDTO{");
// sb.append("country='").append(country).append('\'');
// sb.append(", city='").append(city).append('\'');
// sb.append(", postcode='").append(postcode).append('\'');
// sb.append(", street='").append(street).append('\'');
// sb.append(", streetNumber='").append(streetNumber).append('\'');
// sb.append('}');
// return sb.toString();
// }
// }
// Path: transport-api-gateway/src/main/java/de/codecentric/resilient/transport/api/gateway/commands/AddressCommand.java
import com.netflix.hystrix.exception.HystrixRuntimeException;
import com.netflix.hystrix.exception.HystrixTimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.client.RestTemplate;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandKey;
import de.codecentric.resilient.dto.AddressDTO;
import de.codecentric.resilient.dto.AddressResponseDTO;
package de.codecentric.resilient.transport.api.gateway.commands;
/**
* @author Benjamin Wilms (xd98870)
*/
public class AddressCommand extends HystrixCommand<AddressResponseDTO> {
private static final Logger LOGGER = LoggerFactory.getLogger(AddressCommand.class);
| private final AddressDTO addressDTO; |
MrBW/resilient-transport-service | customer-service/src/main/java/de/codecentric/resilient/customer/CustomerServiceApplication.java | // Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java
// @Entity
// public class Customer {
//
// @Id
// @GeneratedValue
// private Long id;
//
// private String name;
//
// public Customer(String name) {
// this.name = name;
// }
//
// public Customer() {
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/repository/CustomerRepository.java
// public interface CustomerRepository extends CrudRepository<Customer, Long> {
// Customer findByName(String name);
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java
// @Configuration
// public class DefautConfiguration {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class);
//
// @RefreshScope
// @Bean
// public AbstractConfiguration archaiusConfiguration() throws Exception {
//
// LOGGER.info("Enable Archaius Configuration");
// ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration();
//
// return concurrentMapConfiguration;
// }
//
// @LoadBalanced
// @Bean
// RestTemplate restTemplate() {
// return new RestTemplate();
// }
//
// }
| import de.codecentric.resilient.customer.entity.Customer;
import de.codecentric.resilient.customer.repository.CustomerRepository;
import de.mrbw.chaos.monkey.EnableChaosMonkey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.sleuth.Sampler;
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters;
import de.codecentric.resilient.configuration.DefautConfiguration; | package de.codecentric.resilient.customer;
/**
* @author Benjamin Wilms
*/
@EnableChaosMonkey
@EnableAutoConfiguration
@RefreshScope
@EnableDiscoveryClient
@SpringBootApplication | // Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java
// @Entity
// public class Customer {
//
// @Id
// @GeneratedValue
// private Long id;
//
// private String name;
//
// public Customer(String name) {
// this.name = name;
// }
//
// public Customer() {
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/repository/CustomerRepository.java
// public interface CustomerRepository extends CrudRepository<Customer, Long> {
// Customer findByName(String name);
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java
// @Configuration
// public class DefautConfiguration {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class);
//
// @RefreshScope
// @Bean
// public AbstractConfiguration archaiusConfiguration() throws Exception {
//
// LOGGER.info("Enable Archaius Configuration");
// ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration();
//
// return concurrentMapConfiguration;
// }
//
// @LoadBalanced
// @Bean
// RestTemplate restTemplate() {
// return new RestTemplate();
// }
//
// }
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/CustomerServiceApplication.java
import de.codecentric.resilient.customer.entity.Customer;
import de.codecentric.resilient.customer.repository.CustomerRepository;
import de.mrbw.chaos.monkey.EnableChaosMonkey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.sleuth.Sampler;
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters;
import de.codecentric.resilient.configuration.DefautConfiguration;
package de.codecentric.resilient.customer;
/**
* @author Benjamin Wilms
*/
@EnableChaosMonkey
@EnableAutoConfiguration
@RefreshScope
@EnableDiscoveryClient
@SpringBootApplication | @Import(DefautConfiguration.class) |
MrBW/resilient-transport-service | customer-service/src/main/java/de/codecentric/resilient/customer/CustomerServiceApplication.java | // Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java
// @Entity
// public class Customer {
//
// @Id
// @GeneratedValue
// private Long id;
//
// private String name;
//
// public Customer(String name) {
// this.name = name;
// }
//
// public Customer() {
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/repository/CustomerRepository.java
// public interface CustomerRepository extends CrudRepository<Customer, Long> {
// Customer findByName(String name);
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java
// @Configuration
// public class DefautConfiguration {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class);
//
// @RefreshScope
// @Bean
// public AbstractConfiguration archaiusConfiguration() throws Exception {
//
// LOGGER.info("Enable Archaius Configuration");
// ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration();
//
// return concurrentMapConfiguration;
// }
//
// @LoadBalanced
// @Bean
// RestTemplate restTemplate() {
// return new RestTemplate();
// }
//
// }
| import de.codecentric.resilient.customer.entity.Customer;
import de.codecentric.resilient.customer.repository.CustomerRepository;
import de.mrbw.chaos.monkey.EnableChaosMonkey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.sleuth.Sampler;
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters;
import de.codecentric.resilient.configuration.DefautConfiguration; | package de.codecentric.resilient.customer;
/**
* @author Benjamin Wilms
*/
@EnableChaosMonkey
@EnableAutoConfiguration
@RefreshScope
@EnableDiscoveryClient
@SpringBootApplication
@Import(DefautConfiguration.class)
@EntityScan(basePackageClasses = {CustomerServiceApplication.class, Jsr310JpaConverters.class})
public class CustomerServiceApplication {
@Bean
public Sampler sampler(){
return new AlwaysSampler();
}
private static final Logger log = LoggerFactory.getLogger(CustomerServiceApplication.class);
public static void main(String[] args) {
SpringApplication.run(CustomerServiceApplication.class, args);
}
@Bean | // Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java
// @Entity
// public class Customer {
//
// @Id
// @GeneratedValue
// private Long id;
//
// private String name;
//
// public Customer(String name) {
// this.name = name;
// }
//
// public Customer() {
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/repository/CustomerRepository.java
// public interface CustomerRepository extends CrudRepository<Customer, Long> {
// Customer findByName(String name);
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java
// @Configuration
// public class DefautConfiguration {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class);
//
// @RefreshScope
// @Bean
// public AbstractConfiguration archaiusConfiguration() throws Exception {
//
// LOGGER.info("Enable Archaius Configuration");
// ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration();
//
// return concurrentMapConfiguration;
// }
//
// @LoadBalanced
// @Bean
// RestTemplate restTemplate() {
// return new RestTemplate();
// }
//
// }
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/CustomerServiceApplication.java
import de.codecentric.resilient.customer.entity.Customer;
import de.codecentric.resilient.customer.repository.CustomerRepository;
import de.mrbw.chaos.monkey.EnableChaosMonkey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.sleuth.Sampler;
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters;
import de.codecentric.resilient.configuration.DefautConfiguration;
package de.codecentric.resilient.customer;
/**
* @author Benjamin Wilms
*/
@EnableChaosMonkey
@EnableAutoConfiguration
@RefreshScope
@EnableDiscoveryClient
@SpringBootApplication
@Import(DefautConfiguration.class)
@EntityScan(basePackageClasses = {CustomerServiceApplication.class, Jsr310JpaConverters.class})
public class CustomerServiceApplication {
@Bean
public Sampler sampler(){
return new AlwaysSampler();
}
private static final Logger log = LoggerFactory.getLogger(CustomerServiceApplication.class);
public static void main(String[] args) {
SpringApplication.run(CustomerServiceApplication.class, args);
}
@Bean | public CommandLineRunner demo(CustomerRepository repository) { |
MrBW/resilient-transport-service | customer-service/src/main/java/de/codecentric/resilient/customer/CustomerServiceApplication.java | // Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java
// @Entity
// public class Customer {
//
// @Id
// @GeneratedValue
// private Long id;
//
// private String name;
//
// public Customer(String name) {
// this.name = name;
// }
//
// public Customer() {
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/repository/CustomerRepository.java
// public interface CustomerRepository extends CrudRepository<Customer, Long> {
// Customer findByName(String name);
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java
// @Configuration
// public class DefautConfiguration {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class);
//
// @RefreshScope
// @Bean
// public AbstractConfiguration archaiusConfiguration() throws Exception {
//
// LOGGER.info("Enable Archaius Configuration");
// ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration();
//
// return concurrentMapConfiguration;
// }
//
// @LoadBalanced
// @Bean
// RestTemplate restTemplate() {
// return new RestTemplate();
// }
//
// }
| import de.codecentric.resilient.customer.entity.Customer;
import de.codecentric.resilient.customer.repository.CustomerRepository;
import de.mrbw.chaos.monkey.EnableChaosMonkey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.sleuth.Sampler;
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters;
import de.codecentric.resilient.configuration.DefautConfiguration; | package de.codecentric.resilient.customer;
/**
* @author Benjamin Wilms
*/
@EnableChaosMonkey
@EnableAutoConfiguration
@RefreshScope
@EnableDiscoveryClient
@SpringBootApplication
@Import(DefautConfiguration.class)
@EntityScan(basePackageClasses = {CustomerServiceApplication.class, Jsr310JpaConverters.class})
public class CustomerServiceApplication {
@Bean
public Sampler sampler(){
return new AlwaysSampler();
}
private static final Logger log = LoggerFactory.getLogger(CustomerServiceApplication.class);
public static void main(String[] args) {
SpringApplication.run(CustomerServiceApplication.class, args);
}
@Bean
public CommandLineRunner demo(CustomerRepository repository) {
return (args) -> { | // Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java
// @Entity
// public class Customer {
//
// @Id
// @GeneratedValue
// private Long id;
//
// private String name;
//
// public Customer(String name) {
// this.name = name;
// }
//
// public Customer() {
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/repository/CustomerRepository.java
// public interface CustomerRepository extends CrudRepository<Customer, Long> {
// Customer findByName(String name);
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java
// @Configuration
// public class DefautConfiguration {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class);
//
// @RefreshScope
// @Bean
// public AbstractConfiguration archaiusConfiguration() throws Exception {
//
// LOGGER.info("Enable Archaius Configuration");
// ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration();
//
// return concurrentMapConfiguration;
// }
//
// @LoadBalanced
// @Bean
// RestTemplate restTemplate() {
// return new RestTemplate();
// }
//
// }
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/CustomerServiceApplication.java
import de.codecentric.resilient.customer.entity.Customer;
import de.codecentric.resilient.customer.repository.CustomerRepository;
import de.mrbw.chaos.monkey.EnableChaosMonkey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.sleuth.Sampler;
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters;
import de.codecentric.resilient.configuration.DefautConfiguration;
package de.codecentric.resilient.customer;
/**
* @author Benjamin Wilms
*/
@EnableChaosMonkey
@EnableAutoConfiguration
@RefreshScope
@EnableDiscoveryClient
@SpringBootApplication
@Import(DefautConfiguration.class)
@EntityScan(basePackageClasses = {CustomerServiceApplication.class, Jsr310JpaConverters.class})
public class CustomerServiceApplication {
@Bean
public Sampler sampler(){
return new AlwaysSampler();
}
private static final Logger log = LoggerFactory.getLogger(CustomerServiceApplication.class);
public static void main(String[] args) {
SpringApplication.run(CustomerServiceApplication.class, args);
}
@Bean
public CommandLineRunner demo(CustomerRepository repository) {
return (args) -> { | repository.save(new Customer("Meier")); |
MrBW/resilient-transport-service | booking-service/src/test/java/de/codecentric/resilient/booking/repository/BookingRepositoryTest.java | // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Address.java
// @Embeddable
// public class Address {
//
// @Basic
// private String country;
//
// @Basic
// private String city;
//
// @Basic
// private String postcode;
//
// @Basic
// private String street;
//
// @Basic
// private String streetNumber;
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
// }
//
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Booking.java
// @Entity
// public class Booking {
//
// @Id
// @GeneratedValue
// private Long id;
//
// @Embedded
// private Customer customer;
//
// private Long connote;
//
// @Column(name = "created", nullable = false)
// private LocalDateTime created = LocalDateTime.now();
//
// @Embedded
// @AttributeOverrides({
// @AttributeOverride(name="street",column=@Column(name="receiverStreet")),
// @AttributeOverride(name="city",column=@Column(name="receiverCity")),
// @AttributeOverride(name="postcode",column=@Column(name="receiverPostcode")),
// @AttributeOverride(name="country",column=@Column(name="receiverCountry")),
// @AttributeOverride(name="streetNumber",column=@Column(name="receiverStreeNumber"))
// })
// private Address receiverAddress;
//
// @Embedded
// @AttributeOverrides({
// @AttributeOverride(name="street",column=@Column(name="senderStreet")),
// @AttributeOverride(name="city",column=@Column(name="senderCity")),
// @AttributeOverride(name="postcode",column=@Column(name="senderPostcode")),
// @AttributeOverride(name="country",column=@Column(name="senderCountry")),
// @AttributeOverride(name="streetNumber",column=@Column(name="senderStreeNumber"))
// })
// private Address senderAddress;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Customer getCustomer() {
// return customer;
// }
//
// public void setCustomer(Customer customer) {
// this.customer = customer;
// }
//
// public Long getConnote() {
// return connote;
// }
//
// public void setConnote(Long connote) {
// this.connote = connote;
// }
//
// public LocalDateTime getCreated() {
// return created;
// }
//
// public Address getReceiverAddress() {
// return receiverAddress;
// }
//
// public void setReceiverAddress(Address receiverAddress) {
// this.receiverAddress = receiverAddress;
// }
//
// public Address getSenderAddress() {
// return senderAddress;
// }
//
// public void setSenderAddress(Address senderAddress) {
// this.senderAddress = senderAddress;
// }
// }
//
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Customer.java
// @Embeddable
// public class Customer {
//
// private Long customerId;
//
// private String customerName;
//
// public Long getCustomerId() {
// return customerId;
// }
//
// public void setCustomerId(Long customerId) {
// this.customerId = customerId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public void setCustomerName(String customerName) {
// this.customerName = customerName;
// }
// }
| import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import de.codecentric.resilient.booking.entity.Address;
import de.codecentric.resilient.booking.entity.Booking;
import de.codecentric.resilient.booking.entity.Customer;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; | package de.codecentric.resilient.booking.repository;
/**
* @author Benjamin Wilms (xd98870)
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,properties = {"spring.cloud.config.discovery.enabled=false","spring.cloud.config.enabled=false"})
public class BookingRepositoryTest {
@Autowired
private BookingRepository bookingRepository;
@Test
public void checkSaveBooking() throws Exception { | // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Address.java
// @Embeddable
// public class Address {
//
// @Basic
// private String country;
//
// @Basic
// private String city;
//
// @Basic
// private String postcode;
//
// @Basic
// private String street;
//
// @Basic
// private String streetNumber;
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
// }
//
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Booking.java
// @Entity
// public class Booking {
//
// @Id
// @GeneratedValue
// private Long id;
//
// @Embedded
// private Customer customer;
//
// private Long connote;
//
// @Column(name = "created", nullable = false)
// private LocalDateTime created = LocalDateTime.now();
//
// @Embedded
// @AttributeOverrides({
// @AttributeOverride(name="street",column=@Column(name="receiverStreet")),
// @AttributeOverride(name="city",column=@Column(name="receiverCity")),
// @AttributeOverride(name="postcode",column=@Column(name="receiverPostcode")),
// @AttributeOverride(name="country",column=@Column(name="receiverCountry")),
// @AttributeOverride(name="streetNumber",column=@Column(name="receiverStreeNumber"))
// })
// private Address receiverAddress;
//
// @Embedded
// @AttributeOverrides({
// @AttributeOverride(name="street",column=@Column(name="senderStreet")),
// @AttributeOverride(name="city",column=@Column(name="senderCity")),
// @AttributeOverride(name="postcode",column=@Column(name="senderPostcode")),
// @AttributeOverride(name="country",column=@Column(name="senderCountry")),
// @AttributeOverride(name="streetNumber",column=@Column(name="senderStreeNumber"))
// })
// private Address senderAddress;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Customer getCustomer() {
// return customer;
// }
//
// public void setCustomer(Customer customer) {
// this.customer = customer;
// }
//
// public Long getConnote() {
// return connote;
// }
//
// public void setConnote(Long connote) {
// this.connote = connote;
// }
//
// public LocalDateTime getCreated() {
// return created;
// }
//
// public Address getReceiverAddress() {
// return receiverAddress;
// }
//
// public void setReceiverAddress(Address receiverAddress) {
// this.receiverAddress = receiverAddress;
// }
//
// public Address getSenderAddress() {
// return senderAddress;
// }
//
// public void setSenderAddress(Address senderAddress) {
// this.senderAddress = senderAddress;
// }
// }
//
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Customer.java
// @Embeddable
// public class Customer {
//
// private Long customerId;
//
// private String customerName;
//
// public Long getCustomerId() {
// return customerId;
// }
//
// public void setCustomerId(Long customerId) {
// this.customerId = customerId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public void setCustomerName(String customerName) {
// this.customerName = customerName;
// }
// }
// Path: booking-service/src/test/java/de/codecentric/resilient/booking/repository/BookingRepositoryTest.java
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import de.codecentric.resilient.booking.entity.Address;
import de.codecentric.resilient.booking.entity.Booking;
import de.codecentric.resilient.booking.entity.Customer;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
package de.codecentric.resilient.booking.repository;
/**
* @author Benjamin Wilms (xd98870)
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,properties = {"spring.cloud.config.discovery.enabled=false","spring.cloud.config.enabled=false"})
public class BookingRepositoryTest {
@Autowired
private BookingRepository bookingRepository;
@Test
public void checkSaveBooking() throws Exception { | Customer customer = new Customer(); |
MrBW/resilient-transport-service | booking-service/src/test/java/de/codecentric/resilient/booking/repository/BookingRepositoryTest.java | // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Address.java
// @Embeddable
// public class Address {
//
// @Basic
// private String country;
//
// @Basic
// private String city;
//
// @Basic
// private String postcode;
//
// @Basic
// private String street;
//
// @Basic
// private String streetNumber;
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
// }
//
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Booking.java
// @Entity
// public class Booking {
//
// @Id
// @GeneratedValue
// private Long id;
//
// @Embedded
// private Customer customer;
//
// private Long connote;
//
// @Column(name = "created", nullable = false)
// private LocalDateTime created = LocalDateTime.now();
//
// @Embedded
// @AttributeOverrides({
// @AttributeOverride(name="street",column=@Column(name="receiverStreet")),
// @AttributeOverride(name="city",column=@Column(name="receiverCity")),
// @AttributeOverride(name="postcode",column=@Column(name="receiverPostcode")),
// @AttributeOverride(name="country",column=@Column(name="receiverCountry")),
// @AttributeOverride(name="streetNumber",column=@Column(name="receiverStreeNumber"))
// })
// private Address receiverAddress;
//
// @Embedded
// @AttributeOverrides({
// @AttributeOverride(name="street",column=@Column(name="senderStreet")),
// @AttributeOverride(name="city",column=@Column(name="senderCity")),
// @AttributeOverride(name="postcode",column=@Column(name="senderPostcode")),
// @AttributeOverride(name="country",column=@Column(name="senderCountry")),
// @AttributeOverride(name="streetNumber",column=@Column(name="senderStreeNumber"))
// })
// private Address senderAddress;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Customer getCustomer() {
// return customer;
// }
//
// public void setCustomer(Customer customer) {
// this.customer = customer;
// }
//
// public Long getConnote() {
// return connote;
// }
//
// public void setConnote(Long connote) {
// this.connote = connote;
// }
//
// public LocalDateTime getCreated() {
// return created;
// }
//
// public Address getReceiverAddress() {
// return receiverAddress;
// }
//
// public void setReceiverAddress(Address receiverAddress) {
// this.receiverAddress = receiverAddress;
// }
//
// public Address getSenderAddress() {
// return senderAddress;
// }
//
// public void setSenderAddress(Address senderAddress) {
// this.senderAddress = senderAddress;
// }
// }
//
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Customer.java
// @Embeddable
// public class Customer {
//
// private Long customerId;
//
// private String customerName;
//
// public Long getCustomerId() {
// return customerId;
// }
//
// public void setCustomerId(Long customerId) {
// this.customerId = customerId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public void setCustomerName(String customerName) {
// this.customerName = customerName;
// }
// }
| import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import de.codecentric.resilient.booking.entity.Address;
import de.codecentric.resilient.booking.entity.Booking;
import de.codecentric.resilient.booking.entity.Customer;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; | package de.codecentric.resilient.booking.repository;
/**
* @author Benjamin Wilms (xd98870)
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,properties = {"spring.cloud.config.discovery.enabled=false","spring.cloud.config.enabled=false"})
public class BookingRepositoryTest {
@Autowired
private BookingRepository bookingRepository;
@Test
public void checkSaveBooking() throws Exception {
Customer customer = new Customer();
customer.setCustomerId(1L);
customer.setCustomerName("Meier");
| // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Address.java
// @Embeddable
// public class Address {
//
// @Basic
// private String country;
//
// @Basic
// private String city;
//
// @Basic
// private String postcode;
//
// @Basic
// private String street;
//
// @Basic
// private String streetNumber;
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
// }
//
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Booking.java
// @Entity
// public class Booking {
//
// @Id
// @GeneratedValue
// private Long id;
//
// @Embedded
// private Customer customer;
//
// private Long connote;
//
// @Column(name = "created", nullable = false)
// private LocalDateTime created = LocalDateTime.now();
//
// @Embedded
// @AttributeOverrides({
// @AttributeOverride(name="street",column=@Column(name="receiverStreet")),
// @AttributeOverride(name="city",column=@Column(name="receiverCity")),
// @AttributeOverride(name="postcode",column=@Column(name="receiverPostcode")),
// @AttributeOverride(name="country",column=@Column(name="receiverCountry")),
// @AttributeOverride(name="streetNumber",column=@Column(name="receiverStreeNumber"))
// })
// private Address receiverAddress;
//
// @Embedded
// @AttributeOverrides({
// @AttributeOverride(name="street",column=@Column(name="senderStreet")),
// @AttributeOverride(name="city",column=@Column(name="senderCity")),
// @AttributeOverride(name="postcode",column=@Column(name="senderPostcode")),
// @AttributeOverride(name="country",column=@Column(name="senderCountry")),
// @AttributeOverride(name="streetNumber",column=@Column(name="senderStreeNumber"))
// })
// private Address senderAddress;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Customer getCustomer() {
// return customer;
// }
//
// public void setCustomer(Customer customer) {
// this.customer = customer;
// }
//
// public Long getConnote() {
// return connote;
// }
//
// public void setConnote(Long connote) {
// this.connote = connote;
// }
//
// public LocalDateTime getCreated() {
// return created;
// }
//
// public Address getReceiverAddress() {
// return receiverAddress;
// }
//
// public void setReceiverAddress(Address receiverAddress) {
// this.receiverAddress = receiverAddress;
// }
//
// public Address getSenderAddress() {
// return senderAddress;
// }
//
// public void setSenderAddress(Address senderAddress) {
// this.senderAddress = senderAddress;
// }
// }
//
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Customer.java
// @Embeddable
// public class Customer {
//
// private Long customerId;
//
// private String customerName;
//
// public Long getCustomerId() {
// return customerId;
// }
//
// public void setCustomerId(Long customerId) {
// this.customerId = customerId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public void setCustomerName(String customerName) {
// this.customerName = customerName;
// }
// }
// Path: booking-service/src/test/java/de/codecentric/resilient/booking/repository/BookingRepositoryTest.java
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import de.codecentric.resilient.booking.entity.Address;
import de.codecentric.resilient.booking.entity.Booking;
import de.codecentric.resilient.booking.entity.Customer;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
package de.codecentric.resilient.booking.repository;
/**
* @author Benjamin Wilms (xd98870)
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,properties = {"spring.cloud.config.discovery.enabled=false","spring.cloud.config.enabled=false"})
public class BookingRepositoryTest {
@Autowired
private BookingRepository bookingRepository;
@Test
public void checkSaveBooking() throws Exception {
Customer customer = new Customer();
customer.setCustomerId(1L);
customer.setCustomerName("Meier");
| Address senderAddress = createAddress(); |
MrBW/resilient-transport-service | booking-service/src/test/java/de/codecentric/resilient/booking/repository/BookingRepositoryTest.java | // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Address.java
// @Embeddable
// public class Address {
//
// @Basic
// private String country;
//
// @Basic
// private String city;
//
// @Basic
// private String postcode;
//
// @Basic
// private String street;
//
// @Basic
// private String streetNumber;
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
// }
//
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Booking.java
// @Entity
// public class Booking {
//
// @Id
// @GeneratedValue
// private Long id;
//
// @Embedded
// private Customer customer;
//
// private Long connote;
//
// @Column(name = "created", nullable = false)
// private LocalDateTime created = LocalDateTime.now();
//
// @Embedded
// @AttributeOverrides({
// @AttributeOverride(name="street",column=@Column(name="receiverStreet")),
// @AttributeOverride(name="city",column=@Column(name="receiverCity")),
// @AttributeOverride(name="postcode",column=@Column(name="receiverPostcode")),
// @AttributeOverride(name="country",column=@Column(name="receiverCountry")),
// @AttributeOverride(name="streetNumber",column=@Column(name="receiverStreeNumber"))
// })
// private Address receiverAddress;
//
// @Embedded
// @AttributeOverrides({
// @AttributeOverride(name="street",column=@Column(name="senderStreet")),
// @AttributeOverride(name="city",column=@Column(name="senderCity")),
// @AttributeOverride(name="postcode",column=@Column(name="senderPostcode")),
// @AttributeOverride(name="country",column=@Column(name="senderCountry")),
// @AttributeOverride(name="streetNumber",column=@Column(name="senderStreeNumber"))
// })
// private Address senderAddress;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Customer getCustomer() {
// return customer;
// }
//
// public void setCustomer(Customer customer) {
// this.customer = customer;
// }
//
// public Long getConnote() {
// return connote;
// }
//
// public void setConnote(Long connote) {
// this.connote = connote;
// }
//
// public LocalDateTime getCreated() {
// return created;
// }
//
// public Address getReceiverAddress() {
// return receiverAddress;
// }
//
// public void setReceiverAddress(Address receiverAddress) {
// this.receiverAddress = receiverAddress;
// }
//
// public Address getSenderAddress() {
// return senderAddress;
// }
//
// public void setSenderAddress(Address senderAddress) {
// this.senderAddress = senderAddress;
// }
// }
//
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Customer.java
// @Embeddable
// public class Customer {
//
// private Long customerId;
//
// private String customerName;
//
// public Long getCustomerId() {
// return customerId;
// }
//
// public void setCustomerId(Long customerId) {
// this.customerId = customerId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public void setCustomerName(String customerName) {
// this.customerName = customerName;
// }
// }
| import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import de.codecentric.resilient.booking.entity.Address;
import de.codecentric.resilient.booking.entity.Booking;
import de.codecentric.resilient.booking.entity.Customer;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; | package de.codecentric.resilient.booking.repository;
/**
* @author Benjamin Wilms (xd98870)
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,properties = {"spring.cloud.config.discovery.enabled=false","spring.cloud.config.enabled=false"})
public class BookingRepositoryTest {
@Autowired
private BookingRepository bookingRepository;
@Test
public void checkSaveBooking() throws Exception {
Customer customer = new Customer();
customer.setCustomerId(1L);
customer.setCustomerName("Meier");
Address senderAddress = createAddress();
Address receiverAddress = createAddress();
| // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Address.java
// @Embeddable
// public class Address {
//
// @Basic
// private String country;
//
// @Basic
// private String city;
//
// @Basic
// private String postcode;
//
// @Basic
// private String street;
//
// @Basic
// private String streetNumber;
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
// }
//
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Booking.java
// @Entity
// public class Booking {
//
// @Id
// @GeneratedValue
// private Long id;
//
// @Embedded
// private Customer customer;
//
// private Long connote;
//
// @Column(name = "created", nullable = false)
// private LocalDateTime created = LocalDateTime.now();
//
// @Embedded
// @AttributeOverrides({
// @AttributeOverride(name="street",column=@Column(name="receiverStreet")),
// @AttributeOverride(name="city",column=@Column(name="receiverCity")),
// @AttributeOverride(name="postcode",column=@Column(name="receiverPostcode")),
// @AttributeOverride(name="country",column=@Column(name="receiverCountry")),
// @AttributeOverride(name="streetNumber",column=@Column(name="receiverStreeNumber"))
// })
// private Address receiverAddress;
//
// @Embedded
// @AttributeOverrides({
// @AttributeOverride(name="street",column=@Column(name="senderStreet")),
// @AttributeOverride(name="city",column=@Column(name="senderCity")),
// @AttributeOverride(name="postcode",column=@Column(name="senderPostcode")),
// @AttributeOverride(name="country",column=@Column(name="senderCountry")),
// @AttributeOverride(name="streetNumber",column=@Column(name="senderStreeNumber"))
// })
// private Address senderAddress;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Customer getCustomer() {
// return customer;
// }
//
// public void setCustomer(Customer customer) {
// this.customer = customer;
// }
//
// public Long getConnote() {
// return connote;
// }
//
// public void setConnote(Long connote) {
// this.connote = connote;
// }
//
// public LocalDateTime getCreated() {
// return created;
// }
//
// public Address getReceiverAddress() {
// return receiverAddress;
// }
//
// public void setReceiverAddress(Address receiverAddress) {
// this.receiverAddress = receiverAddress;
// }
//
// public Address getSenderAddress() {
// return senderAddress;
// }
//
// public void setSenderAddress(Address senderAddress) {
// this.senderAddress = senderAddress;
// }
// }
//
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Customer.java
// @Embeddable
// public class Customer {
//
// private Long customerId;
//
// private String customerName;
//
// public Long getCustomerId() {
// return customerId;
// }
//
// public void setCustomerId(Long customerId) {
// this.customerId = customerId;
// }
//
// public String getCustomerName() {
// return customerName;
// }
//
// public void setCustomerName(String customerName) {
// this.customerName = customerName;
// }
// }
// Path: booking-service/src/test/java/de/codecentric/resilient/booking/repository/BookingRepositoryTest.java
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import de.codecentric.resilient.booking.entity.Address;
import de.codecentric.resilient.booking.entity.Booking;
import de.codecentric.resilient.booking.entity.Customer;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
package de.codecentric.resilient.booking.repository;
/**
* @author Benjamin Wilms (xd98870)
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,properties = {"spring.cloud.config.discovery.enabled=false","spring.cloud.config.enabled=false"})
public class BookingRepositoryTest {
@Autowired
private BookingRepository bookingRepository;
@Test
public void checkSaveBooking() throws Exception {
Customer customer = new Customer();
customer.setCustomerId(1L);
customer.setCustomerName("Meier");
Address senderAddress = createAddress();
Address receiverAddress = createAddress();
| Booking booking = new Booking(); |
MrBW/resilient-transport-service | address-service/src/test/java/de/codecentric/resilient/address/service/AddressServiceIntegrationTest.java | // Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java
// @Entity
// public class Address {
//
// @Id
// @GeneratedValue
// private Long id;
//
// private String country;
//
// private String city;
//
// private String postcode;
//
// private String street;
//
// private String streetNumber;
//
// public Address() {
// }
//
// /***
// *
// * @param country
// * @param city
// * @param postcode
// * @param street
// * @param streetNumber
// */
// public Address(String country, String city, String postcode, String street, String streetNumber) {
// this.country = country;
// this.city = city;
// this.postcode = postcode;
// this.street = street;
// this.streetNumber = streetNumber;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
// }
//
// Path: address-service/src/main/java/de/codecentric/resilient/address/repository/AddressRepository.java
// public interface AddressRepository extends CrudRepository<Address, Long>, QueryByExampleExecutor<Address> {
//
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/AddressDTO.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class AddressDTO {
//
// @JsonProperty(required = true)
// private String country;
//
// @JsonProperty(required = true)
// private String city;
//
// @JsonProperty(required = true)
// private String postcode;
//
// @JsonProperty(required = true)
// private String street;
//
// @JsonProperty(required = true)
// private String streetNumber;
//
// public AddressDTO() {
// }
//
// public AddressDTO(String country, String city, String postcode, String street, String streetNumber) {
// this.country = country;
// this.city = city;
// this.postcode = postcode;
// this.street = street;
// this.streetNumber = streetNumber;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder("AddressDTO{");
// sb.append("country='").append(country).append('\'');
// sb.append(", city='").append(city).append('\'');
// sb.append(", postcode='").append(postcode).append('\'');
// sb.append(", street='").append(street).append('\'');
// sb.append(", streetNumber='").append(streetNumber).append('\'');
// sb.append('}');
// return sb.toString();
// }
// }
| import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import de.codecentric.resilient.address.entity.Address;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import de.codecentric.resilient.address.repository.AddressRepository;
import de.codecentric.resilient.dto.AddressDTO; | package de.codecentric.resilient.address.service;
/**
* @author Benjamin Wilms (xd98870)
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,properties = {"spring.cloud.config.discovery.enabled=false","spring.cloud.config.enabled=false"})
public class AddressServiceIntegrationTest {
@Autowired | // Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java
// @Entity
// public class Address {
//
// @Id
// @GeneratedValue
// private Long id;
//
// private String country;
//
// private String city;
//
// private String postcode;
//
// private String street;
//
// private String streetNumber;
//
// public Address() {
// }
//
// /***
// *
// * @param country
// * @param city
// * @param postcode
// * @param street
// * @param streetNumber
// */
// public Address(String country, String city, String postcode, String street, String streetNumber) {
// this.country = country;
// this.city = city;
// this.postcode = postcode;
// this.street = street;
// this.streetNumber = streetNumber;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
// }
//
// Path: address-service/src/main/java/de/codecentric/resilient/address/repository/AddressRepository.java
// public interface AddressRepository extends CrudRepository<Address, Long>, QueryByExampleExecutor<Address> {
//
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/AddressDTO.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class AddressDTO {
//
// @JsonProperty(required = true)
// private String country;
//
// @JsonProperty(required = true)
// private String city;
//
// @JsonProperty(required = true)
// private String postcode;
//
// @JsonProperty(required = true)
// private String street;
//
// @JsonProperty(required = true)
// private String streetNumber;
//
// public AddressDTO() {
// }
//
// public AddressDTO(String country, String city, String postcode, String street, String streetNumber) {
// this.country = country;
// this.city = city;
// this.postcode = postcode;
// this.street = street;
// this.streetNumber = streetNumber;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder("AddressDTO{");
// sb.append("country='").append(country).append('\'');
// sb.append(", city='").append(city).append('\'');
// sb.append(", postcode='").append(postcode).append('\'');
// sb.append(", street='").append(street).append('\'');
// sb.append(", streetNumber='").append(streetNumber).append('\'');
// sb.append('}');
// return sb.toString();
// }
// }
// Path: address-service/src/test/java/de/codecentric/resilient/address/service/AddressServiceIntegrationTest.java
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import de.codecentric.resilient.address.entity.Address;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import de.codecentric.resilient.address.repository.AddressRepository;
import de.codecentric.resilient.dto.AddressDTO;
package de.codecentric.resilient.address.service;
/**
* @author Benjamin Wilms (xd98870)
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,properties = {"spring.cloud.config.discovery.enabled=false","spring.cloud.config.enabled=false"})
public class AddressServiceIntegrationTest {
@Autowired | private AddressRepository addressRepository; |
MrBW/resilient-transport-service | address-service/src/test/java/de/codecentric/resilient/address/service/AddressServiceIntegrationTest.java | // Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java
// @Entity
// public class Address {
//
// @Id
// @GeneratedValue
// private Long id;
//
// private String country;
//
// private String city;
//
// private String postcode;
//
// private String street;
//
// private String streetNumber;
//
// public Address() {
// }
//
// /***
// *
// * @param country
// * @param city
// * @param postcode
// * @param street
// * @param streetNumber
// */
// public Address(String country, String city, String postcode, String street, String streetNumber) {
// this.country = country;
// this.city = city;
// this.postcode = postcode;
// this.street = street;
// this.streetNumber = streetNumber;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
// }
//
// Path: address-service/src/main/java/de/codecentric/resilient/address/repository/AddressRepository.java
// public interface AddressRepository extends CrudRepository<Address, Long>, QueryByExampleExecutor<Address> {
//
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/AddressDTO.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class AddressDTO {
//
// @JsonProperty(required = true)
// private String country;
//
// @JsonProperty(required = true)
// private String city;
//
// @JsonProperty(required = true)
// private String postcode;
//
// @JsonProperty(required = true)
// private String street;
//
// @JsonProperty(required = true)
// private String streetNumber;
//
// public AddressDTO() {
// }
//
// public AddressDTO(String country, String city, String postcode, String street, String streetNumber) {
// this.country = country;
// this.city = city;
// this.postcode = postcode;
// this.street = street;
// this.streetNumber = streetNumber;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder("AddressDTO{");
// sb.append("country='").append(country).append('\'');
// sb.append(", city='").append(city).append('\'');
// sb.append(", postcode='").append(postcode).append('\'');
// sb.append(", street='").append(street).append('\'');
// sb.append(", streetNumber='").append(streetNumber).append('\'');
// sb.append('}');
// return sb.toString();
// }
// }
| import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import de.codecentric.resilient.address.entity.Address;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import de.codecentric.resilient.address.repository.AddressRepository;
import de.codecentric.resilient.dto.AddressDTO; | package de.codecentric.resilient.address.service;
/**
* @author Benjamin Wilms (xd98870)
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,properties = {"spring.cloud.config.discovery.enabled=false","spring.cloud.config.enabled=false"})
public class AddressServiceIntegrationTest {
@Autowired
private AddressRepository addressRepository;
private AddressService addressService;
@Before
public void setUp() throws Exception {
addressRepository.deleteAll();
| // Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java
// @Entity
// public class Address {
//
// @Id
// @GeneratedValue
// private Long id;
//
// private String country;
//
// private String city;
//
// private String postcode;
//
// private String street;
//
// private String streetNumber;
//
// public Address() {
// }
//
// /***
// *
// * @param country
// * @param city
// * @param postcode
// * @param street
// * @param streetNumber
// */
// public Address(String country, String city, String postcode, String street, String streetNumber) {
// this.country = country;
// this.city = city;
// this.postcode = postcode;
// this.street = street;
// this.streetNumber = streetNumber;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
// }
//
// Path: address-service/src/main/java/de/codecentric/resilient/address/repository/AddressRepository.java
// public interface AddressRepository extends CrudRepository<Address, Long>, QueryByExampleExecutor<Address> {
//
// }
//
// Path: service-library/src/main/java/de/codecentric/resilient/dto/AddressDTO.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class AddressDTO {
//
// @JsonProperty(required = true)
// private String country;
//
// @JsonProperty(required = true)
// private String city;
//
// @JsonProperty(required = true)
// private String postcode;
//
// @JsonProperty(required = true)
// private String street;
//
// @JsonProperty(required = true)
// private String streetNumber;
//
// public AddressDTO() {
// }
//
// public AddressDTO(String country, String city, String postcode, String street, String streetNumber) {
// this.country = country;
// this.city = city;
// this.postcode = postcode;
// this.street = street;
// this.streetNumber = streetNumber;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getStreet() {
// return street;
// }
//
// public void setStreet(String street) {
// this.street = street;
// }
//
// public String getStreetNumber() {
// return streetNumber;
// }
//
// public void setStreetNumber(String streetNumber) {
// this.streetNumber = streetNumber;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder("AddressDTO{");
// sb.append("country='").append(country).append('\'');
// sb.append(", city='").append(city).append('\'');
// sb.append(", postcode='").append(postcode).append('\'');
// sb.append(", street='").append(street).append('\'');
// sb.append(", streetNumber='").append(streetNumber).append('\'');
// sb.append('}');
// return sb.toString();
// }
// }
// Path: address-service/src/test/java/de/codecentric/resilient/address/service/AddressServiceIntegrationTest.java
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import de.codecentric.resilient.address.entity.Address;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import de.codecentric.resilient.address.repository.AddressRepository;
import de.codecentric.resilient.dto.AddressDTO;
package de.codecentric.resilient.address.service;
/**
* @author Benjamin Wilms (xd98870)
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,properties = {"spring.cloud.config.discovery.enabled=false","spring.cloud.config.enabled=false"})
public class AddressServiceIntegrationTest {
@Autowired
private AddressRepository addressRepository;
private AddressService addressService;
@Before
public void setUp() throws Exception {
addressRepository.deleteAll();
| addressRepository.save(new Address("DE", "Solingen", "42697", "Hochstrasse", "11")); |
wso2/carbon-governance | components/governance/org.wso2.carbon.governance.taxonomy/src/main/java/org/wso2/carbon/governance/taxonomy/services/ManagementProviderImpl.java | // Path: components/governance/org.wso2.carbon.governance.taxonomy/src/main/java/org/wso2/carbon/governance/taxonomy/util/CommonUtils.java
// public static OMElement buildOMElement(String payload) throws RegistryException {
// OMElement element;
// try {
// element = AXIOMUtil.stringToOM(payload);
// element.build();
// } catch (Exception e) {
// String message = "Unable to parse the XML configuration. Please validate the XML configuration";
// throw new RegistryException(message, e);
// }
// return element;
// }
| import static org.wso2.carbon.governance.taxonomy.util.TaxonomyConstants.TAXONOMY_CONFIGURATION_PATH;
import static org.wso2.carbon.governance.taxonomy.util.TaxonomyConstants.TAXONOMY_MEDIA_TYPE;
import org.apache.axiom.om.OMElement;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.governance.taxonomy.beans.TaxonomyBean;
import org.wso2.carbon.governance.taxonomy.clustering.ClusterMessage;
import org.wso2.carbon.governance.taxonomy.clustering.ClusteringUtil;
import org.wso2.carbon.governance.taxonomy.exception.TaxonomyException;
import org.wso2.carbon.registry.common.services.RegistryAbstractAdmin;
import org.wso2.carbon.registry.core.*;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
import org.wso2.carbon.registry.core.utils.RegistryUtils;
import javax.xml.namespace.QName;
import static org.wso2.carbon.governance.taxonomy.util.CommonUtils.buildOMElement; | /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* 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 org.wso2.carbon.governance.taxonomy.services;
class ManagementProviderImpl extends RegistryAbstractAdmin implements IManagementProvider {
/**
* This method will add user defined taxonomy content into the registry
*
* @param storageProvider storage provider instance
* @param taxonomyBean taxonomy bean instance which contains taxonomy meta data
* @return
* @throws RegistryException
*/
@Override
public boolean addTaxonomy(IStorageProvider storageProvider, TaxonomyBean taxonomyBean)
throws RegistryException {
Registry registry = getGovernanceUserRegistry();
Resource resource;
String name;
OMElement element = null; | // Path: components/governance/org.wso2.carbon.governance.taxonomy/src/main/java/org/wso2/carbon/governance/taxonomy/util/CommonUtils.java
// public static OMElement buildOMElement(String payload) throws RegistryException {
// OMElement element;
// try {
// element = AXIOMUtil.stringToOM(payload);
// element.build();
// } catch (Exception e) {
// String message = "Unable to parse the XML configuration. Please validate the XML configuration";
// throw new RegistryException(message, e);
// }
// return element;
// }
// Path: components/governance/org.wso2.carbon.governance.taxonomy/src/main/java/org/wso2/carbon/governance/taxonomy/services/ManagementProviderImpl.java
import static org.wso2.carbon.governance.taxonomy.util.TaxonomyConstants.TAXONOMY_CONFIGURATION_PATH;
import static org.wso2.carbon.governance.taxonomy.util.TaxonomyConstants.TAXONOMY_MEDIA_TYPE;
import org.apache.axiom.om.OMElement;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.governance.taxonomy.beans.TaxonomyBean;
import org.wso2.carbon.governance.taxonomy.clustering.ClusterMessage;
import org.wso2.carbon.governance.taxonomy.clustering.ClusteringUtil;
import org.wso2.carbon.governance.taxonomy.exception.TaxonomyException;
import org.wso2.carbon.registry.common.services.RegistryAbstractAdmin;
import org.wso2.carbon.registry.core.*;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
import org.wso2.carbon.registry.core.utils.RegistryUtils;
import javax.xml.namespace.QName;
import static org.wso2.carbon.governance.taxonomy.util.CommonUtils.buildOMElement;
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* 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 org.wso2.carbon.governance.taxonomy.services;
class ManagementProviderImpl extends RegistryAbstractAdmin implements IManagementProvider {
/**
* This method will add user defined taxonomy content into the registry
*
* @param storageProvider storage provider instance
* @param taxonomyBean taxonomy bean instance which contains taxonomy meta data
* @return
* @throws RegistryException
*/
@Override
public boolean addTaxonomy(IStorageProvider storageProvider, TaxonomyBean taxonomyBean)
throws RegistryException {
Registry registry = getGovernanceUserRegistry();
Resource resource;
String name;
OMElement element = null; | element = buildOMElement(taxonomyBean.getPayload()); |
wso2/carbon-governance | components/governance/org.wso2.carbon.governance.comparator/src/test/java/org/wso2/carbon/governance/comparator/TestDiffGeneratorFactory.java | // Path: components/governance/org.wso2.carbon.governance.comparator/src/main/java/org/wso2/carbon/governance/comparator/wsdl/WSDLComparator.java
// public class WSDLComparator implements Comparator<Definition> {
//
// List<AbstractWSDLComparator> comparators = new ArrayList<>();
//
// public WSDLComparator() {
// comparators.add(new WSDLDeclarationComparator());
// comparators.add(new WSDLImportsComparator());
// comparators.add(new WSDLBindingsComparator());
// comparators.add(new WSDLMessagesComparator());
// comparators.add(new WSDLPortTypeComparator());
// comparators.add(new WSDLOperationComparator());
// comparators.add(new WSDLServicesComparator());
// comparators.add(new WSDLPortComparator());
// }
//
//
// @Override
// public void init() {
// }
//
// @Override
// public void compare(Definition base, Definition changed, Comparison comparison) throws ComparisonException {
// for (AbstractWSDLComparator comparator : comparators) {
// comparator.compareInternal(base, changed, (DefaultComparison) comparison);
// }
// }
//
// @Override
// public boolean isSupportedMediaType(String mediaType) {
// return ComparatorConstants.WSDL_MEDIA_TYPE == mediaType ? true : false;
// }
// }
| import org.wso2.carbon.governance.comparator.wsdl.WSDLComparator;
import java.util.ArrayList;
import java.util.List; | /*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.governance.comparator;
public class TestDiffGeneratorFactory implements DiffGeneratorFactory {
@Override
public DiffGenerator getDiffGenerator() {
List<Comparator<?>> comparators = new ArrayList<>(); | // Path: components/governance/org.wso2.carbon.governance.comparator/src/main/java/org/wso2/carbon/governance/comparator/wsdl/WSDLComparator.java
// public class WSDLComparator implements Comparator<Definition> {
//
// List<AbstractWSDLComparator> comparators = new ArrayList<>();
//
// public WSDLComparator() {
// comparators.add(new WSDLDeclarationComparator());
// comparators.add(new WSDLImportsComparator());
// comparators.add(new WSDLBindingsComparator());
// comparators.add(new WSDLMessagesComparator());
// comparators.add(new WSDLPortTypeComparator());
// comparators.add(new WSDLOperationComparator());
// comparators.add(new WSDLServicesComparator());
// comparators.add(new WSDLPortComparator());
// }
//
//
// @Override
// public void init() {
// }
//
// @Override
// public void compare(Definition base, Definition changed, Comparison comparison) throws ComparisonException {
// for (AbstractWSDLComparator comparator : comparators) {
// comparator.compareInternal(base, changed, (DefaultComparison) comparison);
// }
// }
//
// @Override
// public boolean isSupportedMediaType(String mediaType) {
// return ComparatorConstants.WSDL_MEDIA_TYPE == mediaType ? true : false;
// }
// }
// Path: components/governance/org.wso2.carbon.governance.comparator/src/test/java/org/wso2/carbon/governance/comparator/TestDiffGeneratorFactory.java
import org.wso2.carbon.governance.comparator.wsdl.WSDLComparator;
import java.util.ArrayList;
import java.util.List;
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.governance.comparator;
public class TestDiffGeneratorFactory implements DiffGeneratorFactory {
@Override
public DiffGenerator getDiffGenerator() {
List<Comparator<?>> comparators = new ArrayList<>(); | comparators.add(new WSDLComparator()); |
wso2/carbon-governance | components/governance/org.wso2.carbon.governance.common/src/main/java/org/wso2/carbon/governance/common/utils/GovernanceUtils.java | // Path: components/governance/org.wso2.carbon.governance.common/src/main/java/org/wso2/carbon/governance/common/GovernanceConfiguration.java
// public class GovernanceConfiguration {
//
// private Map<String, Map<String, String>> discoveryAgentConfigs = new HashMap();
// private List<String> comparators = new ArrayList<>();
// private boolean endpointStateManagementEnabled = false;
// private boolean lifecycleChecklistItemsEnabled = false;
// private long defaultEndpointActiveDuration = 90;
//
// private static GovernanceConfiguration instance = new GovernanceConfiguration();
//
// private GovernanceConfiguration() {
// }
//
// public static GovernanceConfiguration getInstance() {
// // Need permissions in order to instantiate ServerConfiguration
// CarbonBaseUtils.checkSecurity();
// return instance;
// }
//
// public void addDiscoveryAgentConfig(String serverTypeId, Map<String, String> properties) {
// discoveryAgentConfigs.put(serverTypeId, properties);
// }
//
// public Map<String, Map<String, String>> getDiscoveryAgentConfigs() {
// return discoveryAgentConfigs;
// }
//
// public void addComparator(String comparatorClass) {
// comparators.add(comparatorClass);
// }
//
// public List<String> getComparators() {
// return comparators;
// }
//
// public void setComparators(List<String> comparators) {
// this.comparators = comparators;
// }
//
//
// public boolean isEndpointStateManagementEnabled() {
// return endpointStateManagementEnabled;
// }
//
// public void setEndpointStateManagementEnabled(boolean endpointStateManagementEnabled) {
// this.endpointStateManagementEnabled = endpointStateManagementEnabled;
// }
//
// public long getDefaultEndpointActiveDuration() {
// return defaultEndpointActiveDuration;
// }
//
// public void setDefaultEndpointActiveDuration(long defaultEndpointActiveDuration) {
// this.defaultEndpointActiveDuration = defaultEndpointActiveDuration;
// }
//
// public boolean isLifecycleChecklistItemsEnabled() {
// return lifecycleChecklistItemsEnabled;
// }
//
// public void setLifecycleChecklistItemsEnabled(boolean lifecycleChecklistItemsEnabled) {
// this.lifecycleChecklistItemsEnabled = lifecycleChecklistItemsEnabled;
// }
//
// @Override
// public String toString() {
// return "GovernanceConfiguration{" +
// "discoveryAgentConfigs=" + discoveryAgentConfigs +
// ", comparators=" + comparators +
// ", endpointStateManagementEnabled=" + endpointStateManagementEnabled +
// ", defaultEndpointActiveDuration=" + defaultEndpointActiveDuration +
// ", lifecycleChecklistItemsEnabled=" + lifecycleChecklistItemsEnabled +
// '}';
// }
// }
| import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.xerces.util.SecurityManager;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.wso2.carbon.governance.common.GovernanceConfiguration;
import org.wso2.carbon.governance.common.GovernanceConfigurationException;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.ServerConstants;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map; | /*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.governance.common.utils;
public class GovernanceUtils {
public static final String DISCOVERY_AGENTS = "DiscoveryAgents";
public static final String DISCOVERY_AGENT = "DiscoveryAgent";
public static final String SERVER_TYPE_ID = "ServerTypeId";
public static final String AGENT_CLASS = "AgentClass";
public static final String PROPERTY = "property";
public static final String NAME = "name";
public static final String VALUE = "value";
public static final String GOVERNANCE_CONFIG_FILE = "governance.xml";
public static final String COMPARATORS = "Comparators";
public static final String COMPARATOR = "Comparator";
public static final String CLASS_ATTR = "class";
public static final String ENDPOINT_STATE_MANAGEMENT = "EndpointStateManagement";
public static final String ENDPOINT_STATE_MANAGEMENT_ENABLED = "enabled";
public static final String DEFAULT_ENDPOINT_ACTIVE_DURATION = "DefaultEndpointActiveDuration";
public static final String ENABLE_LIFECYCLE_CHECKLIST_ITEMS = "enableLifecycleChecklistItems";
public static final String LIFECYCLE_CHECKLIST_ITEMS_ENABLED = "true";
private static final int ENTITY_EXPANSION_LIMIT = 0;
private static Log log = LogFactory.getLog(GovernanceUtils.class);
private static boolean isConfigInitialized = false;
| // Path: components/governance/org.wso2.carbon.governance.common/src/main/java/org/wso2/carbon/governance/common/GovernanceConfiguration.java
// public class GovernanceConfiguration {
//
// private Map<String, Map<String, String>> discoveryAgentConfigs = new HashMap();
// private List<String> comparators = new ArrayList<>();
// private boolean endpointStateManagementEnabled = false;
// private boolean lifecycleChecklistItemsEnabled = false;
// private long defaultEndpointActiveDuration = 90;
//
// private static GovernanceConfiguration instance = new GovernanceConfiguration();
//
// private GovernanceConfiguration() {
// }
//
// public static GovernanceConfiguration getInstance() {
// // Need permissions in order to instantiate ServerConfiguration
// CarbonBaseUtils.checkSecurity();
// return instance;
// }
//
// public void addDiscoveryAgentConfig(String serverTypeId, Map<String, String> properties) {
// discoveryAgentConfigs.put(serverTypeId, properties);
// }
//
// public Map<String, Map<String, String>> getDiscoveryAgentConfigs() {
// return discoveryAgentConfigs;
// }
//
// public void addComparator(String comparatorClass) {
// comparators.add(comparatorClass);
// }
//
// public List<String> getComparators() {
// return comparators;
// }
//
// public void setComparators(List<String> comparators) {
// this.comparators = comparators;
// }
//
//
// public boolean isEndpointStateManagementEnabled() {
// return endpointStateManagementEnabled;
// }
//
// public void setEndpointStateManagementEnabled(boolean endpointStateManagementEnabled) {
// this.endpointStateManagementEnabled = endpointStateManagementEnabled;
// }
//
// public long getDefaultEndpointActiveDuration() {
// return defaultEndpointActiveDuration;
// }
//
// public void setDefaultEndpointActiveDuration(long defaultEndpointActiveDuration) {
// this.defaultEndpointActiveDuration = defaultEndpointActiveDuration;
// }
//
// public boolean isLifecycleChecklistItemsEnabled() {
// return lifecycleChecklistItemsEnabled;
// }
//
// public void setLifecycleChecklistItemsEnabled(boolean lifecycleChecklistItemsEnabled) {
// this.lifecycleChecklistItemsEnabled = lifecycleChecklistItemsEnabled;
// }
//
// @Override
// public String toString() {
// return "GovernanceConfiguration{" +
// "discoveryAgentConfigs=" + discoveryAgentConfigs +
// ", comparators=" + comparators +
// ", endpointStateManagementEnabled=" + endpointStateManagementEnabled +
// ", defaultEndpointActiveDuration=" + defaultEndpointActiveDuration +
// ", lifecycleChecklistItemsEnabled=" + lifecycleChecklistItemsEnabled +
// '}';
// }
// }
// Path: components/governance/org.wso2.carbon.governance.common/src/main/java/org/wso2/carbon/governance/common/utils/GovernanceUtils.java
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.xerces.util.SecurityManager;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.wso2.carbon.governance.common.GovernanceConfiguration;
import org.wso2.carbon.governance.common.GovernanceConfigurationException;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.ServerConstants;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.governance.common.utils;
public class GovernanceUtils {
public static final String DISCOVERY_AGENTS = "DiscoveryAgents";
public static final String DISCOVERY_AGENT = "DiscoveryAgent";
public static final String SERVER_TYPE_ID = "ServerTypeId";
public static final String AGENT_CLASS = "AgentClass";
public static final String PROPERTY = "property";
public static final String NAME = "name";
public static final String VALUE = "value";
public static final String GOVERNANCE_CONFIG_FILE = "governance.xml";
public static final String COMPARATORS = "Comparators";
public static final String COMPARATOR = "Comparator";
public static final String CLASS_ATTR = "class";
public static final String ENDPOINT_STATE_MANAGEMENT = "EndpointStateManagement";
public static final String ENDPOINT_STATE_MANAGEMENT_ENABLED = "enabled";
public static final String DEFAULT_ENDPOINT_ACTIVE_DURATION = "DefaultEndpointActiveDuration";
public static final String ENABLE_LIFECYCLE_CHECKLIST_ITEMS = "enableLifecycleChecklistItems";
public static final String LIFECYCLE_CHECKLIST_ITEMS_ENABLED = "true";
private static final int ENTITY_EXPANSION_LIMIT = 0;
private static Log log = LogFactory.getLog(GovernanceUtils.class);
private static boolean isConfigInitialized = false;
| public static GovernanceConfiguration getGovernanceConfiguration() throws GovernanceConfigurationException { |
wso2/carbon-governance | components/governance/org.wso2.carbon.governance.registry.extensions/src/org/wso2/carbon/governance/registry/extensions/internal/GovernanceRegistryExtensionsComponent.java | // Path: components/governance/org.wso2.carbon.governance.registry.extensions/src/org/wso2/carbon/governance/registry/extensions/listeners/RxtLoader.java
// public class RxtLoader extends AbstractAxis2ConfigurationContextObserver {
// private Log log = LogFactory.getLog(RxtLoader.class);
//
// public void createdConfigurationContext(ConfigurationContext configContext) {
// int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
// RegistryService service = RegistryCoreServiceComponent.getRegistryService();
// if (log.isDebugEnabled()) {
// log.debug("Loading RXTs to the registry for tenant " + tenantId);
// }
// try {
// CommonUtil.addRxtConfigs(service.getGovernanceSystemRegistry(tenantId), tenantId);
// if (log.isDebugEnabled()) {
// log.debug("Successfully loaded RXTs to the registry for tenant " + tenantId);
// }
// } catch (RegistryException e) {
// log.error("Failed to add rxt files to registry", e);
// }
// }
// }
| import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.governance.common.GovernanceConfigurationService;
import org.wso2.carbon.governance.registry.extensions.listeners.RxtLoader;
import org.wso2.carbon.governance.registry.extensions.utils.CommonUtil;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
import org.wso2.carbon.registry.core.internal.RegistryCoreServiceComponent;
import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.registry.extensions.services.RXTStoragePathService;
import org.wso2.carbon.securevault.SecretCallbackHandlerService;
import org.wso2.carbon.utils.Axis2ConfigurationContextObserver;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy; | /*
* Copyright (c) 2005-2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.governance.registry.extensions.internal;
@Component(
name = "org.wso2.governance.registry.extensions.services",
immediate = true)
public class GovernanceRegistryExtensionsComponent {
private static final Log log = LogFactory.getLog(GovernanceRegistryExtensionsComponent.class);
private static SecretCallbackHandlerService secretCallbackHandlerService = null;
private GovernanceRegistryExtensionsDataHolder dataHolder = GovernanceRegistryExtensionsDataHolder.getInstance();
@Activate
protected void activate(ComponentContext componentContext) throws RegistryException {
BundleContext bundleCtx = componentContext.getBundleContext(); | // Path: components/governance/org.wso2.carbon.governance.registry.extensions/src/org/wso2/carbon/governance/registry/extensions/listeners/RxtLoader.java
// public class RxtLoader extends AbstractAxis2ConfigurationContextObserver {
// private Log log = LogFactory.getLog(RxtLoader.class);
//
// public void createdConfigurationContext(ConfigurationContext configContext) {
// int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
// RegistryService service = RegistryCoreServiceComponent.getRegistryService();
// if (log.isDebugEnabled()) {
// log.debug("Loading RXTs to the registry for tenant " + tenantId);
// }
// try {
// CommonUtil.addRxtConfigs(service.getGovernanceSystemRegistry(tenantId), tenantId);
// if (log.isDebugEnabled()) {
// log.debug("Successfully loaded RXTs to the registry for tenant " + tenantId);
// }
// } catch (RegistryException e) {
// log.error("Failed to add rxt files to registry", e);
// }
// }
// }
// Path: components/governance/org.wso2.carbon.governance.registry.extensions/src/org/wso2/carbon/governance/registry/extensions/internal/GovernanceRegistryExtensionsComponent.java
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.governance.common.GovernanceConfigurationService;
import org.wso2.carbon.governance.registry.extensions.listeners.RxtLoader;
import org.wso2.carbon.governance.registry.extensions.utils.CommonUtil;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
import org.wso2.carbon.registry.core.internal.RegistryCoreServiceComponent;
import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.registry.extensions.services.RXTStoragePathService;
import org.wso2.carbon.securevault.SecretCallbackHandlerService;
import org.wso2.carbon.utils.Axis2ConfigurationContextObserver;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
/*
* Copyright (c) 2005-2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.governance.registry.extensions.internal;
@Component(
name = "org.wso2.governance.registry.extensions.services",
immediate = true)
public class GovernanceRegistryExtensionsComponent {
private static final Log log = LogFactory.getLog(GovernanceRegistryExtensionsComponent.class);
private static SecretCallbackHandlerService secretCallbackHandlerService = null;
private GovernanceRegistryExtensionsDataHolder dataHolder = GovernanceRegistryExtensionsDataHolder.getInstance();
@Activate
protected void activate(ComponentContext componentContext) throws RegistryException {
BundleContext bundleCtx = componentContext.getBundleContext(); | RxtLoader rxtLoader = new RxtLoader(); |
cloudfoundry-incubator/uaa-java-client | src/main/java/org/cloudfoundry/identity/uaa/api/group/UaaGroupOperations.java | // Path: src/main/java/org/cloudfoundry/identity/uaa/api/common/model/expr/FilterRequest.java
// public class FilterRequest {
// private String filter;
//
// private List<String> attributes;
//
// private int start;
//
// private int count;
//
// public FilterRequest() {
//
// }
//
// FilterRequest(String filter, List<String> attributes, int start, int count) {
// this.filter = filter;
// this.attributes = attributes;
// this.start = start;
// this.count = count;
// }
//
// /**
// * The SCIM filter string
// * @return
// */
// public String getFilter() {
// return filter;
// }
//
// /**
// * @return The 1-based starting index for the query. If < 0, indicates the start of the list
// */
// public int getStart() {
// return start;
// }
//
// /**
// * @return The number of items to be returned by the query. If < 1, no count will be passed to the API, and the
// * default UAA behavior will take place.
// */
// public int getCount() {
// return count;
// }
//
// /**
// * @return The attributes to be returned by the query. If the list is empty, all attributes are returned.
// */
// public List<String> getAttributes() {
// return attributes;
// }
//
// static final FilterRequest SHOW_ALL = new FilterRequest(null, null, 0, 0);
// }
| import org.cloudfoundry.identity.uaa.rest.SearchResults;
import org.cloudfoundry.identity.uaa.scim.ScimGroup;
import org.cloudfoundry.identity.uaa.scim.ScimGroupExternalMember;
import org.cloudfoundry.identity.uaa.api.common.model.expr.FilterRequest; | /*
* 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 org.cloudfoundry.identity.uaa.api.group;
/**
* Provides endpoints to the UAA group APIs specified <a
* href="https://github.com/cloudfoundry/uaa/blob/master/docs/UAA-APIs.rst#group-management-apis">here</a>
*
* @author Josh Ghiloni
*
*/
public interface UaaGroupOperations {
public enum ScimGroupExternalMemberType {
groupId, displayName
}
/**
* Create a group in the UAA database
*
* @param group The partial group to be created. Members will not be created in this call
* @return The newly created group, with id and meta information
* @see #addMember(String, String)
*/
public ScimGroup createGroup(ScimGroup group);
/**
* Update the display name in the UAA database
*
* @param groupId the ID of the group
* @param newName the new display name
* @return the group with the specified group ID and the new Name
*/
public ScimGroup updateGroupName(String groupId, String newName);
/**
* Add a member to the group
*
* @param groupId the group id
* @param memberName the member's username (will be converted to ID)
* @return the group with the member in it
*/
public ScimGroup addMember(String groupId, String memberName);
/**
* Remove a member from the group
*
* @param groupId the group id
* @param memberName the member's username (will be converted to ID)
* @return the group without the member in it
*/
public ScimGroup deleteMember(String groupId, String memberName);
/**
* Delete the group from the database. An exception will be thrown if the operation fails
*
* @param groupId the group ID
*/
public void deleteGroup(String groupId);
/**
* Get a page of groups based on the given {@link FilterRequest}
*
* @param request the {@link FilterRequest}
* @return The page of groups.
* @see org.cloudfoundry.identity.uaa.api.common.model.expr.FilterRequestBuilder
*/ | // Path: src/main/java/org/cloudfoundry/identity/uaa/api/common/model/expr/FilterRequest.java
// public class FilterRequest {
// private String filter;
//
// private List<String> attributes;
//
// private int start;
//
// private int count;
//
// public FilterRequest() {
//
// }
//
// FilterRequest(String filter, List<String> attributes, int start, int count) {
// this.filter = filter;
// this.attributes = attributes;
// this.start = start;
// this.count = count;
// }
//
// /**
// * The SCIM filter string
// * @return
// */
// public String getFilter() {
// return filter;
// }
//
// /**
// * @return The 1-based starting index for the query. If < 0, indicates the start of the list
// */
// public int getStart() {
// return start;
// }
//
// /**
// * @return The number of items to be returned by the query. If < 1, no count will be passed to the API, and the
// * default UAA behavior will take place.
// */
// public int getCount() {
// return count;
// }
//
// /**
// * @return The attributes to be returned by the query. If the list is empty, all attributes are returned.
// */
// public List<String> getAttributes() {
// return attributes;
// }
//
// static final FilterRequest SHOW_ALL = new FilterRequest(null, null, 0, 0);
// }
// Path: src/main/java/org/cloudfoundry/identity/uaa/api/group/UaaGroupOperations.java
import org.cloudfoundry.identity.uaa.rest.SearchResults;
import org.cloudfoundry.identity.uaa.scim.ScimGroup;
import org.cloudfoundry.identity.uaa.scim.ScimGroupExternalMember;
import org.cloudfoundry.identity.uaa.api.common.model.expr.FilterRequest;
/*
* 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 org.cloudfoundry.identity.uaa.api.group;
/**
* Provides endpoints to the UAA group APIs specified <a
* href="https://github.com/cloudfoundry/uaa/blob/master/docs/UAA-APIs.rst#group-management-apis">here</a>
*
* @author Josh Ghiloni
*
*/
public interface UaaGroupOperations {
public enum ScimGroupExternalMemberType {
groupId, displayName
}
/**
* Create a group in the UAA database
*
* @param group The partial group to be created. Members will not be created in this call
* @return The newly created group, with id and meta information
* @see #addMember(String, String)
*/
public ScimGroup createGroup(ScimGroup group);
/**
* Update the display name in the UAA database
*
* @param groupId the ID of the group
* @param newName the new display name
* @return the group with the specified group ID and the new Name
*/
public ScimGroup updateGroupName(String groupId, String newName);
/**
* Add a member to the group
*
* @param groupId the group id
* @param memberName the member's username (will be converted to ID)
* @return the group with the member in it
*/
public ScimGroup addMember(String groupId, String memberName);
/**
* Remove a member from the group
*
* @param groupId the group id
* @param memberName the member's username (will be converted to ID)
* @return the group without the member in it
*/
public ScimGroup deleteMember(String groupId, String memberName);
/**
* Delete the group from the database. An exception will be thrown if the operation fails
*
* @param groupId the group ID
*/
public void deleteGroup(String groupId);
/**
* Get a page of groups based on the given {@link FilterRequest}
*
* @param request the {@link FilterRequest}
* @return The page of groups.
* @see org.cloudfoundry.identity.uaa.api.common.model.expr.FilterRequestBuilder
*/ | public SearchResults<ScimGroup> getGroups(FilterRequest request); |
cloudfoundry-incubator/uaa-java-client | src/main/java/org/cloudfoundry/identity/uaa/api/client/UaaClientOperations.java | // Path: src/main/java/org/cloudfoundry/identity/uaa/api/common/model/expr/FilterRequest.java
// public class FilterRequest {
// private String filter;
//
// private List<String> attributes;
//
// private int start;
//
// private int count;
//
// public FilterRequest() {
//
// }
//
// FilterRequest(String filter, List<String> attributes, int start, int count) {
// this.filter = filter;
// this.attributes = attributes;
// this.start = start;
// this.count = count;
// }
//
// /**
// * The SCIM filter string
// * @return
// */
// public String getFilter() {
// return filter;
// }
//
// /**
// * @return The 1-based starting index for the query. If < 0, indicates the start of the list
// */
// public int getStart() {
// return start;
// }
//
// /**
// * @return The number of items to be returned by the query. If < 1, no count will be passed to the API, and the
// * default UAA behavior will take place.
// */
// public int getCount() {
// return count;
// }
//
// /**
// * @return The attributes to be returned by the query. If the list is empty, all attributes are returned.
// */
// public List<String> getAttributes() {
// return attributes;
// }
//
// static final FilterRequest SHOW_ALL = new FilterRequest(null, null, 0, 0);
// }
| import org.cloudfoundry.identity.uaa.rest.SearchResults;
import org.springframework.security.oauth2.provider.client.BaseClientDetails;
import org.cloudfoundry.identity.uaa.api.common.model.expr.FilterRequest; | /*
* 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 org.cloudfoundry.identity.uaa.api.client;
/**
* Provides endpoints to the UAA client APIs specified <a
* href="https://github.com/cloudfoundry/uaa/blob/master/docs/UAA-APIs.rst#client-registration-administration-apis"
* >here</a>
*
* @author Josh Ghiloni
*
*/
public interface UaaClientOperations {
/**
* Create a new UAA Client
*
* @param client the new client
* @return the newly created client
*/
public BaseClientDetails create(BaseClientDetails client);
/**
* Find a given client by its ID
* @param clientId the client ID
* @return the client, or null if not found
*/
public BaseClientDetails findById(String clientId);
/**
* Update the client. Secrets cannot be changed in this method.
*
* @param updated the client with new data
* @return the client returned from the API
* @see #changeClientSecret(String, String, String)
*/
public BaseClientDetails update(BaseClientDetails updated);
/**
* Delete the client with the given ID
*
* @param clientId
* @return
*/
public BaseClientDetails delete(String clientId);
/**
* Get clients based on the given SCIM filter.
*
* @param request
* @return the clients
* @see org.cloudfoundry.identity.uaa.api.common.model.expr.FilterRequestBuilder
*/ | // Path: src/main/java/org/cloudfoundry/identity/uaa/api/common/model/expr/FilterRequest.java
// public class FilterRequest {
// private String filter;
//
// private List<String> attributes;
//
// private int start;
//
// private int count;
//
// public FilterRequest() {
//
// }
//
// FilterRequest(String filter, List<String> attributes, int start, int count) {
// this.filter = filter;
// this.attributes = attributes;
// this.start = start;
// this.count = count;
// }
//
// /**
// * The SCIM filter string
// * @return
// */
// public String getFilter() {
// return filter;
// }
//
// /**
// * @return The 1-based starting index for the query. If < 0, indicates the start of the list
// */
// public int getStart() {
// return start;
// }
//
// /**
// * @return The number of items to be returned by the query. If < 1, no count will be passed to the API, and the
// * default UAA behavior will take place.
// */
// public int getCount() {
// return count;
// }
//
// /**
// * @return The attributes to be returned by the query. If the list is empty, all attributes are returned.
// */
// public List<String> getAttributes() {
// return attributes;
// }
//
// static final FilterRequest SHOW_ALL = new FilterRequest(null, null, 0, 0);
// }
// Path: src/main/java/org/cloudfoundry/identity/uaa/api/client/UaaClientOperations.java
import org.cloudfoundry.identity.uaa.rest.SearchResults;
import org.springframework.security.oauth2.provider.client.BaseClientDetails;
import org.cloudfoundry.identity.uaa.api.common.model.expr.FilterRequest;
/*
* 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 org.cloudfoundry.identity.uaa.api.client;
/**
* Provides endpoints to the UAA client APIs specified <a
* href="https://github.com/cloudfoundry/uaa/blob/master/docs/UAA-APIs.rst#client-registration-administration-apis"
* >here</a>
*
* @author Josh Ghiloni
*
*/
public interface UaaClientOperations {
/**
* Create a new UAA Client
*
* @param client the new client
* @return the newly created client
*/
public BaseClientDetails create(BaseClientDetails client);
/**
* Find a given client by its ID
* @param clientId the client ID
* @return the client, or null if not found
*/
public BaseClientDetails findById(String clientId);
/**
* Update the client. Secrets cannot be changed in this method.
*
* @param updated the client with new data
* @return the client returned from the API
* @see #changeClientSecret(String, String, String)
*/
public BaseClientDetails update(BaseClientDetails updated);
/**
* Delete the client with the given ID
*
* @param clientId
* @return
*/
public BaseClientDetails delete(String clientId);
/**
* Get clients based on the given SCIM filter.
*
* @param request
* @return the clients
* @see org.cloudfoundry.identity.uaa.api.common.model.expr.FilterRequestBuilder
*/ | public SearchResults<BaseClientDetails> getClients(FilterRequest request); |
cloudfoundry-incubator/uaa-java-client | src/test/java/org/cloudfoundry/identity/uaa/api/client/test/AbstractOperationTest.java | // Path: src/main/java/org/cloudfoundry/identity/uaa/api/UaaConnectionFactory.java
// public final class UaaConnectionFactory {
// private UaaConnectionFactory() {
//
// }
//
// /**
// * Get a connection object for the given UAA server, from which you can get access to different API operations.
// *
// * @param uaaUrl the base {@link URL} of the UAA server. May have a path prefix (for example,
// * <code>http://localhost:8080/uaa</code>)
// * @param credentials the {@link OAuth2ProtectedResourceDetails} representing the current user. May be client-only
// * @return the connection entry point
// */
// public static UaaConnection getConnection(URL uaaUrl, OAuth2ProtectedResourceDetails credentials) {
// UaaConnectionHelper helper = new UaaConnectionHelper(uaaUrl, credentials);
// return new UaaConnectionImpl(helper);
// }
// }
//
// Path: src/main/java/org/cloudfoundry/identity/uaa/api/common/UaaConnection.java
// public interface UaaConnection {
// /**
// * @return an entry point for client APIs
// */
// public UaaClientOperations clientOperations();
//
// /**
// * @return an entry point for group APIS
// */
// public UaaGroupOperations groupOperations();
//
// /**
// * @return an entry point for user APIs
// */
// public UaaUserOperations userOperations();
// }
| import java.net.URL;
import org.cloudfoundry.identity.uaa.api.UaaConnectionFactory;
import org.cloudfoundry.identity.uaa.api.common.UaaConnection;
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails;
import org.springframework.security.oauth2.common.AuthenticationScheme; | /*
* 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 org.cloudfoundry.identity.uaa.api.client.test;
/**
* @author Josh Ghiloni
*/
public abstract class AbstractOperationTest {
private static final String UAA_BASE_URL = "http://localhost:8080/uaa";
protected ClientCredentialsResourceDetails getDefaultClientCredentials() {
ClientCredentialsResourceDetails credentials = new ClientCredentialsResourceDetails();
credentials.setAccessTokenUri(UAA_BASE_URL + "/oauth/token");
credentials.setClientAuthenticationScheme(AuthenticationScheme.header);
credentials.setClientId("admin");
credentials.setClientSecret("adminsecret");
return credentials;
}
| // Path: src/main/java/org/cloudfoundry/identity/uaa/api/UaaConnectionFactory.java
// public final class UaaConnectionFactory {
// private UaaConnectionFactory() {
//
// }
//
// /**
// * Get a connection object for the given UAA server, from which you can get access to different API operations.
// *
// * @param uaaUrl the base {@link URL} of the UAA server. May have a path prefix (for example,
// * <code>http://localhost:8080/uaa</code>)
// * @param credentials the {@link OAuth2ProtectedResourceDetails} representing the current user. May be client-only
// * @return the connection entry point
// */
// public static UaaConnection getConnection(URL uaaUrl, OAuth2ProtectedResourceDetails credentials) {
// UaaConnectionHelper helper = new UaaConnectionHelper(uaaUrl, credentials);
// return new UaaConnectionImpl(helper);
// }
// }
//
// Path: src/main/java/org/cloudfoundry/identity/uaa/api/common/UaaConnection.java
// public interface UaaConnection {
// /**
// * @return an entry point for client APIs
// */
// public UaaClientOperations clientOperations();
//
// /**
// * @return an entry point for group APIS
// */
// public UaaGroupOperations groupOperations();
//
// /**
// * @return an entry point for user APIs
// */
// public UaaUserOperations userOperations();
// }
// Path: src/test/java/org/cloudfoundry/identity/uaa/api/client/test/AbstractOperationTest.java
import java.net.URL;
import org.cloudfoundry.identity.uaa.api.UaaConnectionFactory;
import org.cloudfoundry.identity.uaa.api.common.UaaConnection;
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails;
import org.springframework.security.oauth2.common.AuthenticationScheme;
/*
* 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 org.cloudfoundry.identity.uaa.api.client.test;
/**
* @author Josh Ghiloni
*/
public abstract class AbstractOperationTest {
private static final String UAA_BASE_URL = "http://localhost:8080/uaa";
protected ClientCredentialsResourceDetails getDefaultClientCredentials() {
ClientCredentialsResourceDetails credentials = new ClientCredentialsResourceDetails();
credentials.setAccessTokenUri(UAA_BASE_URL + "/oauth/token");
credentials.setClientAuthenticationScheme(AuthenticationScheme.header);
credentials.setClientId("admin");
credentials.setClientSecret("adminsecret");
return credentials;
}
| protected UaaConnection getConnection() throws Exception { |
cloudfoundry-incubator/uaa-java-client | src/test/java/org/cloudfoundry/identity/uaa/api/client/test/AbstractOperationTest.java | // Path: src/main/java/org/cloudfoundry/identity/uaa/api/UaaConnectionFactory.java
// public final class UaaConnectionFactory {
// private UaaConnectionFactory() {
//
// }
//
// /**
// * Get a connection object for the given UAA server, from which you can get access to different API operations.
// *
// * @param uaaUrl the base {@link URL} of the UAA server. May have a path prefix (for example,
// * <code>http://localhost:8080/uaa</code>)
// * @param credentials the {@link OAuth2ProtectedResourceDetails} representing the current user. May be client-only
// * @return the connection entry point
// */
// public static UaaConnection getConnection(URL uaaUrl, OAuth2ProtectedResourceDetails credentials) {
// UaaConnectionHelper helper = new UaaConnectionHelper(uaaUrl, credentials);
// return new UaaConnectionImpl(helper);
// }
// }
//
// Path: src/main/java/org/cloudfoundry/identity/uaa/api/common/UaaConnection.java
// public interface UaaConnection {
// /**
// * @return an entry point for client APIs
// */
// public UaaClientOperations clientOperations();
//
// /**
// * @return an entry point for group APIS
// */
// public UaaGroupOperations groupOperations();
//
// /**
// * @return an entry point for user APIs
// */
// public UaaUserOperations userOperations();
// }
| import java.net.URL;
import org.cloudfoundry.identity.uaa.api.UaaConnectionFactory;
import org.cloudfoundry.identity.uaa.api.common.UaaConnection;
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails;
import org.springframework.security.oauth2.common.AuthenticationScheme; | /*
* 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 org.cloudfoundry.identity.uaa.api.client.test;
/**
* @author Josh Ghiloni
*/
public abstract class AbstractOperationTest {
private static final String UAA_BASE_URL = "http://localhost:8080/uaa";
protected ClientCredentialsResourceDetails getDefaultClientCredentials() {
ClientCredentialsResourceDetails credentials = new ClientCredentialsResourceDetails();
credentials.setAccessTokenUri(UAA_BASE_URL + "/oauth/token");
credentials.setClientAuthenticationScheme(AuthenticationScheme.header);
credentials.setClientId("admin");
credentials.setClientSecret("adminsecret");
return credentials;
}
protected UaaConnection getConnection() throws Exception {
return getConnection(getDefaultClientCredentials());
}
protected UaaConnection getConnection(ClientCredentialsResourceDetails clientCredentials) throws Exception { | // Path: src/main/java/org/cloudfoundry/identity/uaa/api/UaaConnectionFactory.java
// public final class UaaConnectionFactory {
// private UaaConnectionFactory() {
//
// }
//
// /**
// * Get a connection object for the given UAA server, from which you can get access to different API operations.
// *
// * @param uaaUrl the base {@link URL} of the UAA server. May have a path prefix (for example,
// * <code>http://localhost:8080/uaa</code>)
// * @param credentials the {@link OAuth2ProtectedResourceDetails} representing the current user. May be client-only
// * @return the connection entry point
// */
// public static UaaConnection getConnection(URL uaaUrl, OAuth2ProtectedResourceDetails credentials) {
// UaaConnectionHelper helper = new UaaConnectionHelper(uaaUrl, credentials);
// return new UaaConnectionImpl(helper);
// }
// }
//
// Path: src/main/java/org/cloudfoundry/identity/uaa/api/common/UaaConnection.java
// public interface UaaConnection {
// /**
// * @return an entry point for client APIs
// */
// public UaaClientOperations clientOperations();
//
// /**
// * @return an entry point for group APIS
// */
// public UaaGroupOperations groupOperations();
//
// /**
// * @return an entry point for user APIs
// */
// public UaaUserOperations userOperations();
// }
// Path: src/test/java/org/cloudfoundry/identity/uaa/api/client/test/AbstractOperationTest.java
import java.net.URL;
import org.cloudfoundry.identity.uaa.api.UaaConnectionFactory;
import org.cloudfoundry.identity.uaa.api.common.UaaConnection;
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails;
import org.springframework.security.oauth2.common.AuthenticationScheme;
/*
* 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 org.cloudfoundry.identity.uaa.api.client.test;
/**
* @author Josh Ghiloni
*/
public abstract class AbstractOperationTest {
private static final String UAA_BASE_URL = "http://localhost:8080/uaa";
protected ClientCredentialsResourceDetails getDefaultClientCredentials() {
ClientCredentialsResourceDetails credentials = new ClientCredentialsResourceDetails();
credentials.setAccessTokenUri(UAA_BASE_URL + "/oauth/token");
credentials.setClientAuthenticationScheme(AuthenticationScheme.header);
credentials.setClientId("admin");
credentials.setClientSecret("adminsecret");
return credentials;
}
protected UaaConnection getConnection() throws Exception {
return getConnection(getDefaultClientCredentials());
}
protected UaaConnection getConnection(ClientCredentialsResourceDetails clientCredentials) throws Exception { | return UaaConnectionFactory.getConnection(new URL(UAA_BASE_URL), clientCredentials); |
cloudfoundry-incubator/uaa-java-client | src/main/java/org/cloudfoundry/identity/uaa/api/user/UaaUserOperations.java | // Path: src/main/java/org/cloudfoundry/identity/uaa/api/common/model/expr/FilterRequest.java
// public class FilterRequest {
// private String filter;
//
// private List<String> attributes;
//
// private int start;
//
// private int count;
//
// public FilterRequest() {
//
// }
//
// FilterRequest(String filter, List<String> attributes, int start, int count) {
// this.filter = filter;
// this.attributes = attributes;
// this.start = start;
// this.count = count;
// }
//
// /**
// * The SCIM filter string
// * @return
// */
// public String getFilter() {
// return filter;
// }
//
// /**
// * @return The 1-based starting index for the query. If < 0, indicates the start of the list
// */
// public int getStart() {
// return start;
// }
//
// /**
// * @return The number of items to be returned by the query. If < 1, no count will be passed to the API, and the
// * default UAA behavior will take place.
// */
// public int getCount() {
// return count;
// }
//
// /**
// * @return The attributes to be returned by the query. If the list is empty, all attributes are returned.
// */
// public List<String> getAttributes() {
// return attributes;
// }
//
// static final FilterRequest SHOW_ALL = new FilterRequest(null, null, 0, 0);
// }
| import org.cloudfoundry.identity.uaa.rest.SearchResults;
import org.cloudfoundry.identity.uaa.scim.ScimUser;
import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails;
import org.cloudfoundry.identity.uaa.api.common.model.expr.FilterRequest; | /*
* 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 org.cloudfoundry.identity.uaa.api.user;
/**
* Provides endpoints to the UAA user APIs specified <a
* href="https://github.com/cloudfoundry/uaa/blob/master/docs/UAA-APIs.rst#user-account-management-apis">here</a>
*
* @author Josh Ghiloni
*
*/
public interface UaaUserOperations {
/**
* Create the user in the UAA database with the given parameters.
*
* @param user The (partial) user information to be created
* @return The newly created user. Will have id and meta information set
*/
public ScimUser createUser(ScimUser user);
/**
* Update the user in the UAA database. Cannot use this method to change the user's password.
*
* @param user the updated user
* @return the user as returned from the UAA api
* @see #changeUserPassword(String, String, String)
*/
public ScimUser updateUser(ScimUser user);
/**
* Delete the user from UAA. Will throw an Exception if the operation fails
*
* @param userId The id of the user
*/
public void deleteUser(String userId);
/**
* Change the given user's password. You must have <code>uaa.admin</code> and <code>password.write</code> scopes in
* your {@link OAuth2ProtectedResourceDetails} object. An exception will be thrown if the operation fails.
*
* <b>TODO</b>: Add a method to change the current user's password, if not in a client-credential-only scope
*
* @param userId the user's id (not their username)
* @param oldPassword the old password
* @param newPassword the new password
*/
public void changeUserPassword(String userId, String oldPassword, String newPassword);
/**
* Looks up a user in the database by their name.
*
* @param userName the user's username
* @return the user object for this user, or null if the user does not exist or the operation fails
* @see #getUsers(FilterRequest)
*/
public ScimUser getUserByName(String userName);
/**
* Get a page of users based on the given {@link FilterRequest}
*
* @param request the {@link FilterRequest}
* @return The page of users.
* @see org.cloudfoundry.identity.uaa.api.common.model.expr.FilterRequestBuilder
*/ | // Path: src/main/java/org/cloudfoundry/identity/uaa/api/common/model/expr/FilterRequest.java
// public class FilterRequest {
// private String filter;
//
// private List<String> attributes;
//
// private int start;
//
// private int count;
//
// public FilterRequest() {
//
// }
//
// FilterRequest(String filter, List<String> attributes, int start, int count) {
// this.filter = filter;
// this.attributes = attributes;
// this.start = start;
// this.count = count;
// }
//
// /**
// * The SCIM filter string
// * @return
// */
// public String getFilter() {
// return filter;
// }
//
// /**
// * @return The 1-based starting index for the query. If < 0, indicates the start of the list
// */
// public int getStart() {
// return start;
// }
//
// /**
// * @return The number of items to be returned by the query. If < 1, no count will be passed to the API, and the
// * default UAA behavior will take place.
// */
// public int getCount() {
// return count;
// }
//
// /**
// * @return The attributes to be returned by the query. If the list is empty, all attributes are returned.
// */
// public List<String> getAttributes() {
// return attributes;
// }
//
// static final FilterRequest SHOW_ALL = new FilterRequest(null, null, 0, 0);
// }
// Path: src/main/java/org/cloudfoundry/identity/uaa/api/user/UaaUserOperations.java
import org.cloudfoundry.identity.uaa.rest.SearchResults;
import org.cloudfoundry.identity.uaa.scim.ScimUser;
import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails;
import org.cloudfoundry.identity.uaa.api.common.model.expr.FilterRequest;
/*
* 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 org.cloudfoundry.identity.uaa.api.user;
/**
* Provides endpoints to the UAA user APIs specified <a
* href="https://github.com/cloudfoundry/uaa/blob/master/docs/UAA-APIs.rst#user-account-management-apis">here</a>
*
* @author Josh Ghiloni
*
*/
public interface UaaUserOperations {
/**
* Create the user in the UAA database with the given parameters.
*
* @param user The (partial) user information to be created
* @return The newly created user. Will have id and meta information set
*/
public ScimUser createUser(ScimUser user);
/**
* Update the user in the UAA database. Cannot use this method to change the user's password.
*
* @param user the updated user
* @return the user as returned from the UAA api
* @see #changeUserPassword(String, String, String)
*/
public ScimUser updateUser(ScimUser user);
/**
* Delete the user from UAA. Will throw an Exception if the operation fails
*
* @param userId The id of the user
*/
public void deleteUser(String userId);
/**
* Change the given user's password. You must have <code>uaa.admin</code> and <code>password.write</code> scopes in
* your {@link OAuth2ProtectedResourceDetails} object. An exception will be thrown if the operation fails.
*
* <b>TODO</b>: Add a method to change the current user's password, if not in a client-credential-only scope
*
* @param userId the user's id (not their username)
* @param oldPassword the old password
* @param newPassword the new password
*/
public void changeUserPassword(String userId, String oldPassword, String newPassword);
/**
* Looks up a user in the database by their name.
*
* @param userName the user's username
* @return the user object for this user, or null if the user does not exist or the operation fails
* @see #getUsers(FilterRequest)
*/
public ScimUser getUserByName(String userName);
/**
* Get a page of users based on the given {@link FilterRequest}
*
* @param request the {@link FilterRequest}
* @return The page of users.
* @see org.cloudfoundry.identity.uaa.api.common.model.expr.FilterRequestBuilder
*/ | public SearchResults<ScimUser> getUsers(FilterRequest request); |
DV8FromTheWorld/JDA-Audio | src/examples/java/WebSocketExample.java | // Path: src/main/java/net/dv8tion/jda/Core.java
// public class Core
// {
// public static SimpleLog LOG = SimpleLog.getLog("Core");
//
// private final HashMap<String, AudioManager> audioManagers = new HashMap<>();
// private final ConnectionManager connManager;
// private final ScheduledThreadPoolExecutor audioKeepAlivePool;
// private final VoiceServerUpdateHandler vsuHandler;
// private final String userId;
// private final CoreClient coreClient;
// private final IAudioSendFactory sendFactory;
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// */
// public Core(String userId, CoreClient coreClient)
// {
// this(userId, coreClient, DefaultConnectionManager::new, new DefaultSendFactory());
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param sendFactory the {@link net.dv8tion.jda.audio.factory.IAudioSendFactory} to use.
// */
// public Core(String userId, CoreClient coreClient, IAudioSendFactory sendFactory) {
// this(userId, coreClient, DefaultConnectionManager::new, sendFactory);
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param connectionManagerBuilder connection manager to use
// */
// public Core(String userId, CoreClient coreClient, ConnectionManagerBuilder connectionManagerBuilder) {
// this(userId, coreClient, connectionManagerBuilder, new DefaultSendFactory());
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param connectionManagerBuilder Connection manager builder
// * @param sendFactory the {@link net.dv8tion.jda.audio.factory.IAudioSendFactory} to use.
// */
// public Core(String userId, CoreClient coreClient, ConnectionManagerBuilder connectionManagerBuilder, IAudioSendFactory sendFactory)
// {
// this.userId = userId;
// this.coreClient = coreClient;
// this.vsuHandler = new VoiceServerUpdateHandler(this);
// this.connManager = connectionManagerBuilder.build(this);
// this.audioKeepAlivePool = new ScheduledThreadPoolExecutor(1, new AudioWebSocket.KeepAliveThreadFactory());
// this.sendFactory = sendFactory;
// }
//
// // ==================================================================
// // = Methods that you can call
// // ==================================================================
//
// public void provideVoiceServerUpdate(String sessionId, JSONObject serverUpdateEvent)
// {
// //More to do here.
// vsuHandler.handle(sessionId, serverUpdateEvent);
// }
//
// public AudioManager getAudioManager(String guildId)
// {
// AudioManager manager = audioManagers.get(guildId);
// if (manager == null)
// {
// synchronized (audioManagers)
// {
// manager = audioManagers.get(guildId);
// if (manager == null)
// {
// manager = new AudioManager(this, guildId);
// audioManagers.put(guildId, manager);
// }
// }
// }
//
// return manager;
// }
//
// public IAudioSendFactory getSendFactory()
// {
// return sendFactory;
// }
//
// // ====================================================================
// // = Helper Methods
// // ====================================================================
//
// public ConnectionManager getConnectionManager()
// {
// return connManager;
// }
//
// public CoreClient getClient()
// {
// return coreClient;
// }
//
// public ScheduledThreadPoolExecutor getAudioKeepAlivePool()
// {
// return audioKeepAlivePool;
// }
//
// public String getUserId()
// {
// return userId;
// }
// }
//
// Path: src/main/java/net/dv8tion/jda/CoreClient.java
// public interface CoreClient
// {
// void sendWS(String message);
// boolean isConnected();
// boolean inGuild(String guildId);
// boolean voiceChannelExists(String guildId, String channelId);
// boolean hasPermissionInChannel(String guildId, String channelId, long permission);
// }
| import com.neovisionaries.ws.client.*;
import net.dv8tion.jda.Core;
import net.dv8tion.jda.CoreClient;
import org.json.JSONObject;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | /*
* Copyright 2015-2017 Austin Keener & Michael Ritter
*
* 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.
*/
public class WebSocketExample extends WebSocketAdapter
{
public static void main(String[] args) throws IOException, WebSocketException
{
//Provide user id of the logged in account.
String userId = "";
new WebSocketExample(userId);
}
// =============================================
| // Path: src/main/java/net/dv8tion/jda/Core.java
// public class Core
// {
// public static SimpleLog LOG = SimpleLog.getLog("Core");
//
// private final HashMap<String, AudioManager> audioManagers = new HashMap<>();
// private final ConnectionManager connManager;
// private final ScheduledThreadPoolExecutor audioKeepAlivePool;
// private final VoiceServerUpdateHandler vsuHandler;
// private final String userId;
// private final CoreClient coreClient;
// private final IAudioSendFactory sendFactory;
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// */
// public Core(String userId, CoreClient coreClient)
// {
// this(userId, coreClient, DefaultConnectionManager::new, new DefaultSendFactory());
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param sendFactory the {@link net.dv8tion.jda.audio.factory.IAudioSendFactory} to use.
// */
// public Core(String userId, CoreClient coreClient, IAudioSendFactory sendFactory) {
// this(userId, coreClient, DefaultConnectionManager::new, sendFactory);
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param connectionManagerBuilder connection manager to use
// */
// public Core(String userId, CoreClient coreClient, ConnectionManagerBuilder connectionManagerBuilder) {
// this(userId, coreClient, connectionManagerBuilder, new DefaultSendFactory());
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param connectionManagerBuilder Connection manager builder
// * @param sendFactory the {@link net.dv8tion.jda.audio.factory.IAudioSendFactory} to use.
// */
// public Core(String userId, CoreClient coreClient, ConnectionManagerBuilder connectionManagerBuilder, IAudioSendFactory sendFactory)
// {
// this.userId = userId;
// this.coreClient = coreClient;
// this.vsuHandler = new VoiceServerUpdateHandler(this);
// this.connManager = connectionManagerBuilder.build(this);
// this.audioKeepAlivePool = new ScheduledThreadPoolExecutor(1, new AudioWebSocket.KeepAliveThreadFactory());
// this.sendFactory = sendFactory;
// }
//
// // ==================================================================
// // = Methods that you can call
// // ==================================================================
//
// public void provideVoiceServerUpdate(String sessionId, JSONObject serverUpdateEvent)
// {
// //More to do here.
// vsuHandler.handle(sessionId, serverUpdateEvent);
// }
//
// public AudioManager getAudioManager(String guildId)
// {
// AudioManager manager = audioManagers.get(guildId);
// if (manager == null)
// {
// synchronized (audioManagers)
// {
// manager = audioManagers.get(guildId);
// if (manager == null)
// {
// manager = new AudioManager(this, guildId);
// audioManagers.put(guildId, manager);
// }
// }
// }
//
// return manager;
// }
//
// public IAudioSendFactory getSendFactory()
// {
// return sendFactory;
// }
//
// // ====================================================================
// // = Helper Methods
// // ====================================================================
//
// public ConnectionManager getConnectionManager()
// {
// return connManager;
// }
//
// public CoreClient getClient()
// {
// return coreClient;
// }
//
// public ScheduledThreadPoolExecutor getAudioKeepAlivePool()
// {
// return audioKeepAlivePool;
// }
//
// public String getUserId()
// {
// return userId;
// }
// }
//
// Path: src/main/java/net/dv8tion/jda/CoreClient.java
// public interface CoreClient
// {
// void sendWS(String message);
// boolean isConnected();
// boolean inGuild(String guildId);
// boolean voiceChannelExists(String guildId, String channelId);
// boolean hasPermissionInChannel(String guildId, String channelId, long permission);
// }
// Path: src/examples/java/WebSocketExample.java
import com.neovisionaries.ws.client.*;
import net.dv8tion.jda.Core;
import net.dv8tion.jda.CoreClient;
import org.json.JSONObject;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/*
* Copyright 2015-2017 Austin Keener & Michael Ritter
*
* 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.
*/
public class WebSocketExample extends WebSocketAdapter
{
public static void main(String[] args) throws IOException, WebSocketException
{
//Provide user id of the logged in account.
String userId = "";
new WebSocketExample(userId);
}
// =============================================
| private final HashMap<String, Core> cores = new HashMap<>(); |
DV8FromTheWorld/JDA-Audio | src/examples/java/WebSocketExample.java | // Path: src/main/java/net/dv8tion/jda/Core.java
// public class Core
// {
// public static SimpleLog LOG = SimpleLog.getLog("Core");
//
// private final HashMap<String, AudioManager> audioManagers = new HashMap<>();
// private final ConnectionManager connManager;
// private final ScheduledThreadPoolExecutor audioKeepAlivePool;
// private final VoiceServerUpdateHandler vsuHandler;
// private final String userId;
// private final CoreClient coreClient;
// private final IAudioSendFactory sendFactory;
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// */
// public Core(String userId, CoreClient coreClient)
// {
// this(userId, coreClient, DefaultConnectionManager::new, new DefaultSendFactory());
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param sendFactory the {@link net.dv8tion.jda.audio.factory.IAudioSendFactory} to use.
// */
// public Core(String userId, CoreClient coreClient, IAudioSendFactory sendFactory) {
// this(userId, coreClient, DefaultConnectionManager::new, sendFactory);
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param connectionManagerBuilder connection manager to use
// */
// public Core(String userId, CoreClient coreClient, ConnectionManagerBuilder connectionManagerBuilder) {
// this(userId, coreClient, connectionManagerBuilder, new DefaultSendFactory());
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param connectionManagerBuilder Connection manager builder
// * @param sendFactory the {@link net.dv8tion.jda.audio.factory.IAudioSendFactory} to use.
// */
// public Core(String userId, CoreClient coreClient, ConnectionManagerBuilder connectionManagerBuilder, IAudioSendFactory sendFactory)
// {
// this.userId = userId;
// this.coreClient = coreClient;
// this.vsuHandler = new VoiceServerUpdateHandler(this);
// this.connManager = connectionManagerBuilder.build(this);
// this.audioKeepAlivePool = new ScheduledThreadPoolExecutor(1, new AudioWebSocket.KeepAliveThreadFactory());
// this.sendFactory = sendFactory;
// }
//
// // ==================================================================
// // = Methods that you can call
// // ==================================================================
//
// public void provideVoiceServerUpdate(String sessionId, JSONObject serverUpdateEvent)
// {
// //More to do here.
// vsuHandler.handle(sessionId, serverUpdateEvent);
// }
//
// public AudioManager getAudioManager(String guildId)
// {
// AudioManager manager = audioManagers.get(guildId);
// if (manager == null)
// {
// synchronized (audioManagers)
// {
// manager = audioManagers.get(guildId);
// if (manager == null)
// {
// manager = new AudioManager(this, guildId);
// audioManagers.put(guildId, manager);
// }
// }
// }
//
// return manager;
// }
//
// public IAudioSendFactory getSendFactory()
// {
// return sendFactory;
// }
//
// // ====================================================================
// // = Helper Methods
// // ====================================================================
//
// public ConnectionManager getConnectionManager()
// {
// return connManager;
// }
//
// public CoreClient getClient()
// {
// return coreClient;
// }
//
// public ScheduledThreadPoolExecutor getAudioKeepAlivePool()
// {
// return audioKeepAlivePool;
// }
//
// public String getUserId()
// {
// return userId;
// }
// }
//
// Path: src/main/java/net/dv8tion/jda/CoreClient.java
// public interface CoreClient
// {
// void sendWS(String message);
// boolean isConnected();
// boolean inGuild(String guildId);
// boolean voiceChannelExists(String guildId, String channelId);
// boolean hasPermissionInChannel(String guildId, String channelId, long permission);
// }
| import com.neovisionaries.ws.client.*;
import net.dv8tion.jda.Core;
import net.dv8tion.jda.CoreClient;
import org.json.JSONObject;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | }
@Override
public void onDisconnected(WebSocket websocket,
WebSocketFrame serverCloseFrame, WebSocketFrame clientCloseFrame,
boolean closedByServer) throws Exception
{
System.out.println("Disconnected from localhost WS. Might wanna build a reconnect system!");
}
private Core getCore(String identifier)
{
Core core = cores.get(identifier);
if (core == null)
{
synchronized (cores)
{
core = cores.get(identifier);
if (core == null)
{
core = new Core(userId, new MyCoreClient(identifier));
cores.put(identifier, core);
}
}
}
return core;
}
| // Path: src/main/java/net/dv8tion/jda/Core.java
// public class Core
// {
// public static SimpleLog LOG = SimpleLog.getLog("Core");
//
// private final HashMap<String, AudioManager> audioManagers = new HashMap<>();
// private final ConnectionManager connManager;
// private final ScheduledThreadPoolExecutor audioKeepAlivePool;
// private final VoiceServerUpdateHandler vsuHandler;
// private final String userId;
// private final CoreClient coreClient;
// private final IAudioSendFactory sendFactory;
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// */
// public Core(String userId, CoreClient coreClient)
// {
// this(userId, coreClient, DefaultConnectionManager::new, new DefaultSendFactory());
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param sendFactory the {@link net.dv8tion.jda.audio.factory.IAudioSendFactory} to use.
// */
// public Core(String userId, CoreClient coreClient, IAudioSendFactory sendFactory) {
// this(userId, coreClient, DefaultConnectionManager::new, sendFactory);
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param connectionManagerBuilder connection manager to use
// */
// public Core(String userId, CoreClient coreClient, ConnectionManagerBuilder connectionManagerBuilder) {
// this(userId, coreClient, connectionManagerBuilder, new DefaultSendFactory());
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param connectionManagerBuilder Connection manager builder
// * @param sendFactory the {@link net.dv8tion.jda.audio.factory.IAudioSendFactory} to use.
// */
// public Core(String userId, CoreClient coreClient, ConnectionManagerBuilder connectionManagerBuilder, IAudioSendFactory sendFactory)
// {
// this.userId = userId;
// this.coreClient = coreClient;
// this.vsuHandler = new VoiceServerUpdateHandler(this);
// this.connManager = connectionManagerBuilder.build(this);
// this.audioKeepAlivePool = new ScheduledThreadPoolExecutor(1, new AudioWebSocket.KeepAliveThreadFactory());
// this.sendFactory = sendFactory;
// }
//
// // ==================================================================
// // = Methods that you can call
// // ==================================================================
//
// public void provideVoiceServerUpdate(String sessionId, JSONObject serverUpdateEvent)
// {
// //More to do here.
// vsuHandler.handle(sessionId, serverUpdateEvent);
// }
//
// public AudioManager getAudioManager(String guildId)
// {
// AudioManager manager = audioManagers.get(guildId);
// if (manager == null)
// {
// synchronized (audioManagers)
// {
// manager = audioManagers.get(guildId);
// if (manager == null)
// {
// manager = new AudioManager(this, guildId);
// audioManagers.put(guildId, manager);
// }
// }
// }
//
// return manager;
// }
//
// public IAudioSendFactory getSendFactory()
// {
// return sendFactory;
// }
//
// // ====================================================================
// // = Helper Methods
// // ====================================================================
//
// public ConnectionManager getConnectionManager()
// {
// return connManager;
// }
//
// public CoreClient getClient()
// {
// return coreClient;
// }
//
// public ScheduledThreadPoolExecutor getAudioKeepAlivePool()
// {
// return audioKeepAlivePool;
// }
//
// public String getUserId()
// {
// return userId;
// }
// }
//
// Path: src/main/java/net/dv8tion/jda/CoreClient.java
// public interface CoreClient
// {
// void sendWS(String message);
// boolean isConnected();
// boolean inGuild(String guildId);
// boolean voiceChannelExists(String guildId, String channelId);
// boolean hasPermissionInChannel(String guildId, String channelId, long permission);
// }
// Path: src/examples/java/WebSocketExample.java
import com.neovisionaries.ws.client.*;
import net.dv8tion.jda.Core;
import net.dv8tion.jda.CoreClient;
import org.json.JSONObject;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
}
@Override
public void onDisconnected(WebSocket websocket,
WebSocketFrame serverCloseFrame, WebSocketFrame clientCloseFrame,
boolean closedByServer) throws Exception
{
System.out.println("Disconnected from localhost WS. Might wanna build a reconnect system!");
}
private Core getCore(String identifier)
{
Core core = cores.get(identifier);
if (core == null)
{
synchronized (cores)
{
core = cores.get(identifier);
if (core == null)
{
core = new Core(userId, new MyCoreClient(identifier));
cores.put(identifier, core);
}
}
}
return core;
}
| private class MyCoreClient implements CoreClient |
DV8FromTheWorld/JDA-Audio | src/examples/java/Tester.java | // Path: src/main/java/net/dv8tion/jda/Core.java
// public class Core
// {
// public static SimpleLog LOG = SimpleLog.getLog("Core");
//
// private final HashMap<String, AudioManager> audioManagers = new HashMap<>();
// private final ConnectionManager connManager;
// private final ScheduledThreadPoolExecutor audioKeepAlivePool;
// private final VoiceServerUpdateHandler vsuHandler;
// private final String userId;
// private final CoreClient coreClient;
// private final IAudioSendFactory sendFactory;
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// */
// public Core(String userId, CoreClient coreClient)
// {
// this(userId, coreClient, DefaultConnectionManager::new, new DefaultSendFactory());
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param sendFactory the {@link net.dv8tion.jda.audio.factory.IAudioSendFactory} to use.
// */
// public Core(String userId, CoreClient coreClient, IAudioSendFactory sendFactory) {
// this(userId, coreClient, DefaultConnectionManager::new, sendFactory);
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param connectionManagerBuilder connection manager to use
// */
// public Core(String userId, CoreClient coreClient, ConnectionManagerBuilder connectionManagerBuilder) {
// this(userId, coreClient, connectionManagerBuilder, new DefaultSendFactory());
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param connectionManagerBuilder Connection manager builder
// * @param sendFactory the {@link net.dv8tion.jda.audio.factory.IAudioSendFactory} to use.
// */
// public Core(String userId, CoreClient coreClient, ConnectionManagerBuilder connectionManagerBuilder, IAudioSendFactory sendFactory)
// {
// this.userId = userId;
// this.coreClient = coreClient;
// this.vsuHandler = new VoiceServerUpdateHandler(this);
// this.connManager = connectionManagerBuilder.build(this);
// this.audioKeepAlivePool = new ScheduledThreadPoolExecutor(1, new AudioWebSocket.KeepAliveThreadFactory());
// this.sendFactory = sendFactory;
// }
//
// // ==================================================================
// // = Methods that you can call
// // ==================================================================
//
// public void provideVoiceServerUpdate(String sessionId, JSONObject serverUpdateEvent)
// {
// //More to do here.
// vsuHandler.handle(sessionId, serverUpdateEvent);
// }
//
// public AudioManager getAudioManager(String guildId)
// {
// AudioManager manager = audioManagers.get(guildId);
// if (manager == null)
// {
// synchronized (audioManagers)
// {
// manager = audioManagers.get(guildId);
// if (manager == null)
// {
// manager = new AudioManager(this, guildId);
// audioManagers.put(guildId, manager);
// }
// }
// }
//
// return manager;
// }
//
// public IAudioSendFactory getSendFactory()
// {
// return sendFactory;
// }
//
// // ====================================================================
// // = Helper Methods
// // ====================================================================
//
// public ConnectionManager getConnectionManager()
// {
// return connManager;
// }
//
// public CoreClient getClient()
// {
// return coreClient;
// }
//
// public ScheduledThreadPoolExecutor getAudioKeepAlivePool()
// {
// return audioKeepAlivePool;
// }
//
// public String getUserId()
// {
// return userId;
// }
// }
//
// Path: src/main/java/net/dv8tion/jda/CoreClient.java
// public interface CoreClient
// {
// void sendWS(String message);
// boolean isConnected();
// boolean inGuild(String guildId);
// boolean voiceChannelExists(String guildId, String channelId);
// boolean hasPermissionInChannel(String guildId, String channelId, long permission);
// }
| import net.dv8tion.jda.Core;
import net.dv8tion.jda.CoreClient;
import org.json.JSONObject; | /*
* Copyright 2015-2017 Austin Keener & Michael Ritter
*
* 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.
*/
public class Tester
{
public static void main(String[] args)
{
String userId = "111761808640978944"; //This is Yui's Id, just as an example. Should be id of bot connected to MainWS | // Path: src/main/java/net/dv8tion/jda/Core.java
// public class Core
// {
// public static SimpleLog LOG = SimpleLog.getLog("Core");
//
// private final HashMap<String, AudioManager> audioManagers = new HashMap<>();
// private final ConnectionManager connManager;
// private final ScheduledThreadPoolExecutor audioKeepAlivePool;
// private final VoiceServerUpdateHandler vsuHandler;
// private final String userId;
// private final CoreClient coreClient;
// private final IAudioSendFactory sendFactory;
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// */
// public Core(String userId, CoreClient coreClient)
// {
// this(userId, coreClient, DefaultConnectionManager::new, new DefaultSendFactory());
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param sendFactory the {@link net.dv8tion.jda.audio.factory.IAudioSendFactory} to use.
// */
// public Core(String userId, CoreClient coreClient, IAudioSendFactory sendFactory) {
// this(userId, coreClient, DefaultConnectionManager::new, sendFactory);
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param connectionManagerBuilder connection manager to use
// */
// public Core(String userId, CoreClient coreClient, ConnectionManagerBuilder connectionManagerBuilder) {
// this(userId, coreClient, connectionManagerBuilder, new DefaultSendFactory());
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param connectionManagerBuilder Connection manager builder
// * @param sendFactory the {@link net.dv8tion.jda.audio.factory.IAudioSendFactory} to use.
// */
// public Core(String userId, CoreClient coreClient, ConnectionManagerBuilder connectionManagerBuilder, IAudioSendFactory sendFactory)
// {
// this.userId = userId;
// this.coreClient = coreClient;
// this.vsuHandler = new VoiceServerUpdateHandler(this);
// this.connManager = connectionManagerBuilder.build(this);
// this.audioKeepAlivePool = new ScheduledThreadPoolExecutor(1, new AudioWebSocket.KeepAliveThreadFactory());
// this.sendFactory = sendFactory;
// }
//
// // ==================================================================
// // = Methods that you can call
// // ==================================================================
//
// public void provideVoiceServerUpdate(String sessionId, JSONObject serverUpdateEvent)
// {
// //More to do here.
// vsuHandler.handle(sessionId, serverUpdateEvent);
// }
//
// public AudioManager getAudioManager(String guildId)
// {
// AudioManager manager = audioManagers.get(guildId);
// if (manager == null)
// {
// synchronized (audioManagers)
// {
// manager = audioManagers.get(guildId);
// if (manager == null)
// {
// manager = new AudioManager(this, guildId);
// audioManagers.put(guildId, manager);
// }
// }
// }
//
// return manager;
// }
//
// public IAudioSendFactory getSendFactory()
// {
// return sendFactory;
// }
//
// // ====================================================================
// // = Helper Methods
// // ====================================================================
//
// public ConnectionManager getConnectionManager()
// {
// return connManager;
// }
//
// public CoreClient getClient()
// {
// return coreClient;
// }
//
// public ScheduledThreadPoolExecutor getAudioKeepAlivePool()
// {
// return audioKeepAlivePool;
// }
//
// public String getUserId()
// {
// return userId;
// }
// }
//
// Path: src/main/java/net/dv8tion/jda/CoreClient.java
// public interface CoreClient
// {
// void sendWS(String message);
// boolean isConnected();
// boolean inGuild(String guildId);
// boolean voiceChannelExists(String guildId, String channelId);
// boolean hasPermissionInChannel(String guildId, String channelId, long permission);
// }
// Path: src/examples/java/Tester.java
import net.dv8tion.jda.Core;
import net.dv8tion.jda.CoreClient;
import org.json.JSONObject;
/*
* Copyright 2015-2017 Austin Keener & Michael Ritter
*
* 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.
*/
public class Tester
{
public static void main(String[] args)
{
String userId = "111761808640978944"; //This is Yui's Id, just as an example. Should be id of bot connected to MainWS | Core core = new Core(userId, new CoreClient() { |
DV8FromTheWorld/JDA-Audio | src/examples/java/Tester.java | // Path: src/main/java/net/dv8tion/jda/Core.java
// public class Core
// {
// public static SimpleLog LOG = SimpleLog.getLog("Core");
//
// private final HashMap<String, AudioManager> audioManagers = new HashMap<>();
// private final ConnectionManager connManager;
// private final ScheduledThreadPoolExecutor audioKeepAlivePool;
// private final VoiceServerUpdateHandler vsuHandler;
// private final String userId;
// private final CoreClient coreClient;
// private final IAudioSendFactory sendFactory;
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// */
// public Core(String userId, CoreClient coreClient)
// {
// this(userId, coreClient, DefaultConnectionManager::new, new DefaultSendFactory());
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param sendFactory the {@link net.dv8tion.jda.audio.factory.IAudioSendFactory} to use.
// */
// public Core(String userId, CoreClient coreClient, IAudioSendFactory sendFactory) {
// this(userId, coreClient, DefaultConnectionManager::new, sendFactory);
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param connectionManagerBuilder connection manager to use
// */
// public Core(String userId, CoreClient coreClient, ConnectionManagerBuilder connectionManagerBuilder) {
// this(userId, coreClient, connectionManagerBuilder, new DefaultSendFactory());
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param connectionManagerBuilder Connection manager builder
// * @param sendFactory the {@link net.dv8tion.jda.audio.factory.IAudioSendFactory} to use.
// */
// public Core(String userId, CoreClient coreClient, ConnectionManagerBuilder connectionManagerBuilder, IAudioSendFactory sendFactory)
// {
// this.userId = userId;
// this.coreClient = coreClient;
// this.vsuHandler = new VoiceServerUpdateHandler(this);
// this.connManager = connectionManagerBuilder.build(this);
// this.audioKeepAlivePool = new ScheduledThreadPoolExecutor(1, new AudioWebSocket.KeepAliveThreadFactory());
// this.sendFactory = sendFactory;
// }
//
// // ==================================================================
// // = Methods that you can call
// // ==================================================================
//
// public void provideVoiceServerUpdate(String sessionId, JSONObject serverUpdateEvent)
// {
// //More to do here.
// vsuHandler.handle(sessionId, serverUpdateEvent);
// }
//
// public AudioManager getAudioManager(String guildId)
// {
// AudioManager manager = audioManagers.get(guildId);
// if (manager == null)
// {
// synchronized (audioManagers)
// {
// manager = audioManagers.get(guildId);
// if (manager == null)
// {
// manager = new AudioManager(this, guildId);
// audioManagers.put(guildId, manager);
// }
// }
// }
//
// return manager;
// }
//
// public IAudioSendFactory getSendFactory()
// {
// return sendFactory;
// }
//
// // ====================================================================
// // = Helper Methods
// // ====================================================================
//
// public ConnectionManager getConnectionManager()
// {
// return connManager;
// }
//
// public CoreClient getClient()
// {
// return coreClient;
// }
//
// public ScheduledThreadPoolExecutor getAudioKeepAlivePool()
// {
// return audioKeepAlivePool;
// }
//
// public String getUserId()
// {
// return userId;
// }
// }
//
// Path: src/main/java/net/dv8tion/jda/CoreClient.java
// public interface CoreClient
// {
// void sendWS(String message);
// boolean isConnected();
// boolean inGuild(String guildId);
// boolean voiceChannelExists(String guildId, String channelId);
// boolean hasPermissionInChannel(String guildId, String channelId, long permission);
// }
| import net.dv8tion.jda.Core;
import net.dv8tion.jda.CoreClient;
import org.json.JSONObject; | /*
* Copyright 2015-2017 Austin Keener & Michael Ritter
*
* 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.
*/
public class Tester
{
public static void main(String[] args)
{
String userId = "111761808640978944"; //This is Yui's Id, just as an example. Should be id of bot connected to MainWS | // Path: src/main/java/net/dv8tion/jda/Core.java
// public class Core
// {
// public static SimpleLog LOG = SimpleLog.getLog("Core");
//
// private final HashMap<String, AudioManager> audioManagers = new HashMap<>();
// private final ConnectionManager connManager;
// private final ScheduledThreadPoolExecutor audioKeepAlivePool;
// private final VoiceServerUpdateHandler vsuHandler;
// private final String userId;
// private final CoreClient coreClient;
// private final IAudioSendFactory sendFactory;
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// */
// public Core(String userId, CoreClient coreClient)
// {
// this(userId, coreClient, DefaultConnectionManager::new, new DefaultSendFactory());
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param sendFactory the {@link net.dv8tion.jda.audio.factory.IAudioSendFactory} to use.
// */
// public Core(String userId, CoreClient coreClient, IAudioSendFactory sendFactory) {
// this(userId, coreClient, DefaultConnectionManager::new, sendFactory);
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param connectionManagerBuilder connection manager to use
// */
// public Core(String userId, CoreClient coreClient, ConnectionManagerBuilder connectionManagerBuilder) {
// this(userId, coreClient, connectionManagerBuilder, new DefaultSendFactory());
// }
//
// /**
// * Creates a new Core instance. You should probably have one of these for each shard, but you do you.
// *
// * @param userId The UserId of the bot.
// * @param coreClient used to insert required functionality to connect Core to the MainWS
// * @param connectionManagerBuilder Connection manager builder
// * @param sendFactory the {@link net.dv8tion.jda.audio.factory.IAudioSendFactory} to use.
// */
// public Core(String userId, CoreClient coreClient, ConnectionManagerBuilder connectionManagerBuilder, IAudioSendFactory sendFactory)
// {
// this.userId = userId;
// this.coreClient = coreClient;
// this.vsuHandler = new VoiceServerUpdateHandler(this);
// this.connManager = connectionManagerBuilder.build(this);
// this.audioKeepAlivePool = new ScheduledThreadPoolExecutor(1, new AudioWebSocket.KeepAliveThreadFactory());
// this.sendFactory = sendFactory;
// }
//
// // ==================================================================
// // = Methods that you can call
// // ==================================================================
//
// public void provideVoiceServerUpdate(String sessionId, JSONObject serverUpdateEvent)
// {
// //More to do here.
// vsuHandler.handle(sessionId, serverUpdateEvent);
// }
//
// public AudioManager getAudioManager(String guildId)
// {
// AudioManager manager = audioManagers.get(guildId);
// if (manager == null)
// {
// synchronized (audioManagers)
// {
// manager = audioManagers.get(guildId);
// if (manager == null)
// {
// manager = new AudioManager(this, guildId);
// audioManagers.put(guildId, manager);
// }
// }
// }
//
// return manager;
// }
//
// public IAudioSendFactory getSendFactory()
// {
// return sendFactory;
// }
//
// // ====================================================================
// // = Helper Methods
// // ====================================================================
//
// public ConnectionManager getConnectionManager()
// {
// return connManager;
// }
//
// public CoreClient getClient()
// {
// return coreClient;
// }
//
// public ScheduledThreadPoolExecutor getAudioKeepAlivePool()
// {
// return audioKeepAlivePool;
// }
//
// public String getUserId()
// {
// return userId;
// }
// }
//
// Path: src/main/java/net/dv8tion/jda/CoreClient.java
// public interface CoreClient
// {
// void sendWS(String message);
// boolean isConnected();
// boolean inGuild(String guildId);
// boolean voiceChannelExists(String guildId, String channelId);
// boolean hasPermissionInChannel(String guildId, String channelId, long permission);
// }
// Path: src/examples/java/Tester.java
import net.dv8tion.jda.Core;
import net.dv8tion.jda.CoreClient;
import org.json.JSONObject;
/*
* Copyright 2015-2017 Austin Keener & Michael Ritter
*
* 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.
*/
public class Tester
{
public static void main(String[] args)
{
String userId = "111761808640978944"; //This is Yui's Id, just as an example. Should be id of bot connected to MainWS | Core core = new Core(userId, new CoreClient() { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/place/DoubleLongitudeGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.place;
public class DoubleLongitudeGenerator extends Generator<Double> {
private Random random = new Random();
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/place/DoubleLongitudeGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.place;
public class DoubleLongitudeGenerator extends Generator<Double> {
private Random random = new Random();
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/place/DoubleLongitudeGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.place;
public class DoubleLongitudeGenerator extends Generator<Double> {
private Random random = new Random();
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("lon");
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/place/DoubleLongitudeGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.place;
public class DoubleLongitudeGenerator extends Generator<Double> {
private Random random = new Random();
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("lon");
}
@Override | public Double next(DataContext context) { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/place/StringCountryGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.place;
public class StringCountryGenerator extends Generator<String> {
private String[] names = {"London", "Zadar", "Warszawa"};
private Random random = new Random();
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/place/StringCountryGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.place;
public class StringCountryGenerator extends Generator<String> {
private String[] names = {"London", "Zadar", "Warszawa"};
private Random random = new Random();
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/place/StringCountryGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.place;
public class StringCountryGenerator extends Generator<String> {
private String[] names = {"London", "Zadar", "Warszawa"};
private Random random = new Random();
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("country");
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/place/StringCountryGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.place;
public class StringCountryGenerator extends Generator<String> {
private String[] names = {"London", "Zadar", "Warszawa"};
private Random random = new Random();
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("country");
}
@Override | public String next(DataContext context) { |
ZieIony/RandomData | finance/src/main/java/tk/zielony/randomdata/finance/FloatAmountGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.finance;
public class FloatAmountGenerator extends AmountGenerator<Float> {
public FloatAmountGenerator() {
super();
}
public FloatAmountGenerator(int max, boolean useCommon) {
super(max, useCommon);
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: finance/src/main/java/tk/zielony/randomdata/finance/FloatAmountGenerator.java
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.finance;
public class FloatAmountGenerator extends AmountGenerator<Float> {
public FloatAmountGenerator() {
super();
}
public FloatAmountGenerator(int max, boolean useCommon) {
super(max, useCommon);
}
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | finance/src/main/java/tk/zielony/randomdata/finance/FloatAmountGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.finance;
public class FloatAmountGenerator extends AmountGenerator<Float> {
public FloatAmountGenerator() {
super();
}
public FloatAmountGenerator(int max, boolean useCommon) {
super(max, useCommon);
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("amount");
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: finance/src/main/java/tk/zielony/randomdata/finance/FloatAmountGenerator.java
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.finance;
public class FloatAmountGenerator extends AmountGenerator<Float> {
public FloatAmountGenerator() {
super();
}
public FloatAmountGenerator(int max, boolean useCommon) {
super(max, useCommon);
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("amount");
}
@Override | public Float next(DataContext context) { |
ZieIony/RandomData | person/src/main/java/tk/zielony/randomdata/person/IntegerAgeGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/common/IntegerGenerator.java
// public class IntegerGenerator extends Generator<Integer> {
// private Random random = new Random();
// private int min;
// private int max;
// private int[] array;
//
// public IntegerGenerator() {
// min = 0;
// max = 100;
// }
//
// public IntegerGenerator(int min, int max) {
// this.min = min;
// this.max = max;
// }
//
// public IntegerGenerator(int[] array) {
// this.array = array;
// }
//
// @Override
// public Integer next(DataContext context) {
// return array != null ? array[random.nextInt(array.length)] : random.nextInt(max + 1 - min) + min;
// }
// }
| import tk.zielony.randomdata.Matcher;
import tk.zielony.randomdata.common.IntegerGenerator; | package tk.zielony.randomdata.person;
public class IntegerAgeGenerator extends IntegerGenerator {
public IntegerAgeGenerator() {
super(15, 65);
}
public IntegerAgeGenerator(int min, int max) {
super(min, max);
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/common/IntegerGenerator.java
// public class IntegerGenerator extends Generator<Integer> {
// private Random random = new Random();
// private int min;
// private int max;
// private int[] array;
//
// public IntegerGenerator() {
// min = 0;
// max = 100;
// }
//
// public IntegerGenerator(int min, int max) {
// this.min = min;
// this.max = max;
// }
//
// public IntegerGenerator(int[] array) {
// this.array = array;
// }
//
// @Override
// public Integer next(DataContext context) {
// return array != null ? array[random.nextInt(array.length)] : random.nextInt(max + 1 - min) + min;
// }
// }
// Path: person/src/main/java/tk/zielony/randomdata/person/IntegerAgeGenerator.java
import tk.zielony.randomdata.Matcher;
import tk.zielony.randomdata.common.IntegerGenerator;
package tk.zielony.randomdata.person;
public class IntegerAgeGenerator extends IntegerGenerator {
public IntegerAgeGenerator() {
super(15, 65);
}
public IntegerAgeGenerator(int min, int max) {
super(min, max);
}
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | util/src/main/java/tk/zielony/randomdata/util/StringIPAddressGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
| import androidx.annotation.Nullable;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator; | }
}
private Random random = new Random();
private ClassRange range = ClassRange.A;
public StringIPAddressGenerator() {
}
public StringIPAddressGenerator(ClassRange range) {
this.range = range;
}
public ClassRange getClassRange() {
return range;
}
public void setClassRange(ClassRange range) {
this.range = range;
}
private int generateInitialSection() {
return range.getValue(random);
}
private int generateSubSection() {
return random.nextInt(256);
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
// Path: util/src/main/java/tk/zielony/randomdata/util/StringIPAddressGenerator.java
import androidx.annotation.Nullable;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
}
}
private Random random = new Random();
private ClassRange range = ClassRange.A;
public StringIPAddressGenerator() {
}
public StringIPAddressGenerator(ClassRange range) {
this.range = range;
}
public ClassRange getClassRange() {
return range;
}
public void setClassRange(ClassRange range) {
this.range = range;
}
private int generateInitialSection() {
return range.getValue(random);
}
private int generateSubSection() {
return random.nextInt(256);
}
@Override | public String next(@Nullable DataContext context) { |
ZieIony/RandomData | person/src/main/java/tk/zielony/randomdata/person/DrawableAvatarGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import android.content.Context;
import android.graphics.drawable.Drawable;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.person;
public class DrawableAvatarGenerator extends Generator<Drawable> {
private Context context;
private Random random = new Random();
private Gender gender;
private boolean preventDuplicates;
private Set<Integer> femaleUsed = new HashSet<>();
private Set<Integer> maleUsed = new HashSet<>();
private int[] female = {
R.drawable.randomdata_woman0, R.drawable.randomdata_woman1, R.drawable.randomdata_woman2, R.drawable.randomdata_woman3, R.drawable.randomdata_woman4, R.drawable.randomdata_woman5, R.drawable.randomdata_woman6, R.drawable.randomdata_woman7, R.drawable.randomdata_woman8, R.drawable.randomdata_woman9
};
private int[] male = {
R.drawable.randomdata_man0, R.drawable.randomdata_man1, R.drawable.randomdata_man2, R.drawable.randomdata_man3, R.drawable.randomdata_man4, R.drawable.randomdata_man5, R.drawable.randomdata_man6, R.drawable.randomdata_man7, R.drawable.randomdata_man8, R.drawable.randomdata_man9
};
public DrawableAvatarGenerator(Context context) {
this.context = context;
gender = Gender.Both;
preventDuplicates = true;
}
public DrawableAvatarGenerator(Context context, Gender gender, boolean preventDuplicates) {
this.context = context;
this.gender = gender;
this.preventDuplicates = preventDuplicates;
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: person/src/main/java/tk/zielony/randomdata/person/DrawableAvatarGenerator.java
import android.content.Context;
import android.graphics.drawable.Drawable;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.person;
public class DrawableAvatarGenerator extends Generator<Drawable> {
private Context context;
private Random random = new Random();
private Gender gender;
private boolean preventDuplicates;
private Set<Integer> femaleUsed = new HashSet<>();
private Set<Integer> maleUsed = new HashSet<>();
private int[] female = {
R.drawable.randomdata_woman0, R.drawable.randomdata_woman1, R.drawable.randomdata_woman2, R.drawable.randomdata_woman3, R.drawable.randomdata_woman4, R.drawable.randomdata_woman5, R.drawable.randomdata_woman6, R.drawable.randomdata_woman7, R.drawable.randomdata_woman8, R.drawable.randomdata_woman9
};
private int[] male = {
R.drawable.randomdata_man0, R.drawable.randomdata_man1, R.drawable.randomdata_man2, R.drawable.randomdata_man3, R.drawable.randomdata_man4, R.drawable.randomdata_man5, R.drawable.randomdata_man6, R.drawable.randomdata_man7, R.drawable.randomdata_man8, R.drawable.randomdata_man9
};
public DrawableAvatarGenerator(Context context) {
this.context = context;
gender = Gender.Both;
preventDuplicates = true;
}
public DrawableAvatarGenerator(Context context, Gender gender, boolean preventDuplicates) {
this.context = context;
this.gender = gender;
this.preventDuplicates = preventDuplicates;
}
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | person/src/main/java/tk/zielony/randomdata/person/DrawableAvatarGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import android.content.Context;
import android.graphics.drawable.Drawable;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.person;
public class DrawableAvatarGenerator extends Generator<Drawable> {
private Context context;
private Random random = new Random();
private Gender gender;
private boolean preventDuplicates;
private Set<Integer> femaleUsed = new HashSet<>();
private Set<Integer> maleUsed = new HashSet<>();
private int[] female = {
R.drawable.randomdata_woman0, R.drawable.randomdata_woman1, R.drawable.randomdata_woman2, R.drawable.randomdata_woman3, R.drawable.randomdata_woman4, R.drawable.randomdata_woman5, R.drawable.randomdata_woman6, R.drawable.randomdata_woman7, R.drawable.randomdata_woman8, R.drawable.randomdata_woman9
};
private int[] male = {
R.drawable.randomdata_man0, R.drawable.randomdata_man1, R.drawable.randomdata_man2, R.drawable.randomdata_man3, R.drawable.randomdata_man4, R.drawable.randomdata_man5, R.drawable.randomdata_man6, R.drawable.randomdata_man7, R.drawable.randomdata_man8, R.drawable.randomdata_man9
};
public DrawableAvatarGenerator(Context context) {
this.context = context;
gender = Gender.Both;
preventDuplicates = true;
}
public DrawableAvatarGenerator(Context context, Gender gender, boolean preventDuplicates) {
this.context = context;
this.gender = gender;
this.preventDuplicates = preventDuplicates;
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("avatar");
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: person/src/main/java/tk/zielony/randomdata/person/DrawableAvatarGenerator.java
import android.content.Context;
import android.graphics.drawable.Drawable;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.person;
public class DrawableAvatarGenerator extends Generator<Drawable> {
private Context context;
private Random random = new Random();
private Gender gender;
private boolean preventDuplicates;
private Set<Integer> femaleUsed = new HashSet<>();
private Set<Integer> maleUsed = new HashSet<>();
private int[] female = {
R.drawable.randomdata_woman0, R.drawable.randomdata_woman1, R.drawable.randomdata_woman2, R.drawable.randomdata_woman3, R.drawable.randomdata_woman4, R.drawable.randomdata_woman5, R.drawable.randomdata_woman6, R.drawable.randomdata_woman7, R.drawable.randomdata_woman8, R.drawable.randomdata_woman9
};
private int[] male = {
R.drawable.randomdata_man0, R.drawable.randomdata_man1, R.drawable.randomdata_man2, R.drawable.randomdata_man3, R.drawable.randomdata_man4, R.drawable.randomdata_man5, R.drawable.randomdata_man6, R.drawable.randomdata_man7, R.drawable.randomdata_man8, R.drawable.randomdata_man9
};
public DrawableAvatarGenerator(Context context) {
this.context = context;
gender = Gender.Both;
preventDuplicates = true;
}
public DrawableAvatarGenerator(Context context, Gender gender, boolean preventDuplicates) {
this.context = context;
this.gender = gender;
this.preventDuplicates = preventDuplicates;
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("avatar");
}
@Override | public Drawable next(DataContext dataContext) { |
ZieIony/RandomData | person/src/main/java/tk/zielony/randomdata/person/StringEmailGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.person;
public class StringEmailGenerator extends Generator<String> {
private StringNameGenerator nameGenerator;
private Random random = new Random();
private static String[] domains = {"gmail.com", "yahoo.com", "hotmail.com"};
public StringEmailGenerator() {
nameGenerator = new StringNameGenerator();
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: person/src/main/java/tk/zielony/randomdata/person/StringEmailGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.person;
public class StringEmailGenerator extends Generator<String> {
private StringNameGenerator nameGenerator;
private Random random = new Random();
private static String[] domains = {"gmail.com", "yahoo.com", "hotmail.com"};
public StringEmailGenerator() {
nameGenerator = new StringNameGenerator();
}
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | person/src/main/java/tk/zielony/randomdata/person/StringEmailGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.person;
public class StringEmailGenerator extends Generator<String> {
private StringNameGenerator nameGenerator;
private Random random = new Random();
private static String[] domains = {"gmail.com", "yahoo.com", "hotmail.com"};
public StringEmailGenerator() {
nameGenerator = new StringNameGenerator();
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("email");
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: person/src/main/java/tk/zielony/randomdata/person/StringEmailGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.person;
public class StringEmailGenerator extends Generator<String> {
private StringNameGenerator nameGenerator;
private Random random = new Random();
private static String[] domains = {"gmail.com", "yahoo.com", "hotmail.com"};
public StringEmailGenerator() {
nameGenerator = new StringNameGenerator();
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("email");
}
@Override | public String next(DataContext context) { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/place/DoubleAltitudeGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.place;
public class DoubleAltitudeGenerator extends Generator<Double> {
private Random random = new Random();
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/place/DoubleAltitudeGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.place;
public class DoubleAltitudeGenerator extends Generator<Double> {
private Random random = new Random();
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/place/DoubleAltitudeGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.place;
public class DoubleAltitudeGenerator extends Generator<Double> {
private Random random = new Random();
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("alt");
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/place/DoubleAltitudeGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.place;
public class DoubleAltitudeGenerator extends Generator<Double> {
private Random random = new Random();
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("alt");
}
@Override | public Double next(DataContext context) { |
ZieIony/RandomData | finance/src/main/java/tk/zielony/randomdata/finance/AmountGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Currency;
import java.util.Locale;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.finance;
public abstract class AmountGenerator<Type> extends Generator<Type> {
private Random random = new Random();
private float max;
private boolean useCommon;
private float[] common = {0.00f, 0.25f, 0.49f, 0.50f, 0.75f, 0.95f, 0.99f};
public AmountGenerator() {
max = 1000;
useCommon = true;
}
public AmountGenerator(int max, boolean useCommon) {
this.max = max;
this.useCommon = useCommon;
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: finance/src/main/java/tk/zielony/randomdata/finance/AmountGenerator.java
import java.util.Currency;
import java.util.Locale;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.finance;
public abstract class AmountGenerator<Type> extends Generator<Type> {
private Random random = new Random();
private float max;
private boolean useCommon;
private float[] common = {0.00f, 0.25f, 0.49f, 0.50f, 0.75f, 0.95f, 0.99f};
public AmountGenerator() {
max = 1000;
useCommon = true;
}
public AmountGenerator(int max, boolean useCommon) {
this.max = max;
this.useCommon = useCommon;
}
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | finance/src/main/java/tk/zielony/randomdata/finance/AmountGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Currency;
import java.util.Locale;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.finance;
public abstract class AmountGenerator<Type> extends Generator<Type> {
private Random random = new Random();
private float max;
private boolean useCommon;
private float[] common = {0.00f, 0.25f, 0.49f, 0.50f, 0.75f, 0.95f, 0.99f};
public AmountGenerator() {
max = 1000;
useCommon = true;
}
public AmountGenerator(int max, boolean useCommon) {
this.max = max;
this.useCommon = useCommon;
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("amount");
}
| // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: finance/src/main/java/tk/zielony/randomdata/finance/AmountGenerator.java
import java.util.Currency;
import java.util.Locale;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.finance;
public abstract class AmountGenerator<Type> extends Generator<Type> {
private Random random = new Random();
private float max;
private boolean useCommon;
private float[] common = {0.00f, 0.25f, 0.49f, 0.50f, 0.75f, 0.95f, 0.99f};
public AmountGenerator() {
max = 1000;
useCommon = true;
}
public AmountGenerator(int max, boolean useCommon) {
this.max = max;
this.useCommon = useCommon;
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("amount");
}
| public float next2(DataContext context) { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/common/EnumGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
| import androidx.annotation.Nullable;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator; | package tk.zielony.randomdata.common;
public class EnumGenerator<Type extends Enum<Type>> extends Generator<Type> {
private Class<Type> type;
private Random random = new Random();
public EnumGenerator(Class<Type> type) {
this.type = type;
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
// Path: lib/src/main/java/tk/zielony/randomdata/common/EnumGenerator.java
import androidx.annotation.Nullable;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
package tk.zielony.randomdata.common;
public class EnumGenerator<Type extends Enum<Type>> extends Generator<Type> {
private Class<Type> type;
private Random random = new Random();
public EnumGenerator(Class<Type> type) {
this.type = type;
}
@Override | public Type next(@Nullable DataContext context) { |
ZieIony/RandomData | person/src/main/java/tk/zielony/randomdata/person/StringPhoneGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.person;
public class StringPhoneGenerator extends Generator<String> {
private Random random = new Random();
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: person/src/main/java/tk/zielony/randomdata/person/StringPhoneGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.person;
public class StringPhoneGenerator extends Generator<String> {
private Random random = new Random();
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | person/src/main/java/tk/zielony/randomdata/person/StringPhoneGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.person;
public class StringPhoneGenerator extends Generator<String> {
private Random random = new Random();
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("phone");
}
// TODO: support country code stored in DataContext
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: person/src/main/java/tk/zielony/randomdata/person/StringPhoneGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.person;
public class StringPhoneGenerator extends Generator<String> {
private Random random = new Random();
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("phone");
}
// TODO: support country code stored in DataContext
@Override | public String next(DataContext context) { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/common/BooleanGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator; | package tk.zielony.randomdata.common;
public class BooleanGenerator extends Generator<Boolean> {
private Random random = new Random();
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
// Path: lib/src/main/java/tk/zielony/randomdata/common/BooleanGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
package tk.zielony.randomdata.common;
public class BooleanGenerator extends Generator<Boolean> {
private Random random = new Random();
@Override | public Boolean next(DataContext context) { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/common/StringHashGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.common;
public class StringHashGenerator extends Generator<String> {
private Random random = new Random();
private int length;
public StringHashGenerator() {
length = 32;
}
public StringHashGenerator(int length) {
this.length = length;
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/common/StringHashGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.common;
public class StringHashGenerator extends Generator<String> {
private Random random = new Random();
private int length;
public StringHashGenerator() {
length = 32;
}
public StringHashGenerator(int length) {
this.length = length;
}
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/common/StringHashGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.common;
public class StringHashGenerator extends Generator<String> {
private Random random = new Random();
private int length;
public StringHashGenerator() {
length = 32;
}
public StringHashGenerator(int length) {
this.length = length;
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("hash");
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/common/StringHashGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.common;
public class StringHashGenerator extends Generator<String> {
private Random random = new Random();
private int length;
public StringHashGenerator() {
length = 32;
}
public StringHashGenerator(int length) {
this.length = length;
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("hash");
}
@Override | public String next(DataContext context) { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/common/LongIdGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.common;
public class LongIdGenerator extends Generator<Long> {
private long id = 0;
private long startId;
public LongIdGenerator() {
startId = 0;
}
public LongIdGenerator(long startId) {
this.startId = startId;
id = startId;
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/common/LongIdGenerator.java
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.common;
public class LongIdGenerator extends Generator<Long> {
private long id = 0;
private long startId;
public LongIdGenerator() {
startId = 0;
}
public LongIdGenerator(long startId) {
this.startId = startId;
id = startId;
}
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/common/LongIdGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.common;
public class LongIdGenerator extends Generator<Long> {
private long id = 0;
private long startId;
public LongIdGenerator() {
startId = 0;
}
public LongIdGenerator(long startId) {
this.startId = startId;
id = startId;
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().equals("id");
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/common/LongIdGenerator.java
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.common;
public class LongIdGenerator extends Generator<Long> {
private long id = 0;
private long startId;
public LongIdGenerator() {
startId = 0;
}
public LongIdGenerator(long startId) {
this.startId = startId;
id = startId;
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().equals("id");
}
@Override | public Long next(DataContext context) { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/place/DoubleLatitudeGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.place;
public class DoubleLatitudeGenerator extends Generator<Double> {
private Random random = new Random();
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/place/DoubleLatitudeGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.place;
public class DoubleLatitudeGenerator extends Generator<Double> {
private Random random = new Random();
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/place/DoubleLatitudeGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.place;
public class DoubleLatitudeGenerator extends Generator<Double> {
private Random random = new Random();
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("lat");
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/place/DoubleLatitudeGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.place;
public class DoubleLatitudeGenerator extends Generator<Double> {
private Random random = new Random();
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("lat");
}
@Override | public Double next(DataContext context) { |
ZieIony/RandomData | person/src/main/java/tk/zielony/randomdata/person/StringGenderGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.person;
public class StringGenderGenerator extends Generator<String> {
private Random random = new Random();
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: person/src/main/java/tk/zielony/randomdata/person/StringGenderGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.person;
public class StringGenderGenerator extends Generator<String> {
private Random random = new Random();
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | person/src/main/java/tk/zielony/randomdata/person/StringGenderGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.person;
public class StringGenderGenerator extends Generator<String> {
private Random random = new Random();
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && (f.getName().equals("gender") || f.getName().equals("sex"));
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: person/src/main/java/tk/zielony/randomdata/person/StringGenderGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.person;
public class StringGenderGenerator extends Generator<String> {
private Random random = new Random();
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && (f.getName().equals("gender") || f.getName().equals("sex"));
}
@Override | public String next(DataContext context) { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/common/TextGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.common;
public class TextGenerator extends Generator<String> {
private static String[] loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin nibh augue, suscipit a, scelerisque sed, lacinia in, mi. Cras vel lorem. Etiam pellentesque aliquet tellus. Phasellus pharetra nulla ac diam. Quisque semper justo at risus. Donec venenatis, turpis vel hendrerit interdum, dui ligula ultricies purus, sed posuere libero dui id orci. Nam congue, pede vitae dapibus aliquet, elit magna vulputate arcu, vel tempus metus leo non est. Etiam sit amet lectus quis est congue mollis. Phasellus congue lacus eget neque. Phasellus ornare, ante vitae consectetuer consequat, purus sapien ultricies dolor, et mollis pede metus eget nisi. Praesent sodales velit quis augue. Cras suscipit, urna at aliquam rhoncus, urna quam viverra nisi, in interdum massa nibh nec erat. ".split("\\. ");
private int sentences;
private boolean useSequence;
private int sequence;
public TextGenerator() {
sentences = 1;
useSequence = true;
}
public TextGenerator(int sentences, boolean useSequence) {
this.sentences = sentences;
this.useSequence = useSequence;
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/common/TextGenerator.java
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.common;
public class TextGenerator extends Generator<String> {
private static String[] loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin nibh augue, suscipit a, scelerisque sed, lacinia in, mi. Cras vel lorem. Etiam pellentesque aliquet tellus. Phasellus pharetra nulla ac diam. Quisque semper justo at risus. Donec venenatis, turpis vel hendrerit interdum, dui ligula ultricies purus, sed posuere libero dui id orci. Nam congue, pede vitae dapibus aliquet, elit magna vulputate arcu, vel tempus metus leo non est. Etiam sit amet lectus quis est congue mollis. Phasellus congue lacus eget neque. Phasellus ornare, ante vitae consectetuer consequat, purus sapien ultricies dolor, et mollis pede metus eget nisi. Praesent sodales velit quis augue. Cras suscipit, urna at aliquam rhoncus, urna quam viverra nisi, in interdum massa nibh nec erat. ".split("\\. ");
private int sentences;
private boolean useSequence;
private int sequence;
public TextGenerator() {
sentences = 1;
useSequence = true;
}
public TextGenerator(int sentences, boolean useSequence) {
this.sentences = sentences;
this.useSequence = useSequence;
}
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/common/TextGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.common;
public class TextGenerator extends Generator<String> {
private static String[] loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin nibh augue, suscipit a, scelerisque sed, lacinia in, mi. Cras vel lorem. Etiam pellentesque aliquet tellus. Phasellus pharetra nulla ac diam. Quisque semper justo at risus. Donec venenatis, turpis vel hendrerit interdum, dui ligula ultricies purus, sed posuere libero dui id orci. Nam congue, pede vitae dapibus aliquet, elit magna vulputate arcu, vel tempus metus leo non est. Etiam sit amet lectus quis est congue mollis. Phasellus congue lacus eget neque. Phasellus ornare, ante vitae consectetuer consequat, purus sapien ultricies dolor, et mollis pede metus eget nisi. Praesent sodales velit quis augue. Cras suscipit, urna at aliquam rhoncus, urna quam viverra nisi, in interdum massa nibh nec erat. ".split("\\. ");
private int sentences;
private boolean useSequence;
private int sequence;
public TextGenerator() {
sentences = 1;
useSequence = true;
}
public TextGenerator(int sentences, boolean useSequence) {
this.sentences = sentences;
this.useSequence = useSequence;
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && (f.getName().contains("description") || f.getName().contains("text"));
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/common/TextGenerator.java
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.common;
public class TextGenerator extends Generator<String> {
private static String[] loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin nibh augue, suscipit a, scelerisque sed, lacinia in, mi. Cras vel lorem. Etiam pellentesque aliquet tellus. Phasellus pharetra nulla ac diam. Quisque semper justo at risus. Donec venenatis, turpis vel hendrerit interdum, dui ligula ultricies purus, sed posuere libero dui id orci. Nam congue, pede vitae dapibus aliquet, elit magna vulputate arcu, vel tempus metus leo non est. Etiam sit amet lectus quis est congue mollis. Phasellus congue lacus eget neque. Phasellus ornare, ante vitae consectetuer consequat, purus sapien ultricies dolor, et mollis pede metus eget nisi. Praesent sodales velit quis augue. Cras suscipit, urna at aliquam rhoncus, urna quam viverra nisi, in interdum massa nibh nec erat. ".split("\\. ");
private int sentences;
private boolean useSequence;
private int sequence;
public TextGenerator() {
sentences = 1;
useSequence = true;
}
public TextGenerator(int sentences, boolean useSequence) {
this.sentences = sentences;
this.useSequence = useSequence;
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && (f.getName().contains("description") || f.getName().contains("text"));
}
@Override | public String next(DataContext context) { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/common/DrawableImageGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
| import android.content.Context;
import android.graphics.drawable.Drawable;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.R; | package tk.zielony.randomdata.common;
public class DrawableImageGenerator extends Generator<Drawable> {
private Context context;
private Random random = new Random();
private boolean preventDuplicates;
private Set<Integer> used = new HashSet<>();
private int[] images = {
R.drawable.randomdata_background0, R.drawable.randomdata_background1, R.drawable.randomdata_background2, R.drawable.randomdata_background3, R.drawable.randomdata_background4
};
public DrawableImageGenerator(Context context) {
this.context = context;
preventDuplicates = true;
}
public DrawableImageGenerator(Context context, boolean preventDuplicates) {
this.context = context;
this.preventDuplicates = preventDuplicates;
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
// Path: lib/src/main/java/tk/zielony/randomdata/common/DrawableImageGenerator.java
import android.content.Context;
import android.graphics.drawable.Drawable;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.R;
package tk.zielony.randomdata.common;
public class DrawableImageGenerator extends Generator<Drawable> {
private Context context;
private Random random = new Random();
private boolean preventDuplicates;
private Set<Integer> used = new HashSet<>();
private int[] images = {
R.drawable.randomdata_background0, R.drawable.randomdata_background1, R.drawable.randomdata_background2, R.drawable.randomdata_background3, R.drawable.randomdata_background4
};
public DrawableImageGenerator(Context context) {
this.context = context;
preventDuplicates = true;
}
public DrawableImageGenerator(Context context, boolean preventDuplicates) {
this.context = context;
this.preventDuplicates = preventDuplicates;
}
@Override | public Drawable next(DataContext dataContext) { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/place/StringCityGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.place;
public class StringCityGenerator extends Generator<String> {
private String[] names = {"London", "Zadar", "Warszawa"};
private Random random = new Random();
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/place/StringCityGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.place;
public class StringCityGenerator extends Generator<String> {
private String[] names = {"London", "Zadar", "Warszawa"};
private Random random = new Random();
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/place/StringCityGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.place;
public class StringCityGenerator extends Generator<String> {
private String[] names = {"London", "Zadar", "Warszawa"};
private Random random = new Random();
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("city");
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/place/StringCityGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.place;
public class StringCityGenerator extends Generator<String> {
private String[] names = {"London", "Zadar", "Warszawa"};
private Random random = new Random();
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("city");
}
@Override | public String next(DataContext context) { |
ZieIony/RandomData | person/src/main/java/tk/zielony/randomdata/person/StringNameGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.person;
public class StringNameGenerator extends Generator<String> {
private StringFirstNameGenerator firstNameGenerator;
private StringLastNameGenerator lastNameGenerator;
public StringNameGenerator() {
firstNameGenerator = new StringFirstNameGenerator();
lastNameGenerator = new StringLastNameGenerator();
}
public StringNameGenerator(Gender gender) {
firstNameGenerator = new StringFirstNameGenerator(gender, true, true);
lastNameGenerator = new StringLastNameGenerator();
}
public StringNameGenerator(Gender gender, boolean preventDuplicates, boolean allowTwoNames) {
firstNameGenerator = new StringFirstNameGenerator(gender, preventDuplicates, allowTwoNames);
lastNameGenerator = new StringLastNameGenerator();
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: person/src/main/java/tk/zielony/randomdata/person/StringNameGenerator.java
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.person;
public class StringNameGenerator extends Generator<String> {
private StringFirstNameGenerator firstNameGenerator;
private StringLastNameGenerator lastNameGenerator;
public StringNameGenerator() {
firstNameGenerator = new StringFirstNameGenerator();
lastNameGenerator = new StringLastNameGenerator();
}
public StringNameGenerator(Gender gender) {
firstNameGenerator = new StringFirstNameGenerator(gender, true, true);
lastNameGenerator = new StringLastNameGenerator();
}
public StringNameGenerator(Gender gender, boolean preventDuplicates, boolean allowTwoNames) {
firstNameGenerator = new StringFirstNameGenerator(gender, preventDuplicates, allowTwoNames);
lastNameGenerator = new StringLastNameGenerator();
}
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | person/src/main/java/tk/zielony/randomdata/person/StringNameGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.person;
public class StringNameGenerator extends Generator<String> {
private StringFirstNameGenerator firstNameGenerator;
private StringLastNameGenerator lastNameGenerator;
public StringNameGenerator() {
firstNameGenerator = new StringFirstNameGenerator();
lastNameGenerator = new StringLastNameGenerator();
}
public StringNameGenerator(Gender gender) {
firstNameGenerator = new StringFirstNameGenerator(gender, true, true);
lastNameGenerator = new StringLastNameGenerator();
}
public StringNameGenerator(Gender gender, boolean preventDuplicates, boolean allowTwoNames) {
firstNameGenerator = new StringFirstNameGenerator(gender, preventDuplicates, allowTwoNames);
lastNameGenerator = new StringLastNameGenerator();
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("name");
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: person/src/main/java/tk/zielony/randomdata/person/StringNameGenerator.java
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.person;
public class StringNameGenerator extends Generator<String> {
private StringFirstNameGenerator firstNameGenerator;
private StringLastNameGenerator lastNameGenerator;
public StringNameGenerator() {
firstNameGenerator = new StringFirstNameGenerator();
lastNameGenerator = new StringLastNameGenerator();
}
public StringNameGenerator(Gender gender) {
firstNameGenerator = new StringFirstNameGenerator(gender, true, true);
lastNameGenerator = new StringLastNameGenerator();
}
public StringNameGenerator(Gender gender, boolean preventDuplicates, boolean allowTwoNames) {
firstNameGenerator = new StringFirstNameGenerator(gender, preventDuplicates, allowTwoNames);
lastNameGenerator = new StringLastNameGenerator();
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("name");
}
@Override | public String next(DataContext context) { |
ZieIony/RandomData | finance/src/main/java/tk/zielony/randomdata/finance/StringAmountGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Currency;
import java.util.Locale;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.finance;
public class StringAmountGenerator extends AmountGenerator<String> {
public StringAmountGenerator() {
super();
}
public StringAmountGenerator(int max, boolean useCommon) {
super(max, useCommon);
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: finance/src/main/java/tk/zielony/randomdata/finance/StringAmountGenerator.java
import java.util.Currency;
import java.util.Locale;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.finance;
public class StringAmountGenerator extends AmountGenerator<String> {
public StringAmountGenerator() {
super();
}
public StringAmountGenerator(int max, boolean useCommon) {
super(max, useCommon);
}
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | finance/src/main/java/tk/zielony/randomdata/finance/StringAmountGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Currency;
import java.util.Locale;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.finance;
public class StringAmountGenerator extends AmountGenerator<String> {
public StringAmountGenerator() {
super();
}
public StringAmountGenerator(int max, boolean useCommon) {
super(max, useCommon);
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("amount");
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: finance/src/main/java/tk/zielony/randomdata/finance/StringAmountGenerator.java
import java.util.Currency;
import java.util.Locale;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.finance;
public class StringAmountGenerator extends AmountGenerator<String> {
public StringAmountGenerator() {
super();
}
public StringAmountGenerator(int max, boolean useCommon) {
super(max, useCommon);
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("amount");
}
@Override | public String next(DataContext context) { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/common/DateGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Date;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.common;
public class DateGenerator extends Generator<Date> {
private Random random = new Random();
private static final int WEEK = 7 * 24 * 60 * 60 * 1000;
private long startDate;
private long endDate;
public DateGenerator() {
endDate = new Date().getTime();
startDate = endDate - WEEK;
}
public DateGenerator(Date startDate, Date endDate) {
this.startDate = Math.min(startDate.getTime(), endDate.getTime());
this.endDate = Math.max(startDate.getTime(), endDate.getTime());
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/common/DateGenerator.java
import java.util.Date;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.common;
public class DateGenerator extends Generator<Date> {
private Random random = new Random();
private static final int WEEK = 7 * 24 * 60 * 60 * 1000;
private long startDate;
private long endDate;
public DateGenerator() {
endDate = new Date().getTime();
startDate = endDate - WEEK;
}
public DateGenerator(Date startDate, Date endDate) {
this.startDate = Math.min(startDate.getTime(), endDate.getTime());
this.endDate = Math.max(startDate.getTime(), endDate.getTime());
}
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/common/DateGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Date;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.common;
public class DateGenerator extends Generator<Date> {
private Random random = new Random();
private static final int WEEK = 7 * 24 * 60 * 60 * 1000;
private long startDate;
private long endDate;
public DateGenerator() {
endDate = new Date().getTime();
startDate = endDate - WEEK;
}
public DateGenerator(Date startDate, Date endDate) {
this.startDate = Math.min(startDate.getTime(), endDate.getTime());
this.endDate = Math.max(startDate.getTime(), endDate.getTime());
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName().equals("date");
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/common/DateGenerator.java
import java.util.Date;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.common;
public class DateGenerator extends Generator<Date> {
private Random random = new Random();
private static final int WEEK = 7 * 24 * 60 * 60 * 1000;
private long startDate;
private long endDate;
public DateGenerator() {
endDate = new Date().getTime();
startDate = endDate - WEEK;
}
public DateGenerator(Date startDate, Date endDate) {
this.startDate = Math.min(startDate.getTime(), endDate.getTime());
this.endDate = Math.max(startDate.getTime(), endDate.getTime());
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName().equals("date");
}
@Override | public Date next(DataContext context) { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/common/IntegerRGBColorGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import android.graphics.Color;
import androidx.annotation.NonNull;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | maxB = 255;
grayscale = false;
}
/**
* Both arrays can be 1, 2, 3 or 4 elements long. Depending on the length, arrays will be
* interpreted as [grayscale], [alpha, grayscale], [r, g, b] or [alpha, r, g, b]
*
* @param min
* @param max
*/
public IntegerRGBColorGenerator(@NonNull int[] min, @NonNull int[] max) {
if (min.length != max.length)
throw new IllegalArgumentException("min.length != max.length");
if (min.length == 0 || min.length > 4)
throw new IllegalArgumentException("min.length == 0 || min.length > 4");
grayscale = min.length <= 2;
minA = min.length == 2 || min.length == 4 ? min[0] : 255;
minR = min.length == 1 ? min[0] : min[1];
minG = grayscale ? 0 : min[min.length - 2];
minB = grayscale ? 0 : min[min.length - 1];
maxA = max.length == 2 || max.length == 4 ? max[0] : 255;
maxR = max.length == 1 ? max[0] : max[1];
maxG = grayscale ? 0 : max[max.length - 2];
maxB = grayscale ? 0 : max[max.length - 1];
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/common/IntegerRGBColorGenerator.java
import android.graphics.Color;
import androidx.annotation.NonNull;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
maxB = 255;
grayscale = false;
}
/**
* Both arrays can be 1, 2, 3 or 4 elements long. Depending on the length, arrays will be
* interpreted as [grayscale], [alpha, grayscale], [r, g, b] or [alpha, r, g, b]
*
* @param min
* @param max
*/
public IntegerRGBColorGenerator(@NonNull int[] min, @NonNull int[] max) {
if (min.length != max.length)
throw new IllegalArgumentException("min.length != max.length");
if (min.length == 0 || min.length > 4)
throw new IllegalArgumentException("min.length == 0 || min.length > 4");
grayscale = min.length <= 2;
minA = min.length == 2 || min.length == 4 ? min[0] : 255;
minR = min.length == 1 ? min[0] : min[1];
minG = grayscale ? 0 : min[min.length - 2];
minB = grayscale ? 0 : min[min.length - 1];
maxA = max.length == 2 || max.length == 4 ? max[0] : 255;
maxR = max.length == 1 ? max[0] : max[1];
maxG = grayscale ? 0 : max[max.length - 2];
maxB = grayscale ? 0 : max[max.length - 1];
}
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/common/IntegerRGBColorGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import android.graphics.Color;
import androidx.annotation.NonNull;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | * Both arrays can be 1, 2, 3 or 4 elements long. Depending on the length, arrays will be
* interpreted as [grayscale], [alpha, grayscale], [r, g, b] or [alpha, r, g, b]
*
* @param min
* @param max
*/
public IntegerRGBColorGenerator(@NonNull int[] min, @NonNull int[] max) {
if (min.length != max.length)
throw new IllegalArgumentException("min.length != max.length");
if (min.length == 0 || min.length > 4)
throw new IllegalArgumentException("min.length == 0 || min.length > 4");
grayscale = min.length <= 2;
minA = min.length == 2 || min.length == 4 ? min[0] : 255;
minR = min.length == 1 ? min[0] : min[1];
minG = grayscale ? 0 : min[min.length - 2];
minB = grayscale ? 0 : min[min.length - 1];
maxA = max.length == 2 || max.length == 4 ? max[0] : 255;
maxR = max.length == 1 ? max[0] : max[1];
maxG = grayscale ? 0 : max[max.length - 2];
maxB = grayscale ? 0 : max[max.length - 1];
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("color");
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/common/IntegerRGBColorGenerator.java
import android.graphics.Color;
import androidx.annotation.NonNull;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
* Both arrays can be 1, 2, 3 or 4 elements long. Depending on the length, arrays will be
* interpreted as [grayscale], [alpha, grayscale], [r, g, b] or [alpha, r, g, b]
*
* @param min
* @param max
*/
public IntegerRGBColorGenerator(@NonNull int[] min, @NonNull int[] max) {
if (min.length != max.length)
throw new IllegalArgumentException("min.length != max.length");
if (min.length == 0 || min.length > 4)
throw new IllegalArgumentException("min.length == 0 || min.length > 4");
grayscale = min.length <= 2;
minA = min.length == 2 || min.length == 4 ? min[0] : 255;
minR = min.length == 1 ? min[0] : min[1];
minG = grayscale ? 0 : min[min.length - 2];
minB = grayscale ? 0 : min[min.length - 1];
maxA = max.length == 2 || max.length == 4 ? max[0] : 255;
maxR = max.length == 1 ? max[0] : max[1];
maxG = grayscale ? 0 : max[max.length - 2];
maxB = grayscale ? 0 : max[max.length - 1];
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("color");
}
@Override | public Integer next(DataContext context) { |
ZieIony/RandomData | finance/src/main/java/tk/zielony/randomdata/finance/StringCardNumberGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.finance;
public class StringCardNumberGenerator extends Generator<String> {
private static class BIN {
String name;
int number;
int length;
BIN(String name, int number, int length) {
this.name = name;
this.number = number;
this.length = length;
}
}
private static BIN[] bins = {
new BIN("MasterCard", 51, 16),
new BIN("MasterCard", 52, 16),
new BIN("MasterCard", 53, 16),
new BIN("MasterCard", 54, 16),
new BIN("MasterCard", 55, 16),
new BIN("VISA", 4, 16),
new BIN("American Express", 34, 15),
new BIN("American Express", 37, 15)
};
private Random random = new Random();
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: finance/src/main/java/tk/zielony/randomdata/finance/StringCardNumberGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.finance;
public class StringCardNumberGenerator extends Generator<String> {
private static class BIN {
String name;
int number;
int length;
BIN(String name, int number, int length) {
this.name = name;
this.number = number;
this.length = length;
}
}
private static BIN[] bins = {
new BIN("MasterCard", 51, 16),
new BIN("MasterCard", 52, 16),
new BIN("MasterCard", 53, 16),
new BIN("MasterCard", 54, 16),
new BIN("MasterCard", 55, 16),
new BIN("VISA", 4, 16),
new BIN("American Express", 34, 15),
new BIN("American Express", 37, 15)
};
private Random random = new Random();
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | finance/src/main/java/tk/zielony/randomdata/finance/StringCardNumberGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.finance;
public class StringCardNumberGenerator extends Generator<String> {
private static class BIN {
String name;
int number;
int length;
BIN(String name, int number, int length) {
this.name = name;
this.number = number;
this.length = length;
}
}
private static BIN[] bins = {
new BIN("MasterCard", 51, 16),
new BIN("MasterCard", 52, 16),
new BIN("MasterCard", 53, 16),
new BIN("MasterCard", 54, 16),
new BIN("MasterCard", 55, 16),
new BIN("VISA", 4, 16),
new BIN("American Express", 34, 15),
new BIN("American Express", 37, 15)
};
private Random random = new Random();
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("number");
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: finance/src/main/java/tk/zielony/randomdata/finance/StringCardNumberGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.finance;
public class StringCardNumberGenerator extends Generator<String> {
private static class BIN {
String name;
int number;
int length;
BIN(String name, int number, int length) {
this.name = name;
this.number = number;
this.length = length;
}
}
private static BIN[] bins = {
new BIN("MasterCard", 51, 16),
new BIN("MasterCard", 52, 16),
new BIN("MasterCard", 53, 16),
new BIN("MasterCard", 54, 16),
new BIN("MasterCard", 55, 16),
new BIN("VISA", 4, 16),
new BIN("American Express", 34, 15),
new BIN("American Express", 37, 15)
};
private Random random = new Random();
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("number");
}
@Override | public String next(DataContext context) { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/common/IntegerHSVColorGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import android.graphics.Color;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | maxV = 1;
grayscale = false;
}
/**
* Both arrays can be 2 or 3 elements long. Depending on the length, arrays will be
* interpreted as [h, v] or [h, s, v]
*
* @param min
* @param max
*/
public IntegerHSVColorGenerator(int minA, float[] min, int maxA, float[] max) {
if (min.length != max.length)
throw new IllegalArgumentException("min.length != max.length");
if (min.length < 2 || min.length > 3)
throw new IllegalArgumentException("min.length < 2 || min.length > 3");
grayscale = min.length == 2;
this.minA = minA;
minH = min[0];
minS = grayscale ? 0 : min[1];
minV = grayscale ? min[1] : min[2];
this.maxA = maxA;
maxH = max[0];
maxS = grayscale ? 0 : max[1];
maxV = grayscale ? max[1] : max[2];
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/common/IntegerHSVColorGenerator.java
import android.graphics.Color;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
maxV = 1;
grayscale = false;
}
/**
* Both arrays can be 2 or 3 elements long. Depending on the length, arrays will be
* interpreted as [h, v] or [h, s, v]
*
* @param min
* @param max
*/
public IntegerHSVColorGenerator(int minA, float[] min, int maxA, float[] max) {
if (min.length != max.length)
throw new IllegalArgumentException("min.length != max.length");
if (min.length < 2 || min.length > 3)
throw new IllegalArgumentException("min.length < 2 || min.length > 3");
grayscale = min.length == 2;
this.minA = minA;
minH = min[0];
minS = grayscale ? 0 : min[1];
minV = grayscale ? min[1] : min[2];
this.maxA = maxA;
maxH = max[0];
maxS = grayscale ? 0 : max[1];
maxV = grayscale ? max[1] : max[2];
}
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/common/IntegerHSVColorGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import android.graphics.Color;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher; | * Both arrays can be 2 or 3 elements long. Depending on the length, arrays will be
* interpreted as [h, v] or [h, s, v]
*
* @param min
* @param max
*/
public IntegerHSVColorGenerator(int minA, float[] min, int maxA, float[] max) {
if (min.length != max.length)
throw new IllegalArgumentException("min.length != max.length");
if (min.length < 2 || min.length > 3)
throw new IllegalArgumentException("min.length < 2 || min.length > 3");
grayscale = min.length == 2;
this.minA = minA;
minH = min[0];
minS = grayscale ? 0 : min[1];
minV = grayscale ? min[1] : min[2];
this.maxA = maxA;
maxH = max[0];
maxS = grayscale ? 0 : max[1];
maxV = grayscale ? max[1] : max[2];
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("color");
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/common/IntegerHSVColorGenerator.java
import android.graphics.Color;
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
import tk.zielony.randomdata.Matcher;
* Both arrays can be 2 or 3 elements long. Depending on the length, arrays will be
* interpreted as [h, v] or [h, s, v]
*
* @param min
* @param max
*/
public IntegerHSVColorGenerator(int minA, float[] min, int maxA, float[] max) {
if (min.length != max.length)
throw new IllegalArgumentException("min.length != max.length");
if (min.length < 2 || min.length > 3)
throw new IllegalArgumentException("min.length < 2 || min.length > 3");
grayscale = min.length == 2;
this.minA = minA;
minH = min[0];
minS = grayscale ? 0 : min[1];
minV = grayscale ? min[1] : min[2];
this.maxA = maxA;
maxH = max[0];
maxS = grayscale ? 0 : max[1];
maxV = grayscale ? max[1] : max[2];
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("color");
}
@Override | public Integer next(DataContext context) { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/food/StringFruitGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/GeneratorWithDuplicates.java
// public abstract class GeneratorWithDuplicates<Type> extends Generator<Type> {
// private Random random = new Random();
// private int total;
// private boolean preventDuplicates;
//
// private List<Integer> used, free;
//
// public GeneratorWithDuplicates(int total) {
// this.total = total;
// preventDuplicates = true;
// used = new ArrayList<>();
// free = new ArrayList<>();
// reset();
// }
//
// public GeneratorWithDuplicates(int total, boolean preventDuplicates) {
// this.total = total;
// this.preventDuplicates = preventDuplicates;
// if (preventDuplicates) {
// used = new ArrayList<>();
// free = new ArrayList<>();
// reset();
// }
// }
//
// protected int nextIndex() {
// int index;
// if (preventDuplicates) {
// if (free.isEmpty()) {
// List<Integer> swap = free;
// free = used;
// used = swap;
// }
// index = free.get(random.nextInt(free.size()));
// used.add(index);
// } else {
// index = random.nextInt(total);
// }
// return index;
// }
//
// @Override
// public void reset() {
// if (!preventDuplicates)
// return;
// for (int i = 0; i < total; i++)
// free.add(i);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.GeneratorWithDuplicates;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.food;
public class StringFruitGenerator extends GeneratorWithDuplicates<String> {
private static String[] fruits = {"Apple", "Apricot", "Avocado", "Banana", "Bilberry", "Blackberry", "Blackcurrant", "Blueberry",
"Boysenberry", "Currant", "Cherry", "Cherimoya", "Cloudberry", "Coconut", "Cranberry", "Cucumber", "Custard apple",
"Damson", "Date", "Dragonfruit", "Durian", "Elderberry", "Feijoa", "Fig", "Goji berry", "Gooseberry", "Grape",
"Raisin", "Grapefruit", "Guava", "Honeyberry", "Huckleberry", "Jabuticaba", "Jackfruit", "Jambul",
"Jujube", "Juniper berry", "Kiwifruit", "Kumquat", "Lemon", "Lime", "Loquat", "Longan", "Lychee", "Mango",
"Marionberry", "Melon", "Cantaloupe", "Honeydew", "Watermelon", "Miracle fruit", "Mulberry", "Nectarine",
"Nance", "Olive", "Orange", "Blood orange", "Clementine", "Mandarine", "Tangerine", "Papaya", "Passionfruit",
"Peach", "Pear", "Persimmon", "Physalis", "Plantain", "Plum", "Prune", "Pineapple", "Plumcot",
"Pomegranate", "Pomelo", "Purple mangosteen", "Quince", "Raspberry", "Salmonberry", "Rambutan", "Redcurrant",
"Salal berry", "Salak", "Satsuma", "Soursop", "Star fruit", "Solanum quitoense", "Strawberry", "Tamarillo",
"Tamarind", "Ugli fruit", "Yuzu"};
public StringFruitGenerator() {
super(fruits.length);
}
public StringFruitGenerator(boolean preventDuplicates) {
super(fruits.length, preventDuplicates);
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/GeneratorWithDuplicates.java
// public abstract class GeneratorWithDuplicates<Type> extends Generator<Type> {
// private Random random = new Random();
// private int total;
// private boolean preventDuplicates;
//
// private List<Integer> used, free;
//
// public GeneratorWithDuplicates(int total) {
// this.total = total;
// preventDuplicates = true;
// used = new ArrayList<>();
// free = new ArrayList<>();
// reset();
// }
//
// public GeneratorWithDuplicates(int total, boolean preventDuplicates) {
// this.total = total;
// this.preventDuplicates = preventDuplicates;
// if (preventDuplicates) {
// used = new ArrayList<>();
// free = new ArrayList<>();
// reset();
// }
// }
//
// protected int nextIndex() {
// int index;
// if (preventDuplicates) {
// if (free.isEmpty()) {
// List<Integer> swap = free;
// free = used;
// used = swap;
// }
// index = free.get(random.nextInt(free.size()));
// used.add(index);
// } else {
// index = random.nextInt(total);
// }
// return index;
// }
//
// @Override
// public void reset() {
// if (!preventDuplicates)
// return;
// for (int i = 0; i < total; i++)
// free.add(i);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/food/StringFruitGenerator.java
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.GeneratorWithDuplicates;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.food;
public class StringFruitGenerator extends GeneratorWithDuplicates<String> {
private static String[] fruits = {"Apple", "Apricot", "Avocado", "Banana", "Bilberry", "Blackberry", "Blackcurrant", "Blueberry",
"Boysenberry", "Currant", "Cherry", "Cherimoya", "Cloudberry", "Coconut", "Cranberry", "Cucumber", "Custard apple",
"Damson", "Date", "Dragonfruit", "Durian", "Elderberry", "Feijoa", "Fig", "Goji berry", "Gooseberry", "Grape",
"Raisin", "Grapefruit", "Guava", "Honeyberry", "Huckleberry", "Jabuticaba", "Jackfruit", "Jambul",
"Jujube", "Juniper berry", "Kiwifruit", "Kumquat", "Lemon", "Lime", "Loquat", "Longan", "Lychee", "Mango",
"Marionberry", "Melon", "Cantaloupe", "Honeydew", "Watermelon", "Miracle fruit", "Mulberry", "Nectarine",
"Nance", "Olive", "Orange", "Blood orange", "Clementine", "Mandarine", "Tangerine", "Papaya", "Passionfruit",
"Peach", "Pear", "Persimmon", "Physalis", "Plantain", "Plum", "Prune", "Pineapple", "Plumcot",
"Pomegranate", "Pomelo", "Purple mangosteen", "Quince", "Raspberry", "Salmonberry", "Rambutan", "Redcurrant",
"Salal berry", "Salak", "Satsuma", "Soursop", "Star fruit", "Solanum quitoense", "Strawberry", "Tamarillo",
"Tamarind", "Ugli fruit", "Yuzu"};
public StringFruitGenerator() {
super(fruits.length);
}
public StringFruitGenerator(boolean preventDuplicates) {
super(fruits.length, preventDuplicates);
}
@Override | protected Matcher getDefaultMatcher() { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/food/StringFruitGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/GeneratorWithDuplicates.java
// public abstract class GeneratorWithDuplicates<Type> extends Generator<Type> {
// private Random random = new Random();
// private int total;
// private boolean preventDuplicates;
//
// private List<Integer> used, free;
//
// public GeneratorWithDuplicates(int total) {
// this.total = total;
// preventDuplicates = true;
// used = new ArrayList<>();
// free = new ArrayList<>();
// reset();
// }
//
// public GeneratorWithDuplicates(int total, boolean preventDuplicates) {
// this.total = total;
// this.preventDuplicates = preventDuplicates;
// if (preventDuplicates) {
// used = new ArrayList<>();
// free = new ArrayList<>();
// reset();
// }
// }
//
// protected int nextIndex() {
// int index;
// if (preventDuplicates) {
// if (free.isEmpty()) {
// List<Integer> swap = free;
// free = used;
// used = swap;
// }
// index = free.get(random.nextInt(free.size()));
// used.add(index);
// } else {
// index = random.nextInt(total);
// }
// return index;
// }
//
// @Override
// public void reset() {
// if (!preventDuplicates)
// return;
// for (int i = 0; i < total; i++)
// free.add(i);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
| import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.GeneratorWithDuplicates;
import tk.zielony.randomdata.Matcher; | package tk.zielony.randomdata.food;
public class StringFruitGenerator extends GeneratorWithDuplicates<String> {
private static String[] fruits = {"Apple", "Apricot", "Avocado", "Banana", "Bilberry", "Blackberry", "Blackcurrant", "Blueberry",
"Boysenberry", "Currant", "Cherry", "Cherimoya", "Cloudberry", "Coconut", "Cranberry", "Cucumber", "Custard apple",
"Damson", "Date", "Dragonfruit", "Durian", "Elderberry", "Feijoa", "Fig", "Goji berry", "Gooseberry", "Grape",
"Raisin", "Grapefruit", "Guava", "Honeyberry", "Huckleberry", "Jabuticaba", "Jackfruit", "Jambul",
"Jujube", "Juniper berry", "Kiwifruit", "Kumquat", "Lemon", "Lime", "Loquat", "Longan", "Lychee", "Mango",
"Marionberry", "Melon", "Cantaloupe", "Honeydew", "Watermelon", "Miracle fruit", "Mulberry", "Nectarine",
"Nance", "Olive", "Orange", "Blood orange", "Clementine", "Mandarine", "Tangerine", "Papaya", "Passionfruit",
"Peach", "Pear", "Persimmon", "Physalis", "Plantain", "Plum", "Prune", "Pineapple", "Plumcot",
"Pomegranate", "Pomelo", "Purple mangosteen", "Quince", "Raspberry", "Salmonberry", "Rambutan", "Redcurrant",
"Salal berry", "Salak", "Satsuma", "Soursop", "Star fruit", "Solanum quitoense", "Strawberry", "Tamarillo",
"Tamarind", "Ugli fruit", "Yuzu"};
public StringFruitGenerator() {
super(fruits.length);
}
public StringFruitGenerator(boolean preventDuplicates) {
super(fruits.length, preventDuplicates);
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("name");
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/GeneratorWithDuplicates.java
// public abstract class GeneratorWithDuplicates<Type> extends Generator<Type> {
// private Random random = new Random();
// private int total;
// private boolean preventDuplicates;
//
// private List<Integer> used, free;
//
// public GeneratorWithDuplicates(int total) {
// this.total = total;
// preventDuplicates = true;
// used = new ArrayList<>();
// free = new ArrayList<>();
// reset();
// }
//
// public GeneratorWithDuplicates(int total, boolean preventDuplicates) {
// this.total = total;
// this.preventDuplicates = preventDuplicates;
// if (preventDuplicates) {
// used = new ArrayList<>();
// free = new ArrayList<>();
// reset();
// }
// }
//
// protected int nextIndex() {
// int index;
// if (preventDuplicates) {
// if (free.isEmpty()) {
// List<Integer> swap = free;
// free = used;
// used = swap;
// }
// index = free.get(random.nextInt(free.size()));
// used.add(index);
// } else {
// index = random.nextInt(total);
// }
// return index;
// }
//
// @Override
// public void reset() {
// if (!preventDuplicates)
// return;
// for (int i = 0; i < total; i++)
// free.add(i);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Matcher.java
// public interface Matcher {
// boolean matches(Target target);
// }
// Path: lib/src/main/java/tk/zielony/randomdata/food/StringFruitGenerator.java
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.GeneratorWithDuplicates;
import tk.zielony.randomdata.Matcher;
package tk.zielony.randomdata.food;
public class StringFruitGenerator extends GeneratorWithDuplicates<String> {
private static String[] fruits = {"Apple", "Apricot", "Avocado", "Banana", "Bilberry", "Blackberry", "Blackcurrant", "Blueberry",
"Boysenberry", "Currant", "Cherry", "Cherimoya", "Cloudberry", "Coconut", "Cranberry", "Cucumber", "Custard apple",
"Damson", "Date", "Dragonfruit", "Durian", "Elderberry", "Feijoa", "Fig", "Goji berry", "Gooseberry", "Grape",
"Raisin", "Grapefruit", "Guava", "Honeyberry", "Huckleberry", "Jabuticaba", "Jackfruit", "Jambul",
"Jujube", "Juniper berry", "Kiwifruit", "Kumquat", "Lemon", "Lime", "Loquat", "Longan", "Lychee", "Mango",
"Marionberry", "Melon", "Cantaloupe", "Honeydew", "Watermelon", "Miracle fruit", "Mulberry", "Nectarine",
"Nance", "Olive", "Orange", "Blood orange", "Clementine", "Mandarine", "Tangerine", "Papaya", "Passionfruit",
"Peach", "Pear", "Persimmon", "Physalis", "Plantain", "Plum", "Prune", "Pineapple", "Plumcot",
"Pomegranate", "Pomelo", "Purple mangosteen", "Quince", "Raspberry", "Salmonberry", "Rambutan", "Redcurrant",
"Salal berry", "Salak", "Satsuma", "Soursop", "Star fruit", "Solanum quitoense", "Strawberry", "Tamarillo",
"Tamarind", "Ugli fruit", "Yuzu"};
public StringFruitGenerator() {
super(fruits.length);
}
public StringFruitGenerator(boolean preventDuplicates) {
super(fruits.length, preventDuplicates);
}
@Override
protected Matcher getDefaultMatcher() {
return f -> f.getName() != null && f.getName().contains("name");
}
@Override | public String next(DataContext context) { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/common/FloatGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator; | package tk.zielony.randomdata.common;
public class FloatGenerator extends Generator<Float> {
private Random random = new Random();
private float min;
private float max;
private float[] array;
public FloatGenerator() {
min = 0;
max = 100;
}
public FloatGenerator(float min, float max) {
this.min = min;
this.max = max;
}
public FloatGenerator(float[] array) {
this.array = array;
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
// Path: lib/src/main/java/tk/zielony/randomdata/common/FloatGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
package tk.zielony.randomdata.common;
public class FloatGenerator extends Generator<Float> {
private Random random = new Random();
private float min;
private float max;
private float[] array;
public FloatGenerator() {
min = 0;
max = 100;
}
public FloatGenerator(float min, float max) {
this.min = min;
this.max = max;
}
public FloatGenerator(float[] array) {
this.array = array;
}
@Override | public Float next(DataContext context) { |
ZieIony/RandomData | lib/src/main/java/tk/zielony/randomdata/common/IntegerGenerator.java | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
| import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator; | package tk.zielony.randomdata.common;
public class IntegerGenerator extends Generator<Integer> {
private Random random = new Random();
private int min;
private int max;
private int[] array;
public IntegerGenerator() {
min = 0;
max = 100;
}
public IntegerGenerator(int min, int max) {
this.min = min;
this.max = max;
}
public IntegerGenerator(int[] array) {
this.array = array;
}
@Override | // Path: lib/src/main/java/tk/zielony/randomdata/DataContext.java
// public class DataContext {
//
// private static final String LOCALE = "locale";
// public static final String NAME = "name";
//
// protected final List<Map<String, Object>> stack = new ArrayList<>();
//
// void save() {
// HashMap<String, Object> contextData = (HashMap<String, Object>) stack.get(stack.size() - 1);
// HashMap<String, Object> clone = (HashMap<String, Object>) contextData.clone();
// stack.add(clone);
// }
//
// public DataContext() {
// stack.add(new HashMap<>());
// }
//
// void restore() {
// stack.remove(stack.size() - 1);
// }
//
// public <Type> Type get(String key) {
// return (Type) stack.get(stack.size() - 1).get(key);
// }
//
// public <Type> void set(String key, Type value) {
// stack.get(stack.size() - 1).put(key, value);
// }
// }
//
// Path: lib/src/main/java/tk/zielony/randomdata/Generator.java
// public abstract class Generator<Type> implements SimpleGenerator<Type> {
// private Matcher matcher;
//
// protected Matcher getDefaultMatcher() {
// return f -> true;
// }
//
// public Generator<Type> withMatcher(Matcher matcher) {
// this.matcher = matcher;
// return this;
// }
//
// public <OutType> GeneratorWithTransformer<Type, OutType> withTransformer(Transformer<Type, OutType> transformer) {
// return new GeneratorWithTransformer<>(this, transformer);
// }
//
// protected boolean match(Target target) {
// if (matcher == null)
// matcher = getDefaultMatcher();
// return matcher.matches(target);
// }
//
// public Type next() {
// return next(null);
// }
//
// public abstract Type next(@Nullable DataContext context);
//
// public void reset() {
// }
// }
// Path: lib/src/main/java/tk/zielony/randomdata/common/IntegerGenerator.java
import java.util.Random;
import tk.zielony.randomdata.DataContext;
import tk.zielony.randomdata.Generator;
package tk.zielony.randomdata.common;
public class IntegerGenerator extends Generator<Integer> {
private Random random = new Random();
private int min;
private int max;
private int[] array;
public IntegerGenerator() {
min = 0;
max = 100;
}
public IntegerGenerator(int min, int max) {
this.min = min;
this.max = max;
}
public IntegerGenerator(int[] array) {
this.array = array;
}
@Override | public Integer next(DataContext context) { |
mauimauer/cheapcast | src/main/java/at/maui/cheapcast/activity/AboutActivity.java | // Path: src/main/java/at/maui/cheapcast/fragment/AboutFragment.java
// public class AboutFragment extends RoboSherlockFragment {
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// return inflater.inflate(R.layout.fragment_about, null);
// }
// }
//
// Path: src/main/java/at/maui/cheapcast/fragment/ChangelogFragment.java
// public class ChangelogFragment extends HtmlAssetFragment {
// @Override
// public String getAssetPath() {
// return "changelog.html";
// }
// }
//
// Path: src/main/java/at/maui/cheapcast/fragment/ExtLibrariesFragment.java
// public class ExtLibrariesFragment extends HtmlAssetFragment {
//
// @Override
// public String getAssetPath() {
// return "third_party.html"; //To change body of implemented methods use File | Settings | File Templates.
// }
// }
| import com.viewpagerindicator.TitlePageIndicator;
import roboguice.inject.InjectView;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import at.maui.cheapcast.App;
import at.maui.cheapcast.R;
import at.maui.cheapcast.fragment.AboutFragment;
import at.maui.cheapcast.fragment.ChangelogFragment;
import at.maui.cheapcast.fragment.ExtLibrariesFragment;
import com.actionbarsherlock.view.MenuItem;
import com.github.rtyley.android.sherlock.roboguice.activity.RoboSherlockFragmentActivity;
| if(item.getItemId() == android.R.id.home) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
public class AboutPagerAdapter extends FragmentStatePagerAdapter {
private Context mContext;
public AboutPagerAdapter(Context ctx, FragmentManager fm) {
super(fm);
mContext = ctx;
}
@Override
public int getItemPosition(Object object) {
return POSITION_NONE;
}
@Override
public int getCount() {
return mContext.getResources().getStringArray(R.array.about_tabs).length;
}
@Override
public Fragment getItem(int position) {
switch(position) {
case 0:
| // Path: src/main/java/at/maui/cheapcast/fragment/AboutFragment.java
// public class AboutFragment extends RoboSherlockFragment {
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// return inflater.inflate(R.layout.fragment_about, null);
// }
// }
//
// Path: src/main/java/at/maui/cheapcast/fragment/ChangelogFragment.java
// public class ChangelogFragment extends HtmlAssetFragment {
// @Override
// public String getAssetPath() {
// return "changelog.html";
// }
// }
//
// Path: src/main/java/at/maui/cheapcast/fragment/ExtLibrariesFragment.java
// public class ExtLibrariesFragment extends HtmlAssetFragment {
//
// @Override
// public String getAssetPath() {
// return "third_party.html"; //To change body of implemented methods use File | Settings | File Templates.
// }
// }
// Path: src/main/java/at/maui/cheapcast/activity/AboutActivity.java
import com.viewpagerindicator.TitlePageIndicator;
import roboguice.inject.InjectView;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import at.maui.cheapcast.App;
import at.maui.cheapcast.R;
import at.maui.cheapcast.fragment.AboutFragment;
import at.maui.cheapcast.fragment.ChangelogFragment;
import at.maui.cheapcast.fragment.ExtLibrariesFragment;
import com.actionbarsherlock.view.MenuItem;
import com.github.rtyley.android.sherlock.roboguice.activity.RoboSherlockFragmentActivity;
if(item.getItemId() == android.R.id.home) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
public class AboutPagerAdapter extends FragmentStatePagerAdapter {
private Context mContext;
public AboutPagerAdapter(Context ctx, FragmentManager fm) {
super(fm);
mContext = ctx;
}
@Override
public int getItemPosition(Object object) {
return POSITION_NONE;
}
@Override
public int getCount() {
return mContext.getResources().getStringArray(R.array.about_tabs).length;
}
@Override
public Fragment getItem(int position) {
switch(position) {
case 0:
| return new AboutFragment();
|
mauimauer/cheapcast | src/main/java/at/maui/cheapcast/activity/AboutActivity.java | // Path: src/main/java/at/maui/cheapcast/fragment/AboutFragment.java
// public class AboutFragment extends RoboSherlockFragment {
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// return inflater.inflate(R.layout.fragment_about, null);
// }
// }
//
// Path: src/main/java/at/maui/cheapcast/fragment/ChangelogFragment.java
// public class ChangelogFragment extends HtmlAssetFragment {
// @Override
// public String getAssetPath() {
// return "changelog.html";
// }
// }
//
// Path: src/main/java/at/maui/cheapcast/fragment/ExtLibrariesFragment.java
// public class ExtLibrariesFragment extends HtmlAssetFragment {
//
// @Override
// public String getAssetPath() {
// return "third_party.html"; //To change body of implemented methods use File | Settings | File Templates.
// }
// }
| import com.viewpagerindicator.TitlePageIndicator;
import roboguice.inject.InjectView;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import at.maui.cheapcast.App;
import at.maui.cheapcast.R;
import at.maui.cheapcast.fragment.AboutFragment;
import at.maui.cheapcast.fragment.ChangelogFragment;
import at.maui.cheapcast.fragment.ExtLibrariesFragment;
import com.actionbarsherlock.view.MenuItem;
import com.github.rtyley.android.sherlock.roboguice.activity.RoboSherlockFragmentActivity;
| return true;
}
return super.onOptionsItemSelected(item);
}
public class AboutPagerAdapter extends FragmentStatePagerAdapter {
private Context mContext;
public AboutPagerAdapter(Context ctx, FragmentManager fm) {
super(fm);
mContext = ctx;
}
@Override
public int getItemPosition(Object object) {
return POSITION_NONE;
}
@Override
public int getCount() {
return mContext.getResources().getStringArray(R.array.about_tabs).length;
}
@Override
public Fragment getItem(int position) {
switch(position) {
case 0:
return new AboutFragment();
case 1:
| // Path: src/main/java/at/maui/cheapcast/fragment/AboutFragment.java
// public class AboutFragment extends RoboSherlockFragment {
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// return inflater.inflate(R.layout.fragment_about, null);
// }
// }
//
// Path: src/main/java/at/maui/cheapcast/fragment/ChangelogFragment.java
// public class ChangelogFragment extends HtmlAssetFragment {
// @Override
// public String getAssetPath() {
// return "changelog.html";
// }
// }
//
// Path: src/main/java/at/maui/cheapcast/fragment/ExtLibrariesFragment.java
// public class ExtLibrariesFragment extends HtmlAssetFragment {
//
// @Override
// public String getAssetPath() {
// return "third_party.html"; //To change body of implemented methods use File | Settings | File Templates.
// }
// }
// Path: src/main/java/at/maui/cheapcast/activity/AboutActivity.java
import com.viewpagerindicator.TitlePageIndicator;
import roboguice.inject.InjectView;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import at.maui.cheapcast.App;
import at.maui.cheapcast.R;
import at.maui.cheapcast.fragment.AboutFragment;
import at.maui.cheapcast.fragment.ChangelogFragment;
import at.maui.cheapcast.fragment.ExtLibrariesFragment;
import com.actionbarsherlock.view.MenuItem;
import com.github.rtyley.android.sherlock.roboguice.activity.RoboSherlockFragmentActivity;
return true;
}
return super.onOptionsItemSelected(item);
}
public class AboutPagerAdapter extends FragmentStatePagerAdapter {
private Context mContext;
public AboutPagerAdapter(Context ctx, FragmentManager fm) {
super(fm);
mContext = ctx;
}
@Override
public int getItemPosition(Object object) {
return POSITION_NONE;
}
@Override
public int getCount() {
return mContext.getResources().getStringArray(R.array.about_tabs).length;
}
@Override
public Fragment getItem(int position) {
switch(position) {
case 0:
return new AboutFragment();
case 1:
| return new ChangelogFragment();
|
mauimauer/cheapcast | src/main/java/at/maui/cheapcast/activity/AboutActivity.java | // Path: src/main/java/at/maui/cheapcast/fragment/AboutFragment.java
// public class AboutFragment extends RoboSherlockFragment {
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// return inflater.inflate(R.layout.fragment_about, null);
// }
// }
//
// Path: src/main/java/at/maui/cheapcast/fragment/ChangelogFragment.java
// public class ChangelogFragment extends HtmlAssetFragment {
// @Override
// public String getAssetPath() {
// return "changelog.html";
// }
// }
//
// Path: src/main/java/at/maui/cheapcast/fragment/ExtLibrariesFragment.java
// public class ExtLibrariesFragment extends HtmlAssetFragment {
//
// @Override
// public String getAssetPath() {
// return "third_party.html"; //To change body of implemented methods use File | Settings | File Templates.
// }
// }
| import com.viewpagerindicator.TitlePageIndicator;
import roboguice.inject.InjectView;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import at.maui.cheapcast.App;
import at.maui.cheapcast.R;
import at.maui.cheapcast.fragment.AboutFragment;
import at.maui.cheapcast.fragment.ChangelogFragment;
import at.maui.cheapcast.fragment.ExtLibrariesFragment;
import com.actionbarsherlock.view.MenuItem;
import com.github.rtyley.android.sherlock.roboguice.activity.RoboSherlockFragmentActivity;
|
return super.onOptionsItemSelected(item);
}
public class AboutPagerAdapter extends FragmentStatePagerAdapter {
private Context mContext;
public AboutPagerAdapter(Context ctx, FragmentManager fm) {
super(fm);
mContext = ctx;
}
@Override
public int getItemPosition(Object object) {
return POSITION_NONE;
}
@Override
public int getCount() {
return mContext.getResources().getStringArray(R.array.about_tabs).length;
}
@Override
public Fragment getItem(int position) {
switch(position) {
case 0:
return new AboutFragment();
case 1:
return new ChangelogFragment();
case 2:
| // Path: src/main/java/at/maui/cheapcast/fragment/AboutFragment.java
// public class AboutFragment extends RoboSherlockFragment {
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// return inflater.inflate(R.layout.fragment_about, null);
// }
// }
//
// Path: src/main/java/at/maui/cheapcast/fragment/ChangelogFragment.java
// public class ChangelogFragment extends HtmlAssetFragment {
// @Override
// public String getAssetPath() {
// return "changelog.html";
// }
// }
//
// Path: src/main/java/at/maui/cheapcast/fragment/ExtLibrariesFragment.java
// public class ExtLibrariesFragment extends HtmlAssetFragment {
//
// @Override
// public String getAssetPath() {
// return "third_party.html"; //To change body of implemented methods use File | Settings | File Templates.
// }
// }
// Path: src/main/java/at/maui/cheapcast/activity/AboutActivity.java
import com.viewpagerindicator.TitlePageIndicator;
import roboguice.inject.InjectView;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import at.maui.cheapcast.App;
import at.maui.cheapcast.R;
import at.maui.cheapcast.fragment.AboutFragment;
import at.maui.cheapcast.fragment.ChangelogFragment;
import at.maui.cheapcast.fragment.ExtLibrariesFragment;
import com.actionbarsherlock.view.MenuItem;
import com.github.rtyley.android.sherlock.roboguice.activity.RoboSherlockFragmentActivity;
return super.onOptionsItemSelected(item);
}
public class AboutPagerAdapter extends FragmentStatePagerAdapter {
private Context mContext;
public AboutPagerAdapter(Context ctx, FragmentManager fm) {
super(fm);
mContext = ctx;
}
@Override
public int getItemPosition(Object object) {
return POSITION_NONE;
}
@Override
public int getCount() {
return mContext.getResources().getStringArray(R.array.about_tabs).length;
}
@Override
public Fragment getItem(int position) {
switch(position) {
case 0:
return new AboutFragment();
case 1:
return new ChangelogFragment();
case 2:
| return new ExtLibrariesFragment();
|
mauimauer/cheapcast | src/main/java/at/maui/cheapcast/json/deserializer/RampMessageDeserializer.java | // Path: src/main/java/at/maui/cheapcast/chromecast/model/ramp/RampMessage.java
// public class RampMessage extends Command implements ProtocolPayload {
// private int cmdId;
//
// public int getCmdId() {
// return cmdId;
// }
//
// public void setCmdId(int cmdId) {
// this.cmdId = cmdId;
// }
// }
//
// Path: src/main/java/at/maui/cheapcast/chromecast/model/ramp/RampVolume.java
// public class RampVolume extends RampMessage {
// private double volume;
//
// public double getVolume() {
// return volume;
// }
//
// public void setVolume(double volume) {
// this.volume = volume;
// }
// }
| import at.maui.cheapcast.chromecast.model.ramp.RampMessage;
import at.maui.cheapcast.chromecast.model.ramp.RampResponse;
import at.maui.cheapcast.chromecast.model.ramp.RampVolume;
import com.google.gson.*;
import java.lang.reflect.Type;
| /*
* Copyright 2013 Sebastian Mauer
*
* 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 at.maui.cheapcast.json.deserializer;
public class RampMessageDeserializer implements JsonDeserializer<RampMessage> {
@Override
public RampMessage deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
if(jsonElement.isJsonObject()) {
JsonObject obj = jsonElement.getAsJsonObject();
String t = obj.getAsJsonPrimitive("type").getAsString();
if(t.equals("VOLUME")) {
| // Path: src/main/java/at/maui/cheapcast/chromecast/model/ramp/RampMessage.java
// public class RampMessage extends Command implements ProtocolPayload {
// private int cmdId;
//
// public int getCmdId() {
// return cmdId;
// }
//
// public void setCmdId(int cmdId) {
// this.cmdId = cmdId;
// }
// }
//
// Path: src/main/java/at/maui/cheapcast/chromecast/model/ramp/RampVolume.java
// public class RampVolume extends RampMessage {
// private double volume;
//
// public double getVolume() {
// return volume;
// }
//
// public void setVolume(double volume) {
// this.volume = volume;
// }
// }
// Path: src/main/java/at/maui/cheapcast/json/deserializer/RampMessageDeserializer.java
import at.maui.cheapcast.chromecast.model.ramp.RampMessage;
import at.maui.cheapcast.chromecast.model.ramp.RampResponse;
import at.maui.cheapcast.chromecast.model.ramp.RampVolume;
import com.google.gson.*;
import java.lang.reflect.Type;
/*
* Copyright 2013 Sebastian Mauer
*
* 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 at.maui.cheapcast.json.deserializer;
public class RampMessageDeserializer implements JsonDeserializer<RampMessage> {
@Override
public RampMessage deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
if(jsonElement.isJsonObject()) {
JsonObject obj = jsonElement.getAsJsonObject();
String t = obj.getAsJsonPrimitive("type").getAsString();
if(t.equals("VOLUME")) {
| return jsonDeserializationContext.deserialize(jsonElement, RampVolume.class);
|
ppicas/android-clean-architecture-mvp | core/src/main/java/cat/ppicas/cleanarch/task/FindCityTask.java | // Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java
// public interface CityRepository {
//
// City getCity(String cityId);
//
// List<City> findCity(String name);
//
// }
//
// Path: core/src/main/java/cat/ppicas/framework/task/Task.java
// public interface Task<R, E extends Exception> {
//
// TaskResult<R, E> execute();
//
// }
//
// Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java
// public class TaskResult<R, E extends Exception> {
//
// private final R mResult;
//
// private final E mError;
//
// private final boolean mCanceled;
//
// public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) {
// return new TaskResult<>(result, null, false);
// }
//
// public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) {
// return new TaskResult<>(null, error, false);
// }
//
// public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() {
// return new TaskResult<>(null, null, true);
// }
//
// TaskResult(R result, E error, boolean canceled) {
// mResult = result;
// mError = error;
// mCanceled = canceled;
// }
//
// public R getResult() {
// return mResult;
// }
//
// public E getError() {
// return mError;
// }
//
// public boolean isSuccess() {
// return !mCanceled && mError == null;
// }
//
// public boolean isCanceled() {
// return mCanceled;
// }
// }
| import java.io.IOException;
import java.util.List;
import cat.ppicas.cleanarch.model.City;
import cat.ppicas.cleanarch.repository.CityRepository;
import cat.ppicas.framework.task.Task;
import cat.ppicas.framework.task.TaskResult;
import retrofit.RetrofitError; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.task;
public class FindCityTask implements Task<List<City>, IOException> {
private String mCityName; | // Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java
// public interface CityRepository {
//
// City getCity(String cityId);
//
// List<City> findCity(String name);
//
// }
//
// Path: core/src/main/java/cat/ppicas/framework/task/Task.java
// public interface Task<R, E extends Exception> {
//
// TaskResult<R, E> execute();
//
// }
//
// Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java
// public class TaskResult<R, E extends Exception> {
//
// private final R mResult;
//
// private final E mError;
//
// private final boolean mCanceled;
//
// public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) {
// return new TaskResult<>(result, null, false);
// }
//
// public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) {
// return new TaskResult<>(null, error, false);
// }
//
// public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() {
// return new TaskResult<>(null, null, true);
// }
//
// TaskResult(R result, E error, boolean canceled) {
// mResult = result;
// mError = error;
// mCanceled = canceled;
// }
//
// public R getResult() {
// return mResult;
// }
//
// public E getError() {
// return mError;
// }
//
// public boolean isSuccess() {
// return !mCanceled && mError == null;
// }
//
// public boolean isCanceled() {
// return mCanceled;
// }
// }
// Path: core/src/main/java/cat/ppicas/cleanarch/task/FindCityTask.java
import java.io.IOException;
import java.util.List;
import cat.ppicas.cleanarch.model.City;
import cat.ppicas.cleanarch.repository.CityRepository;
import cat.ppicas.framework.task.Task;
import cat.ppicas.framework.task.TaskResult;
import retrofit.RetrofitError;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.task;
public class FindCityTask implements Task<List<City>, IOException> {
private String mCityName; | private CityRepository mRepository; |
ppicas/android-clean-architecture-mvp | core/src/main/java/cat/ppicas/cleanarch/task/FindCityTask.java | // Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java
// public interface CityRepository {
//
// City getCity(String cityId);
//
// List<City> findCity(String name);
//
// }
//
// Path: core/src/main/java/cat/ppicas/framework/task/Task.java
// public interface Task<R, E extends Exception> {
//
// TaskResult<R, E> execute();
//
// }
//
// Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java
// public class TaskResult<R, E extends Exception> {
//
// private final R mResult;
//
// private final E mError;
//
// private final boolean mCanceled;
//
// public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) {
// return new TaskResult<>(result, null, false);
// }
//
// public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) {
// return new TaskResult<>(null, error, false);
// }
//
// public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() {
// return new TaskResult<>(null, null, true);
// }
//
// TaskResult(R result, E error, boolean canceled) {
// mResult = result;
// mError = error;
// mCanceled = canceled;
// }
//
// public R getResult() {
// return mResult;
// }
//
// public E getError() {
// return mError;
// }
//
// public boolean isSuccess() {
// return !mCanceled && mError == null;
// }
//
// public boolean isCanceled() {
// return mCanceled;
// }
// }
| import java.io.IOException;
import java.util.List;
import cat.ppicas.cleanarch.model.City;
import cat.ppicas.cleanarch.repository.CityRepository;
import cat.ppicas.framework.task.Task;
import cat.ppicas.framework.task.TaskResult;
import retrofit.RetrofitError; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.task;
public class FindCityTask implements Task<List<City>, IOException> {
private String mCityName;
private CityRepository mRepository;
private boolean mCanceled;
public FindCityTask(String cityName, CityRepository repository) {
mCityName = cityName;
mRepository = repository;
}
@Override | // Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java
// public interface CityRepository {
//
// City getCity(String cityId);
//
// List<City> findCity(String name);
//
// }
//
// Path: core/src/main/java/cat/ppicas/framework/task/Task.java
// public interface Task<R, E extends Exception> {
//
// TaskResult<R, E> execute();
//
// }
//
// Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java
// public class TaskResult<R, E extends Exception> {
//
// private final R mResult;
//
// private final E mError;
//
// private final boolean mCanceled;
//
// public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) {
// return new TaskResult<>(result, null, false);
// }
//
// public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) {
// return new TaskResult<>(null, error, false);
// }
//
// public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() {
// return new TaskResult<>(null, null, true);
// }
//
// TaskResult(R result, E error, boolean canceled) {
// mResult = result;
// mError = error;
// mCanceled = canceled;
// }
//
// public R getResult() {
// return mResult;
// }
//
// public E getError() {
// return mError;
// }
//
// public boolean isSuccess() {
// return !mCanceled && mError == null;
// }
//
// public boolean isCanceled() {
// return mCanceled;
// }
// }
// Path: core/src/main/java/cat/ppicas/cleanarch/task/FindCityTask.java
import java.io.IOException;
import java.util.List;
import cat.ppicas.cleanarch.model.City;
import cat.ppicas.cleanarch.repository.CityRepository;
import cat.ppicas.framework.task.Task;
import cat.ppicas.framework.task.TaskResult;
import retrofit.RetrofitError;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.task;
public class FindCityTask implements Task<List<City>, IOException> {
private String mCityName;
private CityRepository mRepository;
private boolean mCanceled;
public FindCityTask(String cityName, CityRepository repository) {
mCityName = cityName;
mRepository = repository;
}
@Override | public TaskResult<List<City>, IOException> execute() { |
ppicas/android-clean-architecture-mvp | core/src/main/java/cat/ppicas/cleanarch/owm/OWMCityRepository.java | // Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/model/CurrentWeatherPreview.java
// public class CurrentWeatherPreview {
//
// private String mCityId;
// private double mCurrentTemp;
//
// public CurrentWeatherPreview(String cityId, double currentTemp) {
// mCityId = cityId;
// mCurrentTemp = currentTemp;
// }
//
// public String getCityId() {
// return mCityId;
// }
//
// public double getCurrentTemp() {
// return mCurrentTemp;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeatherList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeatherList {
//
// @SerializedName("count")
// private int mCount;
// @SerializedName("list")
// private List<OWMCurrentWeather> mCurrentWeatherList;
//
// public int getCount() {
// return mCount;
// }
//
// public List<OWMCurrentWeather> getList() {
// return mCurrentWeatherList;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java
// public interface CityRepository {
//
// City getCity(String cityId);
//
// List<City> findCity(String name);
//
// }
| import java.util.ArrayList;
import java.util.List;
import cat.ppicas.cleanarch.model.City;
import cat.ppicas.cleanarch.model.CurrentWeatherPreview;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeatherList;
import cat.ppicas.cleanarch.repository.CityRepository; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMCityRepository implements CityRepository {
private final OWMService mService;
public OWMCityRepository(OWMService service) {
mService = service;
}
@Override | // Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/model/CurrentWeatherPreview.java
// public class CurrentWeatherPreview {
//
// private String mCityId;
// private double mCurrentTemp;
//
// public CurrentWeatherPreview(String cityId, double currentTemp) {
// mCityId = cityId;
// mCurrentTemp = currentTemp;
// }
//
// public String getCityId() {
// return mCityId;
// }
//
// public double getCurrentTemp() {
// return mCurrentTemp;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeatherList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeatherList {
//
// @SerializedName("count")
// private int mCount;
// @SerializedName("list")
// private List<OWMCurrentWeather> mCurrentWeatherList;
//
// public int getCount() {
// return mCount;
// }
//
// public List<OWMCurrentWeather> getList() {
// return mCurrentWeatherList;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java
// public interface CityRepository {
//
// City getCity(String cityId);
//
// List<City> findCity(String name);
//
// }
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/OWMCityRepository.java
import java.util.ArrayList;
import java.util.List;
import cat.ppicas.cleanarch.model.City;
import cat.ppicas.cleanarch.model.CurrentWeatherPreview;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeatherList;
import cat.ppicas.cleanarch.repository.CityRepository;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMCityRepository implements CityRepository {
private final OWMService mService;
public OWMCityRepository(OWMService service) {
mService = service;
}
@Override | public City getCity(String cityId) { |
ppicas/android-clean-architecture-mvp | core/src/main/java/cat/ppicas/cleanarch/owm/OWMCityRepository.java | // Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/model/CurrentWeatherPreview.java
// public class CurrentWeatherPreview {
//
// private String mCityId;
// private double mCurrentTemp;
//
// public CurrentWeatherPreview(String cityId, double currentTemp) {
// mCityId = cityId;
// mCurrentTemp = currentTemp;
// }
//
// public String getCityId() {
// return mCityId;
// }
//
// public double getCurrentTemp() {
// return mCurrentTemp;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeatherList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeatherList {
//
// @SerializedName("count")
// private int mCount;
// @SerializedName("list")
// private List<OWMCurrentWeather> mCurrentWeatherList;
//
// public int getCount() {
// return mCount;
// }
//
// public List<OWMCurrentWeather> getList() {
// return mCurrentWeatherList;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java
// public interface CityRepository {
//
// City getCity(String cityId);
//
// List<City> findCity(String name);
//
// }
| import java.util.ArrayList;
import java.util.List;
import cat.ppicas.cleanarch.model.City;
import cat.ppicas.cleanarch.model.CurrentWeatherPreview;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeatherList;
import cat.ppicas.cleanarch.repository.CityRepository; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMCityRepository implements CityRepository {
private final OWMService mService;
public OWMCityRepository(OWMService service) {
mService = service;
}
@Override
public City getCity(String cityId) { | // Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/model/CurrentWeatherPreview.java
// public class CurrentWeatherPreview {
//
// private String mCityId;
// private double mCurrentTemp;
//
// public CurrentWeatherPreview(String cityId, double currentTemp) {
// mCityId = cityId;
// mCurrentTemp = currentTemp;
// }
//
// public String getCityId() {
// return mCityId;
// }
//
// public double getCurrentTemp() {
// return mCurrentTemp;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeatherList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeatherList {
//
// @SerializedName("count")
// private int mCount;
// @SerializedName("list")
// private List<OWMCurrentWeather> mCurrentWeatherList;
//
// public int getCount() {
// return mCount;
// }
//
// public List<OWMCurrentWeather> getList() {
// return mCurrentWeatherList;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java
// public interface CityRepository {
//
// City getCity(String cityId);
//
// List<City> findCity(String name);
//
// }
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/OWMCityRepository.java
import java.util.ArrayList;
import java.util.List;
import cat.ppicas.cleanarch.model.City;
import cat.ppicas.cleanarch.model.CurrentWeatherPreview;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeatherList;
import cat.ppicas.cleanarch.repository.CityRepository;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMCityRepository implements CityRepository {
private final OWMService mService;
public OWMCityRepository(OWMService service) {
mService = service;
}
@Override
public City getCity(String cityId) { | OWMCurrentWeather cw = mService.getCurrentWeatherByCityId(cityId); |
ppicas/android-clean-architecture-mvp | core/src/main/java/cat/ppicas/cleanarch/owm/OWMCityRepository.java | // Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/model/CurrentWeatherPreview.java
// public class CurrentWeatherPreview {
//
// private String mCityId;
// private double mCurrentTemp;
//
// public CurrentWeatherPreview(String cityId, double currentTemp) {
// mCityId = cityId;
// mCurrentTemp = currentTemp;
// }
//
// public String getCityId() {
// return mCityId;
// }
//
// public double getCurrentTemp() {
// return mCurrentTemp;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeatherList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeatherList {
//
// @SerializedName("count")
// private int mCount;
// @SerializedName("list")
// private List<OWMCurrentWeather> mCurrentWeatherList;
//
// public int getCount() {
// return mCount;
// }
//
// public List<OWMCurrentWeather> getList() {
// return mCurrentWeatherList;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java
// public interface CityRepository {
//
// City getCity(String cityId);
//
// List<City> findCity(String name);
//
// }
| import java.util.ArrayList;
import java.util.List;
import cat.ppicas.cleanarch.model.City;
import cat.ppicas.cleanarch.model.CurrentWeatherPreview;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeatherList;
import cat.ppicas.cleanarch.repository.CityRepository; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMCityRepository implements CityRepository {
private final OWMService mService;
public OWMCityRepository(OWMService service) {
mService = service;
}
@Override
public City getCity(String cityId) {
OWMCurrentWeather cw = mService.getCurrentWeatherByCityId(cityId);
return createCityFromCityWeather(cw);
}
@Override
public List<City> findCity(String name) {
List<City> cities = new ArrayList<City>(); | // Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/model/CurrentWeatherPreview.java
// public class CurrentWeatherPreview {
//
// private String mCityId;
// private double mCurrentTemp;
//
// public CurrentWeatherPreview(String cityId, double currentTemp) {
// mCityId = cityId;
// mCurrentTemp = currentTemp;
// }
//
// public String getCityId() {
// return mCityId;
// }
//
// public double getCurrentTemp() {
// return mCurrentTemp;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeatherList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeatherList {
//
// @SerializedName("count")
// private int mCount;
// @SerializedName("list")
// private List<OWMCurrentWeather> mCurrentWeatherList;
//
// public int getCount() {
// return mCount;
// }
//
// public List<OWMCurrentWeather> getList() {
// return mCurrentWeatherList;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java
// public interface CityRepository {
//
// City getCity(String cityId);
//
// List<City> findCity(String name);
//
// }
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/OWMCityRepository.java
import java.util.ArrayList;
import java.util.List;
import cat.ppicas.cleanarch.model.City;
import cat.ppicas.cleanarch.model.CurrentWeatherPreview;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeatherList;
import cat.ppicas.cleanarch.repository.CityRepository;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMCityRepository implements CityRepository {
private final OWMService mService;
public OWMCityRepository(OWMService service) {
mService = service;
}
@Override
public City getCity(String cityId) {
OWMCurrentWeather cw = mService.getCurrentWeatherByCityId(cityId);
return createCityFromCityWeather(cw);
}
@Override
public List<City> findCity(String name) {
List<City> cities = new ArrayList<City>(); | OWMCurrentWeatherList citiesWeather = mService.getCurrentWeatherByCityName(name); |
ppicas/android-clean-architecture-mvp | core/src/main/java/cat/ppicas/cleanarch/owm/OWMCityRepository.java | // Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/model/CurrentWeatherPreview.java
// public class CurrentWeatherPreview {
//
// private String mCityId;
// private double mCurrentTemp;
//
// public CurrentWeatherPreview(String cityId, double currentTemp) {
// mCityId = cityId;
// mCurrentTemp = currentTemp;
// }
//
// public String getCityId() {
// return mCityId;
// }
//
// public double getCurrentTemp() {
// return mCurrentTemp;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeatherList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeatherList {
//
// @SerializedName("count")
// private int mCount;
// @SerializedName("list")
// private List<OWMCurrentWeather> mCurrentWeatherList;
//
// public int getCount() {
// return mCount;
// }
//
// public List<OWMCurrentWeather> getList() {
// return mCurrentWeatherList;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java
// public interface CityRepository {
//
// City getCity(String cityId);
//
// List<City> findCity(String name);
//
// }
| import java.util.ArrayList;
import java.util.List;
import cat.ppicas.cleanarch.model.City;
import cat.ppicas.cleanarch.model.CurrentWeatherPreview;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeatherList;
import cat.ppicas.cleanarch.repository.CityRepository; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMCityRepository implements CityRepository {
private final OWMService mService;
public OWMCityRepository(OWMService service) {
mService = service;
}
@Override
public City getCity(String cityId) {
OWMCurrentWeather cw = mService.getCurrentWeatherByCityId(cityId);
return createCityFromCityWeather(cw);
}
@Override
public List<City> findCity(String name) {
List<City> cities = new ArrayList<City>();
OWMCurrentWeatherList citiesWeather = mService.getCurrentWeatherByCityName(name);
for (OWMCurrentWeather cw : citiesWeather.getList()) {
cities.add(createCityFromCityWeather(cw));
}
return cities;
}
private City createCityFromCityWeather(OWMCurrentWeather cw) { | // Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/model/CurrentWeatherPreview.java
// public class CurrentWeatherPreview {
//
// private String mCityId;
// private double mCurrentTemp;
//
// public CurrentWeatherPreview(String cityId, double currentTemp) {
// mCityId = cityId;
// mCurrentTemp = currentTemp;
// }
//
// public String getCityId() {
// return mCityId;
// }
//
// public double getCurrentTemp() {
// return mCurrentTemp;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeatherList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeatherList {
//
// @SerializedName("count")
// private int mCount;
// @SerializedName("list")
// private List<OWMCurrentWeather> mCurrentWeatherList;
//
// public int getCount() {
// return mCount;
// }
//
// public List<OWMCurrentWeather> getList() {
// return mCurrentWeatherList;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java
// public interface CityRepository {
//
// City getCity(String cityId);
//
// List<City> findCity(String name);
//
// }
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/OWMCityRepository.java
import java.util.ArrayList;
import java.util.List;
import cat.ppicas.cleanarch.model.City;
import cat.ppicas.cleanarch.model.CurrentWeatherPreview;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeatherList;
import cat.ppicas.cleanarch.repository.CityRepository;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMCityRepository implements CityRepository {
private final OWMService mService;
public OWMCityRepository(OWMService service) {
mService = service;
}
@Override
public City getCity(String cityId) {
OWMCurrentWeather cw = mService.getCurrentWeatherByCityId(cityId);
return createCityFromCityWeather(cw);
}
@Override
public List<City> findCity(String name) {
List<City> cities = new ArrayList<City>();
OWMCurrentWeatherList citiesWeather = mService.getCurrentWeatherByCityName(name);
for (OWMCurrentWeather cw : citiesWeather.getList()) {
cities.add(createCityFromCityWeather(cw));
}
return cities;
}
private City createCityFromCityWeather(OWMCurrentWeather cw) { | CurrentWeatherPreview weatherPreview = new CurrentWeatherPreview( |
ppicas/android-clean-architecture-mvp | app/src/main/java/cat/ppicas/cleanarch/ui/fragment/CityDetailFragment.java | // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java
// public interface ServiceContainer {
//
// CityRepository getCityRepository();
//
// CurrentWeatherRepository getCurrentWeatherRepository();
//
// DailyForecastRepository getDailyForecastRepository();
//
// TaskExecutor getTaskExecutor();
//
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java
// public final class ServiceContainers {
//
// private ServiceContainers() {
// throw new RuntimeException("Instances are not allowed for this class");
// }
//
// public static ServiceContainer getFromApp(Context context) {
// Context app = context.getApplicationContext();
// ServiceContainerProvider provider = (ServiceContainerProvider) app;
// return provider.getServiceContainer();
// }
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityDetailPresenter.java
// public class CityDetailPresenter extends Presenter<CityDetailVista> {
//
// private static final String DAY_OF_WEEK_DATE_FORMAT_PATTERN = "cccc";
//
// private final TaskExecutor mTaskExecutor;
// private final CityRepository mCityRepository;
// private final Resources mResources;
// private final String mCityId;
//
// private GetCityTask mGetCityTask;
// private City mCity;
//
// public CityDetailPresenter(TaskExecutor taskExecutor, CityRepository cityRepository,
// Resources resources, String cityId) {
// mTaskExecutor = taskExecutor;
// mCityRepository = cityRepository;
// mResources = resources;
// mCityId = cityId;
// }
//
// @Override
// public void onStart(CityDetailVista vista) {
// vista.setTitle(R.string.city_details__title_loading);
//
// if (mCity != null) {
// vista.setTitle(R.string.city_details__title, mCity.getName());
// } else {
// vista.displayLoading(true);
// if (!mTaskExecutor.isRunning(mGetCityTask)) {
// mGetCityTask = new GetCityTask(mCityRepository, mCityId);
// mTaskExecutor.execute(mGetCityTask, new GetCityTaskCallback());
// }
// }
// }
//
// public String getForecastPageTitle(int daysFromToday) {
// if (daysFromToday == 0) {
// return mResources.getString(R.string.city_details__tab_forecast,
// mResources.getString(R.string.global__today));
// } else if (daysFromToday == 1) {
// return mResources.getString(R.string.city_details__tab_forecast,
// mResources.getString(R.string.global__tomorrow));
// } else {
// Calendar cal = Calendar.getInstance();
// cal.add(Calendar.DAY_OF_MONTH, daysFromToday);
// return mResources.getString(R.string.city_details__tab_forecast,
// DateFormat.format(DAY_OF_WEEK_DATE_FORMAT_PATTERN, cal));
// }
// }
//
// private class GetCityTaskCallback extends DisplayErrorTaskCallback<City> {
//
// public GetCityTaskCallback() {
// super(CityDetailPresenter.this);
// }
//
// @Override
// public void onSuccess(City city) {
// mCity = city;
// CityDetailVista vista = getVista();
// if (vista != null) {
// vista.displayLoading(false);
// vista.setTitle(R.string.city_details__title, city.getName());
// }
// }
// }
// }
//
// Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java
// public interface PresenterFactory<T extends Presenter<?>> {
//
// T createPresenter();
//
// String getPresenterTag();
//
// }
//
// Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java
// public interface PresenterHolder {
//
// <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory);
//
// void destroyPresenter(PresenterFactory<?> presenterFactory);
//
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityDetailVista.java
// public interface CityDetailVista extends TaskResultVista {
//
// void setTitle(int stringResId, Object... args);
//
// }
| import cat.ppicas.framework.ui.PresenterFactory;
import cat.ppicas.framework.ui.PresenterHolder;
import cat.ppicas.cleanarch.ui.vista.CityDetailVista;
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.v13.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import cat.ppicas.cleanarch.R;
import cat.ppicas.cleanarch.app.ServiceContainer;
import cat.ppicas.cleanarch.app.ServiceContainers;
import cat.ppicas.cleanarch.ui.presenter.CityDetailPresenter; | @Override
public void onStart() {
super.onStart();
mPresenter.start(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.stop();
}
@Override
public void setTitle(int stringResId, Object... args) {
getActivity().setTitle(getString(stringResId, args));
}
@Override
public void displayLoading(boolean display) {
getActivity().setProgressBarIndeterminate(true);
getActivity().setProgressBarIndeterminateVisibility(display);
}
@Override
public void displayError(int stringResId, Object... args) {
Toast.makeText(getActivity().getApplicationContext(), stringResId, Toast.LENGTH_LONG).show();
}
@Override
public CityDetailPresenter createPresenter() { | // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java
// public interface ServiceContainer {
//
// CityRepository getCityRepository();
//
// CurrentWeatherRepository getCurrentWeatherRepository();
//
// DailyForecastRepository getDailyForecastRepository();
//
// TaskExecutor getTaskExecutor();
//
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java
// public final class ServiceContainers {
//
// private ServiceContainers() {
// throw new RuntimeException("Instances are not allowed for this class");
// }
//
// public static ServiceContainer getFromApp(Context context) {
// Context app = context.getApplicationContext();
// ServiceContainerProvider provider = (ServiceContainerProvider) app;
// return provider.getServiceContainer();
// }
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityDetailPresenter.java
// public class CityDetailPresenter extends Presenter<CityDetailVista> {
//
// private static final String DAY_OF_WEEK_DATE_FORMAT_PATTERN = "cccc";
//
// private final TaskExecutor mTaskExecutor;
// private final CityRepository mCityRepository;
// private final Resources mResources;
// private final String mCityId;
//
// private GetCityTask mGetCityTask;
// private City mCity;
//
// public CityDetailPresenter(TaskExecutor taskExecutor, CityRepository cityRepository,
// Resources resources, String cityId) {
// mTaskExecutor = taskExecutor;
// mCityRepository = cityRepository;
// mResources = resources;
// mCityId = cityId;
// }
//
// @Override
// public void onStart(CityDetailVista vista) {
// vista.setTitle(R.string.city_details__title_loading);
//
// if (mCity != null) {
// vista.setTitle(R.string.city_details__title, mCity.getName());
// } else {
// vista.displayLoading(true);
// if (!mTaskExecutor.isRunning(mGetCityTask)) {
// mGetCityTask = new GetCityTask(mCityRepository, mCityId);
// mTaskExecutor.execute(mGetCityTask, new GetCityTaskCallback());
// }
// }
// }
//
// public String getForecastPageTitle(int daysFromToday) {
// if (daysFromToday == 0) {
// return mResources.getString(R.string.city_details__tab_forecast,
// mResources.getString(R.string.global__today));
// } else if (daysFromToday == 1) {
// return mResources.getString(R.string.city_details__tab_forecast,
// mResources.getString(R.string.global__tomorrow));
// } else {
// Calendar cal = Calendar.getInstance();
// cal.add(Calendar.DAY_OF_MONTH, daysFromToday);
// return mResources.getString(R.string.city_details__tab_forecast,
// DateFormat.format(DAY_OF_WEEK_DATE_FORMAT_PATTERN, cal));
// }
// }
//
// private class GetCityTaskCallback extends DisplayErrorTaskCallback<City> {
//
// public GetCityTaskCallback() {
// super(CityDetailPresenter.this);
// }
//
// @Override
// public void onSuccess(City city) {
// mCity = city;
// CityDetailVista vista = getVista();
// if (vista != null) {
// vista.displayLoading(false);
// vista.setTitle(R.string.city_details__title, city.getName());
// }
// }
// }
// }
//
// Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java
// public interface PresenterFactory<T extends Presenter<?>> {
//
// T createPresenter();
//
// String getPresenterTag();
//
// }
//
// Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java
// public interface PresenterHolder {
//
// <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory);
//
// void destroyPresenter(PresenterFactory<?> presenterFactory);
//
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityDetailVista.java
// public interface CityDetailVista extends TaskResultVista {
//
// void setTitle(int stringResId, Object... args);
//
// }
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/fragment/CityDetailFragment.java
import cat.ppicas.framework.ui.PresenterFactory;
import cat.ppicas.framework.ui.PresenterHolder;
import cat.ppicas.cleanarch.ui.vista.CityDetailVista;
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.v13.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import cat.ppicas.cleanarch.R;
import cat.ppicas.cleanarch.app.ServiceContainer;
import cat.ppicas.cleanarch.app.ServiceContainers;
import cat.ppicas.cleanarch.ui.presenter.CityDetailPresenter;
@Override
public void onStart() {
super.onStart();
mPresenter.start(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.stop();
}
@Override
public void setTitle(int stringResId, Object... args) {
getActivity().setTitle(getString(stringResId, args));
}
@Override
public void displayLoading(boolean display) {
getActivity().setProgressBarIndeterminate(true);
getActivity().setProgressBarIndeterminateVisibility(display);
}
@Override
public void displayError(int stringResId, Object... args) {
Toast.makeText(getActivity().getApplicationContext(), stringResId, Toast.LENGTH_LONG).show();
}
@Override
public CityDetailPresenter createPresenter() { | ServiceContainer sc = ServiceContainers.getFromApp(getActivity()); |
ppicas/android-clean-architecture-mvp | app/src/main/java/cat/ppicas/cleanarch/ui/fragment/CityDetailFragment.java | // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java
// public interface ServiceContainer {
//
// CityRepository getCityRepository();
//
// CurrentWeatherRepository getCurrentWeatherRepository();
//
// DailyForecastRepository getDailyForecastRepository();
//
// TaskExecutor getTaskExecutor();
//
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java
// public final class ServiceContainers {
//
// private ServiceContainers() {
// throw new RuntimeException("Instances are not allowed for this class");
// }
//
// public static ServiceContainer getFromApp(Context context) {
// Context app = context.getApplicationContext();
// ServiceContainerProvider provider = (ServiceContainerProvider) app;
// return provider.getServiceContainer();
// }
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityDetailPresenter.java
// public class CityDetailPresenter extends Presenter<CityDetailVista> {
//
// private static final String DAY_OF_WEEK_DATE_FORMAT_PATTERN = "cccc";
//
// private final TaskExecutor mTaskExecutor;
// private final CityRepository mCityRepository;
// private final Resources mResources;
// private final String mCityId;
//
// private GetCityTask mGetCityTask;
// private City mCity;
//
// public CityDetailPresenter(TaskExecutor taskExecutor, CityRepository cityRepository,
// Resources resources, String cityId) {
// mTaskExecutor = taskExecutor;
// mCityRepository = cityRepository;
// mResources = resources;
// mCityId = cityId;
// }
//
// @Override
// public void onStart(CityDetailVista vista) {
// vista.setTitle(R.string.city_details__title_loading);
//
// if (mCity != null) {
// vista.setTitle(R.string.city_details__title, mCity.getName());
// } else {
// vista.displayLoading(true);
// if (!mTaskExecutor.isRunning(mGetCityTask)) {
// mGetCityTask = new GetCityTask(mCityRepository, mCityId);
// mTaskExecutor.execute(mGetCityTask, new GetCityTaskCallback());
// }
// }
// }
//
// public String getForecastPageTitle(int daysFromToday) {
// if (daysFromToday == 0) {
// return mResources.getString(R.string.city_details__tab_forecast,
// mResources.getString(R.string.global__today));
// } else if (daysFromToday == 1) {
// return mResources.getString(R.string.city_details__tab_forecast,
// mResources.getString(R.string.global__tomorrow));
// } else {
// Calendar cal = Calendar.getInstance();
// cal.add(Calendar.DAY_OF_MONTH, daysFromToday);
// return mResources.getString(R.string.city_details__tab_forecast,
// DateFormat.format(DAY_OF_WEEK_DATE_FORMAT_PATTERN, cal));
// }
// }
//
// private class GetCityTaskCallback extends DisplayErrorTaskCallback<City> {
//
// public GetCityTaskCallback() {
// super(CityDetailPresenter.this);
// }
//
// @Override
// public void onSuccess(City city) {
// mCity = city;
// CityDetailVista vista = getVista();
// if (vista != null) {
// vista.displayLoading(false);
// vista.setTitle(R.string.city_details__title, city.getName());
// }
// }
// }
// }
//
// Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java
// public interface PresenterFactory<T extends Presenter<?>> {
//
// T createPresenter();
//
// String getPresenterTag();
//
// }
//
// Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java
// public interface PresenterHolder {
//
// <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory);
//
// void destroyPresenter(PresenterFactory<?> presenterFactory);
//
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityDetailVista.java
// public interface CityDetailVista extends TaskResultVista {
//
// void setTitle(int stringResId, Object... args);
//
// }
| import cat.ppicas.framework.ui.PresenterFactory;
import cat.ppicas.framework.ui.PresenterHolder;
import cat.ppicas.cleanarch.ui.vista.CityDetailVista;
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.v13.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import cat.ppicas.cleanarch.R;
import cat.ppicas.cleanarch.app.ServiceContainer;
import cat.ppicas.cleanarch.app.ServiceContainers;
import cat.ppicas.cleanarch.ui.presenter.CityDetailPresenter; | @Override
public void onStart() {
super.onStart();
mPresenter.start(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.stop();
}
@Override
public void setTitle(int stringResId, Object... args) {
getActivity().setTitle(getString(stringResId, args));
}
@Override
public void displayLoading(boolean display) {
getActivity().setProgressBarIndeterminate(true);
getActivity().setProgressBarIndeterminateVisibility(display);
}
@Override
public void displayError(int stringResId, Object... args) {
Toast.makeText(getActivity().getApplicationContext(), stringResId, Toast.LENGTH_LONG).show();
}
@Override
public CityDetailPresenter createPresenter() { | // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java
// public interface ServiceContainer {
//
// CityRepository getCityRepository();
//
// CurrentWeatherRepository getCurrentWeatherRepository();
//
// DailyForecastRepository getDailyForecastRepository();
//
// TaskExecutor getTaskExecutor();
//
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java
// public final class ServiceContainers {
//
// private ServiceContainers() {
// throw new RuntimeException("Instances are not allowed for this class");
// }
//
// public static ServiceContainer getFromApp(Context context) {
// Context app = context.getApplicationContext();
// ServiceContainerProvider provider = (ServiceContainerProvider) app;
// return provider.getServiceContainer();
// }
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityDetailPresenter.java
// public class CityDetailPresenter extends Presenter<CityDetailVista> {
//
// private static final String DAY_OF_WEEK_DATE_FORMAT_PATTERN = "cccc";
//
// private final TaskExecutor mTaskExecutor;
// private final CityRepository mCityRepository;
// private final Resources mResources;
// private final String mCityId;
//
// private GetCityTask mGetCityTask;
// private City mCity;
//
// public CityDetailPresenter(TaskExecutor taskExecutor, CityRepository cityRepository,
// Resources resources, String cityId) {
// mTaskExecutor = taskExecutor;
// mCityRepository = cityRepository;
// mResources = resources;
// mCityId = cityId;
// }
//
// @Override
// public void onStart(CityDetailVista vista) {
// vista.setTitle(R.string.city_details__title_loading);
//
// if (mCity != null) {
// vista.setTitle(R.string.city_details__title, mCity.getName());
// } else {
// vista.displayLoading(true);
// if (!mTaskExecutor.isRunning(mGetCityTask)) {
// mGetCityTask = new GetCityTask(mCityRepository, mCityId);
// mTaskExecutor.execute(mGetCityTask, new GetCityTaskCallback());
// }
// }
// }
//
// public String getForecastPageTitle(int daysFromToday) {
// if (daysFromToday == 0) {
// return mResources.getString(R.string.city_details__tab_forecast,
// mResources.getString(R.string.global__today));
// } else if (daysFromToday == 1) {
// return mResources.getString(R.string.city_details__tab_forecast,
// mResources.getString(R.string.global__tomorrow));
// } else {
// Calendar cal = Calendar.getInstance();
// cal.add(Calendar.DAY_OF_MONTH, daysFromToday);
// return mResources.getString(R.string.city_details__tab_forecast,
// DateFormat.format(DAY_OF_WEEK_DATE_FORMAT_PATTERN, cal));
// }
// }
//
// private class GetCityTaskCallback extends DisplayErrorTaskCallback<City> {
//
// public GetCityTaskCallback() {
// super(CityDetailPresenter.this);
// }
//
// @Override
// public void onSuccess(City city) {
// mCity = city;
// CityDetailVista vista = getVista();
// if (vista != null) {
// vista.displayLoading(false);
// vista.setTitle(R.string.city_details__title, city.getName());
// }
// }
// }
// }
//
// Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java
// public interface PresenterFactory<T extends Presenter<?>> {
//
// T createPresenter();
//
// String getPresenterTag();
//
// }
//
// Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java
// public interface PresenterHolder {
//
// <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory);
//
// void destroyPresenter(PresenterFactory<?> presenterFactory);
//
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityDetailVista.java
// public interface CityDetailVista extends TaskResultVista {
//
// void setTitle(int stringResId, Object... args);
//
// }
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/fragment/CityDetailFragment.java
import cat.ppicas.framework.ui.PresenterFactory;
import cat.ppicas.framework.ui.PresenterHolder;
import cat.ppicas.cleanarch.ui.vista.CityDetailVista;
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.v13.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import cat.ppicas.cleanarch.R;
import cat.ppicas.cleanarch.app.ServiceContainer;
import cat.ppicas.cleanarch.app.ServiceContainers;
import cat.ppicas.cleanarch.ui.presenter.CityDetailPresenter;
@Override
public void onStart() {
super.onStart();
mPresenter.start(this);
}
@Override
public void onStop() {
super.onStop();
mPresenter.stop();
}
@Override
public void setTitle(int stringResId, Object... args) {
getActivity().setTitle(getString(stringResId, args));
}
@Override
public void displayLoading(boolean display) {
getActivity().setProgressBarIndeterminate(true);
getActivity().setProgressBarIndeterminateVisibility(display);
}
@Override
public void displayError(int stringResId, Object... args) {
Toast.makeText(getActivity().getApplicationContext(), stringResId, Toast.LENGTH_LONG).show();
}
@Override
public CityDetailPresenter createPresenter() { | ServiceContainer sc = ServiceContainers.getFromApp(getActivity()); |
ppicas/android-clean-architecture-mvp | core/src/main/java/cat/ppicas/cleanarch/owm/OWMDailyForecastRepository.java | // Path: core/src/main/java/cat/ppicas/cleanarch/model/DailyForecast.java
// public class DailyForecast {
//
// private String mCityId;
// private Date mDate;
// private String mDescription;
// private double mDayTemp;
// private double mMinTemp;
// private double mMaxTemp;
// private double mHumidity;
// private double mWindSpeed;
//
// public DailyForecast(String cityId, Date date, String description, double dayTemp,
// double minTemp, double maxTemp, double humidity, double windSpeed) {
// mCityId = cityId;
// mDate = date;
// mDescription = description;
// mDayTemp = dayTemp;
// mMinTemp = minTemp;
// mMaxTemp = maxTemp;
// mHumidity = humidity;
// mWindSpeed = windSpeed;
// }
//
// public String getCityId() {
// return mCityId;
// }
//
// public Date getDate() {
// return mDate;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public double getDayTemp() {
// return mDayTemp;
// }
//
// public double getMinTemp() {
// return mMinTemp;
// }
//
// public double getMaxTemp() {
// return mMaxTemp;
// }
//
// public double getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecast.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecast {
//
// @SerializedName("dt")
// private int mTimestamp;
// @SerializedName("temp")
// private Temp mTemp;
// @SerializedName("humidity")
// private int mHumidity;
// @SerializedName("speed")
// private double mWindSpeed;
// @SerializedName("weather")
// private Weather[] mWeatherList;
//
// public int getTimestamp() {
// return mTimestamp;
// }
//
// public Temp getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
//
// public Weather[] getWeatherList() {
// return mWeatherList;
// }
//
// public class Temp {
// @SerializedName("day")
// private double mDay;
// @SerializedName("min")
// private double mMin;
// @SerializedName("max")
// private double mMax;
//
// public double getDay() {
// return mDay;
// }
//
// public double getMin() {
// return mMin;
// }
//
// public double getMax() {
// return mMax;
// }
// }
//
// public class Weather {
// @SerializedName("description")
// private String mDescription;
//
// public String getDescription() {
// return mDescription;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecastList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecastList {
//
// @SerializedName("cnt")
// private int mCount;
// @SerializedName("city")
// private City mCity;
// @SerializedName("list")
// private List<OWMDailyForecast> mDailyForecasts;
//
// public int getCount() {
// return mCount;
// }
//
// public City getCity() {
// return mCity;
// }
//
// public List<OWMDailyForecast> getList() {
// return mDailyForecasts;
// }
//
// public class City {
// @SerializedName("id")
// private String mId;
//
// public String getId() {
// return mId;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/DailyForecastRepository.java
// public interface DailyForecastRepository {
//
// List<DailyForecast> getDailyForecasts(String cityId);
//
// }
| import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import cat.ppicas.cleanarch.model.DailyForecast;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecast;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecastList;
import cat.ppicas.cleanarch.repository.DailyForecastRepository; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMDailyForecastRepository implements DailyForecastRepository {
private static final int FORECAST_DAYS = 3;
private OWMService mService;
public OWMDailyForecastRepository(OWMService service) {
mService = service;
}
@Override | // Path: core/src/main/java/cat/ppicas/cleanarch/model/DailyForecast.java
// public class DailyForecast {
//
// private String mCityId;
// private Date mDate;
// private String mDescription;
// private double mDayTemp;
// private double mMinTemp;
// private double mMaxTemp;
// private double mHumidity;
// private double mWindSpeed;
//
// public DailyForecast(String cityId, Date date, String description, double dayTemp,
// double minTemp, double maxTemp, double humidity, double windSpeed) {
// mCityId = cityId;
// mDate = date;
// mDescription = description;
// mDayTemp = dayTemp;
// mMinTemp = minTemp;
// mMaxTemp = maxTemp;
// mHumidity = humidity;
// mWindSpeed = windSpeed;
// }
//
// public String getCityId() {
// return mCityId;
// }
//
// public Date getDate() {
// return mDate;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public double getDayTemp() {
// return mDayTemp;
// }
//
// public double getMinTemp() {
// return mMinTemp;
// }
//
// public double getMaxTemp() {
// return mMaxTemp;
// }
//
// public double getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecast.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecast {
//
// @SerializedName("dt")
// private int mTimestamp;
// @SerializedName("temp")
// private Temp mTemp;
// @SerializedName("humidity")
// private int mHumidity;
// @SerializedName("speed")
// private double mWindSpeed;
// @SerializedName("weather")
// private Weather[] mWeatherList;
//
// public int getTimestamp() {
// return mTimestamp;
// }
//
// public Temp getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
//
// public Weather[] getWeatherList() {
// return mWeatherList;
// }
//
// public class Temp {
// @SerializedName("day")
// private double mDay;
// @SerializedName("min")
// private double mMin;
// @SerializedName("max")
// private double mMax;
//
// public double getDay() {
// return mDay;
// }
//
// public double getMin() {
// return mMin;
// }
//
// public double getMax() {
// return mMax;
// }
// }
//
// public class Weather {
// @SerializedName("description")
// private String mDescription;
//
// public String getDescription() {
// return mDescription;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecastList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecastList {
//
// @SerializedName("cnt")
// private int mCount;
// @SerializedName("city")
// private City mCity;
// @SerializedName("list")
// private List<OWMDailyForecast> mDailyForecasts;
//
// public int getCount() {
// return mCount;
// }
//
// public City getCity() {
// return mCity;
// }
//
// public List<OWMDailyForecast> getList() {
// return mDailyForecasts;
// }
//
// public class City {
// @SerializedName("id")
// private String mId;
//
// public String getId() {
// return mId;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/DailyForecastRepository.java
// public interface DailyForecastRepository {
//
// List<DailyForecast> getDailyForecasts(String cityId);
//
// }
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/OWMDailyForecastRepository.java
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import cat.ppicas.cleanarch.model.DailyForecast;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecast;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecastList;
import cat.ppicas.cleanarch.repository.DailyForecastRepository;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMDailyForecastRepository implements DailyForecastRepository {
private static final int FORECAST_DAYS = 3;
private OWMService mService;
public OWMDailyForecastRepository(OWMService service) {
mService = service;
}
@Override | public List<DailyForecast> getDailyForecasts(String cityId) { |
ppicas/android-clean-architecture-mvp | core/src/main/java/cat/ppicas/cleanarch/owm/OWMDailyForecastRepository.java | // Path: core/src/main/java/cat/ppicas/cleanarch/model/DailyForecast.java
// public class DailyForecast {
//
// private String mCityId;
// private Date mDate;
// private String mDescription;
// private double mDayTemp;
// private double mMinTemp;
// private double mMaxTemp;
// private double mHumidity;
// private double mWindSpeed;
//
// public DailyForecast(String cityId, Date date, String description, double dayTemp,
// double minTemp, double maxTemp, double humidity, double windSpeed) {
// mCityId = cityId;
// mDate = date;
// mDescription = description;
// mDayTemp = dayTemp;
// mMinTemp = minTemp;
// mMaxTemp = maxTemp;
// mHumidity = humidity;
// mWindSpeed = windSpeed;
// }
//
// public String getCityId() {
// return mCityId;
// }
//
// public Date getDate() {
// return mDate;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public double getDayTemp() {
// return mDayTemp;
// }
//
// public double getMinTemp() {
// return mMinTemp;
// }
//
// public double getMaxTemp() {
// return mMaxTemp;
// }
//
// public double getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecast.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecast {
//
// @SerializedName("dt")
// private int mTimestamp;
// @SerializedName("temp")
// private Temp mTemp;
// @SerializedName("humidity")
// private int mHumidity;
// @SerializedName("speed")
// private double mWindSpeed;
// @SerializedName("weather")
// private Weather[] mWeatherList;
//
// public int getTimestamp() {
// return mTimestamp;
// }
//
// public Temp getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
//
// public Weather[] getWeatherList() {
// return mWeatherList;
// }
//
// public class Temp {
// @SerializedName("day")
// private double mDay;
// @SerializedName("min")
// private double mMin;
// @SerializedName("max")
// private double mMax;
//
// public double getDay() {
// return mDay;
// }
//
// public double getMin() {
// return mMin;
// }
//
// public double getMax() {
// return mMax;
// }
// }
//
// public class Weather {
// @SerializedName("description")
// private String mDescription;
//
// public String getDescription() {
// return mDescription;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecastList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecastList {
//
// @SerializedName("cnt")
// private int mCount;
// @SerializedName("city")
// private City mCity;
// @SerializedName("list")
// private List<OWMDailyForecast> mDailyForecasts;
//
// public int getCount() {
// return mCount;
// }
//
// public City getCity() {
// return mCity;
// }
//
// public List<OWMDailyForecast> getList() {
// return mDailyForecasts;
// }
//
// public class City {
// @SerializedName("id")
// private String mId;
//
// public String getId() {
// return mId;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/DailyForecastRepository.java
// public interface DailyForecastRepository {
//
// List<DailyForecast> getDailyForecasts(String cityId);
//
// }
| import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import cat.ppicas.cleanarch.model.DailyForecast;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecast;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecastList;
import cat.ppicas.cleanarch.repository.DailyForecastRepository; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMDailyForecastRepository implements DailyForecastRepository {
private static final int FORECAST_DAYS = 3;
private OWMService mService;
public OWMDailyForecastRepository(OWMService service) {
mService = service;
}
@Override
public List<DailyForecast> getDailyForecasts(String cityId) {
List<DailyForecast> list = new ArrayList<DailyForecast>(); | // Path: core/src/main/java/cat/ppicas/cleanarch/model/DailyForecast.java
// public class DailyForecast {
//
// private String mCityId;
// private Date mDate;
// private String mDescription;
// private double mDayTemp;
// private double mMinTemp;
// private double mMaxTemp;
// private double mHumidity;
// private double mWindSpeed;
//
// public DailyForecast(String cityId, Date date, String description, double dayTemp,
// double minTemp, double maxTemp, double humidity, double windSpeed) {
// mCityId = cityId;
// mDate = date;
// mDescription = description;
// mDayTemp = dayTemp;
// mMinTemp = minTemp;
// mMaxTemp = maxTemp;
// mHumidity = humidity;
// mWindSpeed = windSpeed;
// }
//
// public String getCityId() {
// return mCityId;
// }
//
// public Date getDate() {
// return mDate;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public double getDayTemp() {
// return mDayTemp;
// }
//
// public double getMinTemp() {
// return mMinTemp;
// }
//
// public double getMaxTemp() {
// return mMaxTemp;
// }
//
// public double getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecast.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecast {
//
// @SerializedName("dt")
// private int mTimestamp;
// @SerializedName("temp")
// private Temp mTemp;
// @SerializedName("humidity")
// private int mHumidity;
// @SerializedName("speed")
// private double mWindSpeed;
// @SerializedName("weather")
// private Weather[] mWeatherList;
//
// public int getTimestamp() {
// return mTimestamp;
// }
//
// public Temp getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
//
// public Weather[] getWeatherList() {
// return mWeatherList;
// }
//
// public class Temp {
// @SerializedName("day")
// private double mDay;
// @SerializedName("min")
// private double mMin;
// @SerializedName("max")
// private double mMax;
//
// public double getDay() {
// return mDay;
// }
//
// public double getMin() {
// return mMin;
// }
//
// public double getMax() {
// return mMax;
// }
// }
//
// public class Weather {
// @SerializedName("description")
// private String mDescription;
//
// public String getDescription() {
// return mDescription;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecastList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecastList {
//
// @SerializedName("cnt")
// private int mCount;
// @SerializedName("city")
// private City mCity;
// @SerializedName("list")
// private List<OWMDailyForecast> mDailyForecasts;
//
// public int getCount() {
// return mCount;
// }
//
// public City getCity() {
// return mCity;
// }
//
// public List<OWMDailyForecast> getList() {
// return mDailyForecasts;
// }
//
// public class City {
// @SerializedName("id")
// private String mId;
//
// public String getId() {
// return mId;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/DailyForecastRepository.java
// public interface DailyForecastRepository {
//
// List<DailyForecast> getDailyForecasts(String cityId);
//
// }
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/OWMDailyForecastRepository.java
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import cat.ppicas.cleanarch.model.DailyForecast;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecast;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecastList;
import cat.ppicas.cleanarch.repository.DailyForecastRepository;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMDailyForecastRepository implements DailyForecastRepository {
private static final int FORECAST_DAYS = 3;
private OWMService mService;
public OWMDailyForecastRepository(OWMService service) {
mService = service;
}
@Override
public List<DailyForecast> getDailyForecasts(String cityId) {
List<DailyForecast> list = new ArrayList<DailyForecast>(); | OWMDailyForecastList owmDFList = mService.getDailyForecastByCityId(cityId, FORECAST_DAYS); |
ppicas/android-clean-architecture-mvp | core/src/main/java/cat/ppicas/cleanarch/owm/OWMDailyForecastRepository.java | // Path: core/src/main/java/cat/ppicas/cleanarch/model/DailyForecast.java
// public class DailyForecast {
//
// private String mCityId;
// private Date mDate;
// private String mDescription;
// private double mDayTemp;
// private double mMinTemp;
// private double mMaxTemp;
// private double mHumidity;
// private double mWindSpeed;
//
// public DailyForecast(String cityId, Date date, String description, double dayTemp,
// double minTemp, double maxTemp, double humidity, double windSpeed) {
// mCityId = cityId;
// mDate = date;
// mDescription = description;
// mDayTemp = dayTemp;
// mMinTemp = minTemp;
// mMaxTemp = maxTemp;
// mHumidity = humidity;
// mWindSpeed = windSpeed;
// }
//
// public String getCityId() {
// return mCityId;
// }
//
// public Date getDate() {
// return mDate;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public double getDayTemp() {
// return mDayTemp;
// }
//
// public double getMinTemp() {
// return mMinTemp;
// }
//
// public double getMaxTemp() {
// return mMaxTemp;
// }
//
// public double getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecast.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecast {
//
// @SerializedName("dt")
// private int mTimestamp;
// @SerializedName("temp")
// private Temp mTemp;
// @SerializedName("humidity")
// private int mHumidity;
// @SerializedName("speed")
// private double mWindSpeed;
// @SerializedName("weather")
// private Weather[] mWeatherList;
//
// public int getTimestamp() {
// return mTimestamp;
// }
//
// public Temp getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
//
// public Weather[] getWeatherList() {
// return mWeatherList;
// }
//
// public class Temp {
// @SerializedName("day")
// private double mDay;
// @SerializedName("min")
// private double mMin;
// @SerializedName("max")
// private double mMax;
//
// public double getDay() {
// return mDay;
// }
//
// public double getMin() {
// return mMin;
// }
//
// public double getMax() {
// return mMax;
// }
// }
//
// public class Weather {
// @SerializedName("description")
// private String mDescription;
//
// public String getDescription() {
// return mDescription;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecastList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecastList {
//
// @SerializedName("cnt")
// private int mCount;
// @SerializedName("city")
// private City mCity;
// @SerializedName("list")
// private List<OWMDailyForecast> mDailyForecasts;
//
// public int getCount() {
// return mCount;
// }
//
// public City getCity() {
// return mCity;
// }
//
// public List<OWMDailyForecast> getList() {
// return mDailyForecasts;
// }
//
// public class City {
// @SerializedName("id")
// private String mId;
//
// public String getId() {
// return mId;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/DailyForecastRepository.java
// public interface DailyForecastRepository {
//
// List<DailyForecast> getDailyForecasts(String cityId);
//
// }
| import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import cat.ppicas.cleanarch.model.DailyForecast;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecast;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecastList;
import cat.ppicas.cleanarch.repository.DailyForecastRepository; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMDailyForecastRepository implements DailyForecastRepository {
private static final int FORECAST_DAYS = 3;
private OWMService mService;
public OWMDailyForecastRepository(OWMService service) {
mService = service;
}
@Override
public List<DailyForecast> getDailyForecasts(String cityId) {
List<DailyForecast> list = new ArrayList<DailyForecast>();
OWMDailyForecastList owmDFList = mService.getDailyForecastByCityId(cityId, FORECAST_DAYS); | // Path: core/src/main/java/cat/ppicas/cleanarch/model/DailyForecast.java
// public class DailyForecast {
//
// private String mCityId;
// private Date mDate;
// private String mDescription;
// private double mDayTemp;
// private double mMinTemp;
// private double mMaxTemp;
// private double mHumidity;
// private double mWindSpeed;
//
// public DailyForecast(String cityId, Date date, String description, double dayTemp,
// double minTemp, double maxTemp, double humidity, double windSpeed) {
// mCityId = cityId;
// mDate = date;
// mDescription = description;
// mDayTemp = dayTemp;
// mMinTemp = minTemp;
// mMaxTemp = maxTemp;
// mHumidity = humidity;
// mWindSpeed = windSpeed;
// }
//
// public String getCityId() {
// return mCityId;
// }
//
// public Date getDate() {
// return mDate;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public double getDayTemp() {
// return mDayTemp;
// }
//
// public double getMinTemp() {
// return mMinTemp;
// }
//
// public double getMaxTemp() {
// return mMaxTemp;
// }
//
// public double getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecast.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecast {
//
// @SerializedName("dt")
// private int mTimestamp;
// @SerializedName("temp")
// private Temp mTemp;
// @SerializedName("humidity")
// private int mHumidity;
// @SerializedName("speed")
// private double mWindSpeed;
// @SerializedName("weather")
// private Weather[] mWeatherList;
//
// public int getTimestamp() {
// return mTimestamp;
// }
//
// public Temp getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
//
// public Weather[] getWeatherList() {
// return mWeatherList;
// }
//
// public class Temp {
// @SerializedName("day")
// private double mDay;
// @SerializedName("min")
// private double mMin;
// @SerializedName("max")
// private double mMax;
//
// public double getDay() {
// return mDay;
// }
//
// public double getMin() {
// return mMin;
// }
//
// public double getMax() {
// return mMax;
// }
// }
//
// public class Weather {
// @SerializedName("description")
// private String mDescription;
//
// public String getDescription() {
// return mDescription;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecastList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecastList {
//
// @SerializedName("cnt")
// private int mCount;
// @SerializedName("city")
// private City mCity;
// @SerializedName("list")
// private List<OWMDailyForecast> mDailyForecasts;
//
// public int getCount() {
// return mCount;
// }
//
// public City getCity() {
// return mCity;
// }
//
// public List<OWMDailyForecast> getList() {
// return mDailyForecasts;
// }
//
// public class City {
// @SerializedName("id")
// private String mId;
//
// public String getId() {
// return mId;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/DailyForecastRepository.java
// public interface DailyForecastRepository {
//
// List<DailyForecast> getDailyForecasts(String cityId);
//
// }
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/OWMDailyForecastRepository.java
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import cat.ppicas.cleanarch.model.DailyForecast;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecast;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecastList;
import cat.ppicas.cleanarch.repository.DailyForecastRepository;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMDailyForecastRepository implements DailyForecastRepository {
private static final int FORECAST_DAYS = 3;
private OWMService mService;
public OWMDailyForecastRepository(OWMService service) {
mService = service;
}
@Override
public List<DailyForecast> getDailyForecasts(String cityId) {
List<DailyForecast> list = new ArrayList<DailyForecast>();
OWMDailyForecastList owmDFList = mService.getDailyForecastByCityId(cityId, FORECAST_DAYS); | for (OWMDailyForecast owmDF : owmDFList.getList()) { |
ppicas/android-clean-architecture-mvp | app/src/main/java/cat/ppicas/cleanarch/ui/adapter/CityAdapter.java | // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java
// public final class ServiceContainers {
//
// private ServiceContainers() {
// throw new RuntimeException("Instances are not allowed for this class");
// }
//
// public static ServiceContainer getFromApp(Context context) {
// Context app = context.getApplicationContext();
// ServiceContainerProvider provider = (ServiceContainerProvider) app;
// return provider.getServiceContainer();
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityListItemVista.java
// public interface CityListItemVista extends Vista {
//
// void setCityName(String name);
//
// void setCountry(String country);
//
// void setCurrentTemp(String temp);
//
// void setLoadingElevation(boolean loading);
//
// void setElevation(int elevation);
//
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityListItemPresenter.java
// public class CityListItemPresenter extends Presenter<CityListItemVista> {
//
// private TaskExecutor mTaskExecutor;
// private City mCity;
//
// private int mElevation = -1;
// private GetElevationTask mGetElevationTask;
//
// public CityListItemPresenter(TaskExecutor taskExecutor, City city) {
// mTaskExecutor = taskExecutor;
// mCity = city;
// }
//
// @Override
// public void onStart(CityListItemVista vista) {
// updateVista();
//
// if (mElevation > -1) {
// vista.setLoadingElevation(false);
// vista.setElevation(mElevation);
// } else {
// vista.setLoadingElevation(true);
// if (!mTaskExecutor.isRunning(mGetElevationTask)) {
// mGetElevationTask = new GetElevationTask(mCity);
// mTaskExecutor.execute(mGetElevationTask, new GetElevationTaskCallback());
// }
// }
// }
//
// @Override
// public void onDestroy() {
// if (mTaskExecutor.isRunning(mGetElevationTask)) {
// mGetElevationTask.cancel();
// }
// }
//
// public void setCity(City city) {
// if (mCity.getId().equals(city.getId()) && mCity.getName().equals(city.getName())) {
// return;
// }
//
// mCity = city;
// updateVista();
//
// if (mTaskExecutor.isRunning(mGetElevationTask)) {
// mGetElevationTask.cancel();
// }
// if (getVista() != null) {
// getVista().setLoadingElevation(true);
// }
// mElevation = -1;
// mGetElevationTask = new GetElevationTask(city);
// mTaskExecutor.execute(mGetElevationTask, new GetElevationTaskCallback());
// }
//
// private void updateVista() {
// CityListItemVista vista = getVista();
// if (vista == null) {
// return;
// }
//
// vista.setCityName(mCity.getName());
// vista.setCountry(mCity.getCountry());
// double temp = mCity.getCurrentWeatherPreview().getCurrentTemp();
// vista.setCurrentTemp(NumberFormat.formatTemperature(temp));
// }
//
// private class GetElevationTaskCallback extends SuccessTaskCallback<Integer> {
// @Override
// public void onSuccess(Integer elevation) {
// mElevation = elevation;
// if (getVista() != null) {
// getVista().setElevation(elevation);
// getVista().setLoadingElevation(false);
// }
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/framework/task/TaskExecutor.java
// public interface TaskExecutor {
//
// <R, E extends Exception> void execute(Task<R, E> task, TaskCallback<R, E> callback);
//
// boolean isRunning(Task<?, ?> task);
//
// }
| import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import cat.ppicas.cleanarch.R;
import cat.ppicas.cleanarch.app.ServiceContainers;
import cat.ppicas.cleanarch.model.City;
import cat.ppicas.cleanarch.ui.vista.CityListItemVista;
import cat.ppicas.cleanarch.ui.presenter.CityListItemPresenter;
import cat.ppicas.framework.task.TaskExecutor; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.ui.adapter;
public class CityAdapter extends ArrayAdapter<City> {
private final LayoutInflater mInflater; | // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java
// public final class ServiceContainers {
//
// private ServiceContainers() {
// throw new RuntimeException("Instances are not allowed for this class");
// }
//
// public static ServiceContainer getFromApp(Context context) {
// Context app = context.getApplicationContext();
// ServiceContainerProvider provider = (ServiceContainerProvider) app;
// return provider.getServiceContainer();
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityListItemVista.java
// public interface CityListItemVista extends Vista {
//
// void setCityName(String name);
//
// void setCountry(String country);
//
// void setCurrentTemp(String temp);
//
// void setLoadingElevation(boolean loading);
//
// void setElevation(int elevation);
//
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityListItemPresenter.java
// public class CityListItemPresenter extends Presenter<CityListItemVista> {
//
// private TaskExecutor mTaskExecutor;
// private City mCity;
//
// private int mElevation = -1;
// private GetElevationTask mGetElevationTask;
//
// public CityListItemPresenter(TaskExecutor taskExecutor, City city) {
// mTaskExecutor = taskExecutor;
// mCity = city;
// }
//
// @Override
// public void onStart(CityListItemVista vista) {
// updateVista();
//
// if (mElevation > -1) {
// vista.setLoadingElevation(false);
// vista.setElevation(mElevation);
// } else {
// vista.setLoadingElevation(true);
// if (!mTaskExecutor.isRunning(mGetElevationTask)) {
// mGetElevationTask = new GetElevationTask(mCity);
// mTaskExecutor.execute(mGetElevationTask, new GetElevationTaskCallback());
// }
// }
// }
//
// @Override
// public void onDestroy() {
// if (mTaskExecutor.isRunning(mGetElevationTask)) {
// mGetElevationTask.cancel();
// }
// }
//
// public void setCity(City city) {
// if (mCity.getId().equals(city.getId()) && mCity.getName().equals(city.getName())) {
// return;
// }
//
// mCity = city;
// updateVista();
//
// if (mTaskExecutor.isRunning(mGetElevationTask)) {
// mGetElevationTask.cancel();
// }
// if (getVista() != null) {
// getVista().setLoadingElevation(true);
// }
// mElevation = -1;
// mGetElevationTask = new GetElevationTask(city);
// mTaskExecutor.execute(mGetElevationTask, new GetElevationTaskCallback());
// }
//
// private void updateVista() {
// CityListItemVista vista = getVista();
// if (vista == null) {
// return;
// }
//
// vista.setCityName(mCity.getName());
// vista.setCountry(mCity.getCountry());
// double temp = mCity.getCurrentWeatherPreview().getCurrentTemp();
// vista.setCurrentTemp(NumberFormat.formatTemperature(temp));
// }
//
// private class GetElevationTaskCallback extends SuccessTaskCallback<Integer> {
// @Override
// public void onSuccess(Integer elevation) {
// mElevation = elevation;
// if (getVista() != null) {
// getVista().setElevation(elevation);
// getVista().setLoadingElevation(false);
// }
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/framework/task/TaskExecutor.java
// public interface TaskExecutor {
//
// <R, E extends Exception> void execute(Task<R, E> task, TaskCallback<R, E> callback);
//
// boolean isRunning(Task<?, ?> task);
//
// }
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/adapter/CityAdapter.java
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import cat.ppicas.cleanarch.R;
import cat.ppicas.cleanarch.app.ServiceContainers;
import cat.ppicas.cleanarch.model.City;
import cat.ppicas.cleanarch.ui.vista.CityListItemVista;
import cat.ppicas.cleanarch.ui.presenter.CityListItemPresenter;
import cat.ppicas.framework.task.TaskExecutor;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.ui.adapter;
public class CityAdapter extends ArrayAdapter<City> {
private final LayoutInflater mInflater; | private final TaskExecutor mTaskExecutor; |
ppicas/android-clean-architecture-mvp | app/src/main/java/cat/ppicas/cleanarch/ui/adapter/CityAdapter.java | // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java
// public final class ServiceContainers {
//
// private ServiceContainers() {
// throw new RuntimeException("Instances are not allowed for this class");
// }
//
// public static ServiceContainer getFromApp(Context context) {
// Context app = context.getApplicationContext();
// ServiceContainerProvider provider = (ServiceContainerProvider) app;
// return provider.getServiceContainer();
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityListItemVista.java
// public interface CityListItemVista extends Vista {
//
// void setCityName(String name);
//
// void setCountry(String country);
//
// void setCurrentTemp(String temp);
//
// void setLoadingElevation(boolean loading);
//
// void setElevation(int elevation);
//
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityListItemPresenter.java
// public class CityListItemPresenter extends Presenter<CityListItemVista> {
//
// private TaskExecutor mTaskExecutor;
// private City mCity;
//
// private int mElevation = -1;
// private GetElevationTask mGetElevationTask;
//
// public CityListItemPresenter(TaskExecutor taskExecutor, City city) {
// mTaskExecutor = taskExecutor;
// mCity = city;
// }
//
// @Override
// public void onStart(CityListItemVista vista) {
// updateVista();
//
// if (mElevation > -1) {
// vista.setLoadingElevation(false);
// vista.setElevation(mElevation);
// } else {
// vista.setLoadingElevation(true);
// if (!mTaskExecutor.isRunning(mGetElevationTask)) {
// mGetElevationTask = new GetElevationTask(mCity);
// mTaskExecutor.execute(mGetElevationTask, new GetElevationTaskCallback());
// }
// }
// }
//
// @Override
// public void onDestroy() {
// if (mTaskExecutor.isRunning(mGetElevationTask)) {
// mGetElevationTask.cancel();
// }
// }
//
// public void setCity(City city) {
// if (mCity.getId().equals(city.getId()) && mCity.getName().equals(city.getName())) {
// return;
// }
//
// mCity = city;
// updateVista();
//
// if (mTaskExecutor.isRunning(mGetElevationTask)) {
// mGetElevationTask.cancel();
// }
// if (getVista() != null) {
// getVista().setLoadingElevation(true);
// }
// mElevation = -1;
// mGetElevationTask = new GetElevationTask(city);
// mTaskExecutor.execute(mGetElevationTask, new GetElevationTaskCallback());
// }
//
// private void updateVista() {
// CityListItemVista vista = getVista();
// if (vista == null) {
// return;
// }
//
// vista.setCityName(mCity.getName());
// vista.setCountry(mCity.getCountry());
// double temp = mCity.getCurrentWeatherPreview().getCurrentTemp();
// vista.setCurrentTemp(NumberFormat.formatTemperature(temp));
// }
//
// private class GetElevationTaskCallback extends SuccessTaskCallback<Integer> {
// @Override
// public void onSuccess(Integer elevation) {
// mElevation = elevation;
// if (getVista() != null) {
// getVista().setElevation(elevation);
// getVista().setLoadingElevation(false);
// }
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/framework/task/TaskExecutor.java
// public interface TaskExecutor {
//
// <R, E extends Exception> void execute(Task<R, E> task, TaskCallback<R, E> callback);
//
// boolean isRunning(Task<?, ?> task);
//
// }
| import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import cat.ppicas.cleanarch.R;
import cat.ppicas.cleanarch.app.ServiceContainers;
import cat.ppicas.cleanarch.model.City;
import cat.ppicas.cleanarch.ui.vista.CityListItemVista;
import cat.ppicas.cleanarch.ui.presenter.CityListItemPresenter;
import cat.ppicas.framework.task.TaskExecutor; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.ui.adapter;
public class CityAdapter extends ArrayAdapter<City> {
private final LayoutInflater mInflater;
private final TaskExecutor mTaskExecutor;
public CityAdapter(Context context) {
super(context, android.R.layout.simple_list_item_1);
mInflater = LayoutInflater.from(context);
| // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java
// public final class ServiceContainers {
//
// private ServiceContainers() {
// throw new RuntimeException("Instances are not allowed for this class");
// }
//
// public static ServiceContainer getFromApp(Context context) {
// Context app = context.getApplicationContext();
// ServiceContainerProvider provider = (ServiceContainerProvider) app;
// return provider.getServiceContainer();
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityListItemVista.java
// public interface CityListItemVista extends Vista {
//
// void setCityName(String name);
//
// void setCountry(String country);
//
// void setCurrentTemp(String temp);
//
// void setLoadingElevation(boolean loading);
//
// void setElevation(int elevation);
//
// }
//
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityListItemPresenter.java
// public class CityListItemPresenter extends Presenter<CityListItemVista> {
//
// private TaskExecutor mTaskExecutor;
// private City mCity;
//
// private int mElevation = -1;
// private GetElevationTask mGetElevationTask;
//
// public CityListItemPresenter(TaskExecutor taskExecutor, City city) {
// mTaskExecutor = taskExecutor;
// mCity = city;
// }
//
// @Override
// public void onStart(CityListItemVista vista) {
// updateVista();
//
// if (mElevation > -1) {
// vista.setLoadingElevation(false);
// vista.setElevation(mElevation);
// } else {
// vista.setLoadingElevation(true);
// if (!mTaskExecutor.isRunning(mGetElevationTask)) {
// mGetElevationTask = new GetElevationTask(mCity);
// mTaskExecutor.execute(mGetElevationTask, new GetElevationTaskCallback());
// }
// }
// }
//
// @Override
// public void onDestroy() {
// if (mTaskExecutor.isRunning(mGetElevationTask)) {
// mGetElevationTask.cancel();
// }
// }
//
// public void setCity(City city) {
// if (mCity.getId().equals(city.getId()) && mCity.getName().equals(city.getName())) {
// return;
// }
//
// mCity = city;
// updateVista();
//
// if (mTaskExecutor.isRunning(mGetElevationTask)) {
// mGetElevationTask.cancel();
// }
// if (getVista() != null) {
// getVista().setLoadingElevation(true);
// }
// mElevation = -1;
// mGetElevationTask = new GetElevationTask(city);
// mTaskExecutor.execute(mGetElevationTask, new GetElevationTaskCallback());
// }
//
// private void updateVista() {
// CityListItemVista vista = getVista();
// if (vista == null) {
// return;
// }
//
// vista.setCityName(mCity.getName());
// vista.setCountry(mCity.getCountry());
// double temp = mCity.getCurrentWeatherPreview().getCurrentTemp();
// vista.setCurrentTemp(NumberFormat.formatTemperature(temp));
// }
//
// private class GetElevationTaskCallback extends SuccessTaskCallback<Integer> {
// @Override
// public void onSuccess(Integer elevation) {
// mElevation = elevation;
// if (getVista() != null) {
// getVista().setElevation(elevation);
// getVista().setLoadingElevation(false);
// }
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/framework/task/TaskExecutor.java
// public interface TaskExecutor {
//
// <R, E extends Exception> void execute(Task<R, E> task, TaskCallback<R, E> callback);
//
// boolean isRunning(Task<?, ?> task);
//
// }
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/adapter/CityAdapter.java
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import cat.ppicas.cleanarch.R;
import cat.ppicas.cleanarch.app.ServiceContainers;
import cat.ppicas.cleanarch.model.City;
import cat.ppicas.cleanarch.ui.vista.CityListItemVista;
import cat.ppicas.cleanarch.ui.presenter.CityListItemPresenter;
import cat.ppicas.framework.task.TaskExecutor;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.ui.adapter;
public class CityAdapter extends ArrayAdapter<City> {
private final LayoutInflater mInflater;
private final TaskExecutor mTaskExecutor;
public CityAdapter(Context context) {
super(context, android.R.layout.simple_list_item_1);
mInflater = LayoutInflater.from(context);
| mTaskExecutor = ServiceContainers.getFromApp(context).getTaskExecutor(); |
ppicas/android-clean-architecture-mvp | core/src/main/java/cat/ppicas/cleanarch/owm/OWMCurrentWeatherRepository.java | // Path: core/src/main/java/cat/ppicas/cleanarch/model/CurrentWeather.java
// public class CurrentWeather extends CurrentWeatherPreview {
//
// private int mHumidity;
// private double mWindSpeed;
//
// public CurrentWeather(String cityId, double currentTemp, int humidity, double windSpeed) {
// super(cityId, currentTemp);
// mHumidity = humidity;
// mWindSpeed = windSpeed;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CurrentWeatherRepository.java
// public interface CurrentWeatherRepository {
//
// CurrentWeather getCityCurrentWeather(String cityId);
//
// }
| import cat.ppicas.cleanarch.model.CurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.repository.CurrentWeatherRepository; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMCurrentWeatherRepository implements CurrentWeatherRepository {
private OWMService mService;
public OWMCurrentWeatherRepository(OWMService service) {
mService = service;
}
@Override | // Path: core/src/main/java/cat/ppicas/cleanarch/model/CurrentWeather.java
// public class CurrentWeather extends CurrentWeatherPreview {
//
// private int mHumidity;
// private double mWindSpeed;
//
// public CurrentWeather(String cityId, double currentTemp, int humidity, double windSpeed) {
// super(cityId, currentTemp);
// mHumidity = humidity;
// mWindSpeed = windSpeed;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CurrentWeatherRepository.java
// public interface CurrentWeatherRepository {
//
// CurrentWeather getCityCurrentWeather(String cityId);
//
// }
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/OWMCurrentWeatherRepository.java
import cat.ppicas.cleanarch.model.CurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.repository.CurrentWeatherRepository;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMCurrentWeatherRepository implements CurrentWeatherRepository {
private OWMService mService;
public OWMCurrentWeatherRepository(OWMService service) {
mService = service;
}
@Override | public CurrentWeather getCityCurrentWeather(String cityId) { |
ppicas/android-clean-architecture-mvp | core/src/main/java/cat/ppicas/cleanarch/owm/OWMCurrentWeatherRepository.java | // Path: core/src/main/java/cat/ppicas/cleanarch/model/CurrentWeather.java
// public class CurrentWeather extends CurrentWeatherPreview {
//
// private int mHumidity;
// private double mWindSpeed;
//
// public CurrentWeather(String cityId, double currentTemp, int humidity, double windSpeed) {
// super(cityId, currentTemp);
// mHumidity = humidity;
// mWindSpeed = windSpeed;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CurrentWeatherRepository.java
// public interface CurrentWeatherRepository {
//
// CurrentWeather getCityCurrentWeather(String cityId);
//
// }
| import cat.ppicas.cleanarch.model.CurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.repository.CurrentWeatherRepository; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMCurrentWeatherRepository implements CurrentWeatherRepository {
private OWMService mService;
public OWMCurrentWeatherRepository(OWMService service) {
mService = service;
}
@Override
public CurrentWeather getCityCurrentWeather(String cityId) { | // Path: core/src/main/java/cat/ppicas/cleanarch/model/CurrentWeather.java
// public class CurrentWeather extends CurrentWeatherPreview {
//
// private int mHumidity;
// private double mWindSpeed;
//
// public CurrentWeather(String cityId, double currentTemp, int humidity, double windSpeed) {
// super(cityId, currentTemp);
// mHumidity = humidity;
// mWindSpeed = windSpeed;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CurrentWeatherRepository.java
// public interface CurrentWeatherRepository {
//
// CurrentWeather getCityCurrentWeather(String cityId);
//
// }
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/OWMCurrentWeatherRepository.java
import cat.ppicas.cleanarch.model.CurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.repository.CurrentWeatherRepository;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public class OWMCurrentWeatherRepository implements CurrentWeatherRepository {
private OWMService mService;
public OWMCurrentWeatherRepository(OWMService service) {
mService = service;
}
@Override
public CurrentWeather getCityCurrentWeather(String cityId) { | OWMCurrentWeather cw = mService.getCurrentWeatherByCityId(cityId); |
ppicas/android-clean-architecture-mvp | core/src/main/java/cat/ppicas/cleanarch/owm/OWMService.java | // Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeatherList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeatherList {
//
// @SerializedName("count")
// private int mCount;
// @SerializedName("list")
// private List<OWMCurrentWeather> mCurrentWeatherList;
//
// public int getCount() {
// return mCount;
// }
//
// public List<OWMCurrentWeather> getList() {
// return mCurrentWeatherList;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecastList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecastList {
//
// @SerializedName("cnt")
// private int mCount;
// @SerializedName("city")
// private City mCity;
// @SerializedName("list")
// private List<OWMDailyForecast> mDailyForecasts;
//
// public int getCount() {
// return mCount;
// }
//
// public City getCity() {
// return mCity;
// }
//
// public List<OWMDailyForecast> getList() {
// return mDailyForecasts;
// }
//
// public class City {
// @SerializedName("id")
// private String mId;
//
// public String getId() {
// return mId;
// }
// }
// }
| import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeatherList;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecastList;
import retrofit.http.GET;
import retrofit.http.Headers;
import retrofit.http.Query; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public interface OWMService {
@GET("/data/2.5/find?units=metric")
@Headers("Cache-Control: max-age=300, max-stale=900") | // Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeatherList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeatherList {
//
// @SerializedName("count")
// private int mCount;
// @SerializedName("list")
// private List<OWMCurrentWeather> mCurrentWeatherList;
//
// public int getCount() {
// return mCount;
// }
//
// public List<OWMCurrentWeather> getList() {
// return mCurrentWeatherList;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecastList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecastList {
//
// @SerializedName("cnt")
// private int mCount;
// @SerializedName("city")
// private City mCity;
// @SerializedName("list")
// private List<OWMDailyForecast> mDailyForecasts;
//
// public int getCount() {
// return mCount;
// }
//
// public City getCity() {
// return mCity;
// }
//
// public List<OWMDailyForecast> getList() {
// return mDailyForecasts;
// }
//
// public class City {
// @SerializedName("id")
// private String mId;
//
// public String getId() {
// return mId;
// }
// }
// }
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/OWMService.java
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeatherList;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecastList;
import retrofit.http.GET;
import retrofit.http.Headers;
import retrofit.http.Query;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public interface OWMService {
@GET("/data/2.5/find?units=metric")
@Headers("Cache-Control: max-age=300, max-stale=900") | OWMCurrentWeatherList getCurrentWeatherByCityName(@Query("q") String query); |
ppicas/android-clean-architecture-mvp | core/src/main/java/cat/ppicas/cleanarch/owm/OWMService.java | // Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeatherList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeatherList {
//
// @SerializedName("count")
// private int mCount;
// @SerializedName("list")
// private List<OWMCurrentWeather> mCurrentWeatherList;
//
// public int getCount() {
// return mCount;
// }
//
// public List<OWMCurrentWeather> getList() {
// return mCurrentWeatherList;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecastList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecastList {
//
// @SerializedName("cnt")
// private int mCount;
// @SerializedName("city")
// private City mCity;
// @SerializedName("list")
// private List<OWMDailyForecast> mDailyForecasts;
//
// public int getCount() {
// return mCount;
// }
//
// public City getCity() {
// return mCity;
// }
//
// public List<OWMDailyForecast> getList() {
// return mDailyForecasts;
// }
//
// public class City {
// @SerializedName("id")
// private String mId;
//
// public String getId() {
// return mId;
// }
// }
// }
| import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeatherList;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecastList;
import retrofit.http.GET;
import retrofit.http.Headers;
import retrofit.http.Query; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public interface OWMService {
@GET("/data/2.5/find?units=metric")
@Headers("Cache-Control: max-age=300, max-stale=900")
OWMCurrentWeatherList getCurrentWeatherByCityName(@Query("q") String query);
@GET("/data/2.5/weather?units=metric")
@Headers("Cache-Control: max-age=300, max-stale=900") | // Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeatherList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeatherList {
//
// @SerializedName("count")
// private int mCount;
// @SerializedName("list")
// private List<OWMCurrentWeather> mCurrentWeatherList;
//
// public int getCount() {
// return mCount;
// }
//
// public List<OWMCurrentWeather> getList() {
// return mCurrentWeatherList;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecastList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecastList {
//
// @SerializedName("cnt")
// private int mCount;
// @SerializedName("city")
// private City mCity;
// @SerializedName("list")
// private List<OWMDailyForecast> mDailyForecasts;
//
// public int getCount() {
// return mCount;
// }
//
// public City getCity() {
// return mCity;
// }
//
// public List<OWMDailyForecast> getList() {
// return mDailyForecasts;
// }
//
// public class City {
// @SerializedName("id")
// private String mId;
//
// public String getId() {
// return mId;
// }
// }
// }
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/OWMService.java
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeatherList;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecastList;
import retrofit.http.GET;
import retrofit.http.Headers;
import retrofit.http.Query;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public interface OWMService {
@GET("/data/2.5/find?units=metric")
@Headers("Cache-Control: max-age=300, max-stale=900")
OWMCurrentWeatherList getCurrentWeatherByCityName(@Query("q") String query);
@GET("/data/2.5/weather?units=metric")
@Headers("Cache-Control: max-age=300, max-stale=900") | OWMCurrentWeather getCurrentWeatherByCityId(@Query("id") String id); |
ppicas/android-clean-architecture-mvp | core/src/main/java/cat/ppicas/cleanarch/owm/OWMService.java | // Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeatherList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeatherList {
//
// @SerializedName("count")
// private int mCount;
// @SerializedName("list")
// private List<OWMCurrentWeather> mCurrentWeatherList;
//
// public int getCount() {
// return mCount;
// }
//
// public List<OWMCurrentWeather> getList() {
// return mCurrentWeatherList;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecastList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecastList {
//
// @SerializedName("cnt")
// private int mCount;
// @SerializedName("city")
// private City mCity;
// @SerializedName("list")
// private List<OWMDailyForecast> mDailyForecasts;
//
// public int getCount() {
// return mCount;
// }
//
// public City getCity() {
// return mCity;
// }
//
// public List<OWMDailyForecast> getList() {
// return mDailyForecasts;
// }
//
// public class City {
// @SerializedName("id")
// private String mId;
//
// public String getId() {
// return mId;
// }
// }
// }
| import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeatherList;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecastList;
import retrofit.http.GET;
import retrofit.http.Headers;
import retrofit.http.Query; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public interface OWMService {
@GET("/data/2.5/find?units=metric")
@Headers("Cache-Control: max-age=300, max-stale=900")
OWMCurrentWeatherList getCurrentWeatherByCityName(@Query("q") String query);
@GET("/data/2.5/weather?units=metric")
@Headers("Cache-Control: max-age=300, max-stale=900")
OWMCurrentWeather getCurrentWeatherByCityId(@Query("id") String id);
@GET("/data/2.5/forecast/daily?units=metric")
@Headers("Cache-Control: max-age=300, max-stale=900") | // Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeather.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeather {
//
// @SerializedName("id")
// private String mCityId;
// @SerializedName("name")
// private String mCityName;
// @SerializedName("main")
// private Main mMain;
// @SerializedName("wind")
// private Wind mWind;
// @SerializedName("sys")
// private System mSystem;
//
// public String getCityId() {
// return mCityId;
// }
//
// public String getCityName() {
// return mCityName;
// }
//
// public Main getMain() {
// return mMain;
// }
//
// public Wind getWind() {
// return mWind;
// }
//
// public System getSystem() {
// return mSystem;
// }
//
// public class Main {
// @SerializedName("temp")
// private double mTemp;
// @SerializedName("humidity")
// private int mHumidity;
//
// public double getTemp() {
// return mTemp;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
// }
//
// public class Wind {
// @SerializedName("speed")
// private double mSpeed;
//
// public double getSpeed() {
// return mSpeed;
// }
// }
//
// public class System {
// @SerializedName("country")
// private String mCountry;
//
// public String getCountry() {
// return mCountry;
// }
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMCurrentWeatherList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMCurrentWeatherList {
//
// @SerializedName("count")
// private int mCount;
// @SerializedName("list")
// private List<OWMCurrentWeather> mCurrentWeatherList;
//
// public int getCount() {
// return mCount;
// }
//
// public List<OWMCurrentWeather> getList() {
// return mCurrentWeatherList;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/model/OWMDailyForecastList.java
// @SuppressWarnings("UnusedDeclaration")
// public class OWMDailyForecastList {
//
// @SerializedName("cnt")
// private int mCount;
// @SerializedName("city")
// private City mCity;
// @SerializedName("list")
// private List<OWMDailyForecast> mDailyForecasts;
//
// public int getCount() {
// return mCount;
// }
//
// public City getCity() {
// return mCity;
// }
//
// public List<OWMDailyForecast> getList() {
// return mDailyForecasts;
// }
//
// public class City {
// @SerializedName("id")
// private String mId;
//
// public String getId() {
// return mId;
// }
// }
// }
// Path: core/src/main/java/cat/ppicas/cleanarch/owm/OWMService.java
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeather;
import cat.ppicas.cleanarch.owm.model.OWMCurrentWeatherList;
import cat.ppicas.cleanarch.owm.model.OWMDailyForecastList;
import retrofit.http.GET;
import retrofit.http.Headers;
import retrofit.http.Query;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.owm;
public interface OWMService {
@GET("/data/2.5/find?units=metric")
@Headers("Cache-Control: max-age=300, max-stale=900")
OWMCurrentWeatherList getCurrentWeatherByCityName(@Query("q") String query);
@GET("/data/2.5/weather?units=metric")
@Headers("Cache-Control: max-age=300, max-stale=900")
OWMCurrentWeather getCurrentWeatherByCityId(@Query("id") String id);
@GET("/data/2.5/forecast/daily?units=metric")
@Headers("Cache-Control: max-age=300, max-stale=900") | OWMDailyForecastList getDailyForecastByCityId(@Query("id") String id, |
ppicas/android-clean-architecture-mvp | app/src/main/java/cat/ppicas/cleanarch/ui/vista/SearchCitiesVista.java | // Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
| import java.util.List;
import cat.ppicas.cleanarch.model.City; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.ui.vista;
public interface SearchCitiesVista extends TaskResultVista {
void setTitle(int stringResId, Object... args);
| // Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java
// public class City {
//
// private String mId;
// private String mName;
// private String mCountry;
// private CurrentWeatherPreview mCurrentWeatherPreview;
//
// public City(String id, String name, String country) {
// mId = id;
// mName = name;
// mCountry = country;
// }
//
// public City(String id, String name, String country,
// CurrentWeatherPreview currentWeatherPreview) {
// mId = id;
// mName = name;
// mCountry = country;
// mCurrentWeatherPreview = currentWeatherPreview;
// }
//
// public String getId() {
// return mId;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getCountry() {
// return mCountry;
// }
//
// public CurrentWeatherPreview getCurrentWeatherPreview() {
// return mCurrentWeatherPreview;
// }
// }
// Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/SearchCitiesVista.java
import java.util.List;
import cat.ppicas.cleanarch.model.City;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.ui.vista;
public interface SearchCitiesVista extends TaskResultVista {
void setTitle(int stringResId, Object... args);
| void setCities(List<City> cities); |
ppicas/android-clean-architecture-mvp | core/src/main/java/cat/ppicas/cleanarch/task/GetCurrentWeatherTask.java | // Path: core/src/main/java/cat/ppicas/cleanarch/model/CurrentWeather.java
// public class CurrentWeather extends CurrentWeatherPreview {
//
// private int mHumidity;
// private double mWindSpeed;
//
// public CurrentWeather(String cityId, double currentTemp, int humidity, double windSpeed) {
// super(cityId, currentTemp);
// mHumidity = humidity;
// mWindSpeed = windSpeed;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CurrentWeatherRepository.java
// public interface CurrentWeatherRepository {
//
// CurrentWeather getCityCurrentWeather(String cityId);
//
// }
//
// Path: core/src/main/java/cat/ppicas/framework/task/Task.java
// public interface Task<R, E extends Exception> {
//
// TaskResult<R, E> execute();
//
// }
//
// Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java
// public class TaskResult<R, E extends Exception> {
//
// private final R mResult;
//
// private final E mError;
//
// private final boolean mCanceled;
//
// public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) {
// return new TaskResult<>(result, null, false);
// }
//
// public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) {
// return new TaskResult<>(null, error, false);
// }
//
// public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() {
// return new TaskResult<>(null, null, true);
// }
//
// TaskResult(R result, E error, boolean canceled) {
// mResult = result;
// mError = error;
// mCanceled = canceled;
// }
//
// public R getResult() {
// return mResult;
// }
//
// public E getError() {
// return mError;
// }
//
// public boolean isSuccess() {
// return !mCanceled && mError == null;
// }
//
// public boolean isCanceled() {
// return mCanceled;
// }
// }
| import java.io.IOException;
import cat.ppicas.cleanarch.model.CurrentWeather;
import cat.ppicas.cleanarch.repository.CurrentWeatherRepository;
import cat.ppicas.framework.task.Task;
import cat.ppicas.framework.task.TaskResult;
import retrofit.RetrofitError; | /*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.task;
public class GetCurrentWeatherTask implements Task<CurrentWeather, IOException> {
private CurrentWeatherRepository mRepository;
private String mCityId;
public GetCurrentWeatherTask(CurrentWeatherRepository repository, String cityId) {
mRepository = repository;
mCityId = cityId;
}
@Override | // Path: core/src/main/java/cat/ppicas/cleanarch/model/CurrentWeather.java
// public class CurrentWeather extends CurrentWeatherPreview {
//
// private int mHumidity;
// private double mWindSpeed;
//
// public CurrentWeather(String cityId, double currentTemp, int humidity, double windSpeed) {
// super(cityId, currentTemp);
// mHumidity = humidity;
// mWindSpeed = windSpeed;
// }
//
// public int getHumidity() {
// return mHumidity;
// }
//
// public double getWindSpeed() {
// return mWindSpeed;
// }
// }
//
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CurrentWeatherRepository.java
// public interface CurrentWeatherRepository {
//
// CurrentWeather getCityCurrentWeather(String cityId);
//
// }
//
// Path: core/src/main/java/cat/ppicas/framework/task/Task.java
// public interface Task<R, E extends Exception> {
//
// TaskResult<R, E> execute();
//
// }
//
// Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java
// public class TaskResult<R, E extends Exception> {
//
// private final R mResult;
//
// private final E mError;
//
// private final boolean mCanceled;
//
// public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) {
// return new TaskResult<>(result, null, false);
// }
//
// public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) {
// return new TaskResult<>(null, error, false);
// }
//
// public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() {
// return new TaskResult<>(null, null, true);
// }
//
// TaskResult(R result, E error, boolean canceled) {
// mResult = result;
// mError = error;
// mCanceled = canceled;
// }
//
// public R getResult() {
// return mResult;
// }
//
// public E getError() {
// return mError;
// }
//
// public boolean isSuccess() {
// return !mCanceled && mError == null;
// }
//
// public boolean isCanceled() {
// return mCanceled;
// }
// }
// Path: core/src/main/java/cat/ppicas/cleanarch/task/GetCurrentWeatherTask.java
import java.io.IOException;
import cat.ppicas.cleanarch.model.CurrentWeather;
import cat.ppicas.cleanarch.repository.CurrentWeatherRepository;
import cat.ppicas.framework.task.Task;
import cat.ppicas.framework.task.TaskResult;
import retrofit.RetrofitError;
/*
* Copyright (C) 2015 Pau Picas Sans <[email protected]>
*
* 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 cat.ppicas.cleanarch.task;
public class GetCurrentWeatherTask implements Task<CurrentWeather, IOException> {
private CurrentWeatherRepository mRepository;
private String mCityId;
public GetCurrentWeatherTask(CurrentWeatherRepository repository, String cityId) {
mRepository = repository;
mCityId = cityId;
}
@Override | public TaskResult<CurrentWeather, IOException> execute() { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.