hexsha
stringlengths 40
40
| size
int64 3
1.05M
| ext
stringclasses 1
value | lang
stringclasses 1
value | max_stars_repo_path
stringlengths 5
1.02k
| max_stars_repo_name
stringlengths 4
126
| max_stars_repo_head_hexsha
stringlengths 40
78
| max_stars_repo_licenses
sequence | max_stars_count
float64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 5
1.02k
| max_issues_repo_name
stringlengths 4
114
| max_issues_repo_head_hexsha
stringlengths 40
78
| max_issues_repo_licenses
sequence | max_issues_count
float64 1
92.2k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 5
1.02k
| max_forks_repo_name
stringlengths 4
136
| max_forks_repo_head_hexsha
stringlengths 40
78
| max_forks_repo_licenses
sequence | max_forks_count
float64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | avg_line_length
float64 2.55
99.9
| max_line_length
int64 3
1k
| alphanum_fraction
float64 0.25
1
| index
int64 0
1M
| content
stringlengths 3
1.05M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3e00001c6884b6b2f9d926ffac9335875da9b56b | 2,387 | java | Java | src/main/java/org/bian/dto/BQInstructionRetrieveOutputModelCardFinancialSettlementProcedureInstanceRecord.java | bianapis/sd-card-financial-settlement-v2.0 | 471652dcb2731cd10ccc07874ff8ac6afb838a96 | [
"Apache-2.0"
] | null | null | null | src/main/java/org/bian/dto/BQInstructionRetrieveOutputModelCardFinancialSettlementProcedureInstanceRecord.java | bianapis/sd-card-financial-settlement-v2.0 | 471652dcb2731cd10ccc07874ff8ac6afb838a96 | [
"Apache-2.0"
] | null | null | null | src/main/java/org/bian/dto/BQInstructionRetrieveOutputModelCardFinancialSettlementProcedureInstanceRecord.java | bianapis/sd-card-financial-settlement-v2.0 | 471652dcb2731cd10ccc07874ff8ac6afb838a96 | [
"Apache-2.0"
] | null | null | null | 36.723077 | 258 | 0.818182 | 0 | package org.bian.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.Valid;
/**
* BQInstructionRetrieveOutputModelCardFinancialSettlementProcedureInstanceRecord
*/
public class BQInstructionRetrieveOutputModelCardFinancialSettlementProcedureInstanceRecord {
private String cardFinancialSettlementServiceSchedule = null;
private String participantAcquirerBankReference = null;
private String participantIssuerBankReference = null;
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::UNCEFACT::Text general-info: Defines the type and scheduling of card settlement processing, includes Issuer and Acquirer involvement/scheduling details as necessary
* @return cardFinancialSettlementServiceSchedule
**/
public String getCardFinancialSettlementServiceSchedule() {
return cardFinancialSettlementServiceSchedule;
}
public void setCardFinancialSettlementServiceSchedule(String cardFinancialSettlementServiceSchedule) {
this.cardFinancialSettlementServiceSchedule = cardFinancialSettlementServiceSchedule;
}
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::ISO20022andUNCEFACT::Identifier general-info: Refers to the Acquiring bank for which the Network orchestrates settlement processing
* @return participantAcquirerBankReference
**/
public String getParticipantAcquirerBankReference() {
return participantAcquirerBankReference;
}
public void setParticipantAcquirerBankReference(String participantAcquirerBankReference) {
this.participantAcquirerBankReference = participantAcquirerBankReference;
}
/**
* `status: Not Mapped` core-data-type-reference: BIAN::DataTypesLibrary::CoreDataTypes::ISO20022andUNCEFACT::Identifier general-info: Refers to the Issuing bank for which the Network orchestrates settlement processing
* @return participantIssuerBankReference
**/
public String getParticipantIssuerBankReference() {
return participantIssuerBankReference;
}
public void setParticipantIssuerBankReference(String participantIssuerBankReference) {
this.participantIssuerBankReference = participantIssuerBankReference;
}
}
|
3e00004ad6ed9f24f7117c8e2ad0760ff26b6268 | 3,743 | java | Java | realestate/src/main/java/vn/edu/uit/realestate/Controller/RealEstateKindController.java | Fijetso/realestate | 9a00fb87e6a5d1b8ee791a7cde6b3f39df774d1d | [
"Apache-2.0"
] | null | null | null | realestate/src/main/java/vn/edu/uit/realestate/Controller/RealEstateKindController.java | Fijetso/realestate | 9a00fb87e6a5d1b8ee791a7cde6b3f39df774d1d | [
"Apache-2.0"
] | 7 | 2021-03-09T02:50:35.000Z | 2022-03-02T03:49:53.000Z | realestate/src/main/java/vn/edu/uit/realestate/Controller/RealEstateKindController.java | Fijetso/realestate | 9a00fb87e6a5d1b8ee791a7cde6b3f39df774d1d | [
"Apache-2.0"
] | null | null | null | 47.379747 | 143 | 0.776383 | 1 | package vn.edu.uit.realestate.Controller;
import java.net.URI;
import java.util.List;
import java.util.Optional;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import vn.edu.uit.realestate.ExceptionHandler.ExistContentException;
import vn.edu.uit.realestate.ExceptionHandler.NotFoundException;
import vn.edu.uit.realestate.Relational.Model.RealEstateKind;
import vn.edu.uit.realestate.Relational.Model.Trade;
import vn.edu.uit.realestate.Relational.Repository.RealEstateKindRepository;
@RestController
public class RealEstateKindController {
@Autowired
private RealEstateKindRepository realEstateKindRepository;
@GetMapping("/realestatekinds")
public ResponseEntity<List<RealEstateKind>> getRealEstateKinds() {
List<RealEstateKind> realEstateKinds = realEstateKindRepository.findAll();
if (realEstateKinds.isEmpty() == true) {
throw new NotFoundException("Cannot find any Real Estate Kind");
}
return new ResponseEntity<>(realEstateKinds, HttpStatus.OK);
}
@GetMapping("/realestatekinds/{id}")
public ResponseEntity<RealEstateKind> getRealEstateKindById(@PathVariable long id) {
Optional<RealEstateKind> foundRealEstate = realEstateKindRepository.findById(id);
if (foundRealEstate.isPresent()==false) {
throw new NotFoundException("Cannot find any Real Estate Kind with id="+id);
}
return new ResponseEntity<>(foundRealEstate.get(), HttpStatus.OK);
}
@PostMapping("/realestatekinds")
public ResponseEntity<RealEstateKind> postRealEstateKind(@Valid @RequestBody RealEstateKind realEstateKind) throws Exception {
realEstateKindRepository.save(realEstateKind);
URI location = ServletUriComponentsBuilder
.fromCurrentRequest().path("/{id}")
.buildAndExpand(realEstateKind.getId()).toUri();
return ResponseEntity.created(location).build();
}
@GetMapping("/realestatekinds/{realEstateKindId}/trades")
public ResponseEntity<List<Trade>> getTradesByRealEstateKindId(@PathVariable Long realEstateKindId) {
Optional<RealEstateKind> foundRealEstateKind = realEstateKindRepository.findById(realEstateKindId);
if (foundRealEstateKind.isPresent()==false) {
throw new NotFoundException("Cannot find any Real Estate Kind with id="+realEstateKindId);
}
List<Trade> trades = foundRealEstateKind.get().getTrades();
if(trades.isEmpty() == true)
throw new NotFoundException("Cannot find any Trade with Real Estate Kind Id="+realEstateKindId);
return new ResponseEntity<>(trades, HttpStatus.OK);
}
@DeleteMapping("/realestatekinds/{id}")
public void deleteRealEstateKindById(@PathVariable long id) throws Exception {
Optional<RealEstateKind> foundRealEstate = realEstateKindRepository.findById(id);
if (foundRealEstate.isPresent()==false) {
throw new NotFoundException("Cannot find any Real Estate Kind with id="+id);
}
if(foundRealEstate.get().getTrades().isEmpty()==false) {
throw new ExistContentException("There still exist 'Trade' in this Real Estate Kind. You should delete all these Trades before delete.");
}
realEstateKindRepository.deleteById(id);
}
} |
3e0000a84e57ffdb1c99d83ebd42aa2a8cde2687 | 526 | java | Java | src/java/elpoeta/felurian/domain/Variedad.java | elPoeta/FelurianPayPal | aaf42b96bbcbe935046a90f8b80f54b9e2a90a6e | [
"MIT"
] | null | null | null | src/java/elpoeta/felurian/domain/Variedad.java | elPoeta/FelurianPayPal | aaf42b96bbcbe935046a90f8b80f54b9e2a90a6e | [
"MIT"
] | null | null | null | src/java/elpoeta/felurian/domain/Variedad.java | elPoeta/FelurianPayPal | aaf42b96bbcbe935046a90f8b80f54b9e2a90a6e | [
"MIT"
] | null | null | null | 15.939394 | 69 | 0.553232 | 2 |
package elpoeta.felurian.domain;
/**
*
* @author elpoeta
*/
public class Variedad {
private Integer id;
private String nombre;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
@Override
public String toString() {
return "Variedad{" + "id=" + id + ", nombre=" + nombre + '}';
}
}
|
3e0000e9ccf68f74695b5511775311ff493fa92c | 5,215 | java | Java | src/main/java/com/hbm/render/model/ModelCalStock.java | Syncinus/Hbm-s-Nuclear-Tech-GIT | 3ccc662ea0ca016d0d0a507864e2c0ec950c2807 | [
"Unlicense"
] | null | null | null | src/main/java/com/hbm/render/model/ModelCalStock.java | Syncinus/Hbm-s-Nuclear-Tech-GIT | 3ccc662ea0ca016d0d0a507864e2c0ec950c2807 | [
"Unlicense"
] | null | null | null | src/main/java/com/hbm/render/model/ModelCalStock.java | Syncinus/Hbm-s-Nuclear-Tech-GIT | 3ccc662ea0ca016d0d0a507864e2c0ec950c2807 | [
"Unlicense"
] | null | null | null | 30.857988 | 106 | 0.6907 | 3 | package com.hbm.render.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
public class ModelCalStock extends ModelBase {
ModelRenderer Shape8;
ModelRenderer Shape9;
ModelRenderer Shape10;
ModelRenderer Shape11;
ModelRenderer Shape12;
ModelRenderer Shape13;
ModelRenderer Shape14;
ModelRenderer Shape15;
ModelRenderer Shape16;
ModelRenderer Shape17;
ModelRenderer Shape18;
ModelRenderer Shape19;
ModelRenderer Shape20;
ModelRenderer Shape21;
ModelRenderer Shape22;
public ModelCalStock() {
textureWidth = 64;
textureHeight = 32;
Shape8 = new ModelRenderer(this, 0, 0);
Shape8.addBox(0F, 0F, 0F, 15, 6, 3);
Shape8.setRotationPoint(0F, 1F, -1.5F);
Shape8.setTextureSize(64, 32);
Shape8.mirror = true;
setRotation(Shape8, 0F, 0F, 0F);
Shape9 = new ModelRenderer(this, 0, 9);
Shape9.addBox(0F, 0F, 0F, 6, 1, 2);
Shape9.setRotationPoint(7F, 7F, -1F);
Shape9.setTextureSize(64, 32);
Shape9.mirror = true;
setRotation(Shape9, 0F, 0F, 0F);
Shape10 = new ModelRenderer(this, 0, 12);
Shape10.addBox(0F, 0F, 0F, 2, 5, 2);
Shape10.setRotationPoint(10F, 8F, -1F);
Shape10.setTextureSize(64, 32);
Shape10.mirror = true;
setRotation(Shape10, 0F, 0F, -0.2617994F);
Shape11 = new ModelRenderer(this, 0, 26);
Shape11.addBox(0F, 0F, 0F, 3, 4, 2);
Shape11.setRotationPoint(19F, 3F, -1F);
Shape11.setTextureSize(64, 32);
Shape11.mirror = true;
setRotation(Shape11, 0F, 0F, 0F);
Shape12 = new ModelRenderer(this, 0, 22);
Shape12.addBox(-4F, 0F, 0F, 4, 2, 2);
Shape12.setRotationPoint(19F, 3F, -1F);
Shape12.setTextureSize(64, 32);
Shape12.mirror = true;
setRotation(Shape12, 0F, 0F, -0.1115358F);
Shape13 = new ModelRenderer(this, 10, 28);
Shape13.addBox(-5F, -2F, 0F, 5, 2, 2);
Shape13.setRotationPoint(19F, 7F, -1F);
Shape13.setTextureSize(64, 32);
Shape13.mirror = true;
setRotation(Shape13, 0F, 0F, 0.2617994F);
Shape14 = new ModelRenderer(this, 12, 23);
Shape14.addBox(0F, 0F, 0F, 1, 3, 2);
Shape14.setRotationPoint(22F, 3F, -1F);
Shape14.setTextureSize(64, 32);
Shape14.mirror = true;
setRotation(Shape14, 0F, 0F, 0.3490659F);
Shape15 = new ModelRenderer(this, 42, 0);
Shape15.addBox(0F, 0F, 0F, 3, 5, 8);
Shape15.setRotationPoint(3F, 4F, -9.5F);
Shape15.setTextureSize(64, 32);
Shape15.mirror = true;
setRotation(Shape15, 0F, 0F, 0F);
Shape16 = new ModelRenderer(this, 36, 0);
Shape16.addBox(0F, 0F, 0F, 2, 1, 1);
Shape16.setRotationPoint(3.5F, 3.5F, -4F);
Shape16.setTextureSize(64, 32);
Shape16.mirror = true;
setRotation(Shape16, 0F, 0F, 0F);
Shape17 = new ModelRenderer(this, 36, 0);
Shape17.addBox(0F, 0F, 0F, 2, 1, 1);
Shape17.setRotationPoint(3.5F, 2.7F, -3.5F);
Shape17.setTextureSize(64, 32);
Shape17.mirror = true;
setRotation(Shape17, 0F, 0F, 0F);
Shape18 = new ModelRenderer(this, 36, 0);
Shape18.addBox(0F, 0F, 0F, 2, 1, 1);
Shape18.setRotationPoint(3.5F, 2.2F, -2.8F);
Shape18.setTextureSize(64, 32);
Shape18.mirror = true;
setRotation(Shape18, 0F, 0F, 0F);
Shape19 = new ModelRenderer(this, 36, 0);
Shape19.addBox(0F, 0F, 0F, 2, 1, 1);
Shape19.setRotationPoint(3.5F, 1.8F, -2F);
Shape19.setTextureSize(64, 32);
Shape19.mirror = true;
setRotation(Shape19, 0F, 0F, 0F);
Shape20 = new ModelRenderer(this, 16, 9);
Shape20.addBox(0F, 0F, 0F, 6, 1, 4);
Shape20.setRotationPoint(7F, 4F, -2F);
Shape20.setTextureSize(64, 32);
Shape20.mirror = true;
setRotation(Shape20, 0F, 0F, 0F);
Shape21 = new ModelRenderer(this, 8, 12);
Shape21.addBox(0F, 0F, 0F, 2, 1, 1);
Shape21.setRotationPoint(11F, 0F, 0F);
Shape21.setTextureSize(64, 32);
Shape21.mirror = true;
setRotation(Shape21, 0F, 0F, 0F);
Shape22 = new ModelRenderer(this, 8, 14);
Shape22.addBox(0F, 0F, 0F, 2, 1, 2);
Shape22.setRotationPoint(11F, -1F, 0F);
Shape22.setTextureSize(64, 32);
Shape22.mirror = true;
setRotation(Shape22, -0.3490659F, 0F, 0F);
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
super.render(entity, f, f1, f2, f3, f4, f5);
setRotationAngles(f, f1, f2, f3, f4, f5, entity);
Shape8.render(f5);
Shape9.render(f5);
Shape10.render(f5);
Shape11.render(f5);
Shape12.render(f5);
Shape13.render(f5);
Shape14.render(f5);
Shape15.render(f5);
Shape16.render(f5);
Shape17.render(f5);
Shape18.render(f5);
Shape19.render(f5);
Shape20.render(f5);
Shape21.render(f5);
Shape22.render(f5);
}
public void renderAll(float f5) {
Shape8.render(f5);
Shape9.render(f5);
Shape10.render(f5);
Shape11.render(f5);
Shape12.render(f5);
Shape13.render(f5);
Shape14.render(f5);
Shape15.render(f5);
Shape16.render(f5);
Shape17.render(f5);
Shape18.render(f5);
Shape19.render(f5);
Shape20.render(f5);
Shape21.render(f5);
Shape22.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
}
}
|
3e000102d739f6ff1609530a21c82139e5bef8ee | 3,637 | java | Java | src/ds/tcp/client_server/Server.java | tabsnospaces/distributed-systems-for-fun | 54e605265a4d78656aba815184b869b96227d3a9 | [
"Apache-2.0"
] | null | null | null | src/ds/tcp/client_server/Server.java | tabsnospaces/distributed-systems-for-fun | 54e605265a4d78656aba815184b869b96227d3a9 | [
"Apache-2.0"
] | null | null | null | src/ds/tcp/client_server/Server.java | tabsnospaces/distributed-systems-for-fun | 54e605265a4d78656aba815184b869b96227d3a9 | [
"Apache-2.0"
] | null | null | null | 30.057851 | 79 | 0.523783 | 4 |
package ds.tcp.client_server;
import java.net.*;
import java.io.*;
import java.util.Scanner;
/**
*
* @author yuzo
*/
public class Server {
public static void main(String args[]) {
try {
int serverPort = 6666;
ServerSocket serverSocket = new ServerSocket(serverPort);
while (true) {
System.out.println("Waiting for connections...");
Socket clientSocket = serverSocket.accept();
System.out.println("Client Accepted...");
new Thread(new ThreadServerReceiver(clientSocket)).start();
new Thread(new ThreadServerSender(clientSocket)).start();
}
} catch (IOException e) {
System.out.println("Server socket: " + e.getMessage());
}
}
}
class ThreadServerReceiver implements Runnable {
DataInputStream input;
DataOutputStream output;
Socket serverSocket;
public ThreadServerReceiver(Socket serverSocket) {
try {
this.serverSocket = serverSocket;
this.input = new DataInputStream(serverSocket.getInputStream());
this.output = new DataOutputStream(serverSocket.getOutputStream());
} catch (IOException ioe) {
System.out.println("IOE: " + ioe.getMessage());
}
}
@Override
public void run() {
try {
String buffer;
while (true) {
buffer = this.input.readUTF();
System.out.println(buffer);
if (buffer.equals("SAIR")) {
break;
}
}
} catch (EOFException eofe) {
System.out.println("EOF: " + eofe.getMessage());
} catch (IOException ioe) {
System.out.println("IOE: " + ioe.getMessage());
} finally {
try {
this.input.close();
this.output.close();
this.serverSocket.close();
System.exit(0);
} catch (IOException ioe) {
System.err.println("IOE: " + ioe);
}
}
System.out.println("ThreadServerReceiver terminated.");
}
}
class ThreadServerSender implements Runnable {
DataInputStream input;
DataOutputStream output;
Socket serverSocket;
public ThreadServerSender(Socket serverSocket) {
try {
this.serverSocket = serverSocket;
input = new DataInputStream(serverSocket.getInputStream());
output = new DataOutputStream(serverSocket.getOutputStream());
} catch (IOException ioe) {
System.out.println("IOE: " + ioe.getMessage());
}
}
@Override
public void run() {
Scanner reader = new Scanner(System.in);
try {
String buffer;
while (true) {
buffer = reader.nextLine();
this.output.writeUTF(buffer);
if (buffer.equals("SAIR")) {
break;
}
}
} catch (EOFException eofe) {
System.out.println("EOFE: " + eofe.getMessage());
} catch (IOException ioe) {
System.out.println("IOE: " + ioe.getMessage());
} finally {
// try {
//// this.input.close();
//// this.output.close();
//// this.serverSocket.close();
//// System.exit(0);
// } catch (IOException ioe) {
// System.err.println("IOE: " + ioe);
// }
}
System.out.println("ThreadServerSender terminated.");
}
}
|
3e000281de32fee98f383337ccac5048f1d1b42d | 1,078 | java | Java | QuickSort.java | rithwik00/Sorting-Algorithms | ed4c1e88f310eefe0d8a1918bed5ce9dfdaeffdf | [
"MIT"
] | null | null | null | QuickSort.java | rithwik00/Sorting-Algorithms | ed4c1e88f310eefe0d8a1918bed5ce9dfdaeffdf | [
"MIT"
] | null | null | null | QuickSort.java | rithwik00/Sorting-Algorithms | ed4c1e88f310eefe0d8a1918bed5ce9dfdaeffdf | [
"MIT"
] | null | null | null | 22 | 57 | 0.427644 | 5 | class QuickSort {
static void swap (int[] arr, int i, int j) {
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
static int partition(int arr[], int low, int high) {
int pivot = arr[high];
int i = low - 1;
for(int j = low; j < high; j++) {
if (arr[j] < pivot) {
i++;
swap(arr, i, j);
}
}
swap(arr, i + 1, high);
return (i + 1);
}
static void quickSort(int[] arr, int low, int high) {
if(low < high) {
int pi = partition(arr, low, high);
quickSort(arr, low, pi - 1);
quickSort(arr, pi + 1, high);
}
}
static void printArray(int[] arr, int size) {
for(int i = 0; i < size; i++)
System.out.print(arr[i] + " ");
System.out.println();
}
public static void main(String[] args) {
int[] arr = {10,7,8,9,1,5};
int n = arr.length;
quickSort(arr, 0, n - 1);
printArray(arr, n);
}
}
|
3e0002c0fd11b51daff2b6f07e8dd00f3bfb9111 | 190 | java | Java | src/main/java/innerclass/People.java | ThinkDifferenter/demo4java | 7a382000eadc20ffbc735724005c7bfafb9205b8 | [
"Apache-2.0"
] | null | null | null | src/main/java/innerclass/People.java | ThinkDifferenter/demo4java | 7a382000eadc20ffbc735724005c7bfafb9205b8 | [
"Apache-2.0"
] | null | null | null | src/main/java/innerclass/People.java | ThinkDifferenter/demo4java | 7a382000eadc20ffbc735724005c7bfafb9205b8 | [
"Apache-2.0"
] | null | null | null | 15.833333 | 45 | 0.542105 | 6 | package innerclass;
public class People {
public People getWoman(){
class Woman extends People{ //局部内部类
int age =0;
}
return new Woman();
}
}
|
3e0002e6ac2e53c5372fb23b7ffddf61d4b9e6f5 | 13,993 | java | Java | portal-api/src/main/java/com/channelsharing/hongqu/portal/api/service/impl/UserInfoServiceImpl.java | Gradven/portal-api | 2f3740df0591e95e368713b0bb502e122d9ff650 | [
"Apache-2.0"
] | 1 | 2022-02-10T03:51:11.000Z | 2022-02-10T03:51:11.000Z | portal-api/src/main/java/com/channelsharing/hongqu/portal/api/service/impl/UserInfoServiceImpl.java | Gradven/portal-api | 2f3740df0591e95e368713b0bb502e122d9ff650 | [
"Apache-2.0"
] | null | null | null | portal-api/src/main/java/com/channelsharing/hongqu/portal/api/service/impl/UserInfoServiceImpl.java | Gradven/portal-api | 2f3740df0591e95e368713b0bb502e122d9ff650 | [
"Apache-2.0"
] | null | null | null | 30.353579 | 159 | 0.670192 | 7 | /**
* Copyright © 2016-2022 liuhangjun All rights reserved.
*/
package com.channelsharing.hongqu.portal.api.service.impl;
import com.channelsharing.hongqu.portal.api.constant.Constant;
import com.channelsharing.hongqu.portal.api.entity.UserInfo;
import com.channelsharing.hongqu.portal.api.enums.UserStatus;
import com.channelsharing.hongqu.portal.api.service.UserInfoService;
import com.channelsharing.cloud.sms.SmsSenderFactory;
import com.channelsharing.common.cache.CacheDuration;
import com.channelsharing.common.cache.ExpireTimeConstant;
import com.channelsharing.common.exception.BadRequestException;
import com.channelsharing.common.exception.ForbiddenException;
import com.channelsharing.common.exception.NotFoundException;
import com.channelsharing.common.exception.OccupiedException;
import com.channelsharing.common.service.CrudServiceImpl;
import com.channelsharing.common.utils.DateUtils;
import com.channelsharing.common.utils.EmailUtil;
import com.channelsharing.common.utils.IdGen;
import com.channelsharing.common.utils.RandomUtil;
import com.channelsharing.hongqu.portal.api.dao.UserInfoDao;
import com.channelsharing.hongqu.portal.api.enums.AccountType;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 用户信息Service
* @author liuhangjun
* @version 2017-06-15
*/
@CacheDuration(duration = ExpireTimeConstant.ONE_DAY)
@Service
public class UserInfoServiceImpl extends CrudServiceImpl<UserInfoDao, UserInfo> implements UserInfoService {
public static final String PORTAL_CACHE_PREFIX = Constant.PORTAL_CACHE_PREFIX;
@Resource
private EmailUtil emailUtil;
private static final String MSG_CONTENT = "{verificationCode}";
/**
*
* @param userId
* @return
*/
@Cacheable(value = PORTAL_CACHE_PREFIX + "userInfo", key = "#root.target.PORTAL_CACHE_PREFIX + 'userInfo:id:' + #userId", unless = "#result == null")
public UserInfo findOne(Long userId){
UserInfo userInfo = new UserInfo();
userInfo.setId(userId);
UserInfo userInfoResult = super.findOne(userInfo);
if (userInfoResult == null){
return null;
}
return userInfoResult;
}
public UserInfo findOne(Long id, Long currentUserId){
UserInfo model = new UserInfo();
model.setId(id);
UserInfo userInfo = super.findOne(model);
if (userInfo == null)
return new UserInfo();
userInfo.setActivationCode(null);
return userInfo;
}
/**
* 检查昵称是否被占用
* @param userInfo
* @param nickname
*/
public void isNicknameOccupied(UserInfo userInfo, String nickname){
if (super.dao.isNicknameOccupied(userInfo != null ? userInfo.getId() : null, nickname)) {
throw new OccupiedException("昵称", nickname);
}
}
/**
* 检查email是否被占用
* @param userInfo
* @param email
*/
public void isEmailOccupied(UserInfo userInfo, String email){
if (super.dao.isEmailOccupied(userInfo != null ? userInfo.getId() : null, email)) {
throw new OccupiedException("邮箱地址", email);
}
}
/**
* 检查此邮箱是否有注册
* @param email
* @return
*/
public boolean isExistEmail(String email){
return super.dao.isEmailOccupied(null, email);
}
/**
* 检查此手机号码是否有注册
* @param mobile
* @return
*/
public boolean isExistMobile(String mobile){
return super.dao.isMobileOccupied(null, mobile);
}
/**
* 检查mobile是否被占用
*
* @param userInfo
* @param mobile
*/
public void isMobileOccupied(UserInfo userInfo, String mobile) {
if (super.dao.isMobileOccupied(userInfo != null ? userInfo.getId() : null, mobile)) {
throw new OccupiedException("手机号码", mobile);
}
}
/**
* 以邮件的方式发送激活码
*
* @param userInfo
*/
@Cacheable(value = PORTAL_CACHE_PREFIX + "userInfo", key = "#root.target.PORTAL_CACHE_PREFIX + 'userInfo:id:' + #userInfo.id", unless = "#result == null")
@Transactional
public void sendActivationCode(@NotNull UserInfo userInfo) {
if (userInfo.getEmail() != null) {
this.isEmailOccupied(null, userInfo.getEmail());
UserInfo entity = new UserInfo();
entity.setEmail(userInfo.getEmail());
entity.setAccountType(AccountType.email.getCode());
entity.setStatus(UserStatus.forbidden.getCode());
String activationCode = RandomUtil.getRandomNumString(6);
entity.setActivationCode(activationCode);
this.add(entity);
String today = DateUtils.getDate();
String content = "亲爱的" + Constant.APP_NAME + "用户,您好!\n" + "您本次操作的激活码是" + activationCode
+ ",请输入后继续操作。\n" + "如果您没有进行过操作,请忽略此邮件。此邮件为自动发布,无需回复。\n" + "\n" + Constant.APP_NAME + "\n" + today;
emailUtil.sendSimpleMail(userInfo.getEmail(), Constant.APP_NAME + "激活码", content);
} else {
this.isMobileOccupied(null, userInfo.getMobile());
UserInfo entity = new UserInfo();
entity.setMobile(userInfo.getMobile());
entity.setAccountType(AccountType.mobile.getCode());
entity.setStatus(UserStatus.forbidden.getCode());
entity.setActivationCode(RandomUtil.getRandomNumString(6));
this.add(entity);
SmsSenderFactory.getSmsSender().sendSms(entity.getMobile(),
StringUtils.replace(MSG_CONTENT, "{verificationCode}", entity.getActivationCode()));
}
}
/**
* 找回密码时,发送验证码
*
* @param userInfo
*/
@Cacheable(value = PORTAL_CACHE_PREFIX + "userInfo", key = "#root.target.PORTAL_CACHE_PREFIX + 'userInfo:id:' + #userInfo.id", unless = "#result == null")
public void sendVerifyCode(@NotNull UserInfo userInfo) {
if (userInfo.getEmail() != null) {
if (!this.isExistEmail(userInfo.getEmail()))
throw new NotFoundException("邮箱不存在,请注册此邮箱");
UserInfo entity = new UserInfo();
entity.setEmail(userInfo.getEmail());
entity.setAccountType(AccountType.email.getCode());
String activationCode = RandomUtil.getRandomNumString(6);
entity.setActivationCode(activationCode);
super.dao.update(entity);
String today = DateUtils.getDate();
String content = "亲爱的" + Constant.APP_NAME + "用户,您好!\n" + "您本次操作的验证码是" + activationCode
+ ",请输入后继续操作。\n" + "如果您没有进行过操作,请忽略此邮件。此邮件为自动发布,无需回复。\n" + "\n" + Constant.APP_NAME + "\n" + today;
emailUtil.sendSimpleMail(userInfo.getEmail(), Constant.APP_NAME + "验证码", content);
} else {
if (!this.isExistMobile(userInfo.getMobile()))
throw new NotFoundException("手机号不存在,请注册此手机号");
UserInfo entity = new UserInfo();
entity.setMobile(userInfo.getMobile());
entity.setAccountType(AccountType.mobile.getCode());
entity.setActivationCode(RandomUtil.getRandomNumString(6));
super.dao.update(entity);
SmsSenderFactory.getSmsSender().sendSms(entity.getMobile(),
StringUtils.replace(MSG_CONTENT, "{verificationCode}", entity.getActivationCode()));
}
}
/**
* 激活用户
* @param userInfo
*/
@Cacheable(value = PORTAL_CACHE_PREFIX + "userInfo", key = "#root.target.PORTAL_CACHE_PREFIX + 'userInfo:id:' + #result.id", unless = "#result == null")
@Transactional
public UserInfo activateUser(@NotNull UserInfo userInfo) {
UserInfo entity = new UserInfo();
entity.setEmail(userInfo.getEmail());
entity.setMobile(userInfo.getMobile());
UserInfo retEntity = super.dao.findOne(entity);
if (retEntity == null) {
throw new BadRequestException("此用户不存在");
}
if (retEntity.getStatus().equals(UserStatus.activated.getCode())) {
throw new BadRequestException("此用户已被激活,可重置密码");
}
if (retEntity != null) {
String activationCode = retEntity.getActivationCode();
if (StringUtils.isBlank(activationCode))
throw new ForbiddenException("请先获取验证码!");
if (!StringUtils.equals(activationCode, userInfo.getActivationCode()))
throw new BadRequestException("验证码不正确,请重新输入!");
}
entity.setStatus(UserStatus.activated.getCode());
super.dao.update(entity);
return retEntity;
}
/**
* 验证用户
* @param userInfo
*/
@CacheEvict(value = PORTAL_CACHE_PREFIX + "userInfo", key = "#root.target.PORTAL_CACHE_PREFIX + 'userInfo:id:' + #result.id")
@Transactional
public UserInfo verifyUser(@NotNull UserInfo userInfo){
UserInfo entity = new UserInfo();
entity.setEmail(userInfo.getEmail());
entity.setMobile(userInfo.getMobile());
UserInfo retEntity = super.dao.findOne(entity);
if (retEntity != null){
String verifyCode = retEntity.getActivationCode();
if (StringUtils.isBlank(verifyCode))
throw new ForbiddenException("请先获取验证码!");
if (!StringUtils.equals(verifyCode, userInfo.getActivationCode()))
throw new BadRequestException("验证码不正确,请重新输入!");
}
entity.setActivationCode("");
entity.setStatus(UserStatus.activated.getCode());
super.dao.update(entity);
return retEntity;
}
/**
* 用户账户登录逻辑
* 1、用户名不存在,则提醒用户名密码错误
* 2、用户未激活,则提醒先激活用户
* 3、用户登录错误次数过多,请找回密码
* 4、登录成功,返回用户信息
* 5、登录错误次数归零
* @param userInfo
*/
@CacheEvict(value = PORTAL_CACHE_PREFIX + "userInfo", key = "#root.target.PORTAL_CACHE_PREFIX + 'userInfo:id:' + #result.id")
@Transactional
public UserInfo login(@NotNull UserInfo userInfo){
UserInfo retUserInfo = null;
if (userInfo.getEmail() != null || userInfo.getMobile() != null ) {
retUserInfo = super.findOne(userInfo);
}
if (retUserInfo == null)
throw new BadRequestException("用户名或密码错误");
if (retUserInfo.getStatus() == UserStatus.forbidden.getCode())
throw new BadRequestException("未激活");
//允许的最大错误登录次数
int maxLoginErrorTimes = 5;
if (retUserInfo.getLoginErrorTimes() >= maxLoginErrorTimes)
throw new ForbiddenException("密码错误次数已超过" + maxLoginErrorTimes + "次,请选择找回密码");
//比较密码是否可以对应上
String password = retUserInfo.getPassword();
String reqPassword = DigestUtils.sha512Hex(userInfo.getPassword());
logger.debug("Request password is: [{}]; digest password is: [{}] ", userInfo.getPassword(), reqPassword);
if (!StringUtils.equals(reqPassword, password)) {
UserInfo updateErrorTimes = new UserInfo();
updateErrorTimes.setLoginErrorTimes(retUserInfo.getLoginErrorTimes() + 1);
updateErrorTimes.setId(retUserInfo.getId());
super.dao.update(updateErrorTimes);
throw new BadRequestException("用户名或密码错误");
}
super.dao.clearLoginErrorTimes(userInfo);
return retUserInfo;
}
/**
* 第三方用户登录处理逻辑
* 先根据第三方的id判断数据库中是否有此用户,
* 如果有那么直接返回用户信息,
* 如果没有,那么插入一条用户信息到表中,然后返回此用户信息
*
* @param userInfo
* @return
*/
@Transactional
public UserInfo thirdLogin(@NotNull UserInfo userInfo){
UserInfo retUserInfo;
UserInfo thirdUser = new UserInfo();
thirdUser.setThirdPartyUserId(userInfo.getThirdPartyUserId());
//首先查询是否有此用户
retUserInfo = super.findOne(thirdUser);
if (retUserInfo == null){
//如果昵称重复,那么在昵称后面加个4位长的随机数
String nickname = userInfo.getNickname();
if (super.dao.isNicknameOccupied(null, nickname)){
nickname = nickname + "_" + StringUtils.substring(IdGen.uuid(), 0, 4);
userInfo.setNickname(nickname);
}
//首次登录为激活状态
userInfo.setStatus(UserStatus.activated.getCode());
//新用户插入用户表
super.add(userInfo);
retUserInfo = super.findOne(thirdUser);
}
return retUserInfo;
}
/**
* 更新用户信息
* @param userInfo
*/
@CacheEvict(value = PORTAL_CACHE_PREFIX + "userInfo", key = "#root.target.PORTAL_CACHE_PREFIX + 'userInfo:id:' + #userInfo.id")
@Transactional
@Override
public void modify(@NotNull UserInfo userInfo){
this.isEmailOccupied(userInfo, userInfo.getEmail());
this.isNicknameOccupied(userInfo, userInfo.getNickname());
super.dao.update(userInfo);
}
/**
* 初始化用户,只要昵称和密码
* @param userInfo
*/
@Transactional
public void initUserInfo(UserInfo userInfo){
this.isNicknameOccupied(userInfo, userInfo.getNickname());
String password = DigestUtils.sha512Hex(userInfo.getPassword());
userInfo.setPassword(password);
super.dao.update(userInfo);
}
/**
* 修改用户密码
* 先判断旧密码是否可以对应上
* @param userId
* @param oldPassword
* @param newPassword
*/
@Transactional
public void modifyPassword(Long userId, String oldPassword, String newPassword){
UserInfo entity = new UserInfo();
entity.setId(userId);
UserInfo retUserInfo = super.dao.findOne(entity);
if (!DigestUtils.sha512Hex(oldPassword).equals(retUserInfo.getPassword()))
throw new BadRequestException("原始密码错误");
else {
entity.setPassword(DigestUtils.sha512Hex(newPassword));
super.dao.update(entity);
}
}
/**
* 重置密码功能,
* 说明:验证码的数据库字段与激活码是同一个字段
* 更新密码,并把验证码(激活码)字段设置为null
* 验证码可以请求多次,这里没有做次数限制,以后再补充
* @param userInfo
*/
@Transactional
public void resetPassword(UserInfo userInfo) {
userInfo.setPassword(DigestUtils.sha512Hex(userInfo.getPassword()));
userInfo.setActivationCode(null);
super.dao.update(userInfo);
}
/**
* 根据ids获取到用户数据
* @param ids
* @return
*/
public List<UserInfo> findByIds(List<Long> ids){
return super.dao.findByIds(ids);
}
}
|
3e00032d5bbc1892914ec94df1717dc46088cc75 | 1,920 | java | Java | sample/build/generated/source/r/debug/jp/co/cyberagent/android/gpuimage/sample/R.java | messi49/GPUImageTest | 80667ca2ddf7578bd77a0b39debe1fb8143dddc9 | [
"Apache-2.0"
] | 1 | 2017-04-11T06:26:58.000Z | 2017-04-11T06:26:58.000Z | sample/build/generated/source/r/debug/jp/co/cyberagent/android/gpuimage/sample/R.java | messi49/GPUImageTest | 80667ca2ddf7578bd77a0b39debe1fb8143dddc9 | [
"Apache-2.0"
] | null | null | null | sample/build/generated/source/r/debug/jp/co/cyberagent/android/gpuimage/sample/R.java | messi49/GPUImageTest | 80667ca2ddf7578bd77a0b39debe1fb8143dddc9 | [
"Apache-2.0"
] | null | null | null | 39.183673 | 72 | 0.721354 | 8 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package jp.co.cyberagent.android.gpuimage.sample;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int ic_action_search=0x7f020000;
public static final int ic_launcher=0x7f020001;
public static final int ic_switch_camera=0x7f020002;
public static final int lookup_amatorka=0x7f020003;
}
public static final class id {
public static final int bar=0x7f070001;
public static final int button_camera=0x7f070009;
public static final int button_capture=0x7f070005;
public static final int button_choose_filter=0x7f070004;
public static final int button_gallery=0x7f070008;
public static final int button_save=0x7f070007;
public static final int gpuimage=0x7f070006;
public static final int img_switch_camera=0x7f070002;
public static final int seekBar=0x7f070003;
public static final int surfaceView=0x7f070000;
}
public static final class layout {
public static final int activity_camera=0x7f030000;
public static final int activity_gallery=0x7f030001;
public static final int activity_main=0x7f030002;
}
public static final class raw {
public static final int tone_cuver_sample=0x7f040000;
}
public static final class string {
public static final int app_name=0x7f050000;
public static final int title_activity_activity_main=0x7f050001;
}
public static final class style {
public static final int AppTheme=0x7f060000;
public static final int AppTheme_Fullscreen=0x7f060002;
public static final int AppTheme_NoActionBar=0x7f060001;
}
}
|
3e000478a0e785e0a00b3c43057c8f73302e7215 | 6,355 | java | Java | src/main/java/com/krupatek/courier/view/rate/PlaceGenerationForm.java | Atharva-tech/courier | ebf6e3788ebf5d1183ef8872048d9498cd4377bd | [
"Unlicense"
] | null | null | null | src/main/java/com/krupatek/courier/view/rate/PlaceGenerationForm.java | Atharva-tech/courier | ebf6e3788ebf5d1183ef8872048d9498cd4377bd | [
"Unlicense"
] | null | null | null | src/main/java/com/krupatek/courier/view/rate/PlaceGenerationForm.java | Atharva-tech/courier | ebf6e3788ebf5d1183ef8872048d9498cd4377bd | [
"Unlicense"
] | null | null | null | 37.163743 | 152 | 0.679465 | 9 | package com.krupatek.courier.view.rate;
import com.krupatek.courier.model.AccountCopy;
import com.krupatek.courier.model.PlaceGeneration;
import com.krupatek.courier.model.State;
import com.krupatek.courier.model.Zones;
import com.krupatek.courier.repository.PlaceGenerationRepository;
import com.krupatek.courier.repository.StateRepository;
import com.krupatek.courier.service.PlaceGenerationService;
import com.krupatek.courier.service.StateService;
import com.krupatek.courier.service.ZonesService;
import com.krupatek.courier.utils.ViewUtils;
import com.vaadin.flow.component.Key;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.H4;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.dialog.Dialog;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.Binder;
import com.vaadin.flow.data.binder.ValidationException;
import com.vaadin.flow.data.value.ValueChangeMode;
import com.vaadin.flow.component.select.Select;
import com.vaadin.flow.component.button.Button;
//import org.hibernate.sql.Select;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.TreeSet;
import java.util.stream.Collectors;
public class PlaceGenerationForm extends Div {
public PlaceGenerationForm(ZonesService zonesService, PlaceGenerationRepository placeGenerationRepository,
PlaceGenerationService placeGenerationService, StateService stateService){
super();
Dialog dialog=new Dialog();
HorizontalLayout horizontalLayout = new HorizontalLayout();
horizontalLayout.setPadding(true);
horizontalLayout.setMargin(false);
Binder<PlaceGeneration> binder=new Binder<>(PlaceGeneration.class);
PlaceGeneration placeGeneration=placeGenerationRepository.findAll().get(0);
FormLayout formLayout = new FormLayout();
formLayout.setResponsiveSteps(
new FormLayout.ResponsiveStep("25em", 1),
new FormLayout.ResponsiveStep("25em", 2));
formLayout.setMaxWidth("25em");
formLayout.add(ViewUtils.addCloseButton(dialog), 2);
H4 title = new H4();
title.setSizeFull();
title.setText("Place Generation");
formLayout.add(title, 2);
TextField cityTxt = new TextField();
cityTxt.setLabel("City : ");
cityTxt.setValueChangeMode(ValueChangeMode.EAGER);
formLayout.add(cityTxt, 2);
binder.forField(cityTxt).asRequired("City name is mandatory").bind(str -> "", PlaceGeneration::setCityName);
cityTxt.addValueChangeListener(e -> {
if (e.getValue() != null && e.getValue().length() > 3) {
String cityName = e.getValue();
// TODO
// PlaceGeneration - cityName
Optional<PlaceGeneration> placeGenerationOptional = placeGenerationService.findByCityName(cityName);
if(placeGenerationOptional.isPresent()){
// Show error
cityTxt.setInvalid(true);
cityTxt.setErrorMessage("City Already Exists !!");
}
else
{
cityTxt.setInvalid(false);
binder.readBean(placeGenerationOptional.get());
}
}
});
// cityTxt.setValue((placeGeneration.getCityName()));
ComboBox<String> stateSelect=new ComboBox<>();
stateSelect.setWidth("50");
stateSelect.setLabel("State :");
formLayout.add(stateSelect,2);
TreeSet<String> stateSource=stateService.findAll().parallelStream().map(State::getStateName).collect(Collectors.toCollection(TreeSet::new));
stateSelect.setItems(stateSource);
//stateSelect.setValue(stateSource.first());
ComboBox<String> placeCodeSelect=new ComboBox<>();
placeCodeSelect.setWidth("50");
placeCodeSelect.setLabel("Place code :");
formLayout.add(placeCodeSelect,2);
TreeSet<String> placeCodeSource= zonesService.findAll().parallelStream().map(Zones::getZoneCode).collect(Collectors.toCollection(TreeSet::new));
placeCodeSelect.setItems(placeCodeSource);
//placeCodeSelect.setValue(placeCodeSource.first());
//ComboBox<String> stateComboBox = new ComboBox<>();
// stateComboBox.setLabel("State :");
// formLayout.add(stateComboBox,2);
// List<PlaceGeneration> placeGenerationList=placeGenerationService.findAll();
// List<String> stateNameList=new ArrayList<>();
// placeGenerationList.forEach(c->stateNameList.add(c.getStateName()));
// stateComboBox.setItems(stateNameList);
//binder.bind(stateComboBox,PlaceGeneration::getStateName,PlaceGeneration::setStateName);
// ComboBox<String> placeCodeComboBox = new ComboBox<>();
// placeCodeComboBox.setLabel("Place Code :");
// formLayout.add(placeCodeComboBox,2);
// List<String> placeCodeNameList=new ArrayList<>();
// placeGenerationList.forEach(c->placeCodeNameList.add(c.getPlaceCode()));
// placeCodeComboBox.setItems(placeCodeNameList);
Button save=new Button("Save",
event->{
try{
binder.writeBean(placeGeneration);
placeGeneration.setCityName(cityTxt.getValue());
placeGeneration.setStateName(stateSelect.getValue());
placeGeneration.setPlaceCode(placeCodeSelect.getValue());
placeGenerationService.saveAndFlush(placeGeneration);
Notification.show("Details saved successfully");
}catch (ValidationException e){
Notification.show("Details could not be saved");
}
});
Button cancel=new Button("Cancel",event->dialog.close());
HorizontalLayout actions=new HorizontalLayout();
actions.add(save,cancel);
formLayout.add(actions,4);
horizontalLayout.add(formLayout);
dialog.add(horizontalLayout);
dialog.open();
}
}
|
3e00048dc204bb3046b64663dabc69552737397e | 1,044 | java | Java | src/main/java/IP/recursion/WellFormedBrackets.java | skilllessons/coding-interview-prep-today | 3262d606505b0c95cbddffb89c5d09aeae733515 | [
"Apache-2.0"
] | 1 | 2020-08-18T03:01:17.000Z | 2020-08-18T03:01:17.000Z | src/main/java/IP/recursion/WellFormedBrackets.java | skilllessons/coding-interview-prep-today | 3262d606505b0c95cbddffb89c5d09aeae733515 | [
"Apache-2.0"
] | null | null | null | src/main/java/IP/recursion/WellFormedBrackets.java | skilllessons/coding-interview-prep-today | 3262d606505b0c95cbddffb89c5d09aeae733515 | [
"Apache-2.0"
] | 2 | 2020-08-25T14:21:11.000Z | 2021-10-08T04:15:58.000Z | 23.727273 | 93 | 0.542146 | 10 | package main.java.IP.recursion;
import java.util.ArrayList;
import java.util.List;
public class WellFormedBrackets {
static String[] find_all_well_formed_brackets(int n) {
List<String> result = new ArrayList<>();
helper(n,0,0,new StringBuilder(), result);
String[] finalResult = new String[result.size()];
int count = 0;
for(String s : result) {
finalResult[count] = s;
count++;
}
return finalResult;
}
static void helper(int n, int open, int close, StringBuilder slate, List<String> result){
if(slate.length() == n*2){
result.add(slate.toString());
return;
}
if (open < n){
slate.append("(");
helper(n,open+1, close,slate,result);
slate.deleteCharAt(slate.length()-1);
}
if (close < open) {
slate.append(")");
helper(n,open, close+1,slate,result);
slate.deleteCharAt(slate.length()-1);
}
}
}
|
3e0004c401393282608d9438e6c7659735daa3af | 855 | java | Java | immutable/forestop/impl/OpenclMem.java | benrayfield/HumanAiNetNeural | 502a1dc185b9ae7362a15ff89653c6d7f357e003 | [
"MIT"
] | 1 | 2020-01-04T00:36:22.000Z | 2020-01-04T00:36:22.000Z | immutable/forestop/impl/OpenclMem.java | benrayfield/HumanAiNetNeural | 502a1dc185b9ae7362a15ff89653c6d7f357e003 | [
"MIT"
] | null | null | null | immutable/forestop/impl/OpenclMem.java | benrayfield/HumanAiNetNeural | 502a1dc185b9ae7362a15ff89653c6d7f357e003 | [
"MIT"
] | null | null | null | 18.586957 | 63 | 0.706433 | 11 | package immutable.forestop.impl;
import java.io.IOException;
import java.lang.ref.WeakReference;
import org.lwjgl.opencl.CL10;
import org.lwjgl.opencl.CLMem;
import immutable.forestop.Mem;
public class OpenclMem implements Mem{
public CLMem clmem;
//public final WeakReference<CLMem> clmem;
/** TODO can this be read from CLMem instead of storing it? */
public final Class eltype;
/** TODO can this be read from CLMem instead of storing it? */
public final int size;
public OpenclMem(CLMem clmem, Class eltype, int size){
this.clmem = clmem;
this.eltype = eltype;
this.size = size;
}
public Class eltype(){
return eltype;
}
public int size(){
return size;
}
protected void finalize(){
close();
}
public synchronized void close(){
if(clmem != null){
CL10.clReleaseMemObject(clmem);
clmem = null;
}
}
} |
3e000590e977dc3c8af38bccc8b208146a8fbbd5 | 248 | java | Java | app/src/main/java/yooco/uchain/uchainwallet/data/remote/INetCallback.java | Seven777Sylvia/UC | 04f0e01b06a07479f57584d0ca06b0a56a395280 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/yooco/uchain/uchainwallet/data/remote/INetCallback.java | Seven777Sylvia/UC | 04f0e01b06a07479f57584d0ca06b0a56a395280 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/yooco/uchain/uchainwallet/data/remote/INetCallback.java | Seven777Sylvia/UC | 04f0e01b06a07479f57584d0ca06b0a56a395280 | [
"Apache-2.0"
] | null | null | null | 17.714286 | 62 | 0.721774 | 12 | package yooco.uchain.uchainwallet.data.remote;
/**
* Created by SteelCabbage on 2018/3/26.
*/
public interface INetCallback<T> {
void onSuccess(int statusCode, String msg, String result);
void onFailed(int failedCode, String msg);
}
|
3e0005d6ce59ee3e79ac3f51a1611a9887aae39a | 1,259 | java | Java | openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/ItemManager.java | chardon1/onap-sdc | b2370800befb9c7c557a0651717a8fd604736542 | [
"Apache-2.0"
] | 15 | 2018-10-02T14:54:35.000Z | 2022-03-01T18:27:14.000Z | openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/ItemManager.java | chardon1/onap-sdc | b2370800befb9c7c557a0651717a8fd604736542 | [
"Apache-2.0"
] | 6 | 2021-12-14T21:00:42.000Z | 2022-02-27T17:07:08.000Z | openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/ItemManager.java | chardon1/onap-sdc | b2370800befb9c7c557a0651717a8fd604736542 | [
"Apache-2.0"
] | 31 | 2018-05-30T19:18:29.000Z | 2022-03-01T06:16:47.000Z | 29.27907 | 114 | 0.75139 | 13 | /*
* Copyright © 2016-2018 European Support Limited
*
* 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.openecomp.sdc.versioning;
import java.util.Collection;
import java.util.function.Predicate;
import org.openecomp.sdc.versioning.dao.types.VersionStatus;
import org.openecomp.sdc.versioning.types.Item;
public interface ItemManager {
Collection<Item> list(Predicate<Item> predicate);
Item get(String itemId);
Item create(Item item);
void updateVersionStatus(String itemId, VersionStatus addedVersionStatus, VersionStatus removedVersionStatus);
void archive(Item item);
void restore(Item item);
void delete(Item item);
void updateName(String itemId, String name);
void update(Item item);
}
|
3e000719ba31418f590a89b2bbadbce333e1d782 | 1,361 | java | Java | src/main/java/edu/bator/cards/Ally.java | robmat/shadow_era_ai | b6ff43e9a835fe32fee1aa97f54524f0b39e9100 | [
"MIT"
] | null | null | null | src/main/java/edu/bator/cards/Ally.java | robmat/shadow_era_ai | b6ff43e9a835fe32fee1aa97f54524f0b39e9100 | [
"MIT"
] | null | null | null | src/main/java/edu/bator/cards/Ally.java | robmat/shadow_era_ai | b6ff43e9a835fe32fee1aa97f54524f0b39e9100 | [
"MIT"
] | null | null | null | 28.957447 | 85 | 0.735489 | 14 | package edu.bator.cards;
import static java.util.Objects.nonNull;
import edu.bator.cards.util.ArmorUtil;
import edu.bator.cards.util.BonusUtil;
import edu.bator.game.GameState;
import java.util.function.BiConsumer;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class Ally extends Card {
public enum Affinity {
UNDEAD, WULVEN, TWILIGHT, HOMUNCULUS, TEMPLAR, RAVAGER, ALDMOR
}
public Ally(Card cloneFrom) {
super(cloneFrom);
}
public void attackTarget(GameState gameState, Card target) {
Card attackSource = this;
BiConsumer<GameState, Card> attackEvent = (stateOfTheGame, card) -> {
if (nonNull(attackSource.getAttack(stateOfTheGame)) && nonNull(
target.getCurrentHp(gameState))) {
target.setCurrentHp(target.currentHpWithoutBonus() - ArmorUtil
.attachmentModifiesAttack(target, attackSource, gameState));
}
};
attackTarget(attackEvent, target, gameState);
}
@Override
public Integer getAttack(GameState gameState) {
int attack = super.getAttack(gameState) + BonusUtil.attackBonus(gameState, this);
return Math.max(attack, 0);
}
@Override
public Integer getCurrentHp(GameState gameState) {
return super.getCurrentHp(gameState) + BonusUtil.hpBonus(gameState, this);
}
}
|
3e00074f5c109f4295efc8a6e05b5127991ca12a | 4,380 | java | Java | src/main/java/ch/uzh/ifi/seal/soprafs20/cluechecker/ClueChecker.java | Marinolino/sopra-fs20-group11-justone-server | c88673d0aba4223126dddc53b8848994f4e93bb7 | [
"Apache-2.0"
] | null | null | null | src/main/java/ch/uzh/ifi/seal/soprafs20/cluechecker/ClueChecker.java | Marinolino/sopra-fs20-group11-justone-server | c88673d0aba4223126dddc53b8848994f4e93bb7 | [
"Apache-2.0"
] | null | null | null | src/main/java/ch/uzh/ifi/seal/soprafs20/cluechecker/ClueChecker.java | Marinolino/sopra-fs20-group11-justone-server | c88673d0aba4223126dddc53b8848994f4e93bb7 | [
"Apache-2.0"
] | null | null | null | 39.818182 | 171 | 0.636301 | 15 | package ch.uzh.ifi.seal.soprafs20.cluechecker;
import ch.uzh.ifi.seal.soprafs20.constant.ClueStatus;
import ch.uzh.ifi.seal.soprafs20.entity.game.Clue;
import ch.uzh.ifi.seal.soprafs20.entity.game.Game;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
public final class ClueChecker {
private ClueChecker(){
}
public static Clue checkClue(Clue clueInput, Game game) throws IOException {
List<String> stringClues = new ArrayList<>();
//check if the clue input is valid
if (clueInput.getClueWord() == null || clueInput.getClueWord().isBlank() || clueInput.getClueWord().contains(" ") || clueInput.getClueWord().equals("OVERTIMED")) {
clueInput.setValid(ClueStatus.INVALID);
return clueInput;
}
//add all clues that are already saved in the game
for (Clue existingClue : game.getClues()){
stringClues.add(existingClue.getClueWord());
}
for (String clue: stringClues) {
//check if the clue already exists
if (checkForDuplicate(clueInput.getClueWord(), clue)) {
clueInput.setValid(ClueStatus.DUPLICATE);
return clueInput;
}
}
//check if the clue is equal to the chosen word
if (game.getChosenWord().equals(clueInput.getClueWord())){
clueInput.setValid(ClueStatus.INVALID);
return clueInput;
}
//check if clue is contained in chosenWord or vice versa
if (checkIfClueOrWordSubstring(clueInput.getClueWord(), game.getChosenWord())) {
clueInput.setValid((ClueStatus.INVALID));
return clueInput;
}
//create list of homophones
String str = ClueChecker.makeRequest(game.getChosenWord());
ArrayList<String> wordList = ClueChecker.makeList(str);
//check if clue is homophone of chosenword
for (int i = 0; i<wordList.size(); i++) {
if (wordList.get(i).equalsIgnoreCase("\"" + clueInput.getClueWord() + "\"")) {
clueInput.setValid(ClueStatus.INVALID);
return clueInput;
}
}
//check if clue is plural of chosenword or vice versa.
if (clueInput.getClueWord().equalsIgnoreCase(game.getChosenWord() + "s") ||
game.getChosenWord().equalsIgnoreCase(clueInput.getClueWord() + "s")) {
clueInput.setValid(ClueStatus.INVALID);
return clueInput;
}
clueInput.setValid(ClueStatus.VALID);
return clueInput;
}
//checks if the clue already exists
//returns true if the clues are duplicates, false otherwise
private static boolean checkForDuplicate(String newClue, String existingClue){
//remove all whitespaces
newClue = newClue.replaceAll("\\s+","");
existingClue = existingClue.replaceAll("\\s+","");
//changes both strings to lowercase and compares them
return newClue.equalsIgnoreCase(existingClue);
}
//
private static boolean checkIfClueOrWordSubstring(String newClue, String chosenWord){
return chosenWord.toLowerCase().contains(newClue.toLowerCase()) || newClue.toLowerCase().contains(chosenWord.toLowerCase());
}
private static String makeRequest(String chosenWord) throws IOException {
String response;
String urlString = "https://api.datamuse.com/words?rel_hom=" + chosenWord;
URL url = new URL(urlString);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
StringBuilder content = new StringBuilder();
response = content.append(in.readLine()).toString();
in.close();
return response;
}
private static ArrayList<String> makeList(String rawList) {
String[] tempList;
ArrayList<String> finalList = new ArrayList<>();
tempList = rawList.split(":|\\,");
for (int i = 0; i < tempList.length; i ++) {
if ((i-1)%6 == 0) {
finalList.add(tempList[i]);
}
}
return finalList;
}
}
|
3e000777f05224fe96c01a21f5bdd9fd8113332c | 1,477 | java | Java | simplity/core/src/main/java/org/simplity/core/dm/field/ChildRecord.java | simplity/simplity | 3d67e612c112917f8567c5ec6f00bb10e894a459 | [
"MIT"
] | 3 | 2017-02-03T05:19:53.000Z | 2021-05-24T22:24:06.000Z | simplity/core/src/main/java/org/simplity/core/dm/field/ChildRecord.java | simplity/simplity | 3d67e612c112917f8567c5ec6f00bb10e894a459 | [
"MIT"
] | 124 | 2016-08-27T05:14:14.000Z | 2017-12-28T02:30:36.000Z | simplity/core/src/main/java/org/simplity/core/dm/field/ChildRecord.java | simplity/simplity | 3d67e612c112917f8567c5ec6f00bb10e894a459 | [
"MIT"
] | 2 | 2021-11-27T10:15:25.000Z | 2022-01-01T20:07:34.000Z | 37.871795 | 86 | 0.758294 | 16 | /*
* Copyright (c) 2019 simplity.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.simplity.core.dm.field;
import org.simplity.core.dm.Record;
/**
* data structure that is defined in another record
*/
public class ChildRecord extends DataStructureField {
@Override
protected void resolverReference(Record parentRecord, Record defaultRefferedRecord) {
/*
* purpose of referred record is different here..
*/
return;
}
}
|
3e00079da60ac8e4e82fc7f96273aa639647ff79 | 1,597 | java | Java | common/src/main/java/com/styx/common/utils/convert/DateFormatUtil.java | zxwgdft/styx | 1b48397d3e4f980fb6cf9d2d2a7536c74bf2199b | [
"Apache-2.0"
] | null | null | null | common/src/main/java/com/styx/common/utils/convert/DateFormatUtil.java | zxwgdft/styx | 1b48397d3e4f980fb6cf9d2d2a7536c74bf2199b | [
"Apache-2.0"
] | null | null | null | common/src/main/java/com/styx/common/utils/convert/DateFormatUtil.java | zxwgdft/styx | 1b48397d3e4f980fb6cf9d2d2a7536c74bf2199b | [
"Apache-2.0"
] | null | null | null | 32.591837 | 111 | 0.611146 | 17 | package com.styx.common.utils.convert;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* 通过线程变量提高效率,使用jmh测试结果几乎快100倍
* <p>
* 10线程 5轮测试结果如下(测试时只获取了两种format,如果format多了以后可能会稍微影响map命中率,但影响较小)
* Benchmark Mode Cnt Score Error Units
* thread local方式 thrpt 5 386642994.134 ± 4473165.392 ops/s
* new Object方式 thrpt 5 3391447.593 ± 327200.206 ops/s
*/
public class DateFormatUtil {
private final static Map<String, ThreadLocal<SimpleDateFormat>> threadLocalMap = new ConcurrentHashMap<>();
private static ThreadLocal<SimpleDateFormat> getThreadLocal(final String format) {
ThreadLocal<SimpleDateFormat> threadLocal = threadLocalMap.get(format);
if (threadLocal == null) {
synchronized (threadLocalMap) {
threadLocal = threadLocalMap.get(format);
if (threadLocal == null) {
threadLocal = new ThreadLocal<SimpleDateFormat>() {
public SimpleDateFormat initialValue() {
return new SimpleDateFormat(format);
}
};
threadLocalMap.put(format, threadLocal);
}
}
}
return threadLocal;
}
/**
* 通过线程变量创建并获取安全的{@link SimpleDateFormat}
*
* @param format
* @return
*/
public static SimpleDateFormat getThreadSafeFormat(String format) {
return getThreadLocal(format).get();
}
}
|
3e0007b700f6dcf839b5a05c1e3e30a8ec7fb680 | 4,907 | java | Java | app/src/main/java/com/example/android/miwok/PhrasesActivity.java | DhyanSh/Miwok-Language-App | 5f20e381af73c39480034cc108622ef92dec6d74 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/example/android/miwok/PhrasesActivity.java | DhyanSh/Miwok-Language-App | 5f20e381af73c39480034cc108622ef92dec6d74 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/example/android/miwok/PhrasesActivity.java | DhyanSh/Miwok-Language-App | 5f20e381af73c39480034cc108622ef92dec6d74 | [
"Apache-2.0"
] | null | null | null | 39.256 | 124 | 0.665987 | 18 | package com.example.android.miwok;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Color;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Build;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import static android.media.AudioManager.AUDIOFOCUS_GAIN;
import static android.media.AudioManager.AUDIOFOCUS_LOSS;
import static android.media.AudioManager.AUDIOFOCUS_LOSS_TRANSIENT;
public class PhrasesActivity extends AppCompatActivity {
private MediaPlayer mediaPlayer;
private MediaPlayer.OnCompletionListener mCompletionListener = new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
releaseMediaPlayer();
}
};
private AudioManager mAudioManager ;
AudioManager.OnAudioFocusChangeListener mOnAudioFocusChangeListener = new AudioManager.OnAudioFocusChangeListener() {
@Override
public void onAudioFocusChange(int focusChange) {
if (focusChange == AUDIOFOCUS_LOSS_TRANSIENT || focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK){
mediaPlayer.pause();
mediaPlayer.seekTo(0);
}
else if (focusChange == AUDIOFOCUS_GAIN){
mediaPlayer.start();
}
else if (focusChange == AUDIOFOCUS_LOSS){
releaseMediaPlayer();
}
}
};
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.word_list);
final ArrayList<Word> words = new ArrayList<Word>();
words.add(new Word("Where are you going?","minto wuksus",R.raw.phrase_where_are_you_going));
words.add(new Word("What is your name?","tinnә oyaase'nә",R.raw.phrase_what_is_your_name));
words.add(new Word("My name is...","oyaaset...",R.raw.phrase_my_name_is));
words.add(new Word("How are you feeling?","michәksәs?",R.raw.phrase_how_are_you_feeling));
words.add(new Word("I’m feeling good.","kuchi achit",R.raw.phrase_im_feeling_good));
words.add(new Word("Are you coming?","әәnәs'aa?",R.raw.phrase_are_you_coming));
words.add(new Word("Yes, I’m coming.","hәә’ әәnәm",R.raw.phrase_yes_im_coming));
words.add(new Word("I’m coming.","әәnәm",R.raw.phrase_im_coming));
words.add(new Word("Let’s go.","yoowutis",R.raw.phrase_lets_go));
words.add(new Word("Come here.","әnni'nem",R.raw.phrase_come_here));
WordAdapter adapter = new WordAdapter(this,words,R.color.category_phrases);
ListView listView =(ListView) findViewById(R.id.list);
listView.setAdapter(adapter);
mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
releaseMediaPlayer();
int result = mAudioManager.requestAudioFocus(mOnAudioFocusChangeListener,
// Use the music stream.
AudioManager.STREAM_MUSIC,
// Request permanent focus.
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
// Start playback
mediaPlayer = MediaPlayer.create(PhrasesActivity.this,words.get(position).getSound());
mediaPlayer.start();
mediaPlayer.setOnCompletionListener(mCompletionListener);
}
}
});
}
@Override
protected void onStop() {
super.onStop();
releaseMediaPlayer();
}
private void releaseMediaPlayer() {
// If the media player is not null, then it may be currently playing a sound.
if (mediaPlayer != null) {
// Regardless of the current state of the media player, release its resources
// because we no longer need it.
mediaPlayer.release();
// Set the media player back to null. For our code, we've decided that
// setting the media player to null is an easy way to tell that the media player
// is not configured to play an audio file at the moment.
mediaPlayer = null;
mAudioManager.abandonAudioFocus(mOnAudioFocusChangeListener);
}
}
}
|
3e0008320be5f6216f1b1fa820cb0e5175d8fd42 | 1,079 | java | Java | _nami/nami/src/test/java/feature/JsonTest.java | greenflute/noear_solon | 9aa5eefaa080705cb337286bfd36719d11196dfc | [
"Apache-2.0"
] | 232 | 2019-02-15T03:44:00.000Z | 2022-03-27T08:44:51.000Z | _nami/nami/src/test/java/feature/JsonTest.java | greenflute/noear_solon | 9aa5eefaa080705cb337286bfd36719d11196dfc | [
"Apache-2.0"
] | 26 | 2019-11-21T04:47:38.000Z | 2022-03-15T13:44:21.000Z | _nami/nami/src/test/java/feature/JsonTest.java | greenflute/noear_solon | 9aa5eefaa080705cb337286bfd36719d11196dfc | [
"Apache-2.0"
] | 31 | 2019-07-15T14:36:27.000Z | 2022-03-13T09:59:25.000Z | 27.666667 | 70 | 0.55607 | 19 | package feature;
public class JsonTest {
// @Test
// public void test1(){
// ISerializer serializer = new FastjsonSerializer();
//
// String str1 = "\"\"";
// String str11 = serializer.deserialize(str1, String.class);
// assert "".equals(str11);
//
// String str2 = "false";
// boolean str22 = serializer.deserialize(str2, Boolean.class);
// assert str22 == false;
//
// String str3 = "12";
// int str33 = serializer.deserialize(str3, Integer.class);
// assert str33 == 12;
// }
//
// @Test
// public void test2(){
// ISerializer serializer = new SnackSerializer();
//
// String str1 = "\"\"";
// String str11 = serializer.deserialize(str1, String.class);
// assert "".equals(str11);
//
// String str2 = "false";
// boolean str22 = serializer.deserialize(str2, Boolean.class);
// assert str22 == false;
//
// String str3 = "12";
// int str33 = serializer.deserialize(str3, Integer.class);
// assert str33 == 12;
// }
}
|
3e00086783cc7e9ffbd4b8902a9f12f31c193d48 | 1,645 | java | Java | app/src/main/java/ca/lakeland/plantsd/flightlogger/Adapters/ChecklistAdapter.java | splant10/FlightLogger | 40e339be29f0f82561f2d120472fb7d860a4126a | [
"Apache-2.0"
] | null | null | null | app/src/main/java/ca/lakeland/plantsd/flightlogger/Adapters/ChecklistAdapter.java | splant10/FlightLogger | 40e339be29f0f82561f2d120472fb7d860a4126a | [
"Apache-2.0"
] | 1 | 2016-07-26T20:50:15.000Z | 2016-07-27T16:45:14.000Z | app/src/main/java/ca/lakeland/plantsd/flightlogger/Adapters/ChecklistAdapter.java | splant10/FlightLogger | 40e339be29f0f82561f2d120472fb7d860a4126a | [
"Apache-2.0"
] | null | null | null | 26.967213 | 92 | 0.645593 | 20 | package ca.lakeland.plantsd.flightlogger.Adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.List;
import ca.lakeland.plantsd.flightlogger.Objects.DoneChecklist;
import ca.lakeland.plantsd.flightlogger.R;
/**
* Created by plantsd on 6/3/2016.
*/
public class ChecklistAdapter extends ArrayAdapter<DoneChecklist> {
List checklists;
LayoutInflater vi;
public ChecklistAdapter(Context context, int textViewResourceId) {
super(context, textViewResourceId);
}
public ChecklistAdapter(Context context, int resource, List<DoneChecklist> checklists) {
super(context, resource, checklists);
this.checklists = checklists;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
vi = LayoutInflater.from(getContext());
v = vi.inflate(R.layout.adapter_checklist_row, null);
}
DoneChecklist dc = (DoneChecklist) checklists.get(position);
if (dc != null) {
TextView txt1 = (TextView) v.findViewById(R.id.txtChecklistDate);
if (txt1 != null) {
txt1.setText(dc.getDate());
}
TextView txt2 = (TextView) v.findViewById(R.id.txtChecklistAuthor);
if (txt2 != null) {
String auth = "Completed by " + dc.getAuthor();
txt2.setText(auth);
}
}
return v;
}
}
|
3e00086ff391c7d666c3f0243e910b5ff9fb041a | 1,061 | java | Java | Ktr4j/src/main/java/com/kotor4j/materials/MaterialWithClipping.java | Otaka/Ktr4j | 536e52b50b28e999cfced9b6f6b6a96b5871c168 | [
"Apache-2.0"
] | null | null | null | Ktr4j/src/main/java/com/kotor4j/materials/MaterialWithClipping.java | Otaka/Ktr4j | 536e52b50b28e999cfced9b6f6b6a96b5871c168 | [
"Apache-2.0"
] | 1 | 2021-02-03T19:23:06.000Z | 2021-02-03T19:23:06.000Z | Ktr4j/src/main/java/com/kotor4j/materials/MaterialWithClipping.java | Otaka/Ktr4j | 536e52b50b28e999cfced9b6f6b6a96b5871c168 | [
"Apache-2.0"
] | null | null | null | 24.674419 | 90 | 0.678605 | 21 | package com.kotor4j.materials;
import com.jme3.asset.AssetManager;
import com.jme3.light.LightList;
import com.jme3.material.Material;
import com.jme3.material.MaterialDef;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
/**
* @author Dmitry
*/
public class MaterialWithClipping extends Material {
int x=0;
int y=0;
int width = 8000;
int height = 8000;
public MaterialWithClipping(MaterialDef def) {
super(def);
}
public MaterialWithClipping(AssetManager contentMan, String defName) {
super(contentMan, defName);
}
@Override
public void render(Geometry geometry, LightList lights, RenderManager renderManager) {
renderManager.getRenderer().setClipRect(x, y, width,height);
super.render(geometry, lights, renderManager);
renderManager.getRenderer().clearClipRect();
}
public void setClipping(int x, int y, int width, int height){
this.x=x;
this.y=y;
this.width=width;
this.height=height;
}
}
|
3e0008bc59843d8cedea2681d4f3fab3320ce950 | 1,156 | java | Java | Chapter9/src/edu/packt/neuralnet/Neuron.java | xushjie1987/neural-networking-4j | d83fe51410355b698fca288395d78cf6ef324e6d | [
"Apache-2.0"
] | 1 | 2017-12-30T10:43:19.000Z | 2017-12-30T10:43:19.000Z | Chapter9/src/edu/packt/neuralnet/Neuron.java | xushjie1987/neural-networking-4j | d83fe51410355b698fca288395d78cf6ef324e6d | [
"Apache-2.0"
] | null | null | null | Chapter9/src/edu/packt/neuralnet/Neuron.java | xushjie1987/neural-networking-4j | d83fe51410355b698fca288395d78cf6ef324e6d | [
"Apache-2.0"
] | null | null | null | 19.266667 | 68 | 0.752595 | 22 | package edu.packt.neuralnet;
import java.util.ArrayList;
import java.util.Random;
public class Neuron {
private ArrayList<Double> listOfWeightIn;
private ArrayList<Double> listOfWeightOut;
private double outputValue;
private double error;
private double sensibility;
public double initNeuron(){
Random r = new Random();
return r.nextDouble();
}
public ArrayList<Double> getListOfWeightIn() {
return listOfWeightIn;
}
public void setListOfWeightIn(ArrayList<Double> listOfWeightIn) {
this.listOfWeightIn = listOfWeightIn;
}
public ArrayList<Double> getListOfWeightOut() {
return listOfWeightOut;
}
public void setListOfWeightOut(ArrayList<Double> listOfWeightOut) {
this.listOfWeightOut = listOfWeightOut;
}
public double getOutputValue() {
return outputValue;
}
public void setOutputValue(double outputValue) {
this.outputValue = outputValue;
}
public double getError() {
return error;
}
public void setError(double error) {
this.error = error;
}
public double getSensibility() {
return sensibility;
}
public void setSensibility(double sensibility) {
this.sensibility = sensibility;
}
}
|
3e00096f051c969facc1d7c76fbe60adf6bf7a9c | 555 | java | Java | app/src/main/java/com/felix/simplebook/database/TypeBean.java | 1162242970/Bill | f9088225888d8b31445ff59253e8b13541ea5d62 | [
"Apache-2.0"
] | 1 | 2018-07-02T14:52:05.000Z | 2018-07-02T14:52:05.000Z | app/src/main/java/com/felix/simplebook/database/TypeBean.java | 1162242970/Bill | f9088225888d8b31445ff59253e8b13541ea5d62 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/felix/simplebook/database/TypeBean.java | 1162242970/Bill | f9088225888d8b31445ff59253e8b13541ea5d62 | [
"Apache-2.0"
] | null | null | null | 16.323529 | 67 | 0.625225 | 23 | package com.felix.simplebook.database;
import org.litepal.crud.DataSupport;
import java.io.Serializable;
/**
* Created by chaofei.xue on 2017/11/29.
*/
public class TypeBean extends DataSupport implements Serializable {
private String type;
private long id;
public TypeBean() {
}
public TypeBean(String type) {
this.type = type;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public long getId() {
return id;
}
}
|
3e000b7176d779487eeea45d11bbb34cde912443 | 1,858 | java | Java | core/src/main/java/com/flowci/core/user/service/UserService.java | trency92/flow-core-x | 16bd725bea0b51739c07f7deade10e84797e95a9 | [
"Apache-2.0"
] | 886 | 2017-08-01T10:14:18.000Z | 2020-03-23T08:53:12.000Z | core/src/main/java/com/flowci/core/user/service/UserService.java | trency92/flow-core-x | 16bd725bea0b51739c07f7deade10e84797e95a9 | [
"Apache-2.0"
] | 118 | 2017-11-14T06:24:01.000Z | 2020-03-23T22:19:21.000Z | core/src/main/java/com/flowci/core/user/service/UserService.java | trency92/flow-core-x | 16bd725bea0b51739c07f7deade10e84797e95a9 | [
"Apache-2.0"
] | 107 | 2017-07-12T13:47:12.000Z | 2020-02-28T03:36:24.000Z | 23.518987 | 75 | 0.664693 | 24 | /*
* Copyright 2018 flow.ci
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.flowci.core.user.service;
import com.flowci.core.user.domain.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
/**
* @author yang
*/
public interface UserService {
/**
* List all users
*/
Page<User> list(Pageable pageable);
/**
* List users by given emails
*/
List<User> list(Collection<String> emails);
/**
* Get default admin user
*/
Optional<User> defaultAdmin();
/**
* Create default admin user
*/
User createDefaultAdmin(String email, String passwordOnMd5);
/**
* Create user by email and password;
*/
User create(String email, String passwordOnMd5, User.Role role);
/**
* Get user by email
*/
User getByEmail(String email);
/**
* Change password for current user
*/
void changePassword(String old, String newOne);
/**
* Change role for target user
* @param email target user email
* @param newRole new role will be change
*/
void changeRole(String email, User.Role newRole);
/**
* Delete user by email
*/
User delete(String email);
}
|
3e000bd6a1f5d0ba3a2cb539e970729b1a5f5f6c | 9,540 | java | Java | src/test/java/org/jsoup/select/TraversorTest.java | JsoupMaster/jsoup | cb0f4d2823cb39a3c6af2797b5906115aff94e7b | [
"MIT"
] | null | null | null | src/test/java/org/jsoup/select/TraversorTest.java | JsoupMaster/jsoup | cb0f4d2823cb39a3c6af2797b5906115aff94e7b | [
"MIT"
] | 5 | 2019-11-02T04:59:21.000Z | 2019-12-06T02:49:41.000Z | src/test/java/org/jsoup/select/TraversorTest.java | JsoupMaster/jsoup | cb0f4d2823cb39a3c6af2797b5906115aff94e7b | [
"MIT"
] | null | null | null | 41.12069 | 106 | 0.557023 | 25 | package org.jsoup.select;
import static org.junit.Assert.assertEquals;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Node;
import org.junit.Test;
public class TraversorTest {
// Note: NodeTraversor.traverse(new NodeVisitor) is tested in
// ElementsTest#traverse()
@Test
public void HeadToTailFilterVisit() {
Document doc = Jsoup.parse("<div><p>Hello</p></div><div>There</div>");
final StringBuilder accum = new StringBuilder();
NodeTraversor nodeTraversor = new HeadToTailTraversor();
nodeTraversor.filter(new NodeFilter() {
@Override
public FilterResult head(Node node, int depth) {
accum.append("<").append(node.nodeName()).append(">");
return FilterResult.CONTINUE;
}
@Override
public FilterResult tail(Node node, int depth) {
accum.append("</").append(node.nodeName()).append(">");
return FilterResult.CONTINUE;
}
}, doc.select("div"));
assertEquals("<div><p><#text></#text></p></div><div><#text></#text></div>", accum.toString());
}
@Test
public void HeadToTailFilterSkipChildren() {
Document doc = Jsoup.parse("<div><p>Hello</p></div><div>There</div>");
final StringBuilder accum = new StringBuilder();
NodeTraversor nodeTraversor = new HeadToTailTraversor();
nodeTraversor.filter(new NodeFilter() {
@Override
public FilterResult head(Node node, int depth) {
accum.append("<").append(node.nodeName()).append(">");
// OMIT contents of p:
return ("p".equals(node.nodeName())) ? FilterResult.SKIP_CHILDREN : FilterResult.CONTINUE;
}
@Override
public FilterResult tail(Node node, int depth) {
accum.append("</").append(node.nodeName()).append(">");
return FilterResult.CONTINUE;
}
}, doc.select("div"));
assertEquals("<div><p></p></div><div><#text></#text></div>", accum.toString());
}
@Test
public void HeadToTailFilterSkipEntirely() {
Document doc = Jsoup.parse("<div><p>Hello</p></div><div>There</div>");
final StringBuilder accum = new StringBuilder();
NodeTraversor nodeTraversor = new HeadToTailTraversor();
nodeTraversor.filter(new NodeFilter() {
@Override
public FilterResult head(Node node, int depth) {
// OMIT p:
if ("p".equals(node.nodeName()))
return FilterResult.SKIP_ENTIRELY;
accum.append("<").append(node.nodeName()).append(">");
return FilterResult.CONTINUE;
}
@Override
public FilterResult tail(Node node, int depth) {
accum.append("</").append(node.nodeName()).append(">");
return FilterResult.CONTINUE;
}
}, doc.select("div"));
assertEquals("<div></div><div><#text></#text></div>", accum.toString());
}
@Test
public void HeadToTailFilterRemove() {
Document doc = Jsoup.parse("<div><p>Hello</p></div><div>There be <b>bold</b></div>");
NodeTraversor nodeTraversor = new HeadToTailTraversor();
nodeTraversor.filter(new NodeFilter() {
@Override
public FilterResult head(Node node, int depth) {
// Delete "p" in head:
return ("p".equals(node.nodeName())) ? FilterResult.REMOVE : FilterResult.CONTINUE;
}
@Override
public FilterResult tail(Node node, int depth) {
// Delete "b" in tail:
return ("b".equals(node.nodeName())) ? FilterResult.REMOVE : FilterResult.CONTINUE;
}
}, doc.select("div"));
assertEquals("<div></div>\n<div>\n There be \n</div>", doc.select("body").html());
}
@Test
public void HeadToTailFilterStop() {
Document doc = Jsoup.parse("<div><p>Hello</p></div><div>There</div>");
final StringBuilder accum = new StringBuilder();
NodeTraversor nodeTraversor = new HeadToTailTraversor();
nodeTraversor.filter(new NodeFilter() {
@Override
public FilterResult head(Node node, int depth) {
accum.append("<").append(node.nodeName()).append(">");
return FilterResult.CONTINUE;
}
@Override
public FilterResult tail(Node node, int depth) {
accum.append("</").append(node.nodeName()).append(">");
// Stop after p.
return ("p".equals(node.nodeName())) ? FilterResult.STOP : FilterResult.CONTINUE;
}
}, doc.select("div"));
assertEquals("<div><p><#text></#text></p>", accum.toString());
}
@Test
public void TailToHeadFilterVisit() {
Document doc = Jsoup.parse("<div><p>Hello</p></div><div>There</div>");
final StringBuilder accum = new StringBuilder();
NodeTraversor nodeTraversor = new TailToHeadTraversor();
nodeTraversor.filter(new NodeFilter() {
@Override
public FilterResult head(Node node, int depth) {
accum.append("<").append(node.nodeName()).append(">");
return FilterResult.CONTINUE;
}
@Override
public FilterResult tail(Node node, int depth) {
accum.append("</").append(node.nodeName()).append(">");
return FilterResult.CONTINUE;
}
}, doc.select("div"));
assertEquals("</div></#text><#text><div></div></p></#text><#text><p><div>", accum.toString());
}
@Test
public void TailToHeadFilterSkipChildren() {
Document doc = Jsoup.parse("<div><p>Hello</p></div><div>There</div>");
final StringBuilder accum = new StringBuilder();
NodeTraversor nodeTraversor = new TailToHeadTraversor();
nodeTraversor.filter(new NodeFilter() {
@Override
public FilterResult head(Node node, int depth) {
accum.append("<").append(node.nodeName()).append(">");
return FilterResult.CONTINUE;
}
@Override
public FilterResult tail(Node node, int depth) {
accum.append("</").append(node.nodeName()).append(">");
// OMIT contents of p:
return ("p".equals(node.nodeName())) ? FilterResult.SKIP_CHILDREN : FilterResult.CONTINUE;
}
}, doc.select("div"));
assertEquals("</div></#text><#text><div></div></p><p><div>", accum.toString());
}
@Test
public void TailToHeadFilterSkipEntirely() {
Document doc = Jsoup.parse("<div><p>Hello</p></div><div>There</div>");
final StringBuilder accum = new StringBuilder();
NodeTraversor nodeTraversor = new TailToHeadTraversor();
nodeTraversor.filter(new NodeFilter() {
@Override
public FilterResult head(Node node, int depth) {
accum.append("<").append(node.nodeName()).append(">");
return FilterResult.CONTINUE;
}
@Override
public FilterResult tail(Node node, int depth) {
// OMIT p:
if ("p".equals(node.nodeName()))
return FilterResult.SKIP_ENTIRELY;
accum.append("</").append(node.nodeName()).append(">");
return FilterResult.CONTINUE;
}
}, doc.select("div"));
assertEquals("</div></#text><#text><div></div><div>", accum.toString());
}
@Test
public void TailToHeadFilterRemove() {
Document doc = Jsoup.parse("<div><p>Hello</p></div><div>There be <b>bold</b></div>");
NodeTraversor nodeTraversor = new TailToHeadTraversor();
nodeTraversor.filter(new NodeFilter() {
@Override
public FilterResult head(Node node, int depth) {
// Delete "p" in head:
return ("p".equals(node.nodeName())) ? FilterResult.REMOVE : FilterResult.CONTINUE;
}
@Override
public FilterResult tail(Node node, int depth) {
// Delete "b" in tail:
return ("b".equals(node.nodeName())) ? FilterResult.REMOVE : FilterResult.CONTINUE;
}
}, doc.select("div"));
assertEquals("<div></div>\n<div>\n There be \n</div>", doc.select("body").html());
}
@Test
public void TailToHeadFilterStop() {
Document doc = Jsoup.parse("<div><p>Hello</p></div><div>There</div>");
final StringBuilder accum = new StringBuilder();
NodeTraversor nodeTraversor = new TailToHeadTraversor();
nodeTraversor.filter(new NodeFilter() {
@Override
public FilterResult head(Node node, int depth) {
accum.append("<").append(node.nodeName()).append(">");
return FilterResult.CONTINUE;
}
@Override
public FilterResult tail(Node node, int depth) {
accum.append("</").append(node.nodeName()).append(">");
// Stop after p.
return ("p".equals(node.nodeName())) ? FilterResult.STOP : FilterResult.CONTINUE;
}
}, doc.select("div"));
assertEquals("</div></#text><#text><div></div></p>", accum.toString());
}
}
|
3e000bf238a10149c57c7bdf18cc19f448de5a84 | 189 | java | Java | src/main/java/ru/devsand/eventregistrator/collection/QueueProcessor.java | kisliakovsky/EventRegistrator | b51e310e62fe0f9437651d571c0e863e6ca55084 | [
"MIT"
] | null | null | null | src/main/java/ru/devsand/eventregistrator/collection/QueueProcessor.java | kisliakovsky/EventRegistrator | b51e310e62fe0f9437651d571c0e863e6ca55084 | [
"MIT"
] | null | null | null | src/main/java/ru/devsand/eventregistrator/collection/QueueProcessor.java | kisliakovsky/EventRegistrator | b51e310e62fe0f9437651d571c0e863e6ca55084 | [
"MIT"
] | null | null | null | 23.625 | 76 | 0.798942 | 26 | package ru.devsand.eventregistrator.collection;
import java.util.Queue;
import java.util.function.Consumer;
public interface QueueProcessor<E, Q extends Queue<E>> extends Consumer<Q> {
}
|
3e000c5ae04f16290cd51ad3deef75db1cf6c16e | 1,255 | java | Java | analyzed_libs/jdk1.6.0_06_src/java/util/UnknownFormatFlagsException.java | jgaltidor/VarJ | 3a25102f8a1a406f5e458cb7d8945cc33b6a4fea | [
"MIT"
] | 1 | 2017-01-26T20:25:00.000Z | 2017-01-26T20:25:00.000Z | analyzed_libs/jdk1.6.0_06_src/java/util/UnknownFormatFlagsException.java | jgaltidor/VarJ | 3a25102f8a1a406f5e458cb7d8945cc33b6a4fea | [
"MIT"
] | null | null | null | analyzed_libs/jdk1.6.0_06_src/java/util/UnknownFormatFlagsException.java | jgaltidor/VarJ | 3a25102f8a1a406f5e458cb7d8945cc33b6a4fea | [
"MIT"
] | null | null | null | 24.134615 | 74 | 0.663745 | 27 | /*
* @(#)UnknownFormatFlagsException.java 1.3 05/11/17
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package java.util;
/**
* Unchecked exception thrown when an unknown flag is given.
*
* <p> Unless otherwise specified, passing a <tt>null</tt> argument to any
* method or constructor in this class will cause a {@link
* NullPointerException} to be thrown.
*
* @version 1.3, 11/17/05
* @since 1.5
*/
public class UnknownFormatFlagsException extends IllegalFormatException {
private static final long serialVersionUID = 19370506L;
private String flags;
/**
* Constructs an instance of this class with the specified flags.
*
* @param f
* The set of format flags which contain an unknown flag
*/
public UnknownFormatFlagsException(String f) {
if (f == null)
throw new NullPointerException();
this.flags = f;
}
/**
* Returns the set of flags which contains an unknown flag.
*
* @return The flags
*/
public String getFlags() {
return flags;
}
// javadoc inherited from Throwable.java
public String getMessage() {
return "Flags = " + flags;
}
}
|
3e000c888945ca3a23fab6ee444fd5365c89522f | 1,038 | java | Java | elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/annotation/Join.java | vandanabhandari/elide | e891dec78d7a2e0639691c404b33e666b131b2b9 | [
"Apache-2.0"
] | 936 | 2015-10-16T21:27:51.000Z | 2022-03-28T01:34:06.000Z | elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/annotation/Join.java | vandanabhandari/elide | e891dec78d7a2e0639691c404b33e666b131b2b9 | [
"Apache-2.0"
] | 1,613 | 2015-10-16T19:16:19.000Z | 2022-03-24T21:17:44.000Z | elide-datastore/elide-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/annotation/Join.java | vandanabhandari/elide | e891dec78d7a2e0639691c404b33e666b131b2b9 | [
"Apache-2.0"
] | 261 | 2015-10-16T18:14:35.000Z | 2022-03-28T01:34:13.000Z | 28.054054 | 106 | 0.691715 | 28 | /*
* Copyright 2020, Yahoo Inc.
* Licensed under the Apache License, Version 2.0
* See LICENSE file in project root for terms.
*/
package com.yahoo.elide.datastores.aggregation.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Documented
@Target({ElementType.FIELD, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Join {
/**
* Join ON clause constraint for customizing relationship joins. {{..}} is used for column references.
*
* @return join constraint like <code>{{col1}} = {{joinField.col2}}</code>
*/
String value();
/**
* Join type.
* @return join type like {@code left, inner, full or cross}
*/
JoinType type() default JoinType.LEFT;
/**
* Whether this joins to one or to many rows.
* @return true if it joins to one row.
*/
boolean toOne() default false;
}
|
3e000d0d8de064a8075ff2b3721ff5f7a70ec9d3 | 181 | java | Java | src/main/java/com/imbus/bank/announcementModule/bo/AnnouncementBo.java | kitman0000/BankManagementSystem | ef8fcb845e85a7b466a43306e74c2db1468e1f91 | [
"MIT"
] | null | null | null | src/main/java/com/imbus/bank/announcementModule/bo/AnnouncementBo.java | kitman0000/BankManagementSystem | ef8fcb845e85a7b466a43306e74c2db1468e1f91 | [
"MIT"
] | null | null | null | src/main/java/com/imbus/bank/announcementModule/bo/AnnouncementBo.java | kitman0000/BankManagementSystem | ef8fcb845e85a7b466a43306e74c2db1468e1f91 | [
"MIT"
] | null | null | null | 13.923077 | 45 | 0.734807 | 29 | package com.imbus.bank.announcementModule.bo;
import lombok.Data;
@Data
public class AnnouncementBo {
private int id;
private String title;
private String author;
}
|
3e000d97d09692cce3e1084fd67331a4eb9e4545 | 5,827 | java | Java | open-metadata-implementation/access-services/subject-area/subject-area-api/src/main/java/org/odpi/openmetadata/accessservices/subjectarea/properties/classifications/Folder.java | JPWKU/egeria | 4dc404fd1b077c39a90e50fb195fb4977314ba5c | [
"Apache-2.0"
] | null | null | null | open-metadata-implementation/access-services/subject-area/subject-area-api/src/main/java/org/odpi/openmetadata/accessservices/subjectarea/properties/classifications/Folder.java | JPWKU/egeria | 4dc404fd1b077c39a90e50fb195fb4977314ba5c | [
"Apache-2.0"
] | null | null | null | open-metadata-implementation/access-services/subject-area/subject-area-api/src/main/java/org/odpi/openmetadata/accessservices/subjectarea/properties/classifications/Folder.java | JPWKU/egeria | 4dc404fd1b077c39a90e50fb195fb4977314ba5c | [
"Apache-2.0"
] | null | null | null | 40.186207 | 138 | 0.728334 | 30 | /* SPDX-License-Identifier: Apache-2.0 */
package org.odpi.openmetadata.accessservices.subjectarea.properties.classifications;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.odpi.openmetadata.accessservices.subjectarea.properties.classifications.Classification;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EnumPropertyValue;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.MapPropertyValue;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.PrimitivePropertyValue;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties;
import org.odpi.openmetadata.accessservices.subjectarea.ffdc.exceptions.InvalidParameterException;
import java.io.Serializable;
import java.util.*;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.odpi.openmetadata.accessservices.subjectarea.properties.enums.*;
/**
* Defines that a collection should be treated like a file folder.
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
public class Folder extends Classification {
private static final Logger log = LoggerFactory.getLogger( Folder.class);
private static final String className = Folder.class.getName();
private Map<String, Object> extraAttributes;
public static final String[] PROPERTY_NAMES_SET_VALUES = new String[] {
"orderBy",
"otherPropertyName",
// Terminate the list
null
};
public static final String[] ATTRIBUTE_NAMES_SET_VALUES = new String[] {
"otherPropertyName",
// Terminate the list
null
};
public static final String[] ENUM_NAMES_SET_VALUES = new String[] {
"orderBy",
// Terminate the list
null
};
public static final String[] MAP_NAMES_SET_VALUES = new String[] {
// Terminate the list
null
};
// note the below definitions needs to be fully qualified
public static final java.util.Set<String> PROPERTY_NAMES_SET = new HashSet(new HashSet<>(Arrays.asList(PROPERTY_NAMES_SET_VALUES)));
public static final java.util.Set<String> ATTRIBUTE_NAMES_SET = new HashSet(new HashSet<>(Arrays.asList(ATTRIBUTE_NAMES_SET_VALUES)));
public static final java.util.Set<String> ENUM_NAMES_SET = new HashSet(new HashSet<>(Arrays.asList(ENUM_NAMES_SET_VALUES)));
public static final java.util.Set<String> MAP_NAMES_SET = new HashSet(new HashSet<>(Arrays.asList(MAP_NAMES_SET_VALUES)));
/**
* Default constructor
*/
public Folder() {
super.classificationName="Folder";
}
@Override
public InstanceProperties obtainInstanceProperties() {
final String methodName = "obtainInstanceProperties";
if (log.isDebugEnabled()) {
log.debug("==> Method: " + methodName);
}
InstanceProperties instanceProperties = new InstanceProperties();
EnumPropertyValue enumPropertyValue=null;
enumPropertyValue = new EnumPropertyValue();
// definition for how elements in the collection should be ordered.
if (orderBy !=null) {
enumPropertyValue.setOrdinal(orderBy.ordinal());
enumPropertyValue.setSymbolicName(orderBy.name());
instanceProperties.setProperty("orderBy",enumPropertyValue);
}
MapPropertyValue mapPropertyValue=null;
PrimitivePropertyValue primitivePropertyValue=null;
primitivePropertyValue = new PrimitivePropertyValue();
primitivePropertyValue.setPrimitiveValue(otherPropertyName);
instanceProperties.setProperty("otherPropertyName",primitivePropertyValue);
if (log.isDebugEnabled()) {
log.debug("<== Method: " + methodName);
}
return instanceProperties;
}
private OrderBy orderBy;
/**
* {@literal Definition for how elements in the collection should be ordered. }
* @return {@code OrderBy }
*/
public OrderBy getOrderBy() {
return this.orderBy;
}
public void setOrderBy(OrderBy orderBy) {
this.orderBy = orderBy;
}
private String otherPropertyName;
/**
* {@literal Name of property to use for ordering. }
* @return {@code String }
*/
public String getOtherPropertyName() {
return this.otherPropertyName;
}
public void setOtherPropertyName(String otherPropertyName) {
this.otherPropertyName = otherPropertyName;
}
/**
* Get the extra attributes - ones that are in addition to the standard types.
* @return extra attributes
*/
public Map<String, Object> getExtraAttributes() {
return extraAttributes;
}
public void setExtraAttributes(Map<String, Object> extraAttributes) {
this.extraAttributes = extraAttributes;
}
}
|
3e000e81bfb27945fe5c5a4dcfdee101299a56f0 | 8,721 | java | Java | src/main/java/org/usfirst/frc/team4944/robot/custom/XboxController.java | EmperorPopo/2020-robot-code-Imported | 7e9bf1ee133b93ddfbe77ef0d0c42a871ccf2c23 | [
"BSD-3-Clause"
] | null | null | null | src/main/java/org/usfirst/frc/team4944/robot/custom/XboxController.java | EmperorPopo/2020-robot-code-Imported | 7e9bf1ee133b93ddfbe77ef0d0c42a871ccf2c23 | [
"BSD-3-Clause"
] | null | null | null | src/main/java/org/usfirst/frc/team4944/robot/custom/XboxController.java | EmperorPopo/2020-robot-code-Imported | 7e9bf1ee133b93ddfbe77ef0d0c42a871ccf2c23 | [
"BSD-3-Clause"
] | null | null | null | 19.77551 | 104 | 0.695562 | 31 | package org.usfirst.frc.team4944.robot.custom;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.buttons.Button;
import edu.wpi.first.wpilibj.buttons.JoystickButton;
import edu.wpi.first.wpilibj.buttons.POVButton;
import edu.wpi.first.wpilibj.command.Command;
/*
* When Creating a new XboxController: XboxController controller = new XboxController(Port#);
*
* This class allows you to add commands to every button on the Xbox controller :
* controller.addCommandToA(Command c);
*
* While also providing the means to check the values for every form of input on the
* controller : controller.getBUTTONNAMEButton() (ex: controller.getAButton();)
*
* USE THIS INSTEAD OF A JOYSTICK
*/
public class XboxController extends Joystick {
Button A, B, X, Y, leftBumper, rightBumper, leftMenu, rightMenu, leftStick, rightStick;
POVButton dpad0, dpad45, dpad90, dpad135, dpad180, dpad225, dpad270, dpad315;
Boolean AToggle, BToggle, XToggle, YToggle, RBToggle, LBToggle, RTToggle, LTToggle, LMToggle, RMToggle;
Boolean prevA, prevB, prevX, prevY, prevRB, prevLB, prevRT, prevLT;
Button leftTrig, rightTrig;
public XboxController(int port) {
super(port);
this.A = new JoystickButton(this, 1);
this.B = new JoystickButton(this, 2);
this.X = new JoystickButton(this, 3);
this.Y = new JoystickButton(this, 4);
this.leftBumper = new JoystickButton(this, 5);
this.rightBumper = new JoystickButton(this, 6);
this.leftMenu = new JoystickButton(this, 7);
this.rightMenu = new JoystickButton(this, 8);
this.leftStick = new JoystickButton(this, 9);
this.rightStick = new JoystickButton(this, 10);
this.AToggle = false;
this.BToggle = false;
this.XToggle = false;
this.YToggle = false;
this.RBToggle = false;
this.LBToggle = false;
this.RTToggle = false;
this.LTToggle = false;
this.LMToggle = false;
this.RMToggle = false;
this.rightTrig = new Button() {
@Override
public boolean get() {
return getRawAxis(3) > 0.75;
}
};
this.leftTrig = new Button() {
@Override
public boolean get() {
return getRawAxis(2) > 0.75;
}
};
}
// A BUTTON
public boolean getAButton() {
return this.getRawButton(1);
}
public void toggleAButton() {
if (this.AToggle) {
this.AToggle = false;
} else if (!this.AToggle) {
this.AToggle = true;
}
}
public boolean getAToggle() {
if (this.AToggle) {
return true;
} else {
return false;
}
}
public void addCommandToA(Command c) {
A.whenActive(c);
}
public void addWhenReleasedToA(Command c) {
A.whenReleased(c);
}
public void addWhenHeldToA(Command c) {
A.whileHeld(c);
}
public void addWhenPressedToA(Command c) {
A.whenPressed(c);
}
// B BUTTON
public boolean getBButton() {
return this.getRawButton(2);
}
public void toggleBButton() {
if (this.BToggle) {
this.BToggle = false;
} else if (!this.BToggle) {
this.BToggle = true;
}
}
public boolean getBToggle() {
if (this.BToggle) {
return true;
} else {
return false;
}
}
public void addCommandToB(Command c) {
B.whenActive(c);
}
public void addWhenReleasedToB(Command c) {
B.whenReleased(c);
}
public void addWhenHeldToB(Command c) {
B.whileHeld(c);
}
public void addWhenPressedToB(Command c) {
B.whenPressed(c);
}
// X BUTTON
public boolean getXButton() {
return this.getRawButton(3);
}
public void toggleXButton() {
if (this.XToggle) {
this.XToggle = false;
} else if (!this.XToggle) {
this.XToggle = true;
}
}
public boolean getXToggle() {
if (this.XToggle) {
return true;
} else {
return false;
}
}
public void addCommandToX(Command c) {
X.whenActive(c);
}
public void addWhenReleasedToX(Command c) {
X.whenReleased(c);
}
public void addWhenHeldToX(Command c) {
X.whileHeld(c);
}
public void addWhenPressedToX(Command c) {
X.whenPressed(c);
}
// Y BUTTON
public boolean getYButton() {
return this.getRawButton(4);
}
public void toggleYButton() {
if (this.YToggle) {
this.YToggle = false;
} else if (!this.YToggle) {
this.YToggle = true;
}
}
public boolean getYToggle() {
if (this.YToggle) {
return true;
} else {
return false;
}
}
public void addCommandToY(Command c) {
Y.whenActive(c);
}
public void addWhenReleasedToY(Command c) {
Y.whenReleased(c);
}
public void addWhenHeldToY(Command c) {
Y.whileHeld(c);
}
public void addWhenPressedToY(Command c) {
Y.whenPressed(c);
}
// LEFT BUMPER
public boolean getLeftBumper() {
return this.getRawButton(5);
}
public void toggleLeftBumper() {
if (this.LBToggle) {
this.LBToggle = false;
} else if (!this.LBToggle) {
this.LBToggle = true;
}
}
public boolean getLBToggle() {
if (this.LBToggle) {
return true;
} else {
return false;
}
}
public void addCommandToLeftBumper(Command c) {
leftBumper.whenActive(c);
}
public void addWhenReleasedToLeftBumper(Command c) {
leftBumper.whenReleased(c);
}
public void addWhenHeldToLeftBumper(Command c) {
leftBumper.whileHeld(c);
}
public void addWhenPressedToLeftBumper(Command c) {
leftBumper.whenPressed(c);
}
// RIGHT BUMPER
public boolean getRightBumper() {
return this.getRawButton(6);
}
public void toggleRightBumper() {
if (this.RBToggle) {
this.RBToggle = false;
} else if (!this.RBToggle) {
this.RBToggle = true;
}
}
public boolean getRBToggle() {
if (this.RBToggle) {
return true;
} else {
return false;
}
}
public void addCommandToRightBumper(Command c) {
rightBumper.whenActive(c);
}
public void addWhenReleasedToRightBumper(Command c) {
rightBumper.whenReleased(c);
}
public void addWhenHeldToRightBumper(Command c) {
rightBumper.whileHeld(c);
}
public void addWhenPressedToRightBumper(Command c) {
rightBumper.whenPressed(c);
}
// LEFT MENU BUTTON
public boolean getLeftMenu() {
return this.getRawButton(7);
}
public void toggleLeftMenu() {
if (this.LMToggle) {
this.LMToggle = false;
} else if (!this.LMToggle) {
this.LMToggle = true;
}
}
public boolean getLMToggle() {
if (this.LMToggle) {
return true;
} else {
return false;
}
}
public void addCommandToLeftMenu(Command c) {
leftMenu.whenActive(c);
}
public void addWhenReleasedToLeftMenu(Command c) {
leftMenu.whenReleased(c);
}
public void addWhenHeldToLeftMenu(Command c) {
leftMenu.whileHeld(c);
}
public void addWhenPressedToLeftMenu(Command c) {
leftMenu.whenPressed(c);
}
// RIGHT MENU BUTTON
public boolean getRightMenu() {
return this.getRawButton(8);
}
public void toggleRightMenu() {
if (this.RMToggle) {
this.RMToggle = false;
} else if (!this.RMToggle) {
this.RMToggle = true;
}
}
public boolean getRMToggle() {
if (this.RMToggle) {
return true;
} else {
return false;
}
}
public void addCommandToRightMenu(Command c) {
rightMenu.whenActive(c);
}
public void addWhenReleasedToRightMenu(Command c) {
rightMenu.whenReleased(c);
}
public void addWhenHeldToRightMenu(Command c) {
rightMenu.whileHeld(c);
}
public void addWhenPressedToRightMenu(Command c) {
rightMenu.whenPressed(c);
}
// LEFT STICK BUTTON
public void addCommandToLeftStick(Command c) {
leftStick.whenPressed(c);
}
public boolean getLeftStickButton() {
return this.getRawButton(9);
}
// RIGHT STICK BUTTON
public void addCommandToRightStick(Command c) {
rightStick.whenPressed(c);
}
public boolean getRightStickButton() {
return this.getRawButton(10);
}
// LEFT TRIGGER
public double getLeftTriggerAnalog() {
return this.getRawAxis(2);
}
public boolean getLeftTriggerDown() {
return this.getLeftTriggerAnalog() >= 0.75;
}
public void addWhenPressedToLeftTrigger(Command c) {
this.leftTrig.whenPressed(c);
}
public void addWhenReleasedToLeftTrigger(Command c) {
this.leftTrig.whenReleased(c);
}
public void addWhenHeldToLeftTrigger(Command c) {
this.leftTrig.whileHeld(c);
}
// RIGHT TRIGGER
public double getRightTriggerAnalog() {
return this.getRawAxis(3);
}
public boolean getRightTriggerDown() {
return this.getRightTriggerAnalog() >= 0.75;
}
public void addWhenPressedToRightTrigger(Command c) {
this.rightTrig.whenPressed(c);
}
public void addWhenReleasedToRightTrigger(Command c) {
this.rightTrig.whenReleased(c);
}
public void addWhenHeldRightTrigger(Command c) {
this.rightTrig.whileHeld(c);
}
// LEFT STICK
public double getLeftStickX() {
return this.getRawAxis(0);
}
public double getLeftStickY() {
return this.getRawAxis(1);
}
// RIGHT STICK
public double getRightStickX() {
return this.getRawAxis(4);
}
public double getRightStickY() {
return this.getRawAxis(5);
}
}
|
3e000f05d2c5fc639dd99e36c1ac46aa1298c02c | 672 | java | Java | openTCS-CommAdapter-Serial/src/guiceConfig/java/com/lvsrobot/serial/SerialAdapterKernelInjectionModule.java | touchmii/OpenTCS-4 | e3973bd72da63011369a1935de7303bf11bc2a1f | [
"MIT"
] | 21 | 2021-07-31T09:35:59.000Z | 2022-03-25T18:23:45.000Z | openTCS-CommAdapter-Serial/src/guiceConfig/java/com/lvsrobot/serial/SerialAdapterKernelInjectionModule.java | wmhui007/OpenTCS-4 | 768dc0aebf63b5ac79f869dabcb35f9ebfb4deee | [
"MIT"
] | 2 | 2021-01-21T12:39:47.000Z | 2021-07-29T09:56:22.000Z | openTCS-CommAdapter-Serial/src/guiceConfig/java/com/lvsrobot/serial/SerialAdapterKernelInjectionModule.java | wmhui007/OpenTCS-4 | 768dc0aebf63b5ac79f869dabcb35f9ebfb4deee | [
"MIT"
] | 17 | 2020-09-24T00:09:50.000Z | 2021-07-07T12:20:41.000Z | 32 | 104 | 0.796131 | 32 | /**
* Copyright (c) Fraunhofer IML
*/
package com.lvsrobot.serial;
import com.google.inject.assistedinject.FactoryModuleBuilder;
import org.opentcs.customizations.kernel.KernelInjectionModule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SerialAdapterKernelInjectionModule extends KernelInjectionModule {
private static final Logger LOG = LoggerFactory.getLogger(SerialAdapterKernelInjectionModule.class);
@Override
protected void configure() {
install(new FactoryModuleBuilder().build(ExampleAdapterComponentsFactory.class));
vehicleCommAdaptersBinder().addBinding().to(ExampleCommAdapterFactory.class);
}
}
|
3e000fdf723be691e486a4c3d393134ddd4e02ac | 679 | java | Java | client/eu-client-service/src/main/java/com/mkl/eu/client/service/vo/enumeration/SiegeUndermineResultEnum.java | BAMGames/eu | d1eb2c8cfc45252285a1b1c1293071b464536ac3 | [
"MIT"
] | 2 | 2019-08-21T21:21:20.000Z | 2019-11-24T15:43:20.000Z | client/eu-client-service/src/main/java/com/mkl/eu/client/service/vo/enumeration/SiegeUndermineResultEnum.java | BAMGames/eu | d1eb2c8cfc45252285a1b1c1293071b464536ac3 | [
"MIT"
] | 12 | 2019-11-14T10:22:15.000Z | 2022-02-01T00:58:02.000Z | client/eu-client-service/src/main/java/com/mkl/eu/client/service/vo/enumeration/SiegeUndermineResultEnum.java | BAMGames/eu | d1eb2c8cfc45252285a1b1c1293071b464536ac3 | [
"MIT"
] | 2 | 2016-03-10T17:45:36.000Z | 2017-04-12T13:56:55.000Z | 30.863636 | 105 | 0.683358 | 33 | package com.mkl.eu.client.service.vo.enumeration;
/**
* Enumeration of status for sieges.
*
* @author MKL
*/
public enum SiegeUndermineResultEnum {
/** Siegework minus. Siege will go on. */
SIEGE_WORK_MINUS,
/** Siegework plus. Siege will go on. */
SIEGE_WORK_PLUS,
/** Breach. Besieger had a breach and will immediately perform an assault and maybe end the siege. */
BREACH_TAKEN,
/** Breach. Besieger had a breach but choose not to use it immediately. */
BREACH_NOT_TAKEN,
/** The fortress falls but any troop inside are given back. The siege ends. */
WAR_HONOUR,
/** The fortress surrenders. The siege ends. */
SURRENDER
}
|
3e0010296eca4684b30359cd700b455fc3a4528a | 4,928 | java | Java | src/main/java/org/everit/atlassian/restclient/jiracloud/v2/model/FieldLastUsed.java | BorvizRobi/atlassian-restclient-jiracloud | 28a81e5b38ad6a34407d7e58ea0ec07eca510ba8 | [
"Apache-2.0"
] | null | null | null | src/main/java/org/everit/atlassian/restclient/jiracloud/v2/model/FieldLastUsed.java | BorvizRobi/atlassian-restclient-jiracloud | 28a81e5b38ad6a34407d7e58ea0ec07eca510ba8 | [
"Apache-2.0"
] | null | null | null | src/main/java/org/everit/atlassian/restclient/jiracloud/v2/model/FieldLastUsed.java | BorvizRobi/atlassian-restclient-jiracloud | 28a81e5b38ad6a34407d7e58ea0ec07eca510ba8 | [
"Apache-2.0"
] | null | null | null | 29.195266 | 274 | 0.676125 | 34 | /*
* Copyright © 2011 Everit Kft. (http://www.everit.org)
*
* 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.
*/
/*
* The Jira Cloud platform REST API
* Jira Cloud platform REST API documentation
*
* The version of the OpenAPI document: 1001.0.0-SNAPSHOT
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.everit.atlassian.restclient.jiracloud.v2.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.time.OffsetDateTime;
/**
* Information about the most recent use of a field.
*/
@ApiModel(description = "Information about the most recent use of a field.")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2020-10-28T14:12:34.799+01:00[Europe/Prague]")
public class FieldLastUsed {
/**
* Last used value type: * *TRACKED*: field is tracked and a last used date is available. * *NOT\\_TRACKED*: field is not tracked, last used date is not available. * *NO\\_INFORMATION*: field is tracked, but no last used date is available.
*/
public enum TypeEnum {
TRACKED("TRACKED"),
NOT_TRACKED("NOT_TRACKED"),
NO_INFORMATION("NO_INFORMATION");
private String value;
TypeEnum(String value) {
this.value = value;
}
@JsonValue
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
@JsonCreator
public static TypeEnum fromValue(String value) {
for (TypeEnum b : TypeEnum.values()) {
if (b.value.equalsIgnoreCase(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}
@JsonProperty("type")
private TypeEnum type;
@JsonProperty("value")
private OffsetDateTime value;
public FieldLastUsed type(TypeEnum type) {
this.type = type;
return this;
}
/**
* Last used value type: * *TRACKED*: field is tracked and a last used date is available. * *NOT\\_TRACKED*: field is not tracked, last used date is not available. * *NO\\_INFORMATION*: field is tracked, but no last used date is available.
* @return type
**/
@ApiModelProperty(value = "Last used value type: * *TRACKED*: field is tracked and a last used date is available. * *NOT\\_TRACKED*: field is not tracked, last used date is not available. * *NO\\_INFORMATION*: field is tracked, but no last used date is available.")
public TypeEnum getType() {
return type;
}
public void setType(TypeEnum type) {
this.type = type;
}
public FieldLastUsed value(OffsetDateTime value) {
this.value = value;
return this;
}
/**
* The date when the value of the field last changed.
* @return value
**/
@ApiModelProperty(value = "The date when the value of the field last changed.")
public OffsetDateTime getValue() {
return value;
}
public void setValue(OffsetDateTime value) {
this.value = value;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
FieldLastUsed fieldLastUsed = (FieldLastUsed) o;
return Objects.equals(this.type, fieldLastUsed.type) &&
Objects.equals(this.value, fieldLastUsed.value);
}
@Override
public int hashCode() {
return Objects.hash(type, value);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class FieldLastUsed {\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" value: ").append(toIndentedString(value)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
|
3e0010312e6c2daea5c628e0f90ca17d4a45ec06 | 431 | java | Java | src/test/java/com/github/xuqplus/hi/leetcode/q1200/q1202/ATest.java | xuqplus/hi-leetcode | c1c6ce860393ff2179ccd23ddfb13901881d61de | [
"Apache-2.0"
] | null | null | null | src/test/java/com/github/xuqplus/hi/leetcode/q1200/q1202/ATest.java | xuqplus/hi-leetcode | c1c6ce860393ff2179ccd23ddfb13901881d61de | [
"Apache-2.0"
] | null | null | null | src/test/java/com/github/xuqplus/hi/leetcode/q1200/q1202/ATest.java | xuqplus/hi-leetcode | c1c6ce860393ff2179ccd23ddfb13901881d61de | [
"Apache-2.0"
] | null | null | null | 16.576923 | 63 | 0.62645 | 35 | package com.github.xuqplus.hi.leetcode.q1200.q1202;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
/**
* 交换字符串中的元素
* medium
* https://leetcode-cn.com/problems/smallest-string-with-swaps/
*/
@Slf4j
public class ATest {
@Test
void a() {
Solution solution = new Solution();
log.info("{}", solution.run());
}
}
class Solution {
public int run() {
return 0;
}
}
|
3e0013263a6f25d3e40f41681677af285edb0738 | 2,169 | java | Java | kodejava-lang-package/src/main/java/org/kodejava/example/lang/LoadResourceFile.java | kodejava/kodejava.project | a99fdbbf5a0bca6c79dd1ee2b520d74f1d9d13d4 | [
"BSD-2-Clause"
] | null | null | null | kodejava-lang-package/src/main/java/org/kodejava/example/lang/LoadResourceFile.java | kodejava/kodejava.project | a99fdbbf5a0bca6c79dd1ee2b520d74f1d9d13d4 | [
"BSD-2-Clause"
] | 3 | 2020-06-18T15:53:00.000Z | 2021-12-09T20:36:34.000Z | kodejava-lang-package/src/main/java/org/kodejava/example/lang/LoadResourceFile.java | kodejava/kodejava.project | a99fdbbf5a0bca6c79dd1ee2b520d74f1d9d13d4 | [
"BSD-2-Clause"
] | null | null | null | 41.711538 | 76 | 0.687875 | 36 | package org.kodejava.example.lang;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;
public class LoadResourceFile {
public static void main(String[] args) throws Exception {
LoadResourceFile demo = new LoadResourceFile();
demo.loadUsingClassMethod();
demo.loadUsingClassLoaderMethod();
}
private void loadUsingClassMethod() throws IOException {
System.out.println("LoadResourceFile.loadUsingClassMethod");
Properties properties = new Properties();
// Load resource relatively to the LoadResourceFile package.
// This actually load resource from
// "/org/kodejava/example/lang/database.conf".
URL resource = getClass().getResource("database.conf");
properties.load(new FileReader(new File(resource.getFile())));
System.out.println("JDBC Driver: " + properties.get("jdbc.driver"));
// Load resource using absolute name. This will read resource
// from the root of the package. This will load "/database.conf".
InputStream is = getClass().getResourceAsStream("/database.conf");
properties.load(is);
System.out.println("JDBC Driver: " + properties.get("jdbc.driver"));
}
private void loadUsingClassLoaderMethod() throws IOException {
System.out.println("LoadResourceFile.loadUsingClassLoaderMethod");
Properties properties = new Properties();
// When using the ClassLoader method the resource name should
// not started with "/". This method will not apply any
// absolute/relative transformation to the resource name.
ClassLoader classLoader = getClass().getClassLoader();
URL resource = classLoader.getResource("database.conf");
properties.load(new FileReader(new File(resource.getFile())));
System.out.println("JDBC URL: " + properties.get("jdbc.url"));
InputStream is = classLoader.getResourceAsStream("database.conf");
properties.load(is);
System.out.println("JDBC URL: " + properties.get("jdbc.url"));
}
}
|
3e00135347787f671945fb1217c0e23a2685d3fb | 7,458 | java | Java | src/main/java/com/moon/core/lang/CharUtil.java | moon-util/moon-util | 28c5cb418861da4d0a5a035a3de919b86b939c0e | [
"MIT"
] | 5 | 2019-04-30T09:23:32.000Z | 2022-01-04T05:28:43.000Z | src/main/java/com/moon/core/lang/CharUtil.java | moon-util/moon-util | 28c5cb418861da4d0a5a035a3de919b86b939c0e | [
"MIT"
] | 7 | 2020-09-08T07:47:18.000Z | 2022-01-04T16:47:25.000Z | src/main/java/com/moon/core/lang/CharUtil.java | moon-util/moon-util | 28c5cb418861da4d0a5a035a3de919b86b939c0e | [
"MIT"
] | 1 | 2022-01-04T05:28:49.000Z | 2022-01-04T05:28:49.000Z | 25.895833 | 111 | 0.496246 | 37 | package com.moon.core.lang;
import java.util.Objects;
import static com.moon.core.lang.ThrowUtil.noInstanceError;
/**
* @author moonsky
*/
public final class CharUtil {
private CharUtil() { noInstanceError(); }
/**
* 字符片段是否相等
*
* @param src 字符数组 1
* @param srcStart 起始位置
* @param srcEnd 结束位置
* @param dest 字符数组 2
* @param destStart 起始位置
* @param destEnd 结束位置
*
* @return 如果两个字符数组指定片段内的内容相同返回 true,否则返回 false
*/
public static boolean isRegionMatches(
char[] src, int srcStart, int srcEnd, char[] dest, int destStart, int destEnd
) {
int srcCnt = srcEnd - srcStart, destCnt = destEnd - destStart;
if (srcCnt != destCnt || srcStart < 0 || destStart < 0) {
return false;
}
int srcLen = src.length;
if (srcEnd >= srcLen) {
return false;
}
int destLen = dest.length;
if (destEnd >= destLen) {
return false;
}
for (int i = 0; i < srcCnt; i++) {
if (src[srcStart + i] != dest[destStart + i]) {
return false;
}
}
return true;
}
/**
* 字符片段是否相等
* <p>
* 这个方法默认由调用方保证索引位置安全
*
* @param src 字符数组 1
* @param srcStart 起始位置
* @param dest 字符数组 2
* @param destStart 起始位置
*
* @return 如果两个字符数组指定片段内的内容相同返回 true,否则返回 false
*/
public static boolean isSafeRegionMatches(char[] src, int srcStart, char[] dest, int destStart) {
int count = dest.length - destStart;
if (srcStart + count <= src.length) {
for (int i = 0; i < count; i++) {
if (src[srcStart + i] != dest[destStart + i]) {
return false;
}
}
return true;
}
return false;
}
public static int indexOf(final char[] src, final char[] test) { return indexOf(src, test, 0); }
public static int indexOf(final char[] src, final char[] test, int fromIndex) {
BooleanUtil.requireFalse(fromIndex < 0);
if (src == test) {
return fromIndex > 0 ? -1 : 0;
}
final int l1 = src.length, l2 = test.length;
if (fromIndex == l1) {
return -1;
}
BooleanUtil.requireTrue(fromIndex < l1);
if (l2 == 0) {
return fromIndex;
}
if (l2 > l1) {
return -1;
}
final char first = test[0];
for (int i = fromIndex, idx, actIdx; i < l1; i++) {
if (src[i] == first) {
idx = 1;
for (; idx < l2; idx++) {
actIdx = idx + i;
if (actIdx < l1) {
if (src[actIdx] != test[idx]) {
break;
}
} else {
return -1;
}
}
if (idx >= l2) {
return i;
}
}
}
return -1;
}
public static boolean isVarStarting(int ch) { return isLetter(ch) || is_(ch) || is$(ch) || isChinese(ch); }
public static boolean isVar(int ch) { return isLetterOrDigit(ch) || is_(ch) || is$(ch) || isChinese(ch); }
public static boolean is_(int ch) { return isUnderscore(ch); }
public static boolean is$(int ch) { return ch == '$'; }
public static boolean isUnderscore(int ch) { return ch == '_'; }
public static boolean isChineseYuan(int ch) { return ch == '¥'; }
public static boolean isDollar(int ch) { return is$(ch); }
/**
* "[4e00-9fa5]"
*
* @param ch 字符
*
* @return 是否是汉字
*/
public static boolean isChinese(int ch) { return ch < 40870 && ch > 19967; }
public static boolean isLetterOrDigit(int ch) { return isDigit(ch) || isLetter(ch); }
/**
* A-Z,a-z
*
* @param ch 字符
*
* @return 是否是字母
*/
public static boolean isLetter(int ch) { return isLowerCase(ch) || isUpperCase(ch); }
/**
* A-Z
*
* @param ch 字符
*
* @return 是否是大写字母
*/
public static boolean isUpperCase(int ch) { return ch > 64 && ch < 91; }
/**
* a-z
*
* @param ch 字符
*
* @return 是否是小写字母
*/
public static boolean isLowerCase(int ch) { return ch > 96 && ch < 123; }
/**
* 0-9
*
* @param ch 字符
*
* @return 是否是数字
*/
public static boolean isDigit(int ch) { return ch > 47 && ch < 58; }
public static boolean equalsIgnoreCase(int ch1, int ch2) {
return ch1 == ch2 || (isLowerCase(ch1) ? ch1 - 32 == ch2 : (isUpperCase(ch1) && ch2 - 32 == ch1));
}
public static boolean isASCIICode(int ch) { return ch < 128; }
public static boolean isChar(Object o) {
if (o instanceof Character) {
return true;
}
if (o instanceof Integer) {
int value = ((Number) o).intValue();
return value > -1 && value < 65536;
}
return false;
}
/**
* 字符转换为数字
* <pre>
* 0-9: 0 - 9;
* A-Z: 10 - 36;
* a-z: 37 - 61;
* (other): -1
* </pre>
*
* @param codePoint
*
* @return
*/
public static int toDigitMaxAs62(int codePoint) {
if (isDigit(codePoint)) {
return codePoint - 48;
}
if (isUpperCase(codePoint)) {
return codePoint - 55;
}
if (isLowerCase(codePoint)) {
return codePoint - 61;
}
return -1;
}
/**
* null : '0'
* false : '0'
* (other): '1'
*
* @param bool
*
* @return
*/
public static char toCharValue(Boolean bool) { return (char) (bool == null || !bool ? 48 : 49); }
public static char toCharValue(long value) { return (char) value; }
public static char toCharValue(float value) { return (char) value; }
public static char toCharValue(double value) { return (char) value; }
/**
* 当且仅当字符串包含一个字符时,返回这个字符,否则抛出异常
*
* @param cs
*
* @return 字符串中仅有的一个字符
*
* @throws NullPointerException 当 cs == null 时,空指针异常
* @throws IllegalArgumentException 当 cs 长度不符合要求 1 时抛出异常
*/
public static char toCharValue(CharSequence cs) {
Objects.requireNonNull(cs, "Can not cast to char from a null value.");
if (cs.length() == 1) {
return cs.charAt(0);
}
throw new IllegalArgumentException(String.format("Can not cast to char of: %s", cs));
}
/**
* @param o 带转换值
*
* @return 转换后的值
*
* @see IntUtil#toIntValue(Object)
*/
public static char toCharValue(Object o) {
if (o == null) {
return 0;
}
if (o instanceof Character) {
return (Character) o;
}
if (o instanceof Number) {
return (char) ((Number) o).intValue();
}
if (o instanceof CharSequence) {
return toCharValue(o.toString());
}
if (o instanceof Boolean) {
return toCharValue((Boolean) o);
}
try {
return toCharValue(ParseSupportUtil.unboxing(o));
} catch (Exception e) {
throw new IllegalArgumentException(String.format("Can not cast to char of: %s", o), e);
}
}
}
|
3e0013b9f1b6f31ec681a04046f355f186563a90 | 3,364 | java | Java | app/src/main/java/com/yhy/widget/demo/activity/SliderActivity.java | yhyzgn/Widgets | c19f53982b5f5285cd967ec15e313458ee305d15 | [
"Apache-2.0"
] | 10 | 2017-08-28T07:24:23.000Z | 2021-11-25T12:31:00.000Z | app/src/main/java/com/yhy/widget/demo/activity/SliderActivity.java | SilentWolf1993/Widgets | c19f53982b5f5285cd967ec15e313458ee305d15 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/yhy/widget/demo/activity/SliderActivity.java | SilentWolf1993/Widgets | c19f53982b5f5285cd967ec15e313458ee305d15 | [
"Apache-2.0"
] | 3 | 2018-12-03T01:50:46.000Z | 2021-03-24T03:42:08.000Z | 29.761062 | 137 | 0.569432 | 38 | package com.yhy.widget.demo.activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.yhy.widget.layout.slider.SlideLayout;
import com.yhy.widget.demo.R;
import com.yhy.widget.demo.activity.base.BaseActivity;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
/**
* author : 颜洪毅
* e-mail : [email protected]
* time : 2017-10-14 9:31
* version: 1.0.0
* desc :
*/
public class SliderActivity extends BaseActivity {
private SlideLayout slSlide;
private TextView tvMenu;
private ViewPager vpContent;
@Override
protected int getLayout() {
return R.layout.activity_slider;
}
@Override
protected void initView() {
slSlide = (SlideLayout) findViewById(R.id.sl_slide);
tvMenu = (TextView) findViewById(R.id.tv_menu);
vpContent = (ViewPager) findViewById(R.id.vp_content);
}
@Override
protected void initData() {
vpContent.setAdapter(new PagerAdapter() {
@Override
public int getCount() {
return 4;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
ImageView iv = new ImageView(SliderActivity.this);
iv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
if (position == 0) {
iv.setImageResource(R.mipmap.img_pager_1);
} else if (position == 1) {
iv.setImageResource(R.mipmap.img_pager_2);
} else if (position == 2) {
iv.setImageResource(R.mipmap.img_pager_3);
} else {
iv.setImageResource(R.mipmap.img_pager_4);
}
container.addView(iv);
return iv;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
});
}
@Override
protected void initEvent() {
tvMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
slSlide.close();
}
});
slSlide.setOnSlideEnableWatcher(new SlideLayout.OnSlideEnableWatcher() {
@Override
public boolean shouldEnable() {
//第二页禁用侧边栏
return vpContent.getCurrentItem() != 1;
}
});
slSlide.setOnStateChangeListener(new SlideLayout.OnStateChangeListener() {
@Override
public void onOpened() {
tvMenu.setText("已打开");
}
@Override
public void onClosed() {
tvMenu.setText("已关闭");
}
@Override
public void onDragging(float percent, int dx, int total) {
tvMenu.setText("比例:" + percent);
}
});
}
}
|
3e00145696cd8009222a22b788d063184917ffd0 | 13,921 | java | Java | convalida-databinding/src/main/java/convalida/databinding/ValidationBindings.java | WellingtonCosta/aav | ae6a5f27c19292c7db2456346db868ed40d80a19 | [
"Apache-2.0"
] | 186 | 2017-07-25T13:56:00.000Z | 2019-07-31T16:40:25.000Z | convalida-databinding/src/main/java/convalida/databinding/ValidationBindings.java | WellingtonCosta/aav | ae6a5f27c19292c7db2456346db868ed40d80a19 | [
"Apache-2.0"
] | 35 | 2017-08-10T17:00:56.000Z | 2019-02-27T20:11:15.000Z | convalida-databinding/src/main/java/convalida/databinding/ValidationBindings.java | WellingtonCosta/aav | ae6a5f27c19292c7db2456346db868ed40d80a19 | [
"Apache-2.0"
] | 21 | 2017-10-06T07:44:46.000Z | 2019-08-02T22:16:09.000Z | 31.928899 | 80 | 0.568422 | 39 | package convalida.databinding;
import android.widget.Button;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.databinding.BindingAdapter;
import convalida.validators.BetweenValidator;
import convalida.validators.CnpjValidator;
import convalida.validators.ConfirmEmailValidator;
import convalida.validators.ConfirmPasswordValidator;
import convalida.validators.CpfValidator;
import convalida.validators.CreditCardValidator;
import convalida.validators.EmailValidator;
import convalida.validators.FutureDateValidator;
import convalida.validators.Ipv4Validator;
import convalida.validators.Ipv6Validator;
import convalida.validators.IsbnValidator;
import convalida.validators.LengthValidator;
import convalida.validators.NumericLimitValidator;
import convalida.validators.OnlyNumberValidator;
import convalida.validators.PasswordValidator;
import convalida.validators.PastDateValidator;
import convalida.validators.PatternValidator;
import convalida.validators.RequiredValidator;
import convalida.validators.UrlValidator;
import static convalida.databinding.ViewTagUtils.addValidatorToField;
/**
* @author WellingtonCosta on 29/03/18.
*/
public class ValidationBindings {
@BindingAdapter(value = {
"requiredErrorMessage",
"requiredAutoDismiss"
}, requireAll = false)
public static void requiredValidationBindings(
@NonNull EditText field,
@NonNull String errorMessage,
Boolean autoDismiss
) {
addValidatorToField(field, new RequiredValidator(
field,
errorMessage,
autoDismiss != null ? autoDismiss : true
));
}
@BindingAdapter(value = {
"emailErrorMessage",
"emailAutoDismiss",
"emailRequired"
}, requireAll = false)
public static void emailValidationBindings(
@NonNull EditText field,
@NonNull String errorMessage,
Boolean autoDismiss,
Boolean required
) {
addValidatorToField(field, new EmailValidator(
field,
errorMessage,
autoDismiss != null ? autoDismiss : true,
required != null ? required : true
));
}
@BindingAdapter(value = {
"confirmEmailEmailField",
"confirmEmailErrorMessage",
"confirmEmailAutoDismiss"
}, requireAll = false)
public static void confirmEmailValidationBindings(
@NonNull EditText confirmEmailField,
@NonNull EditText emailField,
@NonNull String errorMessage,
Boolean autoDismiss
) {
addValidatorToField(confirmEmailField, new ConfirmEmailValidator(
emailField,
confirmEmailField,
errorMessage,
autoDismiss != null ? autoDismiss : true
));
}
@BindingAdapter(value = {
"patternErrorMessage",
"patternPattern",
"patternAutoDismiss",
"patternRequired"
}, requireAll = false)
public static void patternValidationBindings(
@NonNull EditText field,
@NonNull String errorMessage,
@NonNull String pattern,
Boolean autoDismiss,
Boolean required
) {
addValidatorToField(field, new PatternValidator(
field,
errorMessage,
pattern,
autoDismiss != null ? autoDismiss : true,
required != null ? required : true
));
}
@BindingAdapter(value = {
"lengthMin",
"lengthMax",
"lengthErrorMessage",
"lengthAutoDismiss",
"lengthRequired"
}, requireAll = false)
public static void lengthValidationBindings(
@NonNull EditText field,
int min,
int max,
@NonNull String errorMessage,
Boolean autoDismiss,
Boolean required
) {
addValidatorToField(field, new LengthValidator(
field,
errorMessage,
min,
max,
autoDismiss != null ? autoDismiss : true,
required != null ? required : true
));
}
@BindingAdapter(value = {
"onlyNumberErrorMessage",
"onlyNumberAutoDismiss",
"onlyNumberRequired"
}, requireAll = false)
public static void onlyNumberValidationBindings(
@NonNull EditText field,
@NonNull String errorMessage,
Boolean autoDismiss,
Boolean required
) {
addValidatorToField(field, new OnlyNumberValidator(
field,
errorMessage,
autoDismiss != null ? autoDismiss : true,
required != null ? required : true
));
}
@BindingAdapter(value = {
"passwordErrorMessage",
"passwordMinLength",
"passwordPattern",
"passwordAutoDismiss"
}, requireAll = false)
public static void passwordValidationBindings(
@NonNull EditText field,
@NonNull String errorMessage,
Integer minLength,
String pattern,
Boolean autoDismiss
) {
addValidatorToField(field, new PasswordValidator(
field,
errorMessage,
minLength != null ? minLength : 0,
pattern != null ? pattern : "",
autoDismiss != null ? autoDismiss : true
));
}
@BindingAdapter(value = {
"confirmPasswordPasswordField",
"confirmPasswordErrorMessage",
"confirmPasswordAutoDismiss"
}, requireAll = false)
public static void confirmPasswordValidationBindings(
@NonNull EditText confirmPasswordField,
@NonNull EditText passwordField,
@NonNull String errorMessage,
Boolean autoDismiss
) {
addValidatorToField(confirmPasswordField, new ConfirmPasswordValidator(
passwordField,
confirmPasswordField,
errorMessage,
autoDismiss != null ? autoDismiss : true
));
}
@BindingAdapter(value = {
"cpfErrorMessage",
"cpfAutoDismiss",
"cpfRequired"
}, requireAll = false)
public static void cpfValidationBindings(
@NonNull EditText field,
@NonNull String errorMessage,
Boolean autoDismiss,
Boolean required
) {
addValidatorToField(field, new CpfValidator(
field,
errorMessage,
autoDismiss != null ? autoDismiss : true,
required != null ? required : true
));
}
@BindingAdapter(value = {
"cnpjErrorMessage",
"cnpjAutoDismiss",
"cnpjRequired"
}, requireAll = false)
public static void cnpjValidationBindings(
@NonNull EditText field,
@NonNull String errorMessage,
Boolean autoDismiss,
Boolean required
) {
addValidatorToField(field, new CnpjValidator(
field,
errorMessage,
autoDismiss != null ? autoDismiss : true,
required != null ? required : true
));
}
@BindingAdapter(value = {
"isbnErrorMessage",
"isbnAutoDismiss",
"isbnRequired"
}, requireAll = false)
public static void isbnValidationBindings(
@NonNull EditText field,
@NonNull String errorMessage,
Boolean autoDismiss,
Boolean required
) {
addValidatorToField(field, new IsbnValidator(
field,
errorMessage,
autoDismiss != null ? autoDismiss : true,
required != null ? required : true
));
}
@BindingAdapter(value = {
"betweenStartErrorMessage",
"betweenStartAutoDismiss",
"betweenLimitField",
"betweenLimitErrorMessage",
"betweenLimitAutoDismiss"
}, requireAll = false)
public static void betweenValidationBindings(
@NonNull EditText startField,
@NonNull String startErrorMessage,
Boolean startAutoDismiss,
EditText limitField,
@NonNull String limitErrorMessage,
Boolean limitAutoDismiss
) {
addValidatorToField(startField, new BetweenValidator(
startField,
limitField,
startErrorMessage,
limitErrorMessage,
startAutoDismiss != null ? startAutoDismiss : true,
limitAutoDismiss != null ? limitAutoDismiss : true
));
}
@BindingAdapter(value = {
"creditCardErrorMessage",
"creditCardAutoDismiss",
"creditCardRequired"
}, requireAll = false)
public static void creditCardValidationBindings(
@NonNull EditText field,
@NonNull String errorMessage,
Boolean autoDismiss,
Boolean required
) {
addValidatorToField(field, new CreditCardValidator(
field,
errorMessage,
autoDismiss != null ? autoDismiss : true,
required != null ? required : true
));
}
@BindingAdapter(value = {
"numericLimitErrorMessage",
"numericLimitAutoDismiss",
"numericLimitMin",
"numericLimitMax",
"numericLimitRequired"
}, requireAll = false)
public static void numericLimitValidationBindings(
@NonNull EditText field,
@NonNull String errorMessage,
Boolean autoDismiss,
@NonNull String min,
@NonNull String max,
Boolean required
) {
addValidatorToField(field, new NumericLimitValidator(
field,
errorMessage,
autoDismiss != null ? autoDismiss : true,
min,
max,
required != null ? required : true
));
}
@BindingAdapter(value = {
"ipv4ErrorMessage",
"ipv4AutoDismiss",
"ipv4Required"
}, requireAll = false)
public static void ipv4ValidationBindings(
@NonNull EditText field,
@NonNull String errorMessage,
Boolean autoDismiss,
Boolean required
) {
addValidatorToField(field, new Ipv4Validator(
field,
errorMessage,
autoDismiss != null ? autoDismiss : true,
required != null ? required : true
));
}
@BindingAdapter(value = {
"ipv6ErrorMessage",
"ipv6AutoDismiss",
"ipv6Required"
}, requireAll = false)
public static void ipv6ValidationBindings(
@NonNull EditText field,
@NonNull String errorMessage,
Boolean autoDismiss,
Boolean required
) {
addValidatorToField(field, new Ipv6Validator(
field,
errorMessage,
autoDismiss != null ? autoDismiss : true,
required != null ? required : true
));
}
@BindingAdapter(value = {
"urlErrorMessage",
"urlAutoDismiss",
"urlRequired"
}, requireAll = false)
public static void urlValidationBindings(
@NonNull EditText field,
@NonNull String errorMessage,
Boolean autoDismiss,
Boolean required
) {
addValidatorToField(field, new UrlValidator(
field,
errorMessage,
autoDismiss != null ? autoDismiss : true,
required != null ? required : true
));
}
@BindingAdapter(value = {
"pastDateErrorMessage",
"pastDateDateFormat",
"pastDateLimitDate",
"pastDateAutoDismiss",
"pastDateRequired"
}, requireAll = false)
public static void pastDateValidationBindings(
@NonNull EditText field,
@NonNull String errorMessage,
@NonNull String dateFormat,
@NonNull String limitDate,
Boolean autoDismiss,
Boolean required
) {
addValidatorToField(field, new PastDateValidator(
field,
errorMessage,
dateFormat,
limitDate,
autoDismiss != null ? autoDismiss : true,
required != null ? required : true
));
}
@BindingAdapter(value = {
"futureDateErrorMessage",
"futureDateDateFormat",
"futureDateLimitDate",
"futureDateAutoDismiss",
"futureDateRequired"
}, requireAll = false)
public static void futureDateValidationBindings(
@NonNull EditText field,
@NonNull String errorMessage,
@NonNull String dateFormat,
@NonNull String limitDate,
Boolean autoDismiss,
Boolean required
) {
addValidatorToField(field, new FutureDateValidator(
field,
errorMessage,
dateFormat,
limitDate,
autoDismiss != null ? autoDismiss : true,
required != null ? required : true
));
}
@BindingAdapter(value = "validationAction")
public static void validationActionBindings(Button button, Integer action) {
button.setTag(R.id.validation_action, action);
}
}
|
3e001523bd540a30361633d89cc69eba883c3f40 | 3,609 | java | Java | app/controllers/Forms.java | pellerito/to.science.api | d1a48f610f8b35b6cfad77c7af36c443867570db | [
"Apache-2.0"
] | 1 | 2020-12-04T01:15:28.000Z | 2020-12-04T01:15:28.000Z | app/controllers/Forms.java | pellerito/to.science.api | d1a48f610f8b35b6cfad77c7af36c443867570db | [
"Apache-2.0"
] | 99 | 2015-01-15T07:41:41.000Z | 2020-07-01T18:32:44.000Z | app/controllers/Forms.java | pellerito/to.science.api | d1a48f610f8b35b6cfad77c7af36c443867570db | [
"Apache-2.0"
] | 5 | 2016-03-02T13:24:20.000Z | 2020-11-12T12:57:06.000Z | 26.536765 | 135 | 0.670269 | 40 | package controllers;
import java.util.HashMap;
import java.util.Map;
import actions.Modify;
import authenticate.BasicAuth;
import authenticate.User;
import authenticate.UserDB;
import helper.HttpArchiveException;
import helper.JsonMapper;
import models.Message;
import models.Node;
import play.data.DynamicForm;
import play.data.Form;
import play.libs.F.Promise;
import play.mvc.Result;
@BasicAuth
public class Forms extends MyController {
public static Promise<Result> getCatalogForm(String pid) {
return new CreateAction().call((userId) -> {
try {
DynamicForm form = Form.form();
return ok(views.html.catalogForm.render(pid, form));
} catch (Exception e) {
throw new HttpArchiveException(500, e);
}
});
}
public static Promise<Result> postCatalogForm() {
return new CreateAction().call((userId) -> {
try {
DynamicForm form = Form.form().bindFromRequest();
String alephId = form.get("alephId");
String pid = form.get("pid");
Node previewNode = new Node();
previewNode.setPid("preview:1");
String metadata =
new Modify().getLobid2DataAsNtripleString(previewNode, alephId);
previewNode.setMetadata2(metadata);
flash("message",
"Preview! Press 'Create' on the page bottom to create new object.");
return ok(
views.html.catalogPreview.render(pid, previewNode, null, alephId));
} catch (Exception e) {
throw new HttpArchiveException(500, e);
}
});
}
public static Promise<Result> getArticleForm() {
return new CreateAction().call((userId) -> {
try {
return JsonMessage(new Message(
"Here the user will be able add bibligraphic data for articles.",
501));
} catch (Exception e) {
throw new HttpArchiveException(500, e);
}
});
}
public static Promise<Result> getWebpageForm() {
return new CreateAction().call((userId) -> {
try {
return JsonMessage(new Message(
"Here the user will be able to Link a HT-Number to the Form in order to import Aleph data and to configure a webpage gathering.",
501));
} catch (Exception e) {
throw new HttpArchiveException(500, e);
}
});
}
public static Promise<Result> getPartForm() {
return new CreateAction().call((userId) -> {
try {
return JsonMessage(new Message(
"Here the user will be able to create a new part Form.", 501));
} catch (Exception e) {
throw new HttpArchiveException(500, e);
}
});
}
public static Promise<Result> getFileForm() {
return new CreateAction().call((userId) -> {
try {
return JsonMessage(new Message(
"Here the user will be able to upload a new file.", 501));
} catch (Exception e) {
throw new HttpArchiveException(500, e);
}
});
}
public static Promise<Result> getLoginForm() {
return Promise.promise(() -> {
try {
if (models.Globals.users.isLoggedIn(ctx())) {
return redirect(routes.Forms.getLogoutForm());
}
Form<User> userForm = Form.form(User.class);
return ok(views.html.login.render(userForm));
} catch (Exception e) {
throw new HttpArchiveException(500, e);
}
});
}
public static Promise<Result> getLogoutForm() {
try {
return Promise.promise(() -> {
return ok(views.html.logout.render());
});
} catch (Exception e) {
throw new HttpArchiveException(500, e);
}
}
public static Promise<Result> postLogout() {
return new CreateAction().call((userId) -> {
flash("message", "Goodby " + session().get("username")
+ ". You were successfully logged out");
session().clear();
return redirect(routes.Application.index());
});
}
}
|
End of preview. Expand
in Dataset Viewer.
- Downloads last month
- 67