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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3e01a7de81a4ccaa7dd2c2c5d04ae34a4bfa6185 | 912 | java | Java | etc/idlpp/SAJ/tmplTypeSupportImpl.java | agenihorganization/opensplice | 314d3a4538474f2b8e22acffe3c206f4ac38b66b | [
"Apache-2.0"
] | null | null | null | etc/idlpp/SAJ/tmplTypeSupportImpl.java | agenihorganization/opensplice | 314d3a4538474f2b8e22acffe3c206f4ac38b66b | [
"Apache-2.0"
] | null | null | null | etc/idlpp/SAJ/tmplTypeSupportImpl.java | agenihorganization/opensplice | 314d3a4538474f2b8e22acffe3c206f4ac38b66b | [
"Apache-2.0"
] | null | null | null | 24 | 121 | 0.618421 | 701 | public class $(type-name)TypeSupport extends org.opensplice.dds.dcps.TypeSupportImpl implements DDS.TypeSupportOperations
{
private long copyCache;
public $(type-name)TypeSupport()
{
super("$(scoped-meta-type-name)",
"$(internal-type-name)",
"$(key-list)",
$(java-package-redirects),
$(scoped-type-name)MetaHolder.metaDescriptor);
}
@Override
protected void finalize() throws Throwable
{
super.finalize();
}
@Override
protected DDS.DataWriter create_datawriter ()
{
return new $(type-name)DataWriterImpl(this);
}
@Override
protected DDS.DataReader create_datareader ()
{
return new $(type-name)DataReaderImpl(this);
}
@Override
protected DDS.DataReaderView create_dataview ()
{
return new $(type-name)DataReaderViewImpl(this);
}
}
|
3e01a8702420d2f763f754d9262cbcc39cd933f4 | 4,317 | java | Java | src/test/java/org/bioontology/ontologies/api/ClientTest.java | palexander/ontologies_api_java_client | d6e141c2f875b748280ebbc6db67fa43fb7aef91 | [
"Unlicense"
] | null | null | null | src/test/java/org/bioontology/ontologies/api/ClientTest.java | palexander/ontologies_api_java_client | d6e141c2f875b748280ebbc6db67fa43fb7aef91 | [
"Unlicense"
] | 1 | 2017-02-07T22:42:45.000Z | 2017-02-07T22:42:45.000Z | src/test/java/org/bioontology/ontologies/api/ClientTest.java | palexander/ontologies_api_java_client | d6e141c2f875b748280ebbc6db67fa43fb7aef91 | [
"Unlicense"
] | null | null | null | 31.742647 | 107 | 0.65161 | 702 | package org.bioontology.ontologies.api;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bioontology.ontologies.api.http.HTTPOptions;
import org.bioontology.ontologies.api.models.NCBOClass;
import org.bioontology.ontologies.api.models.NCBOOntology;
import org.bioontology.ontologies.api.models.NCBOSubmission;
import org.bioontology.ontologies.api.pages.NCBOPage;
import org.bioontology.ontologies.api.util.SearchOptions;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
/**
*
* @author palexand
*/
public class ClientTest {
private String apikey;
private HTTPOptions opts = null;
public ClientTest() {
apikey = null;
Properties configFile = new Properties();
try {
configFile.load(this.getClass().getResourceAsStream("test_config.properties"));
apikey = configFile.getProperty("APIKEY");
} catch (IOException ex) {
Logger.getLogger(ClientTest.class.getName()).log(Level.SEVERE, null, ex);
}
if (apikey == null || apikey.equals("")) {
throw new IllegalArgumentException("Please provide an API Key in the "
+ "test_config.properties file (see test_config.properties.sample for syntax)");
}
}
@BeforeClass
public static void setUpClass() {
Logger.getGlobal().setLevel(Level.FINER);
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of getAll method, of class Client.
*/
@Test
public void testGetAll() {
System.out.println("getAll");
Client client = new Client(getHTTPOptions());
List<NCBOOntology> result = client.getAll(NCBOOntology.class);
assert (result.size() > 350);
}
@Test
public void testGetByID() {
System.out.println("getByID");
String id = "http://data.bioontology.org/ontologies/SNOMEDCT";
Client client = new Client(getHTTPOptions());
NCBOOntology ont = client.getByID(id, NCBOOntology.class);
assertEquals(id, ont.getId());
}
@Test
public void testGetSubmissions() {
System.out.println("getSubmissions");
String id = "http://data.bioontology.org/ontologies/SNOMEDCT";
Client client = new Client(getHTTPOptions());
NCBOOntology ont = client.getByID(id, NCBOOntology.class);
List<NCBOSubmission> submissions = ont.getSubmissions(getHTTPOptions());
assert (submissions.size() > 2);
}
@Test
public void testSearch() {
System.out.println("search");
Client client = new Client(getHTTPOptions());
SearchOptions searchOpts = new SearchOptions();
NCBOPage<NCBOClass> classes = client.search("melanoma", searchOpts);
assert (classes.getCollection().size() > 10);
}
@Test
public void testSearchIteration() {
System.out.println("searchIteration");
Client client = new Client(getHTTPOptions());
SearchOptions searchOpts = new SearchOptions();
NCBOPage<NCBOClass> result = client.search("amoxicillin", searchOpts);
List<NCBOClass> classes = new ArrayList<>();
while (result.hasNext()) {
classes.addAll(result.getCollection());
result = result.next();
}
assert (classes.size() >= 750);
}
@Test
public void testFollowLink() {
System.out.println("followLink");
String id = "http://data.bioontology.org/ontologies/SNOMEDCT";
Client client = new Client(getHTTPOptions());
NCBOOntology ont = client.getByID(id, NCBOOntology.class);
List<NCBOSubmission> submissions = ont.followLink("latest_submission", NCBOSubmission.class, opts);
assert (submissions.size() == 1);
assert (submissions.get(0) instanceof NCBOSubmission);
}
private HTTPOptions getHTTPOptions() {
if (opts == null) {
opts = new HTTPOptions(apikey);
}
return opts;
}
}
|
3e01a87439ad5e991a49fcc22aa7011a84842e58 | 26,860 | java | Java | connector-it/src/test/java/org/interledger/connector/it/ilpoverhttp/TwoConnectorIlpOverHttpPingTestIT.java | sappenin/java-ilp-connector | e00038b75fbae57bce668ddcb1baeae3e51aa09c | [
"Apache-2.0"
] | 14 | 2020-01-16T19:49:40.000Z | 2021-11-24T02:01:59.000Z | connector-it/src/test/java/org/interledger/connector/it/ilpoverhttp/TwoConnectorIlpOverHttpPingTestIT.java | sappenin/java-ilp-connector | e00038b75fbae57bce668ddcb1baeae3e51aa09c | [
"Apache-2.0"
] | 438 | 2018-07-13T05:35:10.000Z | 2020-01-14T17:15:18.000Z | connector-it/src/test/java/org/interledger/connector/it/ilpoverhttp/TwoConnectorIlpOverHttpPingTestIT.java | sappenin/java-ilp-connector | e00038b75fbae57bce668ddcb1baeae3e51aa09c | [
"Apache-2.0"
] | 6 | 2020-06-09T07:59:54.000Z | 2021-07-24T12:19:33.000Z | 45.067114 | 126 | 0.736337 | 703 | package org.interledger.connector.it.ilpoverhttp;
import static java.math.BigInteger.ONE;
import static java.math.BigInteger.TEN;
import static java.math.BigInteger.ZERO;
import static junit.framework.TestCase.fail;
import static org.assertj.core.api.Assertions.assertThat;
import static org.interledger.connector.accounts.sub.LocalDestinationAddressUtils.PING_ACCOUNT_ID;
import static org.interledger.connector.it.topologies.AbstractTopology.ALICE_ACCOUNT;
import static org.interledger.connector.it.topologies.AbstractTopology.BOB_ACCOUNT;
import static org.interledger.connector.it.topologies.AbstractTopology.PAUL_ACCOUNT;
import static org.interledger.connector.it.topologies.AbstractTopology.PAUL_AT_ALICE_ADDRESS;
import static org.interledger.connector.it.topologies.ilpoverhttp.TwoConnectorPeerIlpOverHttpTopology.ALICE;
import static org.interledger.connector.it.topologies.ilpoverhttp.TwoConnectorPeerIlpOverHttpTopology.ALICE_CONNECTOR_ADDRESS;
import static org.interledger.connector.it.topologies.ilpoverhttp.TwoConnectorPeerIlpOverHttpTopology.BOB;
import static org.interledger.connector.it.topologies.ilpoverhttp.TwoConnectorPeerIlpOverHttpTopology.BOB_CONNECTOR_ADDRESS;
import static org.interledger.link.PingLoopbackLink.PING_PROTOCOL_CONDITION;
import org.interledger.connector.ILPv4Connector;
import org.interledger.connector.it.AbstractIlpOverHttpIT;
import org.interledger.connector.it.ContainerHelper;
import org.interledger.connector.it.markers.IlpOverHttp;
import org.interledger.connector.it.markers.Performance;
import org.interledger.connector.it.topologies.ilpoverhttp.TwoConnectorPeerIlpOverHttpTopology;
import org.interledger.connector.it.topology.Topology;
import org.interledger.connector.ping.DefaultPingInitiator;
import org.interledger.connector.ping.PingInitiator;
import org.interledger.core.InterledgerAddress;
import org.interledger.core.InterledgerAddressPrefix;
import org.interledger.core.InterledgerCondition;
import org.interledger.core.InterledgerErrorCode;
import org.interledger.core.InterledgerPreparePacket;
import org.interledger.link.http.IlpOverHttpLink;
import org.interledger.link.http.IlpOverHttpLinkSettings;
import com.google.common.primitives.UnsignedLong;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runners.MethodSorters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import java.math.BigInteger;
import java.time.Instant;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* <p>Tests to verify that a single connector can route data and money to/from a single child peer. In this test,
* value is transferred both from Alice->Bob, and then in the opposite direction. Thus, both Alice and Bob sometimes
* play the role of sender and sometimes play the role of receiver.</p>
*/
// TODO: Once the PING protocol is specified via RFC, extract the PING tests into an abstract super-class. Every IT
// should exercise PING functionality as a baseline, but both BTP and ILP-over-HTTP duplicate the same PING tests.
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Category( {IlpOverHttp.class})
public class TwoConnectorIlpOverHttpPingTestIT extends AbstractIlpOverHttpIT {
private static final Logger LOGGER = LoggerFactory.getLogger(TwoConnectorIlpOverHttpPingTestIT.class);
private static final Network network = Network.newNetwork();
private static Topology topology = TwoConnectorPeerIlpOverHttpTopology.init();
private static GenericContainer redis = ContainerHelper.redis(network);
private static GenericContainer postgres = ContainerHelper.postgres(network);
private ILPv4Connector aliceConnector;
private ILPv4Connector bobConnector;
@BeforeClass
public static void startTopology() {
LOGGER.info("Starting test topology `{}`...", topology.toString());
redis.start();
postgres.start();
topology.start();
LOGGER.info("Test topology `{}` started!", topology.toString());
}
@AfterClass
public static void stopTopology() {
LOGGER.info("Stopping test topology `{}`...", topology.toString());
topology.stop();
postgres.stop();
redis.stop();
LOGGER.info("Test topology `{}` stopped!", topology.toString());
}
@Before
public void setUp() {
aliceConnector = this.getILPv4NodeFromGraph(getAliceConnectorAddress());
// Note Bob's Connector's address is purposefully a child of Alice due to IL-DCP
bobConnector = this.getILPv4NodeFromGraph(getBobConnectorAddress());
this.resetBalanceTracking();
}
@Override
protected InterledgerAddress getAliceConnectorAddress() {
return ALICE_CONNECTOR_ADDRESS;
}
@Override
protected InterledgerAddress getBobConnectorAddress() {
return BOB_CONNECTOR_ADDRESS;
}
@Test
public void testAliceNodeSettings() {
final ILPv4Connector connector = getILPv4NodeFromGraph(getAliceConnectorAddress());
assertThat(connector.getConnectorSettings().operatorAddress()).isEqualTo(getAliceConnectorAddress());
final IlpOverHttpLinkSettings ilpOverHttpLinkSettings = getLinkSettings(getAliceConnectorAddress(), BOB_ACCOUNT);
assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().jwtAuthSettings().get().tokenSubject())
.isEqualTo(ALICE);
assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().authType())
.isEqualTo(IlpOverHttpLinkSettings.AuthType.JWT_HS_256);
assertThat(ilpOverHttpLinkSettings.incomingLinkSettings().get().authType())
.isEqualTo(IlpOverHttpLinkSettings.AuthType.JWT_HS_256);
assertThat(connector.getStaticRoutesManager().getAllStaticRoutes().size()).isEqualTo(1);
}
@Test
public void testBobNodeSettings() {
final ILPv4Connector connector = getILPv4NodeFromGraph(getBobConnectorAddress());
assertThat(connector.getConnectorSettings().operatorAddress()).isEqualTo(getBobConnectorAddress());
final IlpOverHttpLinkSettings ilpOverHttpLinkSettings = getLinkSettings(getBobConnectorAddress(), ALICE_ACCOUNT);
assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().jwtAuthSettings().get().tokenSubject())
.isEqualTo(BOB);
assertThat(ilpOverHttpLinkSettings.outgoingLinkSettings().get().authType())
.isEqualTo(IlpOverHttpLinkSettings.AuthType.JWT_HS_256);
assertThat(ilpOverHttpLinkSettings.incomingLinkSettings().get().authType())
.isEqualTo(IlpOverHttpLinkSettings.AuthType.JWT_HS_256);
assertThat(connector.getStaticRoutesManager().getAllStaticRoutes().size()).isEqualTo(1);
}
/**
* Pinging a non-connector account (i.e., yourself) is not allowed because ping is only meant to be used at a
* Connector level. Thus, this should ping request should reject.
*/
@Test
public void testPaulPingsPaulChildAccount() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final IlpOverHttpLink ilpOverHttpLink = getIlpOverHttpLinkFromGraph(getAliceConnectorAddress(), PAUL_ACCOUNT);
final PingInitiator pingInitiator = new DefaultPingInitiator(ilpOverHttpLink, () -> Instant.now().plusSeconds(30));
// Note Bob's Connector's address is purposefully a child of Alice due to IL-DCP
final long start = System.currentTimeMillis();
pingInitiator.ping(PAUL_AT_ALICE_ADDRESS, UnsignedLong.ONE).handle(
fulfillPacket -> {
fail(String.format("Ping request fulfilled, but should have rejected: %s)", fulfillPacket));
latch.countDown();
}, rejectPacket -> {
assertThat(rejectPacket.getCode()).isEqualTo(InterledgerErrorCode.F02_UNREACHABLE);
assertThat(rejectPacket.getMessage()).isEqualTo("Destination address is unreachable");
assertThat(rejectPacket.getTriggeredBy().isPresent()).isTrue();
assertThat(rejectPacket.getTriggeredBy().get()).isEqualTo(getAliceConnectorAddress());
latch.countDown();
}
);
latch.await(5, TimeUnit.SECONDS);
final long end = System.currentTimeMillis();
LOGGER.info("Ping took {}ms", end - start);
}
/**
* Pinging a local connector account (i.e., Paul to his own Connector) is allowed.
*/
@Test
public void testPaulPingsAliceConnector() throws InterruptedException {
this.testPing(PAUL_ACCOUNT, getAliceConnectorAddress(), getAliceConnectorAddress(), UnsignedLong.ONE);
// test.alice.paul: Should be -1 because that account initiated and paid for the ping.
assertAccountBalance(aliceConnector, PAUL_ACCOUNT, ONE.negate());
// test.alice.bob: Should be 0 because this account is never engaged.
assertAccountBalance(aliceConnector, BOB_ACCOUNT, ZERO);
// test.alice.__ping_account__: Should be +1 because this account fulfills and is actually receiving money.
assertAccountBalance(aliceConnector, PING_ACCOUNT_ID, ONE);
// test.alice.__ping_account__: Should be 1 since this account received the ping request.
// NOTE: This test doesn't assert any other PING account balances because when Redis is running (e.g., in the IT)
// then both Connectors share the same Redis instance, and this test breaks (i.e., the ITs only work with the
// in-memory balance tracker)
assertAccountBalance(aliceConnector, PING_ACCOUNT_ID, ONE);
}
/**
* In this setup, the peering account that Alice uses to talk to Bob is used to ping Alice. Here, the outbound link
* will place a ping packet on the link, sending it directly to Bob, who will try to route it back to Alice. However,
* the next-hop routing logic will detect a routing loop, and reject the packet.
*/
@Test
public void testAlicePingsAliceUsingBobAccount() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final IlpOverHttpLink ilpOverHttpLink = getIlpOverHttpLinkFromGraph(getAliceConnectorAddress(), BOB_ACCOUNT);
final PingInitiator pingInitiator = new DefaultPingInitiator(ilpOverHttpLink, () -> Instant.now().plusSeconds(30));
final long start = System.currentTimeMillis();
pingInitiator.ping(getAliceConnectorAddress(), UnsignedLong.ONE).handle(
fulfillPacket -> {
fail(String.format("Ping request fulfilled, but should have rejected: %s)", fulfillPacket));
latch.countDown();
}, rejectPacket -> {
assertThat(rejectPacket.getCode()).isEqualTo(InterledgerErrorCode.F02_UNREACHABLE);
assertThat(rejectPacket.getMessage()).isEqualTo("Destination address is unreachable");
assertThat(rejectPacket.getTriggeredBy().isPresent()).isTrue();
assertThat(rejectPacket.getTriggeredBy().get()).isEqualTo(getBobConnectorAddress());
latch.countDown();
}
);
latch.await(5, TimeUnit.SECONDS);
final long end = System.currentTimeMillis();
LOGGER.info("Ping took {}ms", end - start);
}
/**
* Paul (a child account of Alice) pings Bob via Alice, which should succeed using 0 units.
*/
@Test
public void testPaulPingsBobConnectorWith0Units() throws InterruptedException {
this.testPing(PAUL_ACCOUNT, getAliceConnectorAddress(), getBobConnectorAddress(), UnsignedLong.ZERO);
// test.alice.paul: Should be 0 because the packet units are 0
assertAccountBalance(aliceConnector, PAUL_ACCOUNT, ZERO);
// test.alice.bob: Should be 0 because the packet units are 0
assertAccountBalance(aliceConnector, BOB_ACCOUNT, ZERO);
// test.alice.__ping_account__: Should be 0 because the packet units are 0
assertAccountBalance(aliceConnector, PING_ACCOUNT_ID, ZERO);
// test.bob.__ping_account__: Untouched
// NOTE: This test doesn't assert any other PING account balances because when Redis is running (e.g., in the IT)
// then both Connectors share the same Redis instance, and this test breaks (i.e., the ITs only work with the
// in-memory balance tracker)
assertAccountBalance(bobConnector, PING_ACCOUNT_ID, ZERO);
}
/**
* Paul (a child account of Alice) pings Bob via Alice, which should succeed using 1 units.
*/
@Test
public void testPaulPingsBobConnectorWith1Units() throws InterruptedException {
// After the Ping, the balances should look like this:
// [[PAUL]][1] <-> [-1][[ALICE]][1] <-> [-1][BOB][1] <-> [-1][[PING_ACT]]
this.testPing(PAUL_ACCOUNT, getAliceConnectorAddress(), getBobConnectorAddress(), UnsignedLong.ONE);
// test.alice.paul: SHOULD BE -1 because that account initiated and paid for the ping.
assertAccountBalance(aliceConnector, PAUL_ACCOUNT, ONE.negate());
// test.alice.bob: SHOULD BE 1 because this account will get fulfilled and increment by 1.
assertAccountBalance(aliceConnector, BOB_ACCOUNT, ONE);
// test.bob.alice: SHOULD BE -1 because it prepares on Bob.
assertAccountBalance(bobConnector, ALICE_ACCOUNT, ONE.negate());
// test.bob.__ping_account__: SHOULD BE +1 because it's receiving the ping funds.
// NOTE: This test doesn't assert any other PING account balances because when Redis is running (e.g., in the IT)
// then both Connectors share the same Redis instance, and this test breaks (i.e., the ITs only work with the
// in-memory balance tracker)
assertAccountBalance(bobConnector, PING_ACCOUNT_ID, ONE);
}
/**
* Paul (a child account of Alice) pings Bob via Alice, which should succeed using 10 units.
*/
@Test
public void testPaulPingsBobWith10Units() throws InterruptedException {
this.testPing(PAUL_ACCOUNT, getAliceConnectorAddress(), getBobConnectorAddress(), UnsignedLong.valueOf(10));
// test.alice.paul: Should be -10 because that account initiated and paid for the ping.
assertAccountBalance(aliceConnector, PAUL_ACCOUNT, TEN.negate());
// test.alice.bob: Should be 10 because this account will receive ten from Paul on this Connector.
assertAccountBalance(aliceConnector, BOB_ACCOUNT, TEN);
// test.bob.alice: Should be -10 because it pays from Alice Connector, but pays one to the ping account on Bob.
assertAccountBalance(bobConnector, ALICE_ACCOUNT, TEN.negate());
// test.bob.__ping_account__: Should be +10 because it's receiving the ping funds. Because this account is owned
// by the Connector, it's OK to extend the 1 unit of credit above to the incoming account.
// NOTE: This test doesn't assert any other PING account balances because when Redis is running (e.g., in the IT)
// then both Connectors share the same Redis instance, and this test breaks (i.e., the ITs only work with the
// in-memory balance tracker)
assertAccountBalance(bobConnector, PING_ACCOUNT_ID, TEN);
}
/**
* Random address should reject since it's not in the Bob's routing table.
*/
@Test
public void testPaulPingsRandom() throws InterruptedException {
final InterledgerAddress randomDestination =
InterledgerAddress.of(InterledgerAddressPrefix.TEST3.with(UUID.randomUUID().toString()).getValue());
final IlpOverHttpLink ilpOverHttpLink = getIlpOverHttpLinkFromGraph(getAliceConnectorAddress(), PAUL_ACCOUNT);
final PingInitiator pingInitiator = new DefaultPingInitiator(ilpOverHttpLink, () -> Instant.now().plusSeconds(30));
final CountDownLatch latch = new CountDownLatch(1);
final long start = System.currentTimeMillis();
pingInitiator.ping(randomDestination, UnsignedLong.ONE).handle(
fulfillPacket -> {
fail(String.format("Ping request fulfilled, but should have rejected: %s)", fulfillPacket));
latch.countDown();
}, rejectPacket -> {
assertThat(rejectPacket.getCode()).isEqualTo(InterledgerErrorCode.F02_UNREACHABLE);
assertThat(rejectPacket.getMessage()).isEqualTo("Destination address is unreachable");
assertThat(rejectPacket.getTriggeredBy().isPresent()).isTrue();
assertThat(rejectPacket.getTriggeredBy().get()).isEqualTo(getAliceConnectorAddress());
latch.countDown();
}
);
latch.await(5, TimeUnit.SECONDS);
final long end = System.currentTimeMillis();
LOGGER.info("Ping took {}ms", end - start);
}
/**
* Random address should reject since it's not in the Bob's routing table.
*/
@Test
public void testPaulPingsRandomAtBob() throws InterruptedException {
final InterledgerAddress randomDestination = getBobConnectorAddress().with(UUID.randomUUID().toString());
final IlpOverHttpLink ilpOverHttpLink = getIlpOverHttpLinkFromGraph(getAliceConnectorAddress(), PAUL_ACCOUNT);
final PingInitiator pingInitiator = new DefaultPingInitiator(ilpOverHttpLink, () -> Instant.now().plusSeconds(30));
final CountDownLatch latch = new CountDownLatch(1);
final long start = System.currentTimeMillis();
pingInitiator.ping(randomDestination, UnsignedLong.ONE).handle(
fulfillPacket -> {
fail(String.format("Ping request fulfilled, but should have rejected: %s)", fulfillPacket));
latch.countDown();
}, rejectPacket -> {
assertThat(rejectPacket.getCode()).isEqualTo(InterledgerErrorCode.F02_UNREACHABLE);
assertThat(rejectPacket.getMessage()).isEqualTo("Destination address is unreachable");
assertThat(rejectPacket.getTriggeredBy().isPresent()).isTrue();
assertThat(rejectPacket.getTriggeredBy().get()).isEqualTo(getBobConnectorAddress());
latch.countDown();
}
);
latch.await(5, TimeUnit.SECONDS);
final long end = System.currentTimeMillis();
LOGGER.info("Ping took {}ms", end - start);
}
/////////////////
// Expiry Filter
/////////////////
@Test
public void testPaulPingsBobWithExpiredPacket() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final long start = System.currentTimeMillis();
final IlpOverHttpLink ilpOverHttpLink = getIlpOverHttpLinkFromGraph(getAliceConnectorAddress(), PAUL_ACCOUNT);
final InterledgerPreparePacket pingPacket = InterledgerPreparePacket.builder()
.executionCondition(PING_PROTOCOL_CONDITION)
.expiresAt(Instant.now().minusSeconds(500))
.amount(UnsignedLong.ONE) // Ping with the smallest unit...
.destination(getBobConnectorAddress())
.build();
ilpOverHttpLink.sendPacket(pingPacket).handle(
fulfillPacket -> {
fail(String.format("Ping request fulfilled, but should have rejected: %s", fulfillPacket));
latch.countDown();
}, rejectPacket -> {
assertThat(rejectPacket.getCode()).isEqualTo(InterledgerErrorCode.R02_INSUFFICIENT_TIMEOUT);
latch.countDown();
}
);
latch.await(5, TimeUnit.SECONDS);
final long end = System.currentTimeMillis();
LOGGER.info("Ping took {}ms", end - start);
}
/////////////////
// Max Packet Amount Filter
/////////////////
@Test
public void testPaulPingsBobWithAmountTooHigh() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final long start = System.currentTimeMillis();
final IlpOverHttpLink ilpOverHttpLink = getIlpOverHttpLinkFromGraph(getAliceConnectorAddress(), PAUL_ACCOUNT);
final InterledgerPreparePacket pingPacket = InterledgerPreparePacket.builder()
.executionCondition(PING_PROTOCOL_CONDITION)
.expiresAt(Instant.now().plusSeconds(30))
.amount(UnsignedLong.valueOf(100000000000L)) // Ping with a unit that's too large...
.destination(getBobConnectorAddress())
.build();
ilpOverHttpLink.sendPacket(pingPacket).handle(
fulfillPacket -> {
fail(String.format("Ping request fulfilled, but should have rejected: %s", fulfillPacket));
latch.countDown();
}, rejectPacket -> {
assertThat(rejectPacket.getCode()).isEqualTo(InterledgerErrorCode.F08_AMOUNT_TOO_LARGE);
latch.countDown();
}
);
latch.await(5, TimeUnit.SECONDS);
final long end = System.currentTimeMillis();
LOGGER.info("Ping took {}ms", end - start);
}
/////////////////
// Allowed Destination Filter
/////////////////
@Test
public void testPaulPingsDisallowedAddress() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final long start = System.currentTimeMillis();
final IlpOverHttpLink ilpOverHttpLink = getIlpOverHttpLinkFromGraph(getAliceConnectorAddress(), PAUL_ACCOUNT);
final InterledgerPreparePacket pingPacket = InterledgerPreparePacket.builder()
.executionCondition(PING_PROTOCOL_CONDITION)
.expiresAt(Instant.now().plusSeconds(30))
.amount(UnsignedLong.valueOf(1L)) // Ping with a unit that's too large...
.destination(InterledgerAddress.of("self.foo"))
.build();
ilpOverHttpLink.sendPacket(pingPacket).handle(
fulfillPacket -> {
fail(String.format("Ping request fulfilled, but should have rejected: %s", fulfillPacket));
latch.countDown();
}, rejectPacket -> {
assertThat(rejectPacket.getCode()).isEqualTo(InterledgerErrorCode.F02_UNREACHABLE);
latch.countDown();
}
);
latch.await(5, TimeUnit.SECONDS);
final long end = System.currentTimeMillis();
LOGGER.info("Ping took {}ms", end - start);
}
/////////////////
// Invalid Condition
/////////////////
@Test
public void testPaulPingsBobWithInvalidCondition() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final long start = System.currentTimeMillis();
final IlpOverHttpLink ilpOverHttpLink = getIlpOverHttpLinkFromGraph(getAliceConnectorAddress(), PAUL_ACCOUNT);
final InterledgerPreparePacket pingPacket = InterledgerPreparePacket.builder()
.executionCondition(InterledgerCondition.of(new byte[32]))
.expiresAt(Instant.now().plusSeconds(30))
.amount(UnsignedLong.valueOf(1L)) // Ping with the smallest unit...
.destination(getBobConnectorAddress())
.build();
ilpOverHttpLink.sendPacket(pingPacket).handle(
fulfillPacket -> {
fail(String.format("Ping request fulfilled, but should have rejected: %s", fulfillPacket));
latch.countDown();
}, rejectPacket -> {
assertThat(rejectPacket.getCode()).isEqualTo(InterledgerErrorCode.F00_BAD_REQUEST);
latch.countDown();
}
);
latch.await(5, TimeUnit.SECONDS);
final long end = System.currentTimeMillis();
LOGGER.info("Ping took {}ms", end - start);
}
///////////////////////
// Average Fulfill Time
///////////////////////
/**
* Attempts to ping `numReps` packets and measures the time it takes, failing if the time takes longer than some upper
* bound.
*
* Note: this upper-bound may be adjusted as the Connector implementation has perf improvements or degradations.
*/
@Test
@Category(Performance.class)
@Ignore
public void zTestPingPerf() throws InterruptedException {
final IlpOverHttpLink paulToAliceLink = getIlpOverHttpLinkFromGraph(getAliceConnectorAddress(), PAUL_ACCOUNT);
final PingInitiator pingInitiator = new DefaultPingInitiator(paulToAliceLink, () -> Instant.now().plusSeconds(30));
final int TIMEOUT = 30;
final int numReps = 2000;
final int numThreads = 5;
final CountDownLatch latch = new CountDownLatch(numReps);
// Tracks total time spent in the Runnable so we can find an average.
AtomicInteger totalMillis = new AtomicInteger();
final Runnable runnable = () -> {
final long start = System.currentTimeMillis();
pingInitiator.ping(getBobConnectorAddress(), UnsignedLong.ONE).handle(
fulfillPacket -> {
assertThat(fulfillPacket.getFulfillment().validateCondition(PING_PROTOCOL_CONDITION)).isTrue();
latch.countDown();
}, rejectPacket -> {
fail(String.format("Ping request rejected, but should have fulfilled: %s", rejectPacket));
latch.countDown();
}
);
final long end = System.currentTimeMillis();
totalMillis.getAndAdd((int) (end - start));
};
final ExecutorService executor = Executors.newFixedThreadPool(numThreads);
final long start = System.currentTimeMillis();
for (int i = 0; i < numReps; i++) {
executor.submit(runnable);
}
latch.await(TIMEOUT, TimeUnit.SECONDS);
final long end = System.currentTimeMillis();
executor.shutdown();
executor.awaitTermination(TIMEOUT, TimeUnit.SECONDS);
double totalTime = (end - start);
double averageProcessingTime = ((double) (totalMillis.get()) / numReps);
double averageMsPerPing = totalTime / numReps;
LOGGER.info("[Pings Perf Test] Latch Count: {}", latch.getCount());
LOGGER.info("[Pings Perf Test] {} pings took {} ms", numReps, totalTime);
LOGGER.info("[Pings Perf Test] Average CPU (time/ping): {} ms", averageProcessingTime);
LOGGER.info("[Pings Perf Test] Average Ping (ms/ping): {} ms", averageMsPerPing);
assertThat(latch.getCount()).isEqualTo(0L);
assertThat(averageProcessingTime < 30)
.as("averageProcessingTime should have been less than 30, but was " + averageProcessingTime).isTrue();
assertThat(averageMsPerPing < 6).as("averageMsPerPing should have been less than 6, but was " + averageMsPerPing)
.isTrue();
// test.alice.paul: Should be -1 because that account initiated and paid for the ping.
assertAccountBalance(aliceConnector, PAUL_ACCOUNT, BigInteger.valueOf(numReps * -1));
// test.alice.bob: Should be 0 because this account will receive one from Paul, but then pay the Bob Connector.
assertAccountBalance(aliceConnector, BOB_ACCOUNT, BigInteger.valueOf(numReps));
// test.bob.alice: Should be 0 because it gets `numReps` from Alice Connector, but pays `numReps` to the ping
// account on Bob.
assertAccountBalance(bobConnector, ALICE_ACCOUNT, BigInteger.valueOf(numReps * -1));
// test.bob.__ping_account__: Should be `numReps` because it's receiving the ping funds. Because this account is
// owned by the Connector, it's OK to extend the 1 unit of credit above to the incoming account.
// NOTE: This test doesn't assert any other PING account balances because when Redis is running (e.g., in the IT)
// then both Connectors share the same Redis instance, and this test breaks (i.e., the ITs only work with the
// in-memory balance tracker)
assertAccountBalance(bobConnector, PING_ACCOUNT_ID, BigInteger.valueOf(numReps));
}
// TODO: Cross currency ping?
/////////////////
// Helper Methods
/////////////////
@Override
protected Logger getLogger() {
return LOGGER;
}
@Override
protected Topology getTopology() {
return topology;
}
}
|
3e01a995a01ce3e91c97cdf46b6e4d44396368f3 | 2,947 | java | Java | ontopia-navigator/src/main/java/net/ontopia/topicmaps/nav2/taglibs/tolog/ChooseTag.java | ontopia/ontopia | d1d51458dc3a18393545fc0dfafc1ec00506e282 | [
"Apache-2.0"
] | 41 | 2015-06-15T11:08:50.000Z | 2022-02-04T11:17:58.000Z | ontopia-navigator/src/main/java/net/ontopia/topicmaps/nav2/taglibs/tolog/ChooseTag.java | qsiebers/ontopia | fce3d8de1991bb9e355a40dc745db6e25ea6fd45 | [
"Apache-2.0"
] | 79 | 2015-06-17T10:39:21.000Z | 2022-01-21T23:09:49.000Z | ontopia-navigator/src/main/java/net/ontopia/topicmaps/nav2/taglibs/tolog/ChooseTag.java | qsiebers/ontopia | fce3d8de1991bb9e355a40dc745db6e25ea6fd45 | [
"Apache-2.0"
] | 18 | 2015-06-25T11:34:05.000Z | 2022-03-28T04:50:12.000Z | 27.801887 | 87 | 0.659993 | 704 | /*
* #!
* Ontopia Navigator
* #-
* Copyright (C) 2001 - 2013 The Ontopia Project
* #-
* 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 net.ontopia.topicmaps.nav2.taglibs.tolog;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import net.ontopia.topicmaps.nav2.taglibs.logic.ContextTag;
import net.ontopia.topicmaps.nav2.utils.FrameworkUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* INTERNAL: Tolog Tag for evaluating a sequence of child WhenTags.
*/
public class ChooseTag extends BodyTagSupport {
// initialization of logging facility
private static final Logger log = LoggerFactory.getLogger(ChooseTag.class.getName());
// members
private boolean foundMatchingWhen;
private boolean foundWhen;
/**
* Process the start tag for this instance.
*/
@Override
public int doStartTag() throws JspTagException {
ContextTag contextTag = FrameworkUtils.getContextTag(pageContext);
if (contextTag == null)
throw new JspTagException("<tolog:choose> must be nested directly or"
+ " indirectly within a <tolog:context> tag, but no"
+ " <tolog:context> tag was found.");
contextTag.getContextManager().pushScope();
this.foundMatchingWhen = false;
return EVAL_BODY_INCLUDE;
}
/**
* Process the end tag.
*/
@Override
public int doEndTag() throws JspException {
// establish old lexical scope, back to outside of the loop
FrameworkUtils.getContextTag(pageContext).getContextManager().popScope();
if (!foundWhen())
throw new JspTagException("<tolog:choose> : must have one or more"
+ " <tolog:when> tags nested within it, but none were found.\n");
return EVAL_PAGE;
}
/**
* Resets the state of the Tag.
*/
@Override
public void release() {
foundMatchingWhen = false;
}
// -----------------------------------------------------------------
// Set methods for tag attributes
// -----------------------------------------------------------------
public boolean foundMatchingWhen() {
return foundMatchingWhen;
}
public void setFoundMatchingWhen() {
this.foundMatchingWhen = true;
}
public boolean foundWhen() {
return foundWhen;
}
public void setFoundWhen() {
this.foundWhen = true;
}
}
|
3e01a9c00f756b057dbf82d9631eb88d1c0badb7 | 1,254 | java | Java | src/main/java/eiteam/esteemedinnovation/commons/capabilities/player/PlayerDataSerializer.java | Jorch72/Flaxbeard-Steam-Power | 1473daf22eebca0214dacd1911120398bdfbc12a | [
"CC0-1.0",
"MIT"
] | 33 | 2016-10-17T03:56:39.000Z | 2022-01-04T18:27:55.000Z | src/main/java/eiteam/esteemedinnovation/commons/capabilities/player/PlayerDataSerializer.java | Jorch72/Flaxbeard-Steam-Power | 1473daf22eebca0214dacd1911120398bdfbc12a | [
"CC0-1.0",
"MIT"
] | 226 | 2015-04-05T19:49:11.000Z | 2016-08-11T17:08:53.000Z | src/main/java/eiteam/esteemedinnovation/commons/capabilities/player/PlayerDataSerializer.java | Jorch72/Flaxbeard-Steam-Power | 1473daf22eebca0214dacd1911120398bdfbc12a | [
"CC0-1.0",
"MIT"
] | 25 | 2017-02-03T14:21:26.000Z | 2022-02-06T02:24:53.000Z | 39.1875 | 133 | 0.784689 | 705 | package eiteam.esteemedinnovation.commons.capabilities.player;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import eiteam.esteemedinnovation.commons.EsteemedInnovation;
public class PlayerDataSerializer implements ICapabilitySerializable<NBTTagCompound> {
PlayerData instance = EsteemedInnovation.PLAYER_DATA.getDefaultInstance();
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
return capability == EsteemedInnovation.PLAYER_DATA;
}
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
return hasCapability(capability, facing) ? EsteemedInnovation.PLAYER_DATA.cast(instance) : null;
}
@Override
public NBTTagCompound serializeNBT() {
return (NBTTagCompound) EsteemedInnovation.PLAYER_DATA.getStorage().writeNBT(EsteemedInnovation.PLAYER_DATA, instance, null);
}
@Override
public void deserializeNBT(NBTTagCompound nbt) {
EsteemedInnovation.PLAYER_DATA.getStorage().readNBT(EsteemedInnovation.PLAYER_DATA, instance, null, nbt);
}
}
|
3e01aa8d96973021c36a72de1e9314f0d62b108e | 1,578 | java | Java | samples/src/main/java/tk/zielony/carbonsamples/GuidelinesActivity.java | Qenawi/A_Carbon | 7aa64d303cf664c4e5829ee52a8561e490086851 | [
"Apache-2.0"
] | null | null | null | samples/src/main/java/tk/zielony/carbonsamples/GuidelinesActivity.java | Qenawi/A_Carbon | 7aa64d303cf664c4e5829ee52a8561e490086851 | [
"Apache-2.0"
] | null | null | null | samples/src/main/java/tk/zielony/carbonsamples/GuidelinesActivity.java | Qenawi/A_Carbon | 7aa64d303cf664c4e5829ee52a8561e490086851 | [
"Apache-2.0"
] | null | null | null | 43.833333 | 117 | 0.759189 | 706 | package tk.zielony.carbonsamples;
import android.os.Bundle;
import java.io.Serializable;
import carbon.component.PaddingItem;
import tk.zielony.carbonsamples.guidelines.BasilActivity;
import tk.zielony.carbonsamples.guidelines.ButtonsUsageActivity;
import tk.zielony.carbonsamples.guidelines.CraneActivity;
import tk.zielony.carbonsamples.guidelines.MenusBehaviorActivity;
import tk.zielony.carbonsamples.guidelines.ShrineActivity;
public class GuidelinesActivity extends SampleListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Samples.initToolbar(this, getString(R.string.guidelinesActivity_title));
setItems(new Serializable[]{
new PaddingItem(getResources().getDimensionPixelSize(R.dimen.carbon_paddingHalf)),
"Sample screens taken from Material Design guidelines",
new SampleActivityItem(ButtonsUsageActivity.class, getString(R.string.buttonsUsageActivity_title)),
new SampleActivityItem(MenusBehaviorActivity.class, getString(R.string.menusBehaviorActivity_title)),
new SampleActivityItem(ShrineActivity.class, getString(R.string.shrineActivity_title), true),
new SampleActivityItem(CraneActivity.class, getString(R.string.craneActivity_title)),
new SampleActivityItem(BasilActivity.class, getString(R.string.basilActivity_title), true),
new PaddingItem(getResources().getDimensionPixelSize(R.dimen.carbon_paddingHalf))
});
}
}
|
3e01ab07120b41c2f19dcc20618e8e3bed9d0882 | 1,255 | java | Java | Sudoku/src/model/Parser.java | Henney/sudokusolver | 103c7c5452917cefd9df5aee822777a0107c24ca | [
"MIT"
] | 4 | 2016-06-27T15:36:19.000Z | 2021-02-27T00:07:51.000Z | Sudoku/src/model/Parser.java | Henney/sudokusolver | 103c7c5452917cefd9df5aee822777a0107c24ca | [
"MIT"
] | null | null | null | Sudoku/src/model/Parser.java | Henney/sudokusolver | 103c7c5452917cefd9df5aee822777a0107c24ca | [
"MIT"
] | 1 | 2016-06-27T15:30:47.000Z | 2016-06-27T15:30:47.000Z | 22.410714 | 84 | 0.639044 | 707 | package model;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import model.util.Pair;
public class Parser {
public static final String SEPARATOR = ";";
public static final String EMPTY = ".";
public static Pair<int[], Integer> parseGrid(Reader input) throws IOException {
BufferedReader in = new BufferedReader(input);
int k;
try {
k = Integer.parseInt(in.readLine());
} catch (NumberFormatException e) {
throw new IllegalArgumentException("First line in file should be the number k.");
}
int n = k * k;
int[] grid = new int[n * n];
int currentField = 0;
for (int i = 0; i < n; i++) {
String[] fields = in.readLine().split(SEPARATOR);
if (fields.length != n) {
throw new IllegalArgumentException("Not enough columns in row: " + (i + 1));
}
for (int j = 0; j < fields.length; j++) {
if (fields[j].equals(EMPTY)) {
grid[currentField] = 0;
} else
try {
int number = Integer.parseInt(fields[j]);
grid[currentField] = number;
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Illegal character in grid: " + fields[j]);
}
currentField++;
}
}
return new Pair<int[], Integer>(grid, k);
}
}
|
3e01ab182be427bd6c6725b30f33769accb64ae9 | 1,800 | java | Java | common/rya.api/src/main/java/org/apache/rya/api/InvalidValueTypeMarkerRuntimeException.java | iruka2019/rya | 9ed219e7376880794b0566cd5ceff0e23ade6f4b | [
"Apache-2.0"
] | 80 | 2015-11-11T22:28:17.000Z | 2019-10-03T09:25:10.000Z | common/rya.api/src/main/java/org/apache/rya/api/InvalidValueTypeMarkerRuntimeException.java | iruka2019/rya | 9ed219e7376880794b0566cd5ceff0e23ade6f4b | [
"Apache-2.0"
] | 262 | 2015-12-02T17:20:38.000Z | 2019-06-25T13:00:01.000Z | common/rya.api/src/main/java/org/apache/rya/api/InvalidValueTypeMarkerRuntimeException.java | Varulv1997/rya | baf3fe2f2357db7fc86e38df5f4b994b44bd4307 | [
"Apache-2.0"
] | 87 | 2015-11-10T14:12:32.000Z | 2019-09-13T08:44:31.000Z | 32.142857 | 103 | 0.731111 | 708 | package org.apache.rya.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Class InvalidValueTypeMarkerRuntimeException
* Date: Jan 7, 2011
* Time: 12:58:27 PM
*/
public class InvalidValueTypeMarkerRuntimeException extends RuntimeException {
private int valueTypeMarker = -1;
public InvalidValueTypeMarkerRuntimeException(int valueTypeMarker) {
super();
this.valueTypeMarker = valueTypeMarker;
}
public InvalidValueTypeMarkerRuntimeException(int valueTypeMarker, String s) {
super(s);
this.valueTypeMarker = valueTypeMarker;
}
public InvalidValueTypeMarkerRuntimeException(int valueTypeMarker, String s, Throwable throwable) {
super(s, throwable);
this.valueTypeMarker = valueTypeMarker;
}
public InvalidValueTypeMarkerRuntimeException(int valueTypeMarker, Throwable throwable) {
super(throwable);
this.valueTypeMarker = valueTypeMarker;
}
public int getValueTypeMarker() {
return valueTypeMarker;
}
}
|
3e01ac95e07c6ff029ddd1ab8af474ff420d3576 | 361 | java | Java | analysis/reverse-engineering/decompile-fitts-20191031-2200/sources/com/google/android/gms/internal/measurement/zzju.java | skkuse-adv/2019Fall_team2 | 3ea84c6be39855f54634a7f9b1093e80893886eb | [
"Apache-2.0"
] | 4 | 2019-10-07T05:17:21.000Z | 2020-11-02T08:29:13.000Z | analysis/reverse-engineering/decompile-fitts-with-gradle-20191031-2200/src/main/java/com/google/android/gms/internal/measurement/zzju.java | skkuse-adv/2019Fall_team2 | 3ea84c6be39855f54634a7f9b1093e80893886eb | [
"Apache-2.0"
] | 38 | 2019-10-07T02:40:35.000Z | 2019-12-12T09:15:24.000Z | analysis/reverse-engineering/decompile-fitts-with-gradle-20191031-2200/src/main/java/com/google/android/gms/internal/measurement/zzju.java | skkuse-adv/2019Fall_team2 | 3ea84c6be39855f54634a7f9b1093e80893886eb | [
"Apache-2.0"
] | 5 | 2019-10-07T02:41:15.000Z | 2020-10-30T01:36:08.000Z | 36.1 | 158 | 0.709141 | 709 | package com.google.android.gms.internal.measurement;
public final class zzju implements zzjr {
private static final zzcm<Boolean> zzarj = new zzct(zzcn.zzdh("com.google.android.gms.measurement")).zzb("measurement.upload.disable_is_uploader", true);
public final boolean zzyx() {
return ((Boolean) zzarj.get()).booleanValue();
}
}
|
3e01aebcd2003bba078efe9b1d5f98e8cd7a478f | 6,418 | java | Java | src/com/facebook/buck/cli/AuditFlavorsCommand.java | stefb965/buck | 37eee6cd1a13292b45e2e682b32afae1efb9526b | [
"Apache-2.0"
] | null | null | null | src/com/facebook/buck/cli/AuditFlavorsCommand.java | stefb965/buck | 37eee6cd1a13292b45e2e682b32afae1efb9526b | [
"Apache-2.0"
] | null | null | null | src/com/facebook/buck/cli/AuditFlavorsCommand.java | stefb965/buck | 37eee6cd1a13292b45e2e682b32afae1efb9526b | [
"Apache-2.0"
] | null | null | null | 34.691892 | 98 | 0.682144 | 710 | /*
* Copyright 2013-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package com.facebook.buck.cli;
import com.facebook.buck.event.ConsoleEvent;
import com.facebook.buck.json.BuildFileParseException;
import com.facebook.buck.model.BuildTarget;
import com.facebook.buck.model.BuildTargetException;
import com.facebook.buck.model.Flavor;
import com.facebook.buck.model.FlavorDomain;
import com.facebook.buck.model.Flavored;
import com.facebook.buck.parser.BuildTargetParser;
import com.facebook.buck.parser.BuildTargetPatternParser;
import com.facebook.buck.rules.Description;
import com.facebook.buck.rules.TargetNode;
import com.facebook.buck.util.DirtyPrintStreamDecorator;
import com.facebook.buck.util.MoreCollectors;
import com.facebook.buck.util.MoreExceptions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.stream.Collectors;
/**
* List flavor domains for build targets.
*/
public class AuditFlavorsCommand extends AbstractCommand {
@Option(name = "--json",
usage = "Output in JSON format")
private boolean generateJsonOutput;
public boolean shouldGenerateJsonOutput() {
return generateJsonOutput;
}
@Override
public String getShortDescription() {
return "List flavor domains for build targets.";
}
@Argument
private List<String> arguments = Lists.newArrayList();
public List<String> getArguments() {
return arguments;
}
private List<String> getArgumentsFormattedAsBuildTargets(BuckConfig buckConfig) {
return getCommandLineBuildTargetNormalizer(buckConfig).normalizeAll(getArguments());
}
@Override
public int runWithoutHelp(CommandRunnerParams params) throws IOException, InterruptedException {
ImmutableSet<BuildTarget> targets =
getArgumentsFormattedAsBuildTargets(params.getBuckConfig()).stream()
.map(input -> BuildTargetParser.INSTANCE.parse(
input,
BuildTargetPatternParser.fullyQualified(),
params.getCell().getCellPathResolver()))
.collect(MoreCollectors.toImmutableSet());
if (targets.isEmpty()) {
params.getBuckEventBus().post(ConsoleEvent.severe(
"Please specify at least one build target."));
return 1;
}
ImmutableList.Builder<TargetNode<?, ?>> builder = ImmutableList.builder();
try (CommandThreadManager pool = new CommandThreadManager(
"Audit",
getConcurrencyLimit(params.getBuckConfig()))) {
for (BuildTarget target : targets) {
TargetNode<?, ?> targetNode = params.getParser().getTargetNode(
params.getBuckEventBus(),
params.getCell(),
getEnableParserProfiling(),
pool.getExecutor(),
target
);
builder.add(targetNode);
}
} catch (BuildFileParseException | BuildTargetException e) {
params.getBuckEventBus().post(ConsoleEvent.severe(
MoreExceptions.getHumanReadableOrLocalizedMessage(e)));
return 1;
}
ImmutableList<TargetNode<?, ?>> targetNodes = builder.build();
if (shouldGenerateJsonOutput()) {
printJsonFlavors(targetNodes, params);
} else {
printFlavors(targetNodes, params);
}
return 0;
}
@Override
public boolean isReadOnly() {
return true;
}
private void printFlavors(
ImmutableList<TargetNode<?, ?>> targetNodes,
CommandRunnerParams params) {
DirtyPrintStreamDecorator stdout = params.getConsole().getStdOut();
for (TargetNode<?, ?> node : targetNodes) {
Description<?> description = node.getDescription();
stdout.println(node.getBuildTarget().getFullyQualifiedName());
if (description instanceof Flavored) {
Optional<ImmutableSet<FlavorDomain<?>>> flavorDomains =
((Flavored) description).flavorDomains();
if (flavorDomains.isPresent()) {
for (FlavorDomain<?> domain : flavorDomains.get()) {
stdout.printf(" %s\n", domain.getName());
for (Flavor flavor : domain.getFlavors()) {
stdout.printf(" %s\n", flavor.getName());
}
}
} else {
stdout.println(" unknown");
}
} else {
stdout.println(" no flavors");
}
}
}
private void printJsonFlavors(
ImmutableList<TargetNode<?, ?>> targetNodes,
CommandRunnerParams params) throws IOException {
DirtyPrintStreamDecorator stdout = params.getConsole().getStdOut();
SortedMap<String, SortedMap<String, List<String>>> targetsJson = new TreeMap<>();
for (TargetNode<?, ?> node : targetNodes) {
Description<?> description = node.getDescription();
SortedMap<String, List<String>> flavorDomainsJson = new TreeMap<>();
if (description instanceof Flavored) {
Optional<ImmutableSet<FlavorDomain<?>>> flavorDomains =
((Flavored) description).flavorDomains();
if (flavorDomains.isPresent()) {
for (FlavorDomain<?> domain : flavorDomains.get()) {
List<String> flavorsJson =
domain.getFlavors().stream()
.map(Flavor::getName)
.collect(Collectors.toList());
flavorDomainsJson.put(domain.getName(), flavorsJson);
}
} else {
flavorDomainsJson.put("unknown", new ArrayList<>());
}
}
String targetName = node.getBuildTarget().getFullyQualifiedName();
targetsJson.put(targetName, flavorDomainsJson);
}
params.getObjectMapper().writeValue(stdout, targetsJson);
}
}
|
3e01af6cc21d1b7d1f2b5d0714787d62ce9f2ec8 | 6,585 | java | Java | aliyun-java-sdk-sofa/src/main/java/com/aliyuncs/sofa/transform/v20190815/UpdateLinkeantcodeAntcodeSnippetsidResponseUnmarshaller.java | cctvzd7/aliyun-openapi-java-sdk | b8e4dce2a61ca968615c9b910bedebaea71781ae | [
"Apache-2.0"
] | 1 | 2020-11-03T01:40:47.000Z | 2020-11-03T01:40:47.000Z | aliyun-java-sdk-sofa/src/main/java/com/aliyuncs/sofa/transform/v20190815/UpdateLinkeantcodeAntcodeSnippetsidResponseUnmarshaller.java | cctvzd7/aliyun-openapi-java-sdk | b8e4dce2a61ca968615c9b910bedebaea71781ae | [
"Apache-2.0"
] | null | null | null | aliyun-java-sdk-sofa/src/main/java/com/aliyuncs/sofa/transform/v20190815/UpdateLinkeantcodeAntcodeSnippetsidResponseUnmarshaller.java | cctvzd7/aliyun-openapi-java-sdk | b8e4dce2a61ca968615c9b910bedebaea71781ae | [
"Apache-2.0"
] | null | null | null | 79.337349 | 186 | 0.856188 | 711 | /*
* 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.aliyuncs.sofa.transform.v20190815;
import java.util.ArrayList;
import java.util.List;
import com.aliyuncs.sofa.model.v20190815.UpdateLinkeantcodeAntcodeSnippetsidResponse;
import com.aliyuncs.sofa.model.v20190815.UpdateLinkeantcodeAntcodeSnippetsidResponse.Author;
import com.aliyuncs.transform.UnmarshallerContext;
public class UpdateLinkeantcodeAntcodeSnippetsidResponseUnmarshaller {
public static UpdateLinkeantcodeAntcodeSnippetsidResponse unmarshall(UpdateLinkeantcodeAntcodeSnippetsidResponse updateLinkeantcodeAntcodeSnippetsidResponse, UnmarshallerContext _ctx) {
updateLinkeantcodeAntcodeSnippetsidResponse.setRequestId(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.RequestId"));
updateLinkeantcodeAntcodeSnippetsidResponse.setResultCode(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.ResultCode"));
updateLinkeantcodeAntcodeSnippetsidResponse.setResultMessage(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.ResultMessage"));
updateLinkeantcodeAntcodeSnippetsidResponse.setContent(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Content"));
updateLinkeantcodeAntcodeSnippetsidResponse.setCreatedAt(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.CreatedAt"));
updateLinkeantcodeAntcodeSnippetsidResponse.setDescription(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Description"));
updateLinkeantcodeAntcodeSnippetsidResponse.setExpiresAt(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.ExpiresAt"));
updateLinkeantcodeAntcodeSnippetsidResponse.setFileName(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.FileName"));
updateLinkeantcodeAntcodeSnippetsidResponse.setId(_ctx.longValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Id"));
updateLinkeantcodeAntcodeSnippetsidResponse.setLabels(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Labels"));
updateLinkeantcodeAntcodeSnippetsidResponse.setLanguage(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Language"));
updateLinkeantcodeAntcodeSnippetsidResponse.setProjectId(_ctx.longValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.ProjectId"));
updateLinkeantcodeAntcodeSnippetsidResponse.setResponseStatusCode(_ctx.longValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.ResponseStatusCode"));
updateLinkeantcodeAntcodeSnippetsidResponse.setTitle(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Title"));
updateLinkeantcodeAntcodeSnippetsidResponse.setType(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Type"));
updateLinkeantcodeAntcodeSnippetsidResponse.setUpdatedAt(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.UpdatedAt"));
updateLinkeantcodeAntcodeSnippetsidResponse.setVisibilityLevel(_ctx.longValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.VisibilityLevel"));
Author author = new Author();
author.setAccessLevel(_ctx.longValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.AccessLevel"));
author.setAvatarUrl(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.AvatarUrl"));
author.setBio(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.Bio"));
author.setCanCreateGroup(_ctx.booleanValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.CanCreateGroup"));
author.setCanCreateProject(_ctx.booleanValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.CanCreateProject"));
author.setColorSchemeId(_ctx.longValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.ColorSchemeId"));
author.setCreatedAt(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.CreatedAt"));
author.setCurrentSignInAt(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.CurrentSignInAt"));
author.setDepartment(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.Department"));
author.setEmail(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.Email"));
author.setExpiresAt(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.ExpiresAt"));
author.setExternUid(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.ExternUid"));
author.setId(_ctx.longValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.Id"));
author.setIsAdmin(_ctx.booleanValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.IsAdmin"));
author.setName(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.Name"));
author.setPrivateToken(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.PrivateToken"));
author.setProjectsLimit(_ctx.longValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.ProjectsLimit"));
author.setRegistered(_ctx.booleanValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.Registered"));
author.setRole(_ctx.longValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.Role"));
author.setState(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.State"));
author.setThemeId(_ctx.longValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.ThemeId"));
author.setUpdatedAt(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.UpdatedAt"));
author.setUsername(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.Username"));
author.setWebsiteUrl(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.WebsiteUrl"));
author.setWebUrl(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.WebUrl"));
List<String> identities = new ArrayList<String>();
for (int i = 0; i < _ctx.lengthValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.Identities.Length"); i++) {
identities.add(_ctx.stringValue("UpdateLinkeantcodeAntcodeSnippetsidResponse.Author.Identities["+ i +"]"));
}
author.setIdentities(identities);
updateLinkeantcodeAntcodeSnippetsidResponse.setAuthor(author);
return updateLinkeantcodeAntcodeSnippetsidResponse;
}
} |
3e01af8ee1e25334cbecf840bab9b7929ef585ed | 682 | java | Java | allsrc/com/ushaqi/zhuishushenqi/reader/cZ.java | clilystudio/NetBook | a8ca6cb91e9259ed7dec70b830829d622525b4b7 | [
"Unlicense"
] | 1 | 2018-02-04T12:23:55.000Z | 2018-02-04T12:23:55.000Z | allsrc/com/ushaqi/zhuishushenqi/reader/cZ.java | clilystudio/NetBook | a8ca6cb91e9259ed7dec70b830829d622525b4b7 | [
"Unlicense"
] | null | null | null | allsrc/com/ushaqi/zhuishushenqi/reader/cZ.java | clilystudio/NetBook | a8ca6cb91e9259ed7dec70b830829d622525b4b7 | [
"Unlicense"
] | null | null | null | 25.259259 | 83 | 0.719941 | 712 | package com.ushaqi.zhuishushenqi.reader;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
final class cZ
implements View.OnClickListener
{
cZ(SettingWidget paramSettingWidget)
{
}
public final void onClick(View paramView)
{
SettingWidget.d(this.a).setSelected(false);
SettingWidget.e(this.a).setSelected(false);
SettingWidget.f(this.a).setSelected(true);
SettingWidget.b(this.a).a(3);
SettingWidget.g(this.a).a();
}
}
/* Location: E:\Progs\Dev\Android\Decompile\apktool\zssq\zssq-dex2jar.jar
* Qualified Name: com.ushaqi.zhuishushenqi.reader.cZ
* JD-Core Version: 0.6.0
*/ |
3e01b0d2a16f124928bea39ff8f3f0efed98a2fe | 4,566 | java | Java | generated/io/infinite/blackbox/generated/XMLMethodNode.java | INFINITE-STANDARDIZATION/INFINITE-LOGGING-PROTOTYPE-GROOVY | 077e1ba9211efc7151e6ba06e95e5336d067ad62 | [
"Apache-2.0"
] | null | null | null | generated/io/infinite/blackbox/generated/XMLMethodNode.java | INFINITE-STANDARDIZATION/INFINITE-LOGGING-PROTOTYPE-GROOVY | 077e1ba9211efc7151e6ba06e95e5336d067ad62 | [
"Apache-2.0"
] | null | null | null | generated/io/infinite/blackbox/generated/XMLMethodNode.java | INFINITE-STANDARDIZATION/INFINITE-LOGGING-PROTOTYPE-GROOVY | 077e1ba9211efc7151e6ba06e95e5336d067ad62 | [
"Apache-2.0"
] | null | null | null | 25.50838 | 129 | 0.593517 | 713 | //
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2018.10.24 at 05:38:02 PM GST
//
package io.infinite.blackbox.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for MethodNode complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="MethodNode">
* <complexContent>
* <extension base="{https://i-t.io/blackbox/groovy/2_x_x/BlackBox.xsd}ASTNode">
* <sequence>
* <element name="argumentList" type="{https://i-t.io/blackbox/groovy/2_x_x/BlackBox.xsd}ArgumentList" minOccurs="0"/>
* <element name="exception" type="{https://i-t.io/blackbox/groovy/2_x_x/BlackBox.xsd}Exception" minOccurs="0"/>
* <element name="methodResult" type="{https://i-t.io/blackbox/groovy/2_x_x/BlackBox.xsd}Object" minOccurs="0"/>
* </sequence>
* <attribute name="methodName" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
* <attribute name="className" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
* </extension>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MethodNode", propOrder = {
"argumentList",
"exception",
"methodResult"
})
public class XMLMethodNode
extends XMLASTNode
{
protected XMLArgumentList argumentList;
protected XMLException exception;
protected XMLObject methodResult;
@XmlAttribute(name = "methodName", required = true)
protected String methodName;
@XmlAttribute(name = "className", required = true)
protected String className;
/**
* Gets the value of the argumentList property.
*
* @return
* possible object is
* {@link XMLArgumentList }
*
*/
public XMLArgumentList getArgumentList() {
return argumentList;
}
/**
* Sets the value of the argumentList property.
*
* @param value
* allowed object is
* {@link XMLArgumentList }
*
*/
public void setArgumentList(XMLArgumentList value) {
this.argumentList = value;
}
/**
* Gets the value of the exception property.
*
* @return
* possible object is
* {@link XMLException }
*
*/
public XMLException getException() {
return exception;
}
/**
* Sets the value of the exception property.
*
* @param value
* allowed object is
* {@link XMLException }
*
*/
public void setException(XMLException value) {
this.exception = value;
}
/**
* Gets the value of the methodResult property.
*
* @return
* possible object is
* {@link XMLObject }
*
*/
public XMLObject getMethodResult() {
return methodResult;
}
/**
* Sets the value of the methodResult property.
*
* @param value
* allowed object is
* {@link XMLObject }
*
*/
public void setMethodResult(XMLObject value) {
this.methodResult = value;
}
/**
* Gets the value of the methodName property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getMethodName() {
return methodName;
}
/**
* Sets the value of the methodName property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setMethodName(String value) {
this.methodName = value;
}
/**
* Gets the value of the className property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getClassName() {
return className;
}
/**
* Sets the value of the className property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setClassName(String value) {
this.className = value;
}
}
|
3e01b10c6e6932802cd98d4a40fefaeed2d9c0f0 | 13,115 | java | Java | sjk-core/src/main/java/org/gridkit/jvmtool/cmd/StackSampleAnalyzerCmd.java | sskorol/jvm-tools | ea0bfd1831360d96ce0f3a5275528d7d89896911 | [
"Apache-2.0"
] | 1 | 2022-01-24T19:41:47.000Z | 2022-01-24T19:41:47.000Z | sjk-core/src/main/java/org/gridkit/jvmtool/cmd/StackSampleAnalyzerCmd.java | sskorol/jvm-tools | ea0bfd1831360d96ce0f3a5275528d7d89896911 | [
"Apache-2.0"
] | null | null | null | sjk-core/src/main/java/org/gridkit/jvmtool/cmd/StackSampleAnalyzerCmd.java | sskorol/jvm-tools | ea0bfd1831360d96ce0f3a5275528d7d89896911 | [
"Apache-2.0"
] | null | null | null | 33.714653 | 142 | 0.473046 | 714 | /**
* Copyright 2014 Alexey Ragozin
*
* 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.gridkit.jvmtool.cmd;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.gridkit.jvmtool.Cascade;
import org.gridkit.jvmtool.SJK;
import org.gridkit.jvmtool.SJK.CmdRef;
import org.gridkit.jvmtool.StackHisto;
import org.gridkit.jvmtool.StackTraceClassifier;
import org.gridkit.jvmtool.StackTraceClassifier.Config;
import org.gridkit.jvmtool.stacktrace.StackTraceCodec;
import org.gridkit.jvmtool.stacktrace.StackTraceReader;
import org.gridkit.util.formating.Formats;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.beust.jcommander.ParametersDelegate;
public class StackSampleAnalyzerCmd implements CmdRef {
@Override
public String getCommandName() {
return "ssa";
}
@Override
public Runnable newCommand(SJK host) {
return new SSA(host);
}
@Parameters(commandDescription = "[Stack Sample Analyzer] Analyzing stack trace dumps")
public static class SSA implements Runnable {
@ParametersDelegate
private SJK host;
@Parameter(names={"-f", "--file"}, required = true, variableArity=true, description="Path to stack dump file")
private List<String> files;
@Parameter(names={"-c", "--classifier"}, required = false, description="Path to file with stack trace classification definition")
private String classifier = null;
@Parameter(names = { "-b", "--buckets" }, required = false, description = "Restrict analysis to specific class")
private String bucket = null;
@Parameter(names={"-sf", "--simple-filter"}, required = false, description="Process only traces containing this string")
private String simpleFilter = null;
private List<SsaCmd> allCommands = new ArrayList<SsaCmd>();
@ParametersDelegate
private SsaCmd print = new PrintCmd();
@ParametersDelegate
private SsaCmd histo = new HistoCmd();
@ParametersDelegate
private SsaCmd csummary = new ClassSummaryCmd();
StackTraceClassifier buckets;
public SSA(SJK host) {
this.host = host;
}
@Override
public void run() {
try {
List<Runnable> action = new ArrayList<Runnable>();
for(SsaCmd cmd: allCommands) {
if (cmd.isSelected()) {
action.add(cmd);
}
}
if (action.isEmpty() || action.size() > 1) {
SJK.failAndPrintUsage("You should choose one of " + allCommands);
}
if (classifier != null) {
Config cfg = new Config();
Cascade.parse(new FileReader(classifier), cfg);
buckets = cfg.create();
}
if (classifier == null && bucket != null) {
SJK.failAndPrintUsage("--bucket option requires --classifer");
}
action.get(0).run();
} catch (Exception e) {
SJK.fail(e.toString(), e);
}
}
StackTraceReader getFilteredReader() throws IOException {
if (classifier == null ) {
if (simpleFilter == null) {
return getUnclassifiedReader();
}
else {
final StackTraceReader unclassified = getUnclassifiedReader();
return new StackTraceReader.StackTraceReaderDelegate() {
@Override
protected StackTraceReader getReader() {
return unclassified;
}
@Override
public boolean loadNext() throws IOException {
while(unclassified.loadNext()) {
StackTraceElement[] trace = getTrace();
for(StackTraceElement e: trace) {
if (e.toString().startsWith(simpleFilter)) {
return true;
}
}
}
return false;
}
@Override
public boolean isLoaded() {
return unclassified.isLoaded();
}
@Override
public StackTraceElement[] getTrace() {
return unclassified.getTrace();
}
@Override
public long getTimestamp() {
return unclassified.getTimestamp();
}
@Override
public long getThreadId() {
return unclassified.getThreadId();
}
};
}
}
else {
if (simpleFilter != null) {
SJK.fail("Simple filter cannot be used with classification");
}
if (bucket != null && !buckets.getClasses().contains(bucket)) {
SJK.fail("Bucket [" + bucket + "] is not defined");
}
final StackTraceReader unfiltered = getUnclassifiedReader();
return new StackTraceReader.StackTraceReaderDelegate() {
@Override
protected StackTraceReader getReader() {
return unfiltered;
}
@Override
public boolean loadNext() throws IOException {
while(true) {
if (unfiltered.loadNext()) {
String cl = buckets.classify(unfiltered.getTrace());
if (bucket != null) {
if (!bucket.equals(cl)) {
continue;
}
}
else if (cl == null) {
continue;
}
return true;
}
else {
return false;
}
}
}
@Override
public boolean isLoaded() {
return unfiltered.isLoaded();
}
@Override
public StackTraceElement[] getTrace() {
return unfiltered.getTrace();
}
@Override
public long getTimestamp() {
return unfiltered.getTimestamp();
}
@Override
public long getThreadId() {
return unfiltered.getThreadId();
}
};
}
}
StackTraceReader getUnclassifiedReader() throws IOException {
final StackTraceReader reader = StackTraceCodec.newReader(files.toArray(new String[0]));
return new StackTraceReader.StackTraceReaderDelegate() {
@Override
protected StackTraceReader getReader() {
return reader;
}
@Override
public boolean loadNext() throws IOException {
try {
return super.loadNext();
}
catch(IOException e) {
System.err.println("Dump file read error: " + e.toString());
return false;
}
}
};
}
abstract class SsaCmd implements Runnable {
public SsaCmd() {
allCommands.add(this);
}
public abstract boolean isSelected();
}
class PrintCmd extends SsaCmd {
@Parameter(names={"--print"}, description="Print traces from file")
boolean run;
@Override
public boolean isSelected() {
return run;
}
@Override
public void run() {
try {
StackTraceReader reader = getFilteredReader();
while(reader.loadNext()) {
String timestamp = Formats.toDatestamp(reader.getTimestamp());
StringBuilder threadHeader = new StringBuilder();
threadHeader
.append("Thread [")
.append(reader.getThreadId())
.append("] ");
if (reader.getThreadState() != null) {
threadHeader.append(reader.getThreadState()).append(' ');
}
threadHeader.append("at ").append(timestamp);
if (reader.getThreadName() != null) {
threadHeader.append(" - ").append(reader.getThreadName());
}
System.out.println(threadHeader);
StackTraceElement[] trace = reader.getTrace();
for(int i = 0; i != trace.length; ++i) {
System.out.println(trace[i]);
}
System.out.println();
}
} catch (Exception e) {
SJK.fail(e.toString(), e);
}
}
public String toString() {
return "--print";
}
}
class HistoCmd extends SsaCmd {
@Parameter(names={"--histo"}, description="Print frame histogram")
boolean run;
@Override
public boolean isSelected() {
return run;
}
@Override
public void run() {
try {
StackHisto histo = new StackHisto();
StackTraceReader reader = getFilteredReader();
int n = 0;
while(reader.loadNext()) {
StackTraceElement[] trace = reader.getTrace();
histo.feed(trace);
++n;
}
if (n > 0) {
System.out.println(histo.formatHisto());
}
else {
System.out.println("No data");
}
} catch (Exception e) {
SJK.fail(e.toString(), e);
}
}
public String toString() {
return "--histo";
}
}
class ClassSummaryCmd extends SsaCmd {
@Parameter(names={"--summary"}, description="Print summary for provided classification")
boolean run;
@Override
public boolean isSelected() {
return run;
}
@Override
public void run() {
try {
if (classifier == null) {
SJK.failAndPrintUsage("Classification is required");
}
if (bucket != null) {
SJK.failAndPrintUsage("--summary cannot be used with --bucket option");
}
List<String> bucketNames = new ArrayList<String>(buckets.getClasses());
long[] counters = new long[bucketNames.size()];
long total = 0;
StackTraceReader reader = getUnclassifiedReader();
while(reader.loadNext()) {
StackTraceElement[] trace = reader.getTrace();
String cl = buckets.classify(trace);
if (cl != null) {
++total;
++counters[bucketNames.indexOf(cl)];
}
}
System.out.println(String.format("%-40s\t%d\t%.2f%%", "Total samples", total, 100f));
for(int i = 0; i != counters.length; ++i) {
System.out.println(String.format("%-40s\t%d\t%.2f%%", bucketNames.get(i), counters[i], (100f * counters[i]) / total));
}
} catch (Exception e) {
SJK.fail(e.toString(), e);
}
}
public String toString() {
return "--summary";
}
}
}
}
|
3e01b1d385d6a352ec15a1369e574086207b16d1 | 3,412 | java | Java | java/src/map/track/LineTrack.java | AndreJSON/KEX | 78b8b65aaa75fcfb66ca52b5683d694e6824a82f | [
"MIT"
] | 1 | 2022-03-25T09:35:00.000Z | 2022-03-25T09:35:00.000Z | java/src/map/track/LineTrack.java | AndreJSON/KEX | 78b8b65aaa75fcfb66ca52b5683d694e6824a82f | [
"MIT"
] | null | null | null | java/src/map/track/LineTrack.java | AndreJSON/KEX | 78b8b65aaa75fcfb66ca52b5683d694e6824a82f | [
"MIT"
] | null | null | null | 23.531034 | 74 | 0.572978 | 715 | package map.track;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Line2D;
import java.util.ArrayList;
import sim.Simulation;
import math.Vector2D;
public class LineTrack extends AbstractTrack {
private final double length;
private final Vector2D startPoint, endPoint, unit;
private final Line2D.Double shape;
private Vector2D[] points;
public LineTrack(Vector2D startPoint, Vector2D endPoint) {
this.startPoint = startPoint;
this.endPoint = endPoint;
length = startPoint.distance(endPoint);
unit = endPoint.minus(startPoint).unit();
generatePoints();
shape = new Line2D.Double(startPoint, endPoint);
}
private void generatePoints() {
ArrayList<Vector2D> list = new ArrayList<>();
list.add(startPoint);
int curr = 1;
while (curr * POINT_STEP < length) {
list.add(startPoint.plus(unit.mult(curr * super.POINT_STEP)));
curr++;
}
list.add(endPoint);
points = (Vector2D[]) list.toArray(new Vector2D[list.size()]);
}
@Override
public double getLength() {
return length;
}
@Override
public TrackPosition getTrackPosition() {
return new Position(0);
}
@Override
public TrackPosition getTrackPosition(double distance) {
return new Position(distance);
}
@Override
public Vector2D getStartPoint() {
return startPoint;
}
@Override
public Vector2D getEndPoint() {
return endPoint;
}
@Override
public String toString() {
return "LineTrack{" + startPoint + ", " + endPoint + "}";
}
@Override
public Vector2D[] getPoints() {
return points;
}
@Override
public void draw(Graphics2D g2d) {
g2d.setColor(Color.RED);
g2d.draw(Simulation.SCALER.createTransformedShape(shape));
if (!Simulation.DEBUG) {
return;
}
g2d.setColor(Color.MAGENTA);
Vector2D p;
p = startPoint.mult(Simulation.SCALE);
g2d.drawOval((int) (p.x - 1.5), (int) (p.y - 1.5), 3, 3);
p = endPoint.mult(Simulation.SCALE);
g2d.drawOval((int) (p.x - 1.5), (int) (p.y - 1.5), 3, 3);
}
public class Position implements TrackPosition {
private Vector2D point;
private double totalDistance;
private Position(double dist) {
point = new Vector2D(startPoint);
move(dist);
}
@Override
public double getTheta() {
return unit.theta();
}
@Override
public void move(double distance) {
totalDistance += distance;
point = startPoint.plus(unit.mult(totalDistance));
}
@Override
public Vector2D getPoint() {
return point;
}
@Override
public double remaining() {
return length - totalDistance;
}
@Override
public TrackPosition copy() {
Position copy = new Position(0);
copy.point = (Vector2D) point.clone();
copy.totalDistance = totalDistance;
return copy;
}
@Override
public double getX() {
return point.x;
}
@Override
public double getY() {
return point.y;
}
}
}
|
3e01b1e6c856e2951aced5aded60915c2389fdd9 | 5,763 | java | Java | nd4j/nd4j-serde/nd4j-camel-routes/nd4j-kafka/src/main/test/java/org/nd4j/kafka/EmbeddedKafkaCluster.java | jxtps/deeplearning4j | 68ea5f3688be9045cac3c06b1828b21262b22903 | [
"Apache-2.0"
] | 1 | 2019-10-31T15:33:11.000Z | 2019-10-31T15:33:11.000Z | nd4j/nd4j-serde/nd4j-camel-routes/nd4j-kafka/src/main/test/java/org/nd4j/kafka/EmbeddedKafkaCluster.java | jxtps/deeplearning4j | 68ea5f3688be9045cac3c06b1828b21262b22903 | [
"Apache-2.0"
] | 80 | 2019-08-01T19:41:52.000Z | 2021-08-02T16:57:51.000Z | nd4j/nd4j-serde/nd4j-camel-routes/nd4j-kafka/src/main/test/java/org/nd4j/kafka/EmbeddedKafkaCluster.java | jxtps/deeplearning4j | 68ea5f3688be9045cac3c06b1828b21262b22903 | [
"Apache-2.0"
] | 1 | 2022-02-05T08:02:18.000Z | 2022-02-05T08:02:18.000Z | 32.376404 | 102 | 0.616519 | 716 | /*******************************************************************************
* Copyright (c) 2015-2019 Skymind, Inc.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
******************************************************************************/
package org.nd4j.kafka;
import kafka.admin.AdminUtils;
import kafka.server.KafkaConfig;
import kafka.server.KafkaServer;
import org.I0Itec.zkclient.ZkClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
public class EmbeddedKafkaCluster {
private static final Logger LOG = LoggerFactory.getLogger(EmbeddedKafkaCluster.class);
private final List<Integer> ports;
private final String zkConnection;
private final Properties baseProperties;
private final String brokerList;
private final List<KafkaServer> brokers;
private final List<File> logDirs;
public EmbeddedKafkaCluster(String zkConnection) {
this(zkConnection, new Properties());
}
public EmbeddedKafkaCluster(String zkConnection, Properties baseProperties) {
this(zkConnection, baseProperties, Collections.singletonList(-1));
}
public EmbeddedKafkaCluster(String zkConnection, Properties baseProperties, List<Integer> ports) {
this.zkConnection = zkConnection;
this.ports = resolvePorts(ports);
this.baseProperties = baseProperties;
this.brokers = new ArrayList<KafkaServer>();
this.logDirs = new ArrayList<File>();
this.brokerList = constructBrokerList(this.ports);
}
public ZkClient getZkClient() {
for (KafkaServer server : brokers) {
return server.zkClient();
}
return null;
}
public void createTopics(String... topics) {
for (String topic : topics) {
AdminUtils.createTopic(getZkClient(), topic, 2, 1, new Properties());
}
}
private List<Integer> resolvePorts(List<Integer> ports) {
List<Integer> resolvedPorts = new ArrayList<Integer>();
for (Integer port : ports) {
resolvedPorts.add(resolvePort(port));
}
return resolvedPorts;
}
private int resolvePort(int port) {
if (port == -1) {
return TestUtils.getAvailablePort();
}
return port;
}
private String constructBrokerList(List<Integer> ports) {
StringBuilder sb = new StringBuilder();
for (Integer port : ports) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append("localhost:").append(port);
}
return sb.toString();
}
public void startup() {
for (int i = 0; i < ports.size(); i++) {
Integer port = ports.get(i);
File logDir = TestUtils.constructTempDir("kafka-local");
Properties properties = new Properties();
properties.putAll(baseProperties);
properties.setProperty("zookeeper.connect", zkConnection);
properties.setProperty("broker.id", String.valueOf(i + 1));
properties.setProperty("host.opName", "localhost");
properties.setProperty("port", Integer.toString(port));
properties.setProperty("log.dir", logDir.getAbsolutePath());
properties.setProperty("num.partitions", String.valueOf(1));
properties.setProperty("auto.create.topics.enable", String.valueOf(Boolean.TRUE));
properties.setProperty("log.flush.interval.messages", String.valueOf(1));
LOG.info("EmbeddedKafkaCluster: local directory: " + logDir.getAbsolutePath());
KafkaServer broker = startBroker(properties);
brokers.add(broker);
logDirs.add(logDir);
}
}
private KafkaServer startBroker(Properties props) {
KafkaServer server = new KafkaServer(new KafkaConfig(props), new SystemTime());
server.startup();
return server;
}
public Properties getProps() {
Properties props = new Properties();
props.putAll(baseProperties);
props.put("metadata.broker.list", brokerList);
props.put("zookeeper.connect", zkConnection);
return props;
}
public String getBrokerList() {
return brokerList;
}
public List<Integer> getPorts() {
return ports;
}
public String getZkConnection() {
return zkConnection;
}
public void shutdown() {
for (KafkaServer broker : brokers) {
try {
broker.shutdown();
} catch (Exception e) {
e.printStackTrace();
}
}
for (File logDir : logDirs) {
try {
TestUtils.deleteFile(logDir);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("EmbeddedKafkaCluster{");
sb.append("brokerList='").append(brokerList).append('\'');
sb.append('}');
return sb.toString();
}
}
|
3e01b1fcbecab8b3bdebfe3f4b63da7c89908685 | 340 | java | Java | mdm/src/main/java/io/github/adt/categories/Category.java | adtonline/adt-platform | 0a3d221b80e9cd5d78bf48766e2d5c794ebd48db | [
"MIT"
] | 1 | 2018-08-02T08:08:45.000Z | 2018-08-02T08:08:45.000Z | mdm/src/main/java/io/github/adt/categories/Category.java | adtonline/adt-platform | 0a3d221b80e9cd5d78bf48766e2d5c794ebd48db | [
"MIT"
] | 24 | 2018-07-06T14:04:22.000Z | 2018-07-24T01:49:04.000Z | mdm/src/main/java/io/github/adt/categories/Category.java | adtonline/adt-platform | 0a3d221b80e9cd5d78bf48766e2d5c794ebd48db | [
"MIT"
] | 4 | 2018-06-30T00:14:22.000Z | 2020-08-20T02:42:00.000Z | 20 | 41 | 0.808824 | 717 | package io.github.adt.categories;
import java.util.Date;
import io.github.adt.common.DataModel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class Category extends DataModel {
private String values;
private Date effectiveDate;
private Date expirationDate;
} |
3e01b28630052f8d92ea07470546bfef2354fb80 | 1,647 | java | Java | src/main/java/frc/robot/subsystems/ShooterLift.java | FRC-6181/2021-FRC-Robot-Project-Java-Swerve | d0690c0eea28d28015d8c7eb814a1e219e4c03d4 | [
"BSD-3-Clause"
] | 1 | 2021-02-04T22:54:05.000Z | 2021-02-04T22:54:05.000Z | src/main/java/frc/robot/subsystems/ShooterLift.java | FRC-6181/2021-FRC-Robot-Project-Java-Swerve | d0690c0eea28d28015d8c7eb814a1e219e4c03d4 | [
"BSD-3-Clause"
] | null | null | null | src/main/java/frc/robot/subsystems/ShooterLift.java | FRC-6181/2021-FRC-Robot-Project-Java-Swerve | d0690c0eea28d28015d8c7eb814a1e219e4c03d4 | [
"BSD-3-Clause"
] | 1 | 2021-01-17T02:16:54.000Z | 2021-01-17T02:16:54.000Z | 32.94 | 114 | 0.637523 | 718 | /*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package frc.robot.subsystems;
import com.ctre.phoenix.motorcontrol.TalonSRXControlMode;
import com.ctre.phoenix.motorcontrol.TalonSRXFeedbackDevice;
import com.ctre.phoenix.motorcontrol.can.TalonSRX;
import edu.wpi.first.wpilibj.command.Subsystem;
import frc.robot.RobotMap;
/**
* Add your docs here.
*/
public class ShooterLift extends Subsystem {
private TalonSRX shooterLift = new TalonSRX(RobotMap.shooterLiftID);
private double setpoint = 0;
// Put methods for controlling this subsystem
// here. Call these from Commands.
public ShooterLift() {
this.shooterLift.configSelectedFeedbackSensor(TalonSRXFeedbackDevice.QuadEncoder, RobotMap.shooterLiftPID, 0);
}
@Override
public void initDefaultCommand() {
// Set the default command for a subsystem here.
// setDefaultCommand(new MySpecialCommand());
}
public double getshooterPosition(){
return shooterLift.getSelectedSensorPosition();
}
public double getshooterSetpoint(){
return this.setpoint;
}
public void setShooterPosition(Double Position) {
this.setpoint = Position;
shooterLift.set(TalonSRXControlMode.Position, Position);
}
}
|
3e01b339ee52cb4b318f93bd6b49289a6b960d26 | 4,857 | java | Java | profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TraceTest.java | yoonchunjoo/pinpoint | 6dc3ccab46ae159790cc79012d62bcb332f7a65e | [
"Apache-2.0"
] | 1 | 2021-07-06T15:01:40.000Z | 2021-07-06T15:01:40.000Z | profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TraceTest.java | yoonchunjoo/pinpoint | 6dc3ccab46ae159790cc79012d62bcb332f7a65e | [
"Apache-2.0"
] | null | null | null | profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TraceTest.java | yoonchunjoo/pinpoint | 6dc3ccab46ae159790cc79012d62bcb332f7a65e | [
"Apache-2.0"
] | null | null | null | 32.165563 | 200 | 0.696109 | 719 | /*
* Copyright 2014 NAVER Corp.
*
* 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.navercorp.pinpoint.profiler.context;
import com.navercorp.pinpoint.bootstrap.context.Trace;
import com.navercorp.pinpoint.common.AnnotationKey;
import com.navercorp.pinpoint.common.ServiceType;
import com.navercorp.pinpoint.common.Version;
import com.navercorp.pinpoint.profiler.AgentInformation;
import com.navercorp.pinpoint.profiler.context.DefaultTrace;
import com.navercorp.pinpoint.profiler.context.DefaultTraceContext;
import com.navercorp.pinpoint.profiler.context.DefaultTraceId;
import com.navercorp.pinpoint.profiler.context.storage.SpanStorage;
import com.navercorp.pinpoint.profiler.sender.EnhancedDataSender;
import com.navercorp.pinpoint.profiler.sender.LoggingDataSender;
import com.navercorp.pinpoint.rpc.FutureListener;
import com.navercorp.pinpoint.rpc.ResponseMessage;
import com.navercorp.pinpoint.rpc.client.PinpointSocketReconnectEventListener;
import org.apache.thrift.TBase;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author emeroad
*/
public class TraceTest {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Test
public void trace() {
DefaultTraceId traceID = new DefaultTraceId("agent", 0, 1);
DefaultTraceContext defaultTraceConetxt = getDefaultTraceContext();
DefaultTrace trace = new DefaultTrace(defaultTraceConetxt , traceID);
trace.setStorage(new SpanStorage(LoggingDataSender.DEFAULT_LOGGING_DATA_SENDER));
trace.traceBlockBegin();
// http server receive
trace.recordServiceType(ServiceType.UNKNOWN);
trace.recordRpcName("http://");
trace.recordEndPoint("http:localhost:8080");
trace.recordAttribute(AnnotationKey.API, "VALUE");
// get data form db
getDataFromDB(trace);
// response to client
trace.traceBlockEnd();
}
@Test
public void popEventTest() {
DefaultTraceId traceID = new DefaultTraceId("agent", 0, 1);
DefaultTraceContext defaultTraceConetxt = getDefaultTraceContext();
DefaultTrace trace = new DefaultTrace(defaultTraceConetxt, traceID);
TestDataSender dataSender = new TestDataSender();
trace.setStorage(new SpanStorage(LoggingDataSender.DEFAULT_LOGGING_DATA_SENDER));
// trace.traceBlockBegin();
// response to client
trace.traceRootBlockEnd();
logger.info(String.valueOf(dataSender.event));
}
private DefaultTraceContext getDefaultTraceContext() {
DefaultTraceContext defaultTraceContext = new DefaultTraceContext();
defaultTraceContext.setAgentInformation(new AgentInformation("agentId", "applicationName", System.currentTimeMillis(), 10, "test", "127.0.0.1", ServiceType.TOMCAT.getCode(), Version.VERSION));
return defaultTraceContext;
}
public class TestDataSender implements EnhancedDataSender {
public boolean event;
@Override
public boolean send(TBase<?, ?> data) {
event = true;
return false;
}
@Override
public void stop() {
}
@Override
public boolean request(TBase<?, ?> data) {
return send(data);
}
@Override
public boolean request(TBase<?, ?> data, int retry) {
return send(data);
}
@Override
public boolean request(TBase<?, ?> data, FutureListener<ResponseMessage> listener) {
return send(data);
}
@Override
public boolean addReconnectEventListener(PinpointSocketReconnectEventListener eventListener) {
return false;
}
@Override
public boolean removeReconnectEventListener(PinpointSocketReconnectEventListener eventListener) {
return false;
}
@Override
public boolean isNetworkAvailable() {
return true;
}
}
private void getDataFromDB(Trace trace) {
trace.traceBlockBegin();
// db server request
trace.recordServiceType(ServiceType.MYSQL);
trace.recordRpcName("rpc");
trace.recordAttribute(AnnotationKey.SQL, "SELECT * FROM TABLE");
// get a db response
trace.traceBlockEnd();
}
}
|
3e01b3dd5b19255e40c53fee88e3dc2551fcbd54 | 1,016 | java | Java | src/main/java/com/cisco/trex/stateful/api/lowlevel/ASTFCmd.java | leomaatEric/trex-java-sdk | 93947566ca13505923511d7d83bee19da6c97d5b | [
"Apache-2.0"
] | 16 | 2017-06-29T16:58:10.000Z | 2021-09-16T07:29:28.000Z | src/main/java/com/cisco/trex/stateful/api/lowlevel/ASTFCmd.java | leomaatEric/trex-java-sdk | 93947566ca13505923511d7d83bee19da6c97d5b | [
"Apache-2.0"
] | 46 | 2017-09-11T13:07:19.000Z | 2021-06-22T02:36:03.000Z | src/main/java/com/cisco/trex/stateful/api/lowlevel/ASTFCmd.java | leomaatEric/trex-java-sdk | 93947566ca13505923511d7d83bee19da6c97d5b | [
"Apache-2.0"
] | 31 | 2017-09-20T05:32:18.000Z | 2021-12-14T02:36:33.000Z | 17.824561 | 90 | 0.641732 | 720 | package com.cisco.trex.stateful.api.lowlevel;
import com.google.gson.JsonObject;
import java.util.Base64;
/** Java implementation for TRex python sdk ASTFCmd class, the abstract Astf Cmd class, */
public abstract class ASTFCmd {
protected JsonObject fields;
protected Boolean stream = null;
protected Boolean buffer = false;
/** construct */
public ASTFCmd() {
fields = new JsonObject();
}
/**
* get AstfCmd name
*
* @return Astf cmd name
*/
public abstract String getName();
/**
* isStream
*
* @return true if it's stream
*/
public Boolean isStream() {
return stream;
}
/**
* to json format
*
* @return JsonObject
*/
public JsonObject toJson() {
return fields;
}
/**
* isBuffer
*
* @return true if it's buffer
*/
public Boolean isBuffer() {
return buffer;
}
public static String encodeBase64(byte[] bytes) {
Base64.Encoder encoder = Base64.getEncoder();
return encoder.encodeToString(bytes);
}
}
|
3e01b531ade679b4243dc8e48a7f1d74ae76a9bc | 9,794 | java | Java | ABSimpleTelegram/src/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultVideo.java | RealAlwaysbusy/ABTelegram | 203859cc92e9e6a99321d8e917032a073ea8aec5 | [
"MIT"
] | null | null | null | ABSimpleTelegram/src/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultVideo.java | RealAlwaysbusy/ABTelegram | 203859cc92e9e6a99321d8e917032a073ea8aec5 | [
"MIT"
] | null | null | null | ABSimpleTelegram/src/org/telegram/telegrambots/api/objects/inlinequery/result/InlineQueryResultVideo.java | RealAlwaysbusy/ABTelegram | 203859cc92e9e6a99321d8e917032a073ea8aec5 | [
"MIT"
] | null | null | null | 33.656357 | 129 | 0.651215 | 721 | package org.telegram.telegrambots.api.objects.inlinequery.result;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONException;
import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* @brief Represents link to a page containing an embedded video player or a video file.
* Alternatively, you can use input_message_content to send a message with the specified content
* instead of the video.
* @date 01 of January of 2016
*/
import anywheresoftware.b4a.BA.Hide;
@Hide
public class InlineQueryResultVideo implements InlineQueryResult {
/**
*
*/
private static final long serialVersionUID = -3281606024782911360L;
private static final String TYPE_FIELD = "type";
@JsonProperty(TYPE_FIELD)
private static final String type = "video"; ///< Type of the result, must be "video"
private static final String ID_FIELD = "id";
private static final String MIMETYPE_FIELD = "mime_type";
private static final String VIDEOURL_FIELD = "video_url";
private static final String VIDEOWIDTH_FIELD = "video_width";
private static final String VIDEOHEIGHT_FIELD = "video_height";
private static final String VIDEODURATION_FIELD = "video_duration";
private static final String THUMBURL_FIELD = "thumb_url";
private static final String TITLE_FIELD = "title";
private static final String DESCRIPTION_FIELD = "description";
private static final String CAPTION_FIELD = "caption";
private static final String INPUTMESSAGECONTENT_FIELD = "input_message_content";
private static final String REPLY_MARKUP_FIELD = "reply_markup";
@JsonProperty(ID_FIELD)
private String id; ///< Unique identifier of this result
@JsonProperty(MIMETYPE_FIELD)
private String mimeType; ///< Mime type of the content of video url, i.e. "text/html" or "video/mp4"
@JsonProperty(VIDEOURL_FIELD)
private String videoUrl; ///< A valid URL for the embedded video player or video file
@JsonProperty(VIDEOWIDTH_FIELD)
private Integer videoWidth; ///< Optional. Video width
@JsonProperty(VIDEOHEIGHT_FIELD)
private Integer videoHeight; ///< Optional. Video height
@JsonProperty(VIDEODURATION_FIELD)
private Integer videoDuration; ///< Optional. Video duration in seconds
@JsonProperty(THUMBURL_FIELD)
private String thumbUrl; ///< Optional. URL of the thumbnail (jpeg only) for the video
@JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Title for the result
@JsonProperty(DESCRIPTION_FIELD)
private String description; ///< Optional. Short description of the result
@JsonProperty(CAPTION_FIELD)
private String caption; ///< Optional. Caption of the video to be sent, 0-200 characters
@JsonProperty(INPUTMESSAGECONTENT_FIELD)
private InputMessageContent inputMessageContent; ///< Optional. Content of the message to be sent instead of the photo
@JsonProperty(REPLY_MARKUP_FIELD)
private InlineKeyboardMarkup replyMarkup; ///< Optional. Inline keyboard attached to the message
public static String getType() {
return type;
}
public String getId() {
return id;
}
public InlineQueryResultVideo setId(String id) {
this.id = id;
return this;
}
public String getMimeType() {
return mimeType;
}
public InlineQueryResultVideo setMimeType(String mimeType) {
this.mimeType = mimeType;
return this;
}
public String getVideoUrl() {
return videoUrl;
}
public InlineQueryResultVideo setVideoUrl(String videoUrl) {
this.videoUrl = videoUrl;
return this;
}
public Integer getVideoWidth() {
return videoWidth;
}
public InlineQueryResultVideo setVideoWidth(Integer videoWidth) {
this.videoWidth = videoWidth;
return this;
}
public Integer getVideoHeight() {
return videoHeight;
}
public InlineQueryResultVideo setVideoHeight(Integer videoHeight) {
this.videoHeight = videoHeight;
return this;
}
public Integer getVideoDuration() {
return videoDuration;
}
public InlineQueryResultVideo setVideoDuration(Integer videoDuration) {
this.videoDuration = videoDuration;
return this;
}
public String getThumbUrl() {
return thumbUrl;
}
public InlineQueryResultVideo setThumbUrl(String thumbUrl) {
this.thumbUrl = thumbUrl;
return this;
}
public String getTitle() {
return title;
}
public InlineQueryResultVideo setTitle(String title) {
this.title = title;
return this;
}
public String getDescription() {
return description;
}
public InlineQueryResultVideo setDescription(String description) {
this.description = description;
return this;
}
public String getCaption() {
return caption;
}
public InlineQueryResultVideo setCaption(String caption) {
this.caption = caption;
return this;
}
public InputMessageContent getInputMessageContent() {
return inputMessageContent;
}
public InlineQueryResultVideo setInputMessageContent(InputMessageContent inputMessageContent) {
this.inputMessageContent = inputMessageContent;
return this;
}
public InlineKeyboardMarkup getReplyMarkup() {
return replyMarkup;
}
public InlineQueryResultVideo setReplyMarkup(InlineKeyboardMarkup replyMarkup) {
this.replyMarkup = replyMarkup;
return this;
}
@Override
public JSONObject toJson() throws JSONException {
JSONObject jsonObject = new JSONObject();
jsonObject.put(TYPE_FIELD, type);
jsonObject.put(ID_FIELD, this.id);
jsonObject.put(VIDEOURL_FIELD, this.videoUrl);
if (mimeType != null) {
jsonObject.put(MIMETYPE_FIELD, this.mimeType);
}
if (videoWidth != null) {
jsonObject.put(VIDEOWIDTH_FIELD, this.videoWidth);
}
if (videoHeight != null) {
jsonObject.put(VIDEOHEIGHT_FIELD, this.videoHeight);
}
if (videoDuration != null) {
jsonObject.put(VIDEODURATION_FIELD, this.videoDuration);
}
if (thumbUrl != null) {
jsonObject.put(THUMBURL_FIELD, this.thumbUrl);
}
if (title != null) {
jsonObject.put(TITLE_FIELD, this.title);
}
if (description != null) {
jsonObject.put(DESCRIPTION_FIELD, this.description);
}
if (caption != null) {
jsonObject.put(CAPTION_FIELD, caption);
}
if (replyMarkup != null) {
jsonObject.put(REPLY_MARKUP_FIELD, replyMarkup.toJson());
}
if (inputMessageContent != null) {
jsonObject.put(INPUTMESSAGECONTENT_FIELD, inputMessageContent.toJson());
}
return jsonObject;
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeStartObject();
gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id);
gen.writeStringField(VIDEOURL_FIELD, this.videoUrl);
if (mimeType != null) {
gen.writeStringField(MIMETYPE_FIELD, this.mimeType);
}
if (videoWidth != null) {
gen.writeNumberField(VIDEOWIDTH_FIELD, this.videoWidth);
}
if (videoHeight != null) {
gen.writeNumberField(VIDEOHEIGHT_FIELD, this.videoHeight);
}
if (videoDuration != null) {
gen.writeNumberField(VIDEODURATION_FIELD, this.videoDuration);
}
if (thumbUrl != null) {
gen.writeStringField(THUMBURL_FIELD, this.thumbUrl);
}
if (title != null) {
gen.writeStringField(TITLE_FIELD, this.title);
}
if (description != null) {
gen.writeStringField(DESCRIPTION_FIELD, this.description);
}
if (caption != null) {
gen.writeStringField(CAPTION_FIELD, caption);
}
if (replyMarkup != null) {
gen.writeObjectField(REPLY_MARKUP_FIELD, replyMarkup);
}
if (inputMessageContent != null) {
gen.writeObjectField(INPUTMESSAGECONTENT_FIELD, inputMessageContent);
}
gen.writeEndObject();
gen.flush();
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(gen, serializers);
}
@Override
public String toString() {
return "InlineQueryResultVideo{" +
"type='" + type + '\'' +
", id='" + id + '\'' +
", mimeType='" + mimeType + '\'' +
", videoUrl='" + videoUrl + '\'' +
", videoWidth=" + videoWidth +
", videoHeight=" + videoHeight +
", videoDuration=" + videoDuration +
", thumbUrl='" + thumbUrl + '\'' +
", title='" + title + '\'' +
", description='" + description + '\'' +
", caption='" + caption + '\'' +
", inputMessageContent='" + inputMessageContent + '\'' +
", replyMarkup='" + replyMarkup + '\'' +
'}';
}
}
|
3e01b76e6dc11081153ff0d41d902d9946973fe1 | 1,776 | java | Java | data-prepper-plugins/common/src/test/java/com/amazon/dataprepper/plugins/processor/ProcessorFactoryTests.java | AustinTag/simple-ingest-transformation-utility-pipeline | e574d308edd72f6e2afbe045a46b2c3bf3df0791 | [
"Apache-2.0"
] | null | null | null | data-prepper-plugins/common/src/test/java/com/amazon/dataprepper/plugins/processor/ProcessorFactoryTests.java | AustinTag/simple-ingest-transformation-utility-pipeline | e574d308edd72f6e2afbe045a46b2c3bf3df0791 | [
"Apache-2.0"
] | null | null | null | data-prepper-plugins/common/src/test/java/com/amazon/dataprepper/plugins/processor/ProcessorFactoryTests.java | AustinTag/simple-ingest-transformation-utility-pipeline | e574d308edd72f6e2afbe045a46b2c3bf3df0791 | [
"Apache-2.0"
] | null | null | null | 42.285714 | 122 | 0.780405 | 722 | package com.amazon.dataprepper.plugins.processor;
import com.amazon.dataprepper.model.configuration.PluginSetting;
import com.amazon.dataprepper.model.processor.Processor;
import com.amazon.dataprepper.plugins.PluginException;
import com.amazon.dataprepper.plugins.sink.SinkFactory;
import org.junit.Test;
import java.util.HashMap;
import static com.amazon.dataprepper.plugins.PluginFactoryTests.NON_EXISTENT_EMPTY_CONFIGURATION;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertThrows;
@SuppressWarnings("rawtypes")
public class ProcessorFactoryTests {
private static String TEST_PIPELINE = "test-pipeline";
/**
* Tests if ProcessorFactory is able to retrieve default Source plugins by name
*/
@Test
public void testNewSinkClassByNameThatExists() {
final PluginSetting noOpProcessorConfiguration = new PluginSetting("no-op", new HashMap<>());
noOpProcessorConfiguration.setPipelineName(TEST_PIPELINE);
final Processor actualProcessor = ProcessorFactory.newProcessor(noOpProcessorConfiguration);
final Processor expectedProcessor = new NoOpProcessor();
assertThat(actualProcessor, notNullValue());
assertThat(actualProcessor.getClass().getSimpleName(), is(equalTo(expectedProcessor.getClass().getSimpleName())));
}
/**
* Tests if ProcessorFactory fails with correct Exception when queried for a non-existent plugin
*/
@Test
public void testNonExistentSinkRetrieval() {
assertThrows(PluginException.class, () -> SinkFactory.newSink(NON_EXISTENT_EMPTY_CONFIGURATION));
}
}
|
3e01b7848b2a1ea15fc71f4a3cabf77b5994f21b | 946 | java | Java | csharp-psi-api/src/main/java/consulo/csharp/lang/psi/CSharpUsingListOwner.java | consulo/consulo-csharp | 5c87b1ef29b2a3747088e93464fb6d2c6a00bda6 | [
"Apache-2.0"
] | 49 | 2015-01-19T12:19:51.000Z | 2022-03-02T23:34:47.000Z | csharp-psi-api/src/main/java/consulo/csharp/lang/psi/CSharpUsingListOwner.java | consulo/consulo-csharp | 5c87b1ef29b2a3747088e93464fb6d2c6a00bda6 | [
"Apache-2.0"
] | 379 | 2015-01-01T09:15:23.000Z | 2022-03-03T09:17:03.000Z | csharp-psi-api/src/main/java/consulo/csharp/lang/psi/CSharpUsingListOwner.java | consulo/consulo-csharp | 5c87b1ef29b2a3747088e93464fb6d2c6a00bda6 | [
"Apache-2.0"
] | 9 | 2015-06-25T07:12:35.000Z | 2019-06-02T19:01:11.000Z | 27.823529 | 75 | 0.762156 | 723 | /*
* Copyright 2013-2017 consulo.io
*
* 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 consulo.csharp.lang.psi;
import javax.annotation.Nonnull;
import consulo.annotation.access.RequiredReadAction;
import consulo.dotnet.psi.DotNetElement;
/**
* @author VISTALL
* @since 19.10.14
*/
public interface CSharpUsingListOwner extends DotNetElement
{
@Nonnull
@RequiredReadAction
CSharpUsingListChild[] getUsingStatements();
}
|
3e01b7abb57f15104351d6f35d154b07b024b682 | 4,762 | java | Java | src/main/java/net/sorenon/minexraft/client/MineXRaftClient.java | vos6434/MCXR | 8951009769150c78f313badf2f3de1a626886027 | [
"CC0-1.0"
] | null | null | null | src/main/java/net/sorenon/minexraft/client/MineXRaftClient.java | vos6434/MCXR | 8951009769150c78f313badf2f3de1a626886027 | [
"CC0-1.0"
] | null | null | null | src/main/java/net/sorenon/minexraft/client/MineXRaftClient.java | vos6434/MCXR | 8951009769150c78f313badf2f3de1a626886027 | [
"CC0-1.0"
] | null | null | null | 36.630769 | 136 | 0.652247 | 724 | package net.sorenon.minexraft.client;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.Framebuffer;
import net.sorenon.minexraft.client.input.VanillaCompatActionSet;
import net.sorenon.minexraft.client.input.XrInput;
import org.joml.Vector3f;
import org.lwjgl.openxr.XR;
import org.lwjgl.openxr.XrFovf;
import org.lwjgl.openxr.XrRect2Di;
import org.lwjgl.system.SharedLibrary;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Properties;
import static org.lwjgl.system.APIUtil.apiCreateLibrary;
import static org.lwjgl.system.APIUtil.apiLog;
public class MineXRaftClient implements ClientModInitializer {
public static final OpenXR OPEN_XR = new OpenXR();
public static MineXRaftClient INSTANCE;
public static XrInput XR_INPUT;
public static VanillaCompatActionSet vanillaCompatActionSet;
public static XrRenderPass renderPass = XrRenderPass.VANILLA;
public static XrRect2Di viewportRect = null;
public static Framebuffer primaryRenderTarget = null;
public static XrFovf fov = null;
public static Pose eyePose = new Pose();
public static int viewIndex = 0;
public static Framebuffer guiFramebuffer = null;
public static void tmpResetSize() {
// if (viewportRect != null) {
// framebufferWidth = viewportRect.extent().width();
// framebufferHeight = viewportRect.extent().height();
// }
primaryRenderTarget = MinecraftClient.getInstance().getFramebuffer();
}
public static final Pose headPose = new Pose();
// public static Vec3d xrOrigin = new Vec3d(0, 0, 0); //The center of the STAGE set at the same height of the PlayerEntity's feet
public static Vector3f xrOffset = new Vector3f(0, 0, 0);
public static float yawTurn = 0;
public XrHandRenderer handRenderer = new XrHandRenderer();
@Override
public void onInitializeClient() {
INSTANCE = this;
String loaderPath = "";
try { //TODO bundle loader binaries with the mod
File configFile = FabricLoader.getInstance().getConfigDir().resolve("mcxr.properties").toFile();
if (!configFile.exists()) {
if (!configFile.createNewFile()) {
System.err.println("[MCXR] Could not create config file: " + configFile.getAbsolutePath());
}
}
Properties properties = new Properties();
if (configFile.exists()) {
try (FileInputStream inputStream = new FileInputStream(configFile)) {
properties.load(inputStream);
}
}
if (properties.containsKey("loader_path")) {
loaderPath = properties.getProperty("loader_path");
} else {
properties.put("loader_path", "");
}
if (loaderPath.length() == 0) {
if (configFile.exists()) {
try (FileOutputStream stream = new FileOutputStream(configFile)) {
properties.store(stream, "");
}
}
throw new IllegalStateException("Set path to openxr loader in " + configFile.getAbsolutePath());
}
} catch (IOException e) {
e.printStackTrace();
}
SharedLibrary defaultOpenXRLoader = loadNative(XR.class, loaderPath, "openxr_loader");
XR.create(defaultOpenXRLoader);
OPEN_XR.createOpenXRInstance();
OPEN_XR.initializeOpenXRSystem();
System.out.println("Hello Fabric world!");
///execute in minecraft:overworld run tp @s 5804.48 137.00 -4601.16 3.23 72.30
WorldRenderEvents.LAST.register(context -> {
handRenderer.renderHandsDebug(context.camera());
});
WorldRenderEvents.AFTER_ENTITIES.register(context -> {
handRenderer.renderHands(context);
});
}
public static void resetView() {
MineXRaftClient.xrOffset = new Vector3f(0, 0, 0).sub(MineXRaftClient.headPose.getPos()).mul(1, 0, 1);
}
private static SharedLibrary loadNative(Class<?> context, String path, String libName) {
apiLog("Loading library: " + path);
// METHOD 1: absolute path
if (Paths.get(path).isAbsolute()) {
SharedLibrary lib = apiCreateLibrary(path);
apiLog("\tSuccess");
return lib;
}
throw new UnsatisfiedLinkError("Failed to locate library: " + libName);
}
}
|
3e01b81e0aff0e2d9a0d17a17b83cfe7602a90ce | 160 | java | Java | src/main/java/io/renren/common/validator/group/AliyunGroup.java | master-qi/renren-fast | 8ddc85fcb67d4be10159dd8cad13016421d036fc | [
"Apache-2.0"
] | 1 | 2022-03-17T16:49:18.000Z | 2022-03-17T16:49:18.000Z | src/main/java/io/renren/common/validator/group/AliyunGroup.java | master-qi/Epidemic-prevention-and-control-system | 8ddc85fcb67d4be10159dd8cad13016421d036fc | [
"Apache-2.0"
] | null | null | null | src/main/java/io/renren/common/validator/group/AliyunGroup.java | master-qi/Epidemic-prevention-and-control-system | 8ddc85fcb67d4be10159dd8cad13016421d036fc | [
"Apache-2.0"
] | null | null | null | 9.055556 | 41 | 0.582822 | 725 | /**
* .
*
* Thm
*
* !
*/
package io.renren.common.validator.group;
/**
* 阿里云
*
* @author Mark [email protected]
*/
public interface AliyunGroup {
}
|
3e01b8356a8e30e04cbbb58abd4e25f8c87aab4f | 1,699 | java | Java | core/ScreenFlowBase/src/main/java/rt/fx/base/config/CConfigLoader.java | rodel-talampas/FXScreenNavigationFramework | cb72b3f90b52df2b165be843b205569c19e54156 | [
"MIT"
] | 2 | 2020-01-02T16:19:51.000Z | 2020-04-29T20:53:54.000Z | core/ScreenFlowBase/src/main/java/rt/fx/base/config/CConfigLoader.java | rodel-talampas/FXScreenNavigationFramework | cb72b3f90b52df2b165be843b205569c19e54156 | [
"MIT"
] | 1 | 2015-09-22T03:46:17.000Z | 2015-09-22T03:46:17.000Z | core/ScreenFlowBase/src/main/java/rt/fx/base/config/CConfigLoader.java | rodel-talampas/FXScreenNavigationFramework | cb72b3f90b52df2b165be843b205569c19e54156 | [
"MIT"
] | null | null | null | 32.056604 | 81 | 0.732195 | 726 | /*
* Copyright (c) 2015 Rodel M. Talampas
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
*
*/
package rt.fx.base.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author rodel.talampas
*
*/
public class CConfigLoader extends AConfigLoader{
private static Logger LOGGER = LoggerFactory.getLogger(CConfigLoader.class);
public CConfigLoader(){
if (singleton == null) {
LOGGER.debug("Retrieving Config Loader for the first time...");
synchronized (singleton_mutex) {
if (singleton == null) {
singleton = this;
LOGGER.debug("Config Loader has been created...");
}
}
}
//LOGGER.debug(singleton);
}
}
|
3e01b89d96b211b24b4da5813e3903aa72154377 | 6,374 | java | Java | jetcd-core/src/test/java/io/etcd/jetcd/LeaseTest.java | carlanton/jetcd | 5996b0c63fceb0a7f3cf5f64c00ac40f968edfbe | [
"Apache-2.0"
] | 608 | 2018-08-12T13:07:05.000Z | 2022-03-30T08:18:26.000Z | jetcd-core/src/test/java/io/etcd/jetcd/LeaseTest.java | carlanton/jetcd | 5996b0c63fceb0a7f3cf5f64c00ac40f968edfbe | [
"Apache-2.0"
] | 369 | 2018-08-08T17:28:15.000Z | 2022-03-29T10:51:57.000Z | jetcd-core/src/test/java/io/etcd/jetcd/LeaseTest.java | carlanton/jetcd | 5996b0c63fceb0a7f3cf5f64c00ac40f968edfbe | [
"Apache-2.0"
] | 207 | 2018-08-15T06:48:49.000Z | 2022-03-31T06:07:16.000Z | 39.8375 | 104 | 0.697207 | 727 | /*
* Copyright 2016-2021 The jetcd authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.etcd.jetcd;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import com.google.common.base.Charsets;
import io.etcd.jetcd.lease.LeaseKeepAliveResponse;
import io.etcd.jetcd.lease.LeaseTimeToLiveResponse;
import io.etcd.jetcd.options.LeaseOption;
import io.etcd.jetcd.options.PutOption;
import io.etcd.jetcd.support.CloseableClient;
import io.etcd.jetcd.support.Observers;
import io.etcd.jetcd.test.EtcdClusterExtension;
import io.grpc.stub.StreamObserver;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
public class LeaseTest {
@RegisterExtension
public static final EtcdClusterExtension cluster = new EtcdClusterExtension("etcd-lease", 3, false);
private KV kvClient;
private Client client;
private Lease leaseClient;
private static final ByteSequence KEY = ByteSequence.from("foo", Charsets.UTF_8);
private static final ByteSequence KEY_2 = ByteSequence.from("foo2", Charsets.UTF_8);
private static final ByteSequence VALUE = ByteSequence.from("bar", Charsets.UTF_8);
@BeforeEach
public void setUp() {
client = Client.builder().endpoints(cluster.getClientEndpoints()).build();
kvClient = client.getKVClient();
leaseClient = client.getLeaseClient();
}
@AfterEach
public void tearDown() {
if (client != null) {
client.close();
}
}
@Test
public void testGrant() throws Exception {
long leaseID = leaseClient.grant(5).get().getID();
kvClient.put(KEY, VALUE, PutOption.newBuilder().withLeaseId(leaseID).build()).get();
assertThat(kvClient.get(KEY).get().getCount()).isEqualTo(1);
Thread.sleep(6000);
assertThat(kvClient.get(KEY).get().getCount()).isEqualTo(0);
}
@Test
public void testGrantWithTimeout() throws Exception {
long leaseID = leaseClient.grant(5, 10, TimeUnit.SECONDS).get().getID();
kvClient.put(KEY, VALUE, PutOption.newBuilder().withLeaseId(leaseID).build()).get();
assertThat(kvClient.get(KEY).get().getCount()).isEqualTo(1);
Thread.sleep(6000L);
assertThat(kvClient.get(KEY).get().getCount()).isEqualTo(0);
tearDown();
assertThatExceptionOfType(RejectedExecutionException.class)
.isThrownBy(() -> leaseClient.grant(5, 2, TimeUnit.SECONDS).get().getID());
setUp();
}
@Test
public void testRevoke() throws Exception {
long leaseID = leaseClient.grant(5).get().getID();
kvClient.put(KEY, VALUE, PutOption.newBuilder().withLeaseId(leaseID).build()).get();
assertThat(kvClient.get(KEY).get().getCount()).isEqualTo(1);
leaseClient.revoke(leaseID).get();
assertThat(kvClient.get(KEY).get().getCount()).isEqualTo(0);
}
@Test
public void testKeepAliveOnce() throws ExecutionException, InterruptedException {
long leaseID = leaseClient.grant(2).get().getID();
kvClient.put(KEY, VALUE, PutOption.newBuilder().withLeaseId(leaseID).build()).get();
assertThat(kvClient.get(KEY).get().getCount()).isEqualTo(1);
LeaseKeepAliveResponse rp = leaseClient.keepAliveOnce(leaseID).get();
assertThat(rp.getTTL()).isGreaterThan(0);
}
@Test
public void testKeepAlive() throws ExecutionException, InterruptedException {
long leaseID = leaseClient.grant(2).get().getID();
kvClient.put(KEY, VALUE, PutOption.newBuilder().withLeaseId(leaseID).build()).get();
assertThat(kvClient.get(KEY).get().getCount()).isEqualTo(1);
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<LeaseKeepAliveResponse> responseRef = new AtomicReference<>();
StreamObserver<LeaseKeepAliveResponse> observer = Observers.observer(response -> {
responseRef.set(response);
latch.countDown();
});
try (CloseableClient c = leaseClient.keepAlive(leaseID, observer)) {
latch.await(5, TimeUnit.SECONDS);
LeaseKeepAliveResponse response = responseRef.get();
assertThat(response.getTTL()).isGreaterThan(0);
}
Thread.sleep(3000);
assertThat(kvClient.get(KEY).get().getCount()).isEqualTo(0);
}
@Test
public void testTimeToLive() throws ExecutionException, InterruptedException {
long ttl = 5;
long leaseID = leaseClient.grant(ttl).get().getID();
LeaseTimeToLiveResponse resp = leaseClient.timeToLive(leaseID, LeaseOption.DEFAULT).get();
assertThat(resp.getTTl()).isGreaterThan(0);
assertThat(resp.getGrantedTTL()).isEqualTo(ttl);
}
@Test
public void testTimeToLiveWithKeys() throws ExecutionException, InterruptedException {
long ttl = 5;
long leaseID = leaseClient.grant(ttl).get().getID();
PutOption putOption = PutOption.newBuilder().withLeaseId(leaseID).build();
kvClient.put(KEY_2, VALUE, putOption).get();
LeaseOption leaseOption = LeaseOption.newBuilder().withAttachedKeys().build();
LeaseTimeToLiveResponse resp = leaseClient.timeToLive(leaseID, leaseOption).get();
assertThat(resp.getTTl()).isGreaterThan(0);
assertThat(resp.getGrantedTTL()).isEqualTo(ttl);
assertThat(resp.getKeys().size()).isEqualTo(1);
assertThat(resp.getKeys().get(0)).isEqualTo(KEY_2);
}
}
|
3e01b8e67a22de30b30137b7eb726c54a697d0eb | 1,963 | java | Java | my-app/src/main/java/org/gradle/test/performance/mediummonolithicjavaproject/p394/Production7898.java | oehme/analysing-gradle-performance | 9f362b7d488dc0547a4443927d7c47a4b3fd3eec | [
"Apache-2.0"
] | 1 | 2017-08-30T17:59:45.000Z | 2017-08-30T17:59:45.000Z | my-app/src/main/java/org/gradle/test/performance/mediummonolithicjavaproject/p394/Production7898.java | oehme/analysing-gradle-performance | 9f362b7d488dc0547a4443927d7c47a4b3fd3eec | [
"Apache-2.0"
] | null | null | null | my-app/src/main/java/org/gradle/test/performance/mediummonolithicjavaproject/p394/Production7898.java | oehme/analysing-gradle-performance | 9f362b7d488dc0547a4443927d7c47a4b3fd3eec | [
"Apache-2.0"
] | 1 | 2019-03-18T18:52:45.000Z | 2019-03-18T18:52:45.000Z | 18.695238 | 69 | 0.631177 | 728 | package org.gradle.test.performance.mediummonolithicjavaproject.p394;
public class Production7898 {
private Production7895 property0;
public Production7895 getProperty0() {
return property0;
}
public void setProperty0(Production7895 value) {
property0 = value;
}
private Production7896 property1;
public Production7896 getProperty1() {
return property1;
}
public void setProperty1(Production7896 value) {
property1 = value;
}
private Production7897 property2;
public Production7897 getProperty2() {
return property2;
}
public void setProperty2(Production7897 value) {
property2 = value;
}
private String property3;
public String getProperty3() {
return property3;
}
public void setProperty3(String value) {
property3 = value;
}
private String property4;
public String getProperty4() {
return property4;
}
public void setProperty4(String value) {
property4 = value;
}
private String property5;
public String getProperty5() {
return property5;
}
public void setProperty5(String value) {
property5 = value;
}
private String property6;
public String getProperty6() {
return property6;
}
public void setProperty6(String value) {
property6 = value;
}
private String property7;
public String getProperty7() {
return property7;
}
public void setProperty7(String value) {
property7 = value;
}
private String property8;
public String getProperty8() {
return property8;
}
public void setProperty8(String value) {
property8 = value;
}
private String property9;
public String getProperty9() {
return property9;
}
public void setProperty9(String value) {
property9 = value;
}
} |
3e01b9641fd660563c056cd79cd6427159a12831 | 857 | java | Java | java/joa/src-gen/com/wilutions/mslib/outlook/impl/Fire_NameSpaceEvents.java | wolfgangimig/joa | 5a3e51a3d07a32393ef08fda3668fbe5e64ba443 | [
"MIT"
] | 12 | 2015-05-29T09:26:17.000Z | 2021-11-29T07:29:50.000Z | java/joa/src-gen/com/wilutions/mslib/outlook/impl/Fire_NameSpaceEvents.java | wolfgangimig/joa | 5a3e51a3d07a32393ef08fda3668fbe5e64ba443 | [
"MIT"
] | 14 | 2015-01-18T10:51:11.000Z | 2020-12-02T13:02:06.000Z | java/joa/src-gen/com/wilutions/mslib/outlook/impl/Fire_NameSpaceEvents.java | wolfgangimig/joa | 5a3e51a3d07a32393ef08fda3668fbe5e64ba443 | [
"MIT"
] | 13 | 2015-04-24T00:17:05.000Z | 2020-12-03T13:29:55.000Z | 45.105263 | 204 | 0.751459 | 729 | /* ** GENEREATED FILE - DO NOT MODIFY ** */
package com.wilutions.mslib.outlook.impl;
import com.wilutions.com.*;
import com.wilutions.mslib.outlook.NameSpaceEvents;
@SuppressWarnings("all")
public class Fire_NameSpaceEvents {
public final static void onOptionsPagesAdd(final IDispatch __joa__disp, final com.wilutions.mslib.outlook.PropertyPages Pages, final com.wilutions.mslib.outlook.MAPIFolder Folder) throws ComException {
assert(__joa__disp != null);
assert(Pages != null);
assert(Folder != null);
__joa__disp._fireEvent(NameSpaceEvents.class, (l)->l.onOptionsPagesAdd(Pages,Folder));
}
public final static void onAutoDiscoverComplete(final IDispatch __joa__disp) throws ComException {
assert(__joa__disp != null);
__joa__disp._fireEvent(NameSpaceEvents.class, (l)->l.onAutoDiscoverComplete());
}
}
|
3e01ba1543f93740a9890f293f5a080c196f9074 | 2,039 | java | Java | src/main/java/com/garowing/gameexp/game/rts/skill/template/SkillPlayControllor.java | cool112/game | 61071efa6498825f9cbcc7722420c6cd399bb3ab | [
"MIT"
] | null | null | null | src/main/java/com/garowing/gameexp/game/rts/skill/template/SkillPlayControllor.java | cool112/game | 61071efa6498825f9cbcc7722420c6cd399bb3ab | [
"MIT"
] | null | null | null | src/main/java/com/garowing/gameexp/game/rts/skill/template/SkillPlayControllor.java | cool112/game | 61071efa6498825f9cbcc7722420c6cd399bb3ab | [
"MIT"
] | null | null | null | 26.480519 | 122 | 0.706229 | 730 | package com.garowing.gameexp.game.rts.skill.template;
import com.yeto.war.fightcore.GameObject;
import com.yeto.war.fightcore.GameObjectType;
import com.garowing.gameexp.game.rts.skill.entity.EffectEntity;
import com.garowing.gameexp.game.rts.skill.entity.SkillEntity;
import com.garowing.gameexp.game.rts.skill.event.InterruptEffectSkillEvent;
import com.garowing.gameexp.game.rts.skill.manager.SkillManager;
import com.garowing.gameexp.game.rts.objects.WarInstance;
import com.yeto.war.module.troop.Troop;
/**
* 技能播放控制器
* @author seg
* 2017年3月15日
*/
public abstract class SkillPlayControllor
{
/**
* 获取播放时间
* @param skill
* @param currTime
* @return
*/
public abstract long getWaitTime(SkillEntity skill, long currTime);
/**
* 技能是否结束
* @param skill
* @param currTime
* @return
*/
public boolean isSkillEnd(SkillEntity skill, long currTime)
{
WarInstance war = skill.getWar();
if(war == null)
return true;
GameObject caster = skill.getCaster();
if(caster != null && caster.getObjectType() == GameObjectType.TROOP)
{
Troop troopCaster = (Troop) caster;
if(!skill.getModel().isPassive() && (!troopCaster.isLive() || !troopCaster.canAttack() || !troopCaster.canCaseSkill()))
{
for(Integer effectId : skill.getEffectEntityList())
{
GameObject obj = war.getObject(effectId);
if(obj == null || obj.getObjectType() != GameObjectType.SKILL_EFFECT)
continue;
EffectEntity effect = (EffectEntity) obj;
war.getSkillManager().addSkillEvent(new InterruptEffectSkillEvent(war, caster, effect, true));
}
}
}
for(Integer effectId : skill.getEffectEntityList())
{
GameObject obj = war.getObject(effectId);
if(obj == null || obj.getObjectType() != GameObjectType.SKILL_EFFECT)
continue;
EffectEntity effect = (EffectEntity) obj;
if(effect.getState() < SkillManager.IDLE)
return false;
}
return true;
}
/**
* 获取初始延迟
* @return
*/
public abstract long getInitDelay(SkillEntity skill, long currTime);
}
|
3e01ba6724c3fd3fe398d5d70eef116b9e6935df | 452 | java | Java | wezard-dubbo-api/src/main/java/com/natsumes/wezard/service/DubboCategoryService.java | SpikeLavender/wezard | 57df546f09802b38de1151b5fbcba8889070eb2b | [
"Apache-2.0"
] | null | null | null | wezard-dubbo-api/src/main/java/com/natsumes/wezard/service/DubboCategoryService.java | SpikeLavender/wezard | 57df546f09802b38de1151b5fbcba8889070eb2b | [
"Apache-2.0"
] | 3 | 2020-08-06T15:20:02.000Z | 2020-08-06T15:20:02.000Z | wezard-dubbo-api/src/main/java/com/natsumes/wezard/service/DubboCategoryService.java | SpikeLavender/wezard | 57df546f09802b38de1151b5fbcba8889070eb2b | [
"Apache-2.0"
] | null | null | null | 20.545455 | 55 | 0.767699 | 731 | package com.natsumes.wezard.service;
import com.natsumes.wezard.pojo.Category;
import java.util.List;
public interface DubboCategoryService {
int deleteByPrimaryKey(Integer id);
int insert(Category category);
int insertSelective(Category category);
Category selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(Category category);
int updateByPrimaryKey(Category category);
List<Category> selectAll();
}
|
3e01ba88ebdd90da162b247590e1f8e583f7383d | 3,160 | java | Java | gesoft-workflow-model/src/main/java/cl/com/gesoft/workflow/model/RolPermission.java | JMagoSV/gesoft-workflow-backend | aac5e102f6f6386778e987988d75bc5a6eb11f37 | [
"Apache-2.0"
] | null | null | null | gesoft-workflow-model/src/main/java/cl/com/gesoft/workflow/model/RolPermission.java | JMagoSV/gesoft-workflow-backend | aac5e102f6f6386778e987988d75bc5a6eb11f37 | [
"Apache-2.0"
] | 1 | 2022-02-16T01:12:58.000Z | 2022-02-16T01:12:58.000Z | gesoft-workflow-model/src/main/java/cl/com/gesoft/workflow/model/RolPermission.java | JMagoSV/gesoft-workflow-backend | aac5e102f6f6386778e987988d75bc5a6eb11f37 | [
"Apache-2.0"
] | 1 | 2020-11-30T15:56:29.000Z | 2020-11-30T15:56:29.000Z | 20.012658 | 82 | 0.535421 | 732 | /*
* Copyright (c) 2020, Luis Felipe Sosa Alvarez. All rights reserved.
* Use is subject to license terms.
*
* TEMPLATE-BACKEND-SPRING-BOOT
*/
package cl.com.gesoft.workflow.model;
import javax.persistence.*;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
import java.util.Objects;
/**
* The Class RolPermission.
*
* @autor Luis Felipe Sosa Alvarez [email protected]
*/
@Entity
@Table(name = "gwf_rol_permission")
public class RolPermission implements Serializable, Cloneable {
private static final long serialVersionUID = 3767847229388360061L;
/**
* Gets serial version uid.
*
* @return the serial version uid
*/
public static long getSerialVersionUID() {
return serialVersionUID;
}
/** The id. */
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "rol", nullable = false)
@NotEmpty(message = "Rol is required")
private String rol;
@Column(name = "permission" ,nullable = false)
@NotEmpty(message = "Permission is required")
private String permission;
/**
* Gets the id.
*
* @return the id
*/
public Long getId() {
return id;
}
/**
* Sets the id.
*
* @param id the new id
*/
public void setId(Long id) {
this.id = id;
}
/**
* Gets rol.
*
* @return the rol
*/
public String getRol() {
return rol;
}
/**
* Sets rol.
*
* @param rol the rol
*/
public void setRol(String rol) {
this.rol = rol;
}
/**
* Gets permission.
*
* @return the permission
*/
public String getPermission() {
return permission;
}
/**
* Sets permission.
*
* @param permission the permission
*/
public void setPermission(String permission) {
this.permission = permission;
}
/**
* Equals.
*
* @param o the o
* @return true, if successful
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof RolPermission)) {
return false;
}
return id != null && Objects.equals(getId(), ((RolPermission) o).getId());
}
/**
* Hash code.
*
* @return the int
*/
@Override
public int hashCode() {
return Objects.hash(getId());
}
/**
* To Clone.
*
* @return the RolPermission
*/
@Override
public RolPermission clone() {
RolPermission clon = null;
try {
clon = (RolPermission) super.clone();
} catch (CloneNotSupportedException e) {
System.out.println(" no se puede duplicar");
}
return clon;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
return "RolPermission{" +
"id=" + getId() +
", rol='" + getRol() + "'" +
", permission='" + getPermission() + "'" +
"}";
}
}
|
3e01bbb555b9a67e75ac8e4f3a9c8101eb423c29 | 2,698 | java | Java | TeamCode/src/main/java/org/firstinspires/ftc/teamcode/TeleOp/IntakeStorageGauge.java | polygonnedpotato/UltimateGoalImproved | 83725e7db3b4291a5e3c05d6edd5a9a0f33da0c1 | [
"MIT"
] | 1 | 2021-02-11T04:04:36.000Z | 2021-02-11T04:04:36.000Z | TeamCode/src/main/java/org/firstinspires/ftc/teamcode/TeleOp/IntakeStorageGauge.java | polygonnedpotato/UltimateGoalImproved | 83725e7db3b4291a5e3c05d6edd5a9a0f33da0c1 | [
"MIT"
] | null | null | null | TeamCode/src/main/java/org/firstinspires/ftc/teamcode/TeleOp/IntakeStorageGauge.java | polygonnedpotato/UltimateGoalImproved | 83725e7db3b4291a5e3c05d6edd5a9a0f33da0c1 | [
"MIT"
] | null | null | null | 24.089286 | 92 | 0.476279 | 733 | package org.firstinspires.ftc.teamcode.TeleOp;
import com.qualcomm.robotcore.hardware.HardwareMap;
import com.qualcomm.robotcore.hardware.Servo;
public class IntakeStorageGauge {
public Servo ledstrip;
//public ColorSensor colorstore1;
//public ColorSensor colorstore2;
//public ColorSensor colorstore3;
public IntakeStorageGauge(HardwareMap hwm) {
ledstrip = hwm.get(Servo.class, "blinkin");
// colorstore1 = hwm.colorSensor.get("colorstore1");
// colorstore3 = hwm.get(ColorSensor.class, "colorstore3");
// colorstore2 = hwm.get(ColorSensor.class, "colorstore2");
//colorstore1 = hwm.get(ColorSensor.class, "colorstore1");
}
/* public void rings () {
if (isyellow1() == true && (isyellow2 () == false && isyellow3 () == false)) {
ledstrip.setPattern(RevBlinkinLedDriver.BlinkinPattern.GREEN);
}
else if (isyellow2() == true && (isyellow1 () == true && isyellow3 () == false)) {
ledstrip.setPattern(RevBlinkinLedDriver.BlinkinPattern.YELLOW);
}
else if (isyellow3() == true && isyellow2() == true) {
ledstrip.setPattern(RevBlinkinLedDriver.BlinkinPattern.RED);
}
else {
ledstrip.setPattern(RevBlinkinLedDriver.BlinkinPattern.RAINBOW_RAINBOW_PALETTE);
}
}
*/
// lets go :)
/* public boolean isyellow1 () {
if (colorstore1.red() == 10) {
if (colorstore1.green() == 10) {
if (colorstore1.blue() == 10) {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
else {
return false;
}
}*/
/* public boolean isyellow2 () {
if (colorstore1.red() == 10) {
if (colorstore1.green() == 10) {
if (colorstore1.blue() == 10) {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
else {
return false;
}
}
public boolean isyellow3 () {
if (colorstore1.red() == 10) {
if (colorstore1.green() == 10) {
if (colorstore1.blue() == 10) {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
else {
return false;
}
}
*/
}
|
3e01bccebacdced19c0645304cd1cf02b88ac259 | 2,293 | java | Java | fsdevtools-cli/src/main/java/com/espirit/moddev/cli/commands/help/DefaultCommand.java | e-Spirit/FSDevTools | 01835b7cf7a3ef291e36771b7b1b809739904a69 | [
"ECL-2.0",
"Apache-2.0"
] | 31 | 2016-04-06T16:01:24.000Z | 2021-12-17T07:58:23.000Z | fsdevtools-cli/src/main/java/com/espirit/moddev/cli/commands/help/DefaultCommand.java | e-Spirit/FSDevTools | 01835b7cf7a3ef291e36771b7b1b809739904a69 | [
"ECL-2.0",
"Apache-2.0"
] | 46 | 2017-04-07T20:14:40.000Z | 2021-08-09T11:58:42.000Z | fsdevtools-cli/src/main/java/com/espirit/moddev/cli/commands/help/DefaultCommand.java | e-Spirit/FSDevTools | 01835b7cf7a3ef291e36771b7b1b809739904a69 | [
"ECL-2.0",
"Apache-2.0"
] | 29 | 2016-09-09T11:17:07.000Z | 2022-03-12T18:46:31.000Z | 32.757143 | 97 | 0.651984 | 734 | /*
*
* *********************************************************************
* fsdevtools
* %%
* Copyright (C) 2021 e-Spirit AG
* %%
* 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.espirit.moddev.cli.commands.help;
import com.espirit.moddev.cli.api.command.Command;
import com.github.rvesse.airline.annotations.Arguments;
import com.github.rvesse.airline.help.Help;
import com.github.rvesse.airline.model.GlobalMetadata;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
/**
* This command is the default command.
*
* @author e-Spirit AG
*/
@com.github.rvesse.airline.annotations.Command(name = "DefaultCommand", hidden = true)
public class DefaultCommand implements Command<HelpResult> {
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultCommand.class);
@Arguments
protected List<String> args = new ArrayList<>();
@Override
public HelpResult call() throws Exception {
HelpResult result = callStandardHelpCommand();
if(args.isEmpty()) {
GlobalMetadata<Object> metadata = result.get();
return new HelpResult(metadata);
} else {
// enforce exit code 1 with error
final String unknownCommand = args.stream().reduce((t, u) -> t + " " + u).orElse("");
final Exception error = new UnknownCommandException(unknownCommand);
return new HelpResult(error);
}
}
private static HelpResult callStandardHelpCommand() {
LOGGER.info("\nSee help for more information:\n");
final HelpCommand helpCommand = new HelpCommand();
return helpCommand.call();
}
}
|
3e01beb33b7cad1b15fb1d43fe1fc8fa3ceeb3c1 | 3,065 | java | Java | src/main/java/frc/robot/commands/SnapLeft.java | swissskimmilk/2022-Quara-Wallace | cbcc233c80b38ea0568e7d549956579cb0511626 | [
"BSD-3-Clause"
] | null | null | null | src/main/java/frc/robot/commands/SnapLeft.java | swissskimmilk/2022-Quara-Wallace | cbcc233c80b38ea0568e7d549956579cb0511626 | [
"BSD-3-Clause"
] | null | null | null | src/main/java/frc/robot/commands/SnapLeft.java | swissskimmilk/2022-Quara-Wallace | cbcc233c80b38ea0568e7d549956579cb0511626 | [
"BSD-3-Clause"
] | null | null | null | 30.346535 | 89 | 0.690375 | 735 | package frc.robot.commands;
import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.controller.PIDController;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.Constants;
import frc.robot.RobotContainer;
import frc.robot.subsystems.Drivetrain;
import frc.robot.subsystems.IMU;
import java.lang.Math;
import java.text.DecimalFormat;
public class SnapLeft extends CommandBase {
private double initAngle;
private double newAngle;
private IMU subsysIMU;
private Drivetrain drivetrain;
private PIDController pid;
private double angleTolerance;
public SnapLeft(Drivetrain mDrivetrain, IMU mIMU) {
drivetrain = mDrivetrain;
subsysIMU = mIMU;
addRequirements(mDrivetrain, subsysIMU);
}
// Called when the command is initially scheduled.
@Override
public void initialize() {
System.out.println("Snap Left");
DecimalFormat angleFormat = new DecimalFormat("###.##");
// angle bounded from 0 to 360 including negatives
initAngle = (subsysIMU.getAngle() % 360 + 360) % 360;
System.out.println("Initial Angle: " + angleFormat.format(initAngle));
// Find which angle (0, 90, 180, 270) robot is closest to
if (initAngle > (360 - Constants.angleTolerance)) {
newAngle = 90;
} else if (initAngle > (270 - Constants.angleTolerance)) {
newAngle = 360;
} else if (initAngle > (180 - Constants.angleTolerance)) {
newAngle = 270;
} else if (initAngle > (90 - Constants.angleTolerance)) {
newAngle = 180;
} else {
newAngle = 90;
}
System.out.println("Turning to: " + angleFormat.format(newAngle));
System.out.println();
double error = Math.abs(newAngle - initAngle);
// pid constants
double kP = Math.abs(Constants.maxTurnPower / error);
double kD = 0.001;
double kI = 0;
pid = new PIDController(kP, kI, kD);
// angleTolerance = 1.0 / error * 100.0;
pid.setTolerance(Constants.errorTolerance, Constants.speedTolerance);
// pid treats 0 and 360 as the same point for calculationss
pid.enableContinuousInput(0, 360);
}
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
// angle confined from 0 to 360 including negatives
double currAngle = (subsysIMU.getAngle() % 360 + 360) % 360;
// speed dependent on angle distance
double movement = pid.calculate(currAngle, newAngle);
// add bounds on the speed to prevent it from going too fast or slow
movement = Math.signum(movement) *
MathUtil.clamp(Math.abs(movement), Constants.snapMinSpeed, Constants.snapMaxSpeed);
// speed dependent on angle distance
RobotContainer.myRobot.arcadeDrive(-movement, 0, false);
}
// Called once the command ends or is interrupted.
public void end() {
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
// end if the angle is approximately the desired one
if (pid.atSetpoint()) {
return true;
}
else {
return false;
}
}
}
|
3e01bebcc4a74756d9a27009b4d810b8b3da9b18 | 3,504 | java | Java | drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/main/java/org/drools/workbench/screens/guided/dtable/client/widget/analysis/panel/AnalysisReportScreen.java | scandihealth/drools-wb | 9b09c82d97b433c2da1c38b0da1373ef21e92b32 | [
"Apache-2.0"
] | null | null | null | drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/main/java/org/drools/workbench/screens/guided/dtable/client/widget/analysis/panel/AnalysisReportScreen.java | scandihealth/drools-wb | 9b09c82d97b433c2da1c38b0da1373ef21e92b32 | [
"Apache-2.0"
] | null | null | null | drools-wb-screens/drools-wb-guided-dtable-editor/drools-wb-guided-dtable-editor-client/src/main/java/org/drools/workbench/screens/guided/dtable/client/widget/analysis/panel/AnalysisReportScreen.java | scandihealth/drools-wb | 9b09c82d97b433c2da1c38b0da1373ef21e92b32 | [
"Apache-2.0"
] | 1 | 2016-12-20T08:54:38.000Z | 2016-12-20T08:54:38.000Z | 33.371429 | 101 | 0.716039 | 736 | /*
* Copyright 2015 Red Hat, Inc. and/or its affiliates.
*
* 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.drools.workbench.screens.guided.dtable.client.widget.analysis.panel;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.ListDataProvider;
import org.drools.workbench.screens.guided.dtable.client.resources.i18n.GuidedDecisionTableConstants;
import org.drools.workbench.screens.guided.dtable.client.widget.analysis.reporting.Issue;
import org.uberfire.client.annotations.DefaultPosition;
import org.uberfire.client.annotations.WorkbenchPartTitle;
import org.uberfire.client.annotations.WorkbenchPartView;
import org.uberfire.client.annotations.WorkbenchScreen;
import org.uberfire.client.mvp.PlaceManager;
import org.uberfire.client.workbench.events.ClosePlaceEvent;
import org.uberfire.workbench.model.CompassPosition;
import org.uberfire.workbench.model.Position;
@ApplicationScoped
@WorkbenchScreen(identifier = "org.drools.workbench.AnalysisReportScreen", preferredWidth = 360)
public class AnalysisReportScreen {
private static final String IDENTIFIER = "org.drools.workbench.AnalysisReportScreen";
private AnalysisReportScreenView view;
private PlaceManager placeManager;
private final ListDataProvider<Issue> dataProvider = new ListDataProvider<Issue>();
private AnalysisReport currentReport;
public AnalysisReportScreen() {
}
@Inject
public AnalysisReportScreen( final AnalysisReportScreenView view,
final PlaceManager placeManager ) {
this.view = view;
this.placeManager = placeManager;
view.setPresenter( this );
view.setUpDataProvider( dataProvider );
}
public void onDTableClose( @Observes ClosePlaceEvent event ) {
if ( currentReport != null && event.getPlace().equals( currentReport.getPlace() ) ) {
placeManager.closePlace( IDENTIFIER );
}
}
public void showReport( final AnalysisReport report ) {
currentReport = report;
if ( !report.getAnalysisData().isEmpty() ) {
placeManager.goTo( IDENTIFIER );
} else {
placeManager.closePlace( IDENTIFIER );
}
dataProvider.setList( report.getAnalysisData() );
if ( dataProvider.getList().isEmpty() ) {
view.clearIssue();
} else {
view.show( dataProvider.getList().get( 0 ) );
}
}
@DefaultPosition
public Position getDefaultPosition() {
return CompassPosition.EAST;
}
@WorkbenchPartTitle
public String getTitle() {
return GuidedDecisionTableConstants.INSTANCE.Analysis();
}
@WorkbenchPartView
public Widget asWidget() {
return view.asWidget();
}
public void onSelect( final Issue issue ) {
view.show( issue );
}
}
|
3e01c031deb71d71338a6a7e0e0a2f5d0cdca597 | 768 | java | Java | NetflixHystrixCircuitBreaker/caller/src/main/java/com/varun/circuitbreaker/RestaurantService.java | varunmaurya/springboot | c779e9c97203c94d0d1b1a5d5a93d457fe06b848 | [
"MIT"
] | null | null | null | NetflixHystrixCircuitBreaker/caller/src/main/java/com/varun/circuitbreaker/RestaurantService.java | varunmaurya/springboot | c779e9c97203c94d0d1b1a5d5a93d457fe06b848 | [
"MIT"
] | null | null | null | NetflixHystrixCircuitBreaker/caller/src/main/java/com/varun/circuitbreaker/RestaurantService.java | varunmaurya/springboot | c779e9c97203c94d0d1b1a5d5a93d457fe06b848 | [
"MIT"
] | null | null | null | 21.942857 | 70 | 0.707031 | 737 | package com.varun.circuitbreaker;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.net.URI;
/**
* Created by Varun Maurya on 8/28/2018.
*/
@Service
public class RestaurantService {
private final RestTemplate restTemplate;
public RestaurantService(RestTemplate rest) {
this.restTemplate = rest;
}
@HystrixCommand(fallbackMethod = "default_menu")
public String readingList() {
URI uri = URI.create("http://localhost:8090/menu");
return this.restTemplate.getForObject(uri, String.class);
}
public String default_menu() {
return "Tea : $10 \n Coffer : $20";
}
} |
3e01c0b5f7fc98c6ccebc49d5357a20f77296599 | 9,133 | java | Java | android/src/gmvScanner/ui/camera/CameraSourcePreview.java | agoncalvesos/csZBar | ca6f8f6d8cefb4f8cdc520439a1645fe74445502 | [
"Apache-2.0"
] | null | null | null | android/src/gmvScanner/ui/camera/CameraSourcePreview.java | agoncalvesos/csZBar | ca6f8f6d8cefb4f8cdc520439a1645fe74445502 | [
"Apache-2.0"
] | null | null | null | android/src/gmvScanner/ui/camera/CameraSourcePreview.java | agoncalvesos/csZBar | ca6f8f6d8cefb4f8cdc520439a1645fe74445502 | [
"Apache-2.0"
] | null | null | null | 35.536965 | 229 | 0.629914 | 739 | /*
* Copyright (C) The Android Open Source Project
*
* 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.dealrinc.gmvScanner.ui.camera;
import android.Manifest;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.hardware.Camera;
import android.support.annotation.RequiresPermission;
import android.util.AttributeSet;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.ViewGroup;
import android.view.View;
import android.widget.Button;
import com.google.android.gms.common.images.Size;
import java.io.IOException;
public class CameraSourcePreview extends ViewGroup {
private static final String TAG = "CameraSourcePreview";
private Context mContext;
private SurfaceView mSurfaceView;
private View mViewFinderView;
private Button mTorchButton;
private boolean mStartRequested;
private boolean mSurfaceAvailable;
private CameraSource mCameraSource;
public double ViewFinderWidth = .5;
public double ViewFinderHeight = .8;
private GraphicOverlay mOverlay;
public CameraSourcePreview(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
mStartRequested = false;
mSurfaceAvailable = false;
mSurfaceView = new SurfaceView(context);
mSurfaceView.getHolder().addCallback(new SurfaceCallback());
addView(mSurfaceView);
mViewFinderView = new View(mContext);
mViewFinderView.setBackgroundResource(getResources().getIdentifier("rounded_rectangle", "drawable", mContext.getPackageName()));
addView(mViewFinderView);
mTorchButton = new Button(mContext);
mTorchButton.setMaxWidth(50);
mTorchButton.setRotation(90);
mTorchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
mCameraSource.setFlashMode(mCameraSource.getFlashMode() == Camera.Parameters.FLASH_MODE_OFF ? Camera.Parameters.FLASH_MODE_TORCH :Camera.Parameters.FLASH_MODE_OFF);
mTorchButton.setBackgroundResource(getResources().getIdentifier(mCameraSource.getFlashMode() == Camera.Parameters.FLASH_MODE_TORCH ? "torch_active" : "torch_inactive", "drawable", mContext.getPackageName()));
} catch(Exception e) {
}
}
});
addView(mTorchButton);
}
public int dpToPx(int dp) {
float density = mContext.getResources()
.getDisplayMetrics()
.density;
return Math.round((float) dp * density);
}
@RequiresPermission(Manifest.permission.CAMERA)
public void start(CameraSource cameraSource) throws IOException, SecurityException {
if (cameraSource == null) {
stop();
}
mCameraSource = cameraSource;
if (mCameraSource.getFlashMode() == Camera.Parameters.FLASH_MODE_TORCH){
mTorchButton.setBackgroundResource(getResources().getIdentifier("torch_active", "drawable", mContext.getPackageName()));
} else {
mTorchButton.setBackgroundResource(getResources().getIdentifier("torch_inactive", "drawable", mContext.getPackageName()));
}
if (mCameraSource != null) {
mStartRequested = true;
startIfReady();
}
}
@RequiresPermission(Manifest.permission.CAMERA)
public void start(CameraSource cameraSource, GraphicOverlay overlay) throws IOException, SecurityException {
mOverlay = overlay;
start(cameraSource);
}
public void stop() {
if (mCameraSource != null) {
mCameraSource.stop();
}
}
public void release() {
if (mCameraSource != null) {
mCameraSource.release();
mCameraSource = null;
}
}
@RequiresPermission(Manifest.permission.CAMERA)
private void startIfReady() throws IOException, SecurityException {
if (mStartRequested && mSurfaceAvailable) {
mCameraSource.start(mSurfaceView.getHolder());
if (mOverlay != null) {
Size size = mCameraSource.getPreviewSize();
int min = Math.min(size.getWidth(), size.getHeight());
int max = Math.max(size.getWidth(), size.getHeight());
if (isPortraitMode()) {
// Swap width and height sizes when in portrait, since it will be rotated by
// 90 degrees
mOverlay.setCameraInfo(min, max, mCameraSource.getCameraFacing());
} else {
mOverlay.setCameraInfo(max, min, mCameraSource.getCameraFacing());
}
mOverlay.clear();
}
mStartRequested = false;
}
}
private class SurfaceCallback implements SurfaceHolder.Callback {
@Override
public void surfaceCreated(SurfaceHolder surface) {
mSurfaceAvailable = true;
try {
startIfReady();
} catch (SecurityException se) {
Log.e(TAG,"Do not have permission to start the camera", se);
} catch (IOException e) {
Log.e(TAG, "Could not start camera source.", e);
}
}
@Override
public void surfaceDestroyed(SurfaceHolder surface) {
mSurfaceAvailable = false;
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
int width = 320;
int height = 240;
if (mCameraSource != null) {
Size size = mCameraSource.getPreviewSize();
if (size != null) {
width = size.getWidth();
height = size.getHeight();
}
}
// Swap width and height sizes when in portrait, since it will be rotated 90 degrees
if (isPortraitMode()) {
int tmp = width;
//noinspection SuspiciousNameCombination
width = height;
height = tmp;
}
final int layoutWidth = right - left;
final int layoutHeight = bottom - top;
// Computes height and width for potentially doing fit width.
int childHeight = layoutHeight;
int childWidth = (int)(((float) layoutHeight / (float) height) * width);
int leftOffset = ((int)((float) layoutHeight / (float) height) * width - childWidth) / 2;
int topOffset = 0;
if (childHeight > layoutHeight) {
childWidth = layoutWidth;
childHeight = (int)(((float) layoutWidth / (float) width) * height);
leftOffset = 0;
topOffset = ((int)((float) layoutWidth / (float) width) * height - childHeight) / 2;
}
mSurfaceView.layout(leftOffset, topOffset, childWidth, childHeight);
int actualWidth = (int) (layoutWidth*ViewFinderWidth);
int actualHeight = (int) (layoutHeight*ViewFinderHeight);
mViewFinderView.layout(layoutWidth/2 - actualWidth/2,layoutHeight/2 - actualHeight/2, layoutWidth/2 + actualWidth/2, layoutHeight/2 + actualHeight/2);
int buttonSize = dpToPx(45);
int margin = 30;
int torchLeft = layoutWidth - buttonSize - margin;
int torchTop = layoutHeight - buttonSize - margin;
mTorchButton.layout(torchLeft, torchTop, torchLeft + buttonSize, torchTop + buttonSize);
try {
startIfReady();
} catch (SecurityException se) {
Log.e(TAG,"Do not have permission to start the camera", se);
} catch (IOException e) {
Log.e(TAG, "Could not start camera source.", e);
}
}
private boolean isPortraitMode() {
int orientation = mContext.getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
return false;
}
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
return true;
}
Log.d(TAG, "isPortraitMode returning false by default");
return false;
}
public Rect getRect(){
int[] l = new int[2];
mViewFinderView.getLocationOnScreen(l);
Rect rect = new Rect(l[0], l[1], l[0] + mViewFinderView.getWidth(), l[1] + mViewFinderView.getHeight());
return rect;
}
}
|
3e01c11ec83e2a03722057e9e25cf32c558e5b7f | 2,025 | java | Java | hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/slive/ObserveableOp.java | yellowflash/hadoop | aa9cdf2af6fd84aa24ec5a19da4f955472a8d5bd | [
"Apache-2.0",
"BSD-2-Clause",
"MIT",
"ECL-2.0",
"BSD-3-Clause"
] | 14,425 | 2015-01-01T15:34:43.000Z | 2022-03-31T15:28:37.000Z | hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/slive/ObserveableOp.java | yellowflash/hadoop | aa9cdf2af6fd84aa24ec5a19da4f955472a8d5bd | [
"Apache-2.0",
"BSD-2-Clause",
"MIT",
"ECL-2.0",
"BSD-3-Clause"
] | 3,805 | 2015-03-20T15:58:53.000Z | 2022-03-31T23:58:37.000Z | hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/fs/slive/ObserveableOp.java | yellowflash/hadoop | aa9cdf2af6fd84aa24ec5a19da4f955472a8d5bd | [
"Apache-2.0",
"BSD-2-Clause",
"MIT",
"ECL-2.0",
"BSD-3-Clause"
] | 9,521 | 2015-01-01T19:12:52.000Z | 2022-03-31T03:07:51.000Z | 27.739726 | 80 | 0.697778 | 740 | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.fs.slive;
import java.util.List;
import org.apache.hadoop.fs.FileSystem;
/**
* Operation which wraps a given operation and allows an observer to be notified
* when the operation is about to start and when the operation has finished
*/
class ObserveableOp extends Operation {
/**
* The observation interface which class that wish to monitor starting and
* ending events must implement.
*/
interface Observer {
void notifyStarting(Operation op);
void notifyFinished(Operation op);
}
private Operation op;
private Observer observer;
ObserveableOp(Operation op, Observer observer) {
super(op.getType(), op.getConfig(), op.getRandom());
this.op = op;
this.observer = observer;
}
/**
* Proxy to underlying operation toString()
*/
public String toString() {
return op.toString();
}
@Override // Operation
List<OperationOutput> run(FileSystem fs) {
List<OperationOutput> result = null;
try {
if (observer != null) {
observer.notifyStarting(op);
}
result = op.run(fs);
} finally {
if (observer != null) {
observer.notifyFinished(op);
}
}
return result;
}
}
|
3e01c139d572f4082dde173ec2af733511921f0f | 54,107 | java | Java | ExtractedJars/Shopkick_com.shopkick.app/javafiles/io/radar/sdk/model/RadarEvent.java | Andreas237/AndroidPolicyAutomation | c1ed10a2c6d4cf3dfda8b8e6291dee2c2a15ee8a | [
"MIT"
] | 3 | 2019-05-01T09:22:08.000Z | 2019-07-06T22:21:59.000Z | ExtractedJars/Shopkick_com.shopkick.app/javafiles/io/radar/sdk/model/RadarEvent.java | Andreas237/AndroidPolicyAutomation | c1ed10a2c6d4cf3dfda8b8e6291dee2c2a15ee8a | [
"MIT"
] | null | null | null | ExtractedJars/Shopkick_com.shopkick.app/javafiles/io/radar/sdk/model/RadarEvent.java | Andreas237/AndroidPolicyAutomation | c1ed10a2c6d4cf3dfda8b8e6291dee2c2a15ee8a | [
"MIT"
] | 1 | 2020-11-26T12:22:02.000Z | 2020-11-26T12:22:02.000Z | 41.397858 | 254 | 0.573844 | 741 | // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) annotate safe
package io.radar.sdk.model;
import android.location.Location;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import org.json.JSONArray;
import org.json.JSONObject;
// Referenced classes of package io.radar.sdk.model:
// RadarPlace, RadarGeofence
public final class RadarEvent
{
public static final class Companion
{
private final RadarEvent fromJson(JSONObject jsonobject)
{
Object obj;
Date date;
String s2;
label0:
{
s2 = jsonobject.optString("_id");
// 0 0:aload_1
// 1 1:ldc1 #58 <String "_id">
// 2 3:invokevirtual #64 <Method String JSONObject.optString(String)>
// 3 6:astore 17
obj = ((Object) (new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")));
// 4 8:new #66 <Class SimpleDateFormat>
// 5 11:dup
// 6 12:ldc1 #68 <String "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'">
// 7 14:invokespecial #71 <Method void SimpleDateFormat(String)>
// 8 17:astore 8
((SimpleDateFormat) (obj)).setTimeZone(TimeZone.getTimeZone("UTC"));
// 9 19:aload 8
// 10 21:ldc1 #73 <String "UTC">
// 11 23:invokestatic #79 <Method TimeZone TimeZone.getTimeZone(String)>
// 12 26:invokevirtual #83 <Method void SimpleDateFormat.setTimeZone(TimeZone)>
String s = jsonobject.optString("createdAt", ((String) (null)));
// 13 29:aload_1
// 14 30:ldc1 #85 <String "createdAt">
// 15 32:aconst_null
// 16 33:invokevirtual #88 <Method String JSONObject.optString(String, String)>
// 17 36:astore 9
if(s != null)
//* 18 38:aload 9
//* 19 40:ifnull 60
{
date = ((SimpleDateFormat) (obj)).parse(s);
// 20 43:aload 8
// 21 45:aload 9
// 22 47:invokevirtual #92 <Method Date SimpleDateFormat.parse(String)>
// 23 50:astore 11
if(date != null)
//* 24 52:aload 11
//* 25 54:ifnull 60
break label0;
// 26 57:goto 69
}
date = new Date();
// 27 60:new #94 <Class Date>
// 28 63:dup
// 29 64:invokespecial #95 <Method void Date()>
// 30 67:astore 11
}
Date date1;
label1:
{
String s1 = jsonobject.optString("actualCreatedAt", ((String) (null)));
// 31 69:aload_1
// 32 70:ldc1 #97 <String "actualCreatedAt">
// 33 72:aconst_null
// 34 73:invokevirtual #88 <Method String JSONObject.optString(String, String)>
// 35 76:astore 9
if(s1 != null)
//* 36 78:aload 9
//* 37 80:ifnull 100
{
date1 = ((SimpleDateFormat) (obj)).parse(s1);
// 38 83:aload 8
// 39 85:aload 9
// 40 87:invokevirtual #92 <Method Date SimpleDateFormat.parse(String)>
// 41 90:astore 12
if(date1 != null)
//* 42 92:aload 12
//* 43 94:ifnull 100
break label1;
// 44 97:goto 109
}
date1 = new Date();
// 45 100:new #94 <Class Date>
// 46 103:dup
// 47 104:invokespecial #95 <Method void Date()>
// 48 107:astore 12
}
boolean flag;
label2:
{
flag = jsonobject.optBoolean("live");
// 49 109:aload_1
// 50 110:ldc1 #99 <String "live">
// 51 112:invokevirtual #103 <Method boolean JSONObject.optBoolean(String)>
// 52 115:istore 7
obj = ((Object) (jsonobject.optString("type")));
// 53 117:aload_1
// 54 118:ldc1 #105 <String "type">
// 55 120:invokevirtual #64 <Method String JSONObject.optString(String)>
// 56 123:astore 8
if(obj != null)
//* 57 125:aload 8
//* 58 127:ifnonnull 133
//* 59 130:goto 437
switch(((String) (obj)).hashCode())
//* 60 133:aload 8
//* 61 135:invokevirtual #111 <Method int String.hashCode()>
{
default:
break;
//* 62 138:lookupswitch 11: default 236
// -2086465761: 419
// -1716268600: 401
// -1698734565: 383
// -1161746201: 365
// -878348537: 347
// -609787906: 329
// 325491979: 311
// 450282474: 293
// 653871923: 275
// 1081142108: 257
// 1356297932: 239
//* 63 236:goto 437
case 1356297932:
if(((String) (obj)).equals("user.nearby_place_chain"))
//* 64 239:aload 8
//* 65 241:ldc1 #113 <String "user.nearby_place_chain">
//* 66 243:invokevirtual #117 <Method boolean String.equals(Object)>
//* 67 246:ifeq 437
{
obj = ((Object) (RadarEventType.USER_NEARBY_PLACE_CHAIN));
// 68 249:getstatic #123 <Field RadarEvent$RadarEventType RadarEvent$RadarEventType.USER_NEARBY_PLACE_CHAIN>
// 69 252:astore 8
break label2;
// 70 254:goto 442
}
break;
case 1081142108:
if(!((String) (obj)).equals("user.entered_place"))
break;
// 71 257:aload 8
// 72 259:ldc1 #125 <String "user.entered_place">
// 73 261:invokevirtual #117 <Method boolean String.equals(Object)>
// 74 264:ifeq 437
obj = ((Object) (RadarEventType.USER_ENTERED_PLACE));
// 75 267:getstatic #128 <Field RadarEvent$RadarEventType RadarEvent$RadarEventType.USER_ENTERED_PLACE>
// 76 270:astore 8
break label2;
// 77 272:goto 442
case 653871923:
if(!((String) (obj)).equals("user.stopped_traveling"))
break;
// 78 275:aload 8
// 79 277:ldc1 #130 <String "user.stopped_traveling">
// 80 279:invokevirtual #117 <Method boolean String.equals(Object)>
// 81 282:ifeq 437
obj = ((Object) (RadarEventType.USER_STOPPED_TRAVELING));
// 82 285:getstatic #133 <Field RadarEvent$RadarEventType RadarEvent$RadarEventType.USER_STOPPED_TRAVELING>
// 83 288:astore 8
break label2;
// 84 290:goto 442
case 450282474:
if(!((String) (obj)).equals("user.entered_home"))
break;
// 85 293:aload 8
// 86 295:ldc1 #135 <String "user.entered_home">
// 87 297:invokevirtual #117 <Method boolean String.equals(Object)>
// 88 300:ifeq 437
obj = ((Object) (RadarEventType.USER_ENTERED_HOME));
// 89 303:getstatic #138 <Field RadarEvent$RadarEventType RadarEvent$RadarEventType.USER_ENTERED_HOME>
// 90 306:astore 8
break label2;
// 91 308:goto 442
case 325491979:
if(!((String) (obj)).equals("user.entered_geofence"))
break;
// 92 311:aload 8
// 93 313:ldc1 #140 <String "user.entered_geofence">
// 94 315:invokevirtual #117 <Method boolean String.equals(Object)>
// 95 318:ifeq 437
obj = ((Object) (RadarEventType.USER_ENTERED_GEOFENCE));
// 96 321:getstatic #143 <Field RadarEvent$RadarEventType RadarEvent$RadarEventType.USER_ENTERED_GEOFENCE>
// 97 324:astore 8
break label2;
// 98 326:goto 442
case -609787906:
if(!((String) (obj)).equals("user.exited_home"))
break;
// 99 329:aload 8
// 100 331:ldc1 #145 <String "user.exited_home">
// 101 333:invokevirtual #117 <Method boolean String.equals(Object)>
// 102 336:ifeq 437
obj = ((Object) (RadarEventType.USER_EXITED_HOME));
// 103 339:getstatic #148 <Field RadarEvent$RadarEventType RadarEvent$RadarEventType.USER_EXITED_HOME>
// 104 342:astore 8
break label2;
// 105 344:goto 442
case -878348537:
if(!((String) (obj)).equals("user.entered_office"))
break;
// 106 347:aload 8
// 107 349:ldc1 #150 <String "user.entered_office">
// 108 351:invokevirtual #117 <Method boolean String.equals(Object)>
// 109 354:ifeq 437
obj = ((Object) (RadarEventType.USER_ENTERED_OFFICE));
// 110 357:getstatic #153 <Field RadarEvent$RadarEventType RadarEvent$RadarEventType.USER_ENTERED_OFFICE>
// 111 360:astore 8
break label2;
// 112 362:goto 442
case -1161746201:
if(!((String) (obj)).equals("user.started_traveling"))
break;
// 113 365:aload 8
// 114 367:ldc1 #155 <String "user.started_traveling">
// 115 369:invokevirtual #117 <Method boolean String.equals(Object)>
// 116 372:ifeq 437
obj = ((Object) (RadarEventType.USER_STARTED_TRAVELING));
// 117 375:getstatic #158 <Field RadarEvent$RadarEventType RadarEvent$RadarEventType.USER_STARTED_TRAVELING>
// 118 378:astore 8
break label2;
// 119 380:goto 442
case -1698734565:
if(!((String) (obj)).equals("user.exited_office"))
break;
// 120 383:aload 8
// 121 385:ldc1 #160 <String "user.exited_office">
// 122 387:invokevirtual #117 <Method boolean String.equals(Object)>
// 123 390:ifeq 437
obj = ((Object) (RadarEventType.USER_EXITED_OFFICE));
// 124 393:getstatic #163 <Field RadarEvent$RadarEventType RadarEvent$RadarEventType.USER_EXITED_OFFICE>
// 125 396:astore 8
break label2;
// 126 398:goto 442
case -1716268600:
if(!((String) (obj)).equals("user.exited_place"))
break;
// 127 401:aload 8
// 128 403:ldc1 #165 <String "user.exited_place">
// 129 405:invokevirtual #117 <Method boolean String.equals(Object)>
// 130 408:ifeq 437
obj = ((Object) (RadarEventType.USER_EXITED_PLACE));
// 131 411:getstatic #168 <Field RadarEvent$RadarEventType RadarEvent$RadarEventType.USER_EXITED_PLACE>
// 132 414:astore 8
break label2;
// 133 416:goto 442
case -2086465761:
if(!((String) (obj)).equals("user.exited_geofence"))
break;
// 134 419:aload 8
// 135 421:ldc1 #170 <String "user.exited_geofence">
// 136 423:invokevirtual #117 <Method boolean String.equals(Object)>
// 137 426:ifeq 437
obj = ((Object) (RadarEventType.USER_EXITED_GEOFENCE));
// 138 429:getstatic #173 <Field RadarEvent$RadarEventType RadarEvent$RadarEventType.USER_EXITED_GEOFENCE>
// 139 432:astore 8
break label2;
// 140 434:goto 442
}
obj = ((Object) (RadarEventType.UNKNOWN));
// 141 437:getstatic #176 <Field RadarEvent$RadarEventType RadarEvent$RadarEventType.UNKNOWN>
// 142 440:astore 8
}
RadarGeofence radargeofence = RadarGeofence.Companion.fromJson(jsonobject.optJSONObject("geofence"));
// 143 442:getstatic #181 <Field RadarGeofence$Companion RadarGeofence.Companion>
// 144 445:aload_1
// 145 446:ldc1 #183 <String "geofence">
// 146 448:invokevirtual #187 <Method JSONObject JSONObject.optJSONObject(String)>
// 147 451:invokevirtual #192 <Method RadarGeofence RadarGeofence$Companion.fromJson(JSONObject)>
// 148 454:astore 18
Object obj1 = ((Object) (jsonobject.optJSONObject("place")));
// 149 456:aload_1
// 150 457:ldc1 #194 <String "place">
// 151 459:invokevirtual #187 <Method JSONObject JSONObject.optJSONObject(String)>
// 152 462:astore 9
RadarPlace radarplace;
if(obj1 != null)
//* 153 464:aload 9
//* 154 466:ifnull 482
radarplace = RadarPlace.Companion.fromJson(((JSONObject) (obj1)));
// 155 469:getstatic #199 <Field RadarPlace$Companion RadarPlace.Companion>
// 156 472:aload 9
// 157 474:invokevirtual #204 <Method RadarPlace RadarPlace$Companion.fromJson(JSONObject)>
// 158 477:astore 13
else
//* 159 479:goto 485
radarplace = null;
// 160 482:aconst_null
// 161 483:astore 13
Object obj2 = ((Object) (jsonobject.optJSONArray("alternatePlaces")));
// 162 485:aload_1
// 163 486:ldc1 #206 <String "alternatePlaces">
// 164 488:invokevirtual #210 <Method JSONArray JSONObject.optJSONArray(String)>
// 165 491:astore 15
RadarPlace aradarplace1[];
if(obj2 != null)
//* 166 493:aload 15
//* 167 495:ifnull 573
{
RadarPlace aradarplace[] = new RadarPlace[((JSONArray) (obj2)).length()];
// 168 498:aload 15
// 169 500:invokevirtual #215 <Method int JSONArray.length()>
// 170 503:anewarray RadarPlace[]
// 171 506:astore 10
int k = aradarplace.length;
// 172 508:aload 10
// 173 510:arraylength
// 174 511:istore 6
int i = 0;
// 175 513:iconst_0
// 176 514:istore 5
do
{
aradarplace1 = aradarplace;
// 177 516:aload 10
// 178 518:astore 14
if(i >= k)
break;
// 179 520:iload 5
// 180 522:iload 6
// 181 524:icmpge 576
obj1 = ((Object) (((JSONArray) (obj2)).optJSONObject(i)));
// 182 527:aload 15
// 183 529:iload 5
// 184 531:invokevirtual #218 <Method JSONObject JSONArray.optJSONObject(int)>
// 185 534:astore 9
if(obj1 != null)
//* 186 536:aload 9
//* 187 538:ifnull 554
obj1 = ((Object) (RadarPlace.Companion.fromJson(((JSONObject) (obj1)))));
// 188 541:getstatic #199 <Field RadarPlace$Companion RadarPlace.Companion>
// 189 544:aload 9
// 190 546:invokevirtual #204 <Method RadarPlace RadarPlace$Companion.fromJson(JSONObject)>
// 191 549:astore 9
else
//* 192 551:goto 557
obj1 = null;
// 193 554:aconst_null
// 194 555:astore 9
aradarplace[i] = ((RadarPlace) (obj1));
// 195 557:aload 10
// 196 559:iload 5
// 197 561:aload 9
// 198 563:aastore
i++;
// 199 564:iload 5
// 200 566:iconst_1
// 201 567:iadd
// 202 568:istore 5
} while(true);
// 203 570:goto 516
} else
{
aradarplace1 = null;
// 204 573:aconst_null
// 205 574:astore 14
}
obj1 = ((Object) (jsonobject.optJSONObject("verifiedPlace")));
// 206 576:aload_1
// 207 577:ldc1 #220 <String "verifiedPlace">
// 208 579:invokevirtual #187 <Method JSONObject JSONObject.optJSONObject(String)>
// 209 582:astore 9
if(obj1 != null)
//* 210 584:aload 9
//* 211 586:ifnull 602
obj2 = ((Object) (RadarPlace.Companion.fromJson(((JSONObject) (obj1)))));
// 212 589:getstatic #199 <Field RadarPlace$Companion RadarPlace.Companion>
// 213 592:aload 9
// 214 594:invokevirtual #204 <Method RadarPlace RadarPlace$Companion.fromJson(JSONObject)>
// 215 597:astore 15
else
//* 216 599:goto 605
obj2 = null;
// 217 602:aconst_null
// 218 603:astore 15
int j = jsonobject.optInt("verification");
// 219 605:aload_1
// 220 606:ldc1 #222 <String "verification">
// 221 608:invokevirtual #226 <Method int JSONObject.optInt(String)>
// 222 611:istore 5
RadarEventVerification radareventverification;
if(j != -1)
//* 223 613:iload 5
//* 224 615:iconst_m1
//* 225 616:icmpeq 641
{
if(j != 1)
//* 226 619:iload 5
//* 227 621:iconst_1
//* 228 622:icmpeq 633
radareventverification = RadarEventVerification.UNVERIFY;
// 229 625:getstatic #232 <Field RadarEvent$RadarEventVerification RadarEvent$RadarEventVerification.UNVERIFY>
// 230 628:astore 10
else
//* 231 630:goto 646
radareventverification = RadarEventVerification.ACCEPT;
// 232 633:getstatic #235 <Field RadarEvent$RadarEventVerification RadarEvent$RadarEventVerification.ACCEPT>
// 233 636:astore 10
} else
//* 234 638:goto 646
{
radareventverification = RadarEventVerification.REJECT;
// 235 641:getstatic #238 <Field RadarEvent$RadarEventVerification RadarEvent$RadarEventVerification.REJECT>
// 236 644:astore 10
}
switch(jsonobject.optInt("confidence"))
//* 237 646:aload_1
//* 238 647:ldc1 #240 <String "confidence">
//* 239 649:invokevirtual #226 <Method int JSONObject.optInt(String)>
{
//* 240 652:tableswitch 1 3: default 680
// 1 704
// 2 696
// 3 688
default:
obj1 = ((Object) (RadarEventConfidence.NONE));
// 241 680:getstatic #246 <Field RadarEvent$RadarEventConfidence RadarEvent$RadarEventConfidence.NONE>
// 242 683:astore 9
break;
//* 243 685:goto 709
case 3: // '\003'
obj1 = ((Object) (RadarEventConfidence.HIGH));
// 244 688:getstatic #249 <Field RadarEvent$RadarEventConfidence RadarEvent$RadarEventConfidence.HIGH>
// 245 691:astore 9
break;
//* 246 693:goto 709
case 2: // '\002'
obj1 = ((Object) (RadarEventConfidence.MEDIUM));
// 247 696:getstatic #252 <Field RadarEvent$RadarEventConfidence RadarEvent$RadarEventConfidence.MEDIUM>
// 248 699:astore 9
break;
//* 249 701:goto 709
case 1: // '\001'
obj1 = ((Object) (RadarEventConfidence.LOW));
// 250 704:getstatic #255 <Field RadarEvent$RadarEventConfidence RadarEvent$RadarEventConfidence.LOW>
// 251 707:astore 9
break;
}
float f = (float)jsonobject.optDouble("duration", 0.0D);
// 252 709:aload_1
// 253 710:ldc2 #257 <String "duration">
// 254 713:dconst_0
// 255 714:invokevirtual #261 <Method double JSONObject.optDouble(String, double)>
// 256 717:d2f
// 257 718:fstore 4
Object obj3 = ((Object) (jsonobject.optJSONObject("location")));
// 258 720:aload_1
// 259 721:ldc2 #263 <String "location">
// 260 724:invokevirtual #187 <Method JSONObject JSONObject.optJSONObject(String)>
// 261 727:astore 16
if(obj3 != null)
//* 262 729:aload 16
//* 263 731:ifnull 747
obj3 = ((Object) (((JSONObject) (obj3)).optJSONArray("coordinates")));
// 264 734:aload 16
// 265 736:ldc2 #265 <String "coordinates">
// 266 739:invokevirtual #210 <Method JSONArray JSONObject.optJSONArray(String)>
// 267 742:astore 16
else
//* 268 744:goto 750
obj3 = null;
// 269 747:aconst_null
// 270 748:astore 16
Location location1 = new Location("radar");
// 271 750:new #267 <Class Location>
// 272 753:dup
// 273 754:ldc2 #269 <String "radar">
// 274 757:invokespecial #270 <Method void Location(String)>
// 275 760:astore 19
double d;
if(obj3 != null)
//* 276 762:aload 16
//* 277 764:ifnull 777
d = ((JSONArray) (obj3)).optDouble(0);
// 278 767:aload 16
// 279 769:iconst_0
// 280 770:invokevirtual #273 <Method double JSONArray.optDouble(int)>
// 281 773:dstore_2
else
//* 282 774:goto 779
d = 0.0D;
// 283 777:dconst_0
// 284 778:dstore_2
location1.setLongitude(d);
// 285 779:aload 19
// 286 781:dload_2
// 287 782:invokevirtual #277 <Method void Location.setLongitude(double)>
if(obj3 != null)
//* 288 785:aload 16
//* 289 787:ifnull 800
d = ((JSONArray) (obj3)).optDouble(1);
// 290 790:aload 16
// 291 792:iconst_1
// 292 793:invokevirtual #273 <Method double JSONArray.optDouble(int)>
// 293 796:dstore_2
else
//* 294 797:goto 802
d = 0.0D;
// 295 800:dconst_0
// 296 801:dstore_2
location1.setLatitude(d);
// 297 802:aload 19
// 298 804:dload_2
// 299 805:invokevirtual #280 <Method void Location.setLatitude(double)>
if(jsonobject.has("locationAccuracy"))
//* 300 808:aload_1
//* 301 809:ldc2 #282 <String "locationAccuracy">
//* 302 812:invokevirtual #285 <Method boolean JSONObject.has(String)>
//* 303 815:ifeq 831
location1.setAccuracy((float)jsonobject.getDouble("locationAccuracy"));
// 304 818:aload 19
// 305 820:aload_1
// 306 821:ldc2 #282 <String "locationAccuracy">
// 307 824:invokevirtual #289 <Method double JSONObject.getDouble(String)>
// 308 827:d2f
// 309 828:invokevirtual #293 <Method void Location.setAccuracy(float)>
location1.setTime(date.getTime());
// 310 831:aload 19
// 311 833:aload 11
// 312 835:invokevirtual #297 <Method long Date.getTime()>
// 313 838:invokevirtual #301 <Method void Location.setTime(long)>
Intrinsics.checkExpressionValueIsNotNull(((Object) (s2)), "id");
// 314 841:aload 17
// 315 843:ldc2 #303 <String "id">
// 316 846:invokestatic #309 <Method void Intrinsics.checkExpressionValueIsNotNull(Object, String)>
return new RadarEvent(s2, date, date1, flag, ((RadarEventType) (obj)), radargeofence, radarplace, aradarplace1, ((RadarPlace) (obj2)), radareventverification, ((RadarEventConfidence) (obj1)), f, location1);
// 317 849:new #6 <Class RadarEvent>
// 318 852:dup
// 319 853:aload 17
// 320 855:aload 11
// 321 857:aload 12
// 322 859:iload 7
// 323 861:aload 8
// 324 863:aload 18
// 325 865:aload 13
// 326 867:aload 14
// 327 869:aload 15
// 328 871:aload 10
// 329 873:aload 9
// 330 875:fload 4
// 331 877:aload 19
// 332 879:invokespecial #312 <Method void RadarEvent(String, Date, Date, boolean, RadarEvent$RadarEventType, RadarGeofence, RadarPlace, RadarPlace[], RadarPlace, RadarEvent$RadarEventVerification, RadarEvent$RadarEventConfidence, float, Location)>
// 333 882:areturn
}
public final RadarEvent[] eventsFromJSONArray$sdk_release(JSONArray jsonarray)
{
Intrinsics.checkParameterIsNotNull(((Object) (jsonarray)), "array");
// 0 0:aload_1
// 1 1:ldc2 #315 <String "array">
// 2 4:invokestatic #318 <Method void Intrinsics.checkParameterIsNotNull(Object, String)>
RadarEvent aradarevent[] = new RadarEvent[jsonarray.length()];
// 3 7:aload_1
// 4 8:invokevirtual #215 <Method int JSONArray.length()>
// 5 11:anewarray RadarEvent[]
// 6 14:astore 5
int j = aradarevent.length;
// 7 16:aload 5
// 8 18:arraylength
// 9 19:istore_3
for(int i = 0; i < j; i++)
//* 10 20:iconst_0
//* 11 21:istore_2
//* 12 22:iload_2
//* 13 23:iload_3
//* 14 24:icmpge 74
{
Companion companion = RadarEvent.Companion;
// 15 27:getstatic #320 <Field RadarEvent$Companion RadarEvent.Companion>
// 16 30:astore 6
JSONObject jsonobject = jsonarray.optJSONObject(i);
// 17 32:aload_1
// 18 33:iload_2
// 19 34:invokevirtual #218 <Method JSONObject JSONArray.optJSONObject(int)>
// 20 37:astore 4
if(jsonobject == null)
//* 21 39:aload 4
//* 22 41:ifnull 47
//* 23 44:goto 56
jsonobject = new JSONObject();
// 24 47:new #60 <Class JSONObject>
// 25 50:dup
// 26 51:invokespecial #321 <Method void JSONObject()>
// 27 54:astore 4
aradarevent[i] = companion.fromJson(jsonobject);
// 28 56:aload 5
// 29 58:iload_2
// 30 59:aload 6
// 31 61:aload 4
// 32 63:invokespecial #323 <Method RadarEvent fromJson(JSONObject)>
// 33 66:aastore
}
// 34 67:iload_2
// 35 68:iconst_1
// 36 69:iadd
// 37 70:istore_2
//* 38 71:goto 22
return aradarevent;
// 39 74:aload 5
// 40 76:areturn
}
private Companion()
{
// 0 0:aload_0
// 1 1:invokespecial #49 <Method void Object()>
// 2 4:return
}
public Companion(DefaultConstructorMarker defaultconstructormarker)
{
this();
// 0 0:aload_0
// 1 1:invokespecial #52 <Method void RadarEvent$Companion()>
// 2 4:return
}
}
public static final class RadarEventConfidence extends Enum
{
public static RadarEventConfidence valueOf(String s)
{
return (RadarEventConfidence)Enum.valueOf(io/radar/sdk/model/RadarEvent$RadarEventConfidence, s);
// 0 0:ldc1 #2 <Class RadarEvent$RadarEventConfidence>
// 1 2:aload_0
// 2 3:invokestatic #56 <Method Enum Enum.valueOf(Class, String)>
// 3 6:checkcast #2 <Class RadarEvent$RadarEventConfidence>
// 4 9:areturn
}
public static RadarEventConfidence[] values()
{
return (RadarEventConfidence[])((RadarEventConfidence []) ($VALUES)).clone();
// 0 0:getstatic #48 <Field RadarEvent$RadarEventConfidence[] $VALUES>
// 1 3:invokevirtual #63 <Method Object _5B_Lio.radar.sdk.model.RadarEvent$RadarEventConfidence_3B_.clone()>
// 2 6:checkcast #59 <Class RadarEvent$RadarEventConfidence[]>
// 3 9:areturn
}
private static final RadarEventConfidence $VALUES[];
public static final RadarEventConfidence HIGH;
public static final RadarEventConfidence LOW;
public static final RadarEventConfidence MEDIUM;
public static final RadarEventConfidence NONE;
static
{
RadarEventConfidence radareventconfidence = new RadarEventConfidence("NONE", 0);
// 0 0:new #2 <Class RadarEvent$RadarEventConfidence>
// 1 3:dup
// 2 4:ldc1 #32 <String "NONE">
// 3 6:iconst_0
// 4 7:invokespecial #35 <Method void RadarEvent$RadarEventConfidence(String, int)>
// 5 10:astore_0
NONE = radareventconfidence;
// 6 11:aload_0
// 7 12:putstatic #37 <Field RadarEvent$RadarEventConfidence NONE>
RadarEventConfidence radareventconfidence1 = new RadarEventConfidence("LOW", 1);
// 8 15:new #2 <Class RadarEvent$RadarEventConfidence>
// 9 18:dup
// 10 19:ldc1 #38 <String "LOW">
// 11 21:iconst_1
// 12 22:invokespecial #35 <Method void RadarEvent$RadarEventConfidence(String, int)>
// 13 25:astore_1
LOW = radareventconfidence1;
// 14 26:aload_1
// 15 27:putstatic #40 <Field RadarEvent$RadarEventConfidence LOW>
RadarEventConfidence radareventconfidence2 = new RadarEventConfidence("MEDIUM", 2);
// 16 30:new #2 <Class RadarEvent$RadarEventConfidence>
// 17 33:dup
// 18 34:ldc1 #41 <String "MEDIUM">
// 19 36:iconst_2
// 20 37:invokespecial #35 <Method void RadarEvent$RadarEventConfidence(String, int)>
// 21 40:astore_2
MEDIUM = radareventconfidence2;
// 22 41:aload_2
// 23 42:putstatic #43 <Field RadarEvent$RadarEventConfidence MEDIUM>
RadarEventConfidence radareventconfidence3 = new RadarEventConfidence("HIGH", 3);
// 24 45:new #2 <Class RadarEvent$RadarEventConfidence>
// 25 48:dup
// 26 49:ldc1 #44 <String "HIGH">
// 27 51:iconst_3
// 28 52:invokespecial #35 <Method void RadarEvent$RadarEventConfidence(String, int)>
// 29 55:astore_3
HIGH = radareventconfidence3;
// 30 56:aload_3
// 31 57:putstatic #46 <Field RadarEvent$RadarEventConfidence HIGH>
$VALUES = (new RadarEventConfidence[] {
radareventconfidence, radareventconfidence1, radareventconfidence2, radareventconfidence3
});
// 32 60:iconst_4
// 33 61:anewarray RadarEventConfidence[]
// 34 64:dup
// 35 65:iconst_0
// 36 66:aload_0
// 37 67:aastore
// 38 68:dup
// 39 69:iconst_1
// 40 70:aload_1
// 41 71:aastore
// 42 72:dup
// 43 73:iconst_2
// 44 74:aload_2
// 45 75:aastore
// 46 76:dup
// 47 77:iconst_3
// 48 78:aload_3
// 49 79:aastore
// 50 80:putstatic #48 <Field RadarEvent$RadarEventConfidence[] $VALUES>
//* 51 83:return
}
protected RadarEventConfidence(String s, int i)
{
super(s, i);
// 0 0:aload_0
// 1 1:aload_1
// 2 2:iload_2
// 3 3:invokespecial #50 <Method void Enum(String, int)>
// 4 6:return
}
}
public static final class RadarEventType extends Enum
{
public static RadarEventType valueOf(String s)
{
return (RadarEventType)Enum.valueOf(io/radar/sdk/model/RadarEvent$RadarEventType, s);
// 0 0:ldc1 #2 <Class RadarEvent$RadarEventType>
// 1 2:aload_0
// 2 3:invokestatic #88 <Method Enum Enum.valueOf(Class, String)>
// 3 6:checkcast #2 <Class RadarEvent$RadarEventType>
// 4 9:areturn
}
public static RadarEventType[] values()
{
return (RadarEventType[])((RadarEventType []) ($VALUES)).clone();
// 0 0:getstatic #80 <Field RadarEvent$RadarEventType[] $VALUES>
// 1 3:invokevirtual #95 <Method Object _5B_Lio.radar.sdk.model.RadarEvent$RadarEventType_3B_.clone()>
// 2 6:checkcast #91 <Class RadarEvent$RadarEventType[]>
// 3 9:areturn
}
private static final RadarEventType $VALUES[];
public static final RadarEventType UNKNOWN;
public static final RadarEventType USER_ENTERED_GEOFENCE;
public static final RadarEventType USER_ENTERED_HOME;
public static final RadarEventType USER_ENTERED_OFFICE;
public static final RadarEventType USER_ENTERED_PLACE;
public static final RadarEventType USER_EXITED_GEOFENCE;
public static final RadarEventType USER_EXITED_HOME;
public static final RadarEventType USER_EXITED_OFFICE;
public static final RadarEventType USER_EXITED_PLACE;
public static final RadarEventType USER_NEARBY_PLACE_CHAIN;
public static final RadarEventType USER_STARTED_TRAVELING;
public static final RadarEventType USER_STOPPED_TRAVELING;
static
{
RadarEventType radareventtype = new RadarEventType("UNKNOWN", 0);
// 0 0:new #2 <Class RadarEvent$RadarEventType>
// 1 3:dup
// 2 4:ldc1 #40 <String "UNKNOWN">
// 3 6:iconst_0
// 4 7:invokespecial #43 <Method void RadarEvent$RadarEventType(String, int)>
// 5 10:astore_0
UNKNOWN = radareventtype;
// 6 11:aload_0
// 7 12:putstatic #45 <Field RadarEvent$RadarEventType UNKNOWN>
RadarEventType radareventtype1 = new RadarEventType("USER_ENTERED_GEOFENCE", 1);
// 8 15:new #2 <Class RadarEvent$RadarEventType>
// 9 18:dup
// 10 19:ldc1 #46 <String "USER_ENTERED_GEOFENCE">
// 11 21:iconst_1
// 12 22:invokespecial #43 <Method void RadarEvent$RadarEventType(String, int)>
// 13 25:astore_1
USER_ENTERED_GEOFENCE = radareventtype1;
// 14 26:aload_1
// 15 27:putstatic #48 <Field RadarEvent$RadarEventType USER_ENTERED_GEOFENCE>
RadarEventType radareventtype2 = new RadarEventType("USER_EXITED_GEOFENCE", 2);
// 16 30:new #2 <Class RadarEvent$RadarEventType>
// 17 33:dup
// 18 34:ldc1 #49 <String "USER_EXITED_GEOFENCE">
// 19 36:iconst_2
// 20 37:invokespecial #43 <Method void RadarEvent$RadarEventType(String, int)>
// 21 40:astore_2
USER_EXITED_GEOFENCE = radareventtype2;
// 22 41:aload_2
// 23 42:putstatic #51 <Field RadarEvent$RadarEventType USER_EXITED_GEOFENCE>
RadarEventType radareventtype3 = new RadarEventType("USER_ENTERED_HOME", 3);
// 24 45:new #2 <Class RadarEvent$RadarEventType>
// 25 48:dup
// 26 49:ldc1 #52 <String "USER_ENTERED_HOME">
// 27 51:iconst_3
// 28 52:invokespecial #43 <Method void RadarEvent$RadarEventType(String, int)>
// 29 55:astore_3
USER_ENTERED_HOME = radareventtype3;
// 30 56:aload_3
// 31 57:putstatic #54 <Field RadarEvent$RadarEventType USER_ENTERED_HOME>
RadarEventType radareventtype4 = new RadarEventType("USER_EXITED_HOME", 4);
// 32 60:new #2 <Class RadarEvent$RadarEventType>
// 33 63:dup
// 34 64:ldc1 #55 <String "USER_EXITED_HOME">
// 35 66:iconst_4
// 36 67:invokespecial #43 <Method void RadarEvent$RadarEventType(String, int)>
// 37 70:astore 4
USER_EXITED_HOME = radareventtype4;
// 38 72:aload 4
// 39 74:putstatic #57 <Field RadarEvent$RadarEventType USER_EXITED_HOME>
RadarEventType radareventtype5 = new RadarEventType("USER_ENTERED_OFFICE", 5);
// 40 77:new #2 <Class RadarEvent$RadarEventType>
// 41 80:dup
// 42 81:ldc1 #58 <String "USER_ENTERED_OFFICE">
// 43 83:iconst_5
// 44 84:invokespecial #43 <Method void RadarEvent$RadarEventType(String, int)>
// 45 87:astore 5
USER_ENTERED_OFFICE = radareventtype5;
// 46 89:aload 5
// 47 91:putstatic #60 <Field RadarEvent$RadarEventType USER_ENTERED_OFFICE>
RadarEventType radareventtype6 = new RadarEventType("USER_EXITED_OFFICE", 6);
// 48 94:new #2 <Class RadarEvent$RadarEventType>
// 49 97:dup
// 50 98:ldc1 #61 <String "USER_EXITED_OFFICE">
// 51 100:bipush 6
// 52 102:invokespecial #43 <Method void RadarEvent$RadarEventType(String, int)>
// 53 105:astore 6
USER_EXITED_OFFICE = radareventtype6;
// 54 107:aload 6
// 55 109:putstatic #63 <Field RadarEvent$RadarEventType USER_EXITED_OFFICE>
RadarEventType radareventtype7 = new RadarEventType("USER_STARTED_TRAVELING", 7);
// 56 112:new #2 <Class RadarEvent$RadarEventType>
// 57 115:dup
// 58 116:ldc1 #64 <String "USER_STARTED_TRAVELING">
// 59 118:bipush 7
// 60 120:invokespecial #43 <Method void RadarEvent$RadarEventType(String, int)>
// 61 123:astore 7
USER_STARTED_TRAVELING = radareventtype7;
// 62 125:aload 7
// 63 127:putstatic #66 <Field RadarEvent$RadarEventType USER_STARTED_TRAVELING>
RadarEventType radareventtype8 = new RadarEventType("USER_STOPPED_TRAVELING", 8);
// 64 130:new #2 <Class RadarEvent$RadarEventType>
// 65 133:dup
// 66 134:ldc1 #67 <String "USER_STOPPED_TRAVELING">
// 67 136:bipush 8
// 68 138:invokespecial #43 <Method void RadarEvent$RadarEventType(String, int)>
// 69 141:astore 8
USER_STOPPED_TRAVELING = radareventtype8;
// 70 143:aload 8
// 71 145:putstatic #69 <Field RadarEvent$RadarEventType USER_STOPPED_TRAVELING>
RadarEventType radareventtype9 = new RadarEventType("USER_ENTERED_PLACE", 9);
// 72 148:new #2 <Class RadarEvent$RadarEventType>
// 73 151:dup
// 74 152:ldc1 #70 <String "USER_ENTERED_PLACE">
// 75 154:bipush 9
// 76 156:invokespecial #43 <Method void RadarEvent$RadarEventType(String, int)>
// 77 159:astore 9
USER_ENTERED_PLACE = radareventtype9;
// 78 161:aload 9
// 79 163:putstatic #72 <Field RadarEvent$RadarEventType USER_ENTERED_PLACE>
RadarEventType radareventtype10 = new RadarEventType("USER_EXITED_PLACE", 10);
// 80 166:new #2 <Class RadarEvent$RadarEventType>
// 81 169:dup
// 82 170:ldc1 #73 <String "USER_EXITED_PLACE">
// 83 172:bipush 10
// 84 174:invokespecial #43 <Method void RadarEvent$RadarEventType(String, int)>
// 85 177:astore 10
USER_EXITED_PLACE = radareventtype10;
// 86 179:aload 10
// 87 181:putstatic #75 <Field RadarEvent$RadarEventType USER_EXITED_PLACE>
RadarEventType radareventtype11 = new RadarEventType("USER_NEARBY_PLACE_CHAIN", 11);
// 88 184:new #2 <Class RadarEvent$RadarEventType>
// 89 187:dup
// 90 188:ldc1 #76 <String "USER_NEARBY_PLACE_CHAIN">
// 91 190:bipush 11
// 92 192:invokespecial #43 <Method void RadarEvent$RadarEventType(String, int)>
// 93 195:astore 11
USER_NEARBY_PLACE_CHAIN = radareventtype11;
// 94 197:aload 11
// 95 199:putstatic #78 <Field RadarEvent$RadarEventType USER_NEARBY_PLACE_CHAIN>
$VALUES = (new RadarEventType[] {
radareventtype, radareventtype1, radareventtype2, radareventtype3, radareventtype4, radareventtype5, radareventtype6, radareventtype7, radareventtype8, radareventtype9,
radareventtype10, radareventtype11
});
// 96 202:bipush 12
// 97 204:anewarray RadarEventType[]
// 98 207:dup
// 99 208:iconst_0
// 100 209:aload_0
// 101 210:aastore
// 102 211:dup
// 103 212:iconst_1
// 104 213:aload_1
// 105 214:aastore
// 106 215:dup
// 107 216:iconst_2
// 108 217:aload_2
// 109 218:aastore
// 110 219:dup
// 111 220:iconst_3
// 112 221:aload_3
// 113 222:aastore
// 114 223:dup
// 115 224:iconst_4
// 116 225:aload 4
// 117 227:aastore
// 118 228:dup
// 119 229:iconst_5
// 120 230:aload 5
// 121 232:aastore
// 122 233:dup
// 123 234:bipush 6
// 124 236:aload 6
// 125 238:aastore
// 126 239:dup
// 127 240:bipush 7
// 128 242:aload 7
// 129 244:aastore
// 130 245:dup
// 131 246:bipush 8
// 132 248:aload 8
// 133 250:aastore
// 134 251:dup
// 135 252:bipush 9
// 136 254:aload 9
// 137 256:aastore
// 138 257:dup
// 139 258:bipush 10
// 140 260:aload 10
// 141 262:aastore
// 142 263:dup
// 143 264:bipush 11
// 144 266:aload 11
// 145 268:aastore
// 146 269:putstatic #80 <Field RadarEvent$RadarEventType[] $VALUES>
//* 147 272:return
}
protected RadarEventType(String s, int i)
{
super(s, i);
// 0 0:aload_0
// 1 1:aload_1
// 2 2:iload_2
// 3 3:invokespecial #82 <Method void Enum(String, int)>
// 4 6:return
}
}
public static final class RadarEventVerification extends Enum
{
public static RadarEventVerification valueOf(String s)
{
return (RadarEventVerification)Enum.valueOf(io/radar/sdk/model/RadarEvent$RadarEventVerification, s);
// 0 0:ldc1 #2 <Class RadarEvent$RadarEventVerification>
// 1 2:aload_0
// 2 3:invokestatic #52 <Method Enum Enum.valueOf(Class, String)>
// 3 6:checkcast #2 <Class RadarEvent$RadarEventVerification>
// 4 9:areturn
}
public static RadarEventVerification[] values()
{
return (RadarEventVerification[])((RadarEventVerification []) ($VALUES)).clone();
// 0 0:getstatic #44 <Field RadarEvent$RadarEventVerification[] $VALUES>
// 1 3:invokevirtual #59 <Method Object _5B_Lio.radar.sdk.model.RadarEvent$RadarEventVerification_3B_.clone()>
// 2 6:checkcast #55 <Class RadarEvent$RadarEventVerification[]>
// 3 9:areturn
}
private static final RadarEventVerification $VALUES[];
public static final RadarEventVerification ACCEPT;
public static final RadarEventVerification REJECT;
public static final RadarEventVerification UNVERIFY;
static
{
RadarEventVerification radareventverification = new RadarEventVerification("ACCEPT", 0);
// 0 0:new #2 <Class RadarEvent$RadarEventVerification>
// 1 3:dup
// 2 4:ldc1 #31 <String "ACCEPT">
// 3 6:iconst_0
// 4 7:invokespecial #34 <Method void RadarEvent$RadarEventVerification(String, int)>
// 5 10:astore_0
ACCEPT = radareventverification;
// 6 11:aload_0
// 7 12:putstatic #36 <Field RadarEvent$RadarEventVerification ACCEPT>
RadarEventVerification radareventverification1 = new RadarEventVerification("UNVERIFY", 1);
// 8 15:new #2 <Class RadarEvent$RadarEventVerification>
// 9 18:dup
// 10 19:ldc1 #37 <String "UNVERIFY">
// 11 21:iconst_1
// 12 22:invokespecial #34 <Method void RadarEvent$RadarEventVerification(String, int)>
// 13 25:astore_1
UNVERIFY = radareventverification1;
// 14 26:aload_1
// 15 27:putstatic #39 <Field RadarEvent$RadarEventVerification UNVERIFY>
RadarEventVerification radareventverification2 = new RadarEventVerification("REJECT", 2);
// 16 30:new #2 <Class RadarEvent$RadarEventVerification>
// 17 33:dup
// 18 34:ldc1 #40 <String "REJECT">
// 19 36:iconst_2
// 20 37:invokespecial #34 <Method void RadarEvent$RadarEventVerification(String, int)>
// 21 40:astore_2
REJECT = radareventverification2;
// 22 41:aload_2
// 23 42:putstatic #42 <Field RadarEvent$RadarEventVerification REJECT>
$VALUES = (new RadarEventVerification[] {
radareventverification, radareventverification1, radareventverification2
});
// 24 45:iconst_3
// 25 46:anewarray RadarEventVerification[]
// 26 49:dup
// 27 50:iconst_0
// 28 51:aload_0
// 29 52:aastore
// 30 53:dup
// 31 54:iconst_1
// 32 55:aload_1
// 33 56:aastore
// 34 57:dup
// 35 58:iconst_2
// 36 59:aload_2
// 37 60:aastore
// 38 61:putstatic #44 <Field RadarEvent$RadarEventVerification[] $VALUES>
//* 39 64:return
}
protected RadarEventVerification(String s, int i)
{
super(s, i);
// 0 0:aload_0
// 1 1:aload_1
// 2 2:iload_2
// 3 3:invokespecial #46 <Method void Enum(String, int)>
// 4 6:return
}
}
public RadarEvent(String s, Date date, Date date1, boolean flag, RadarEventType radareventtype, RadarGeofence radargeofence, RadarPlace radarplace,
RadarPlace aradarplace[], RadarPlace radarplace1, RadarEventVerification radareventverification, RadarEventConfidence radareventconfidence, float f, Location location1)
{
Intrinsics.checkParameterIsNotNull(((Object) (s)), "id");
// 0 0:aload_1
// 1 1:ldc1 #125 <String "id">
// 2 3:invokestatic #131 <Method void Intrinsics.checkParameterIsNotNull(Object, String)>
Intrinsics.checkParameterIsNotNull(((Object) (date)), "createdAt");
// 3 6:aload_2
// 4 7:ldc1 #89 <String "createdAt">
// 5 9:invokestatic #131 <Method void Intrinsics.checkParameterIsNotNull(Object, String)>
Intrinsics.checkParameterIsNotNull(((Object) (date1)), "actualCreatedAt");
// 6 12:aload_3
// 7 13:ldc1 #80 <String "actualCreatedAt">
// 8 15:invokestatic #131 <Method void Intrinsics.checkParameterIsNotNull(Object, String)>
Intrinsics.checkParameterIsNotNull(((Object) (radareventtype)), "type");
// 9 18:aload 5
// 10 20:ldc1 #107 <String "type">
// 11 22:invokestatic #131 <Method void Intrinsics.checkParameterIsNotNull(Object, String)>
Intrinsics.checkParameterIsNotNull(((Object) (radareventverification)), "verification");
// 12 25:aload 10
// 13 27:ldc1 #109 <String "verification">
// 14 29:invokestatic #131 <Method void Intrinsics.checkParameterIsNotNull(Object, String)>
Intrinsics.checkParameterIsNotNull(((Object) (radareventconfidence)), "confidence");
// 15 32:aload 11
// 16 34:ldc1 #84 <String "confidence">
// 17 36:invokestatic #131 <Method void Intrinsics.checkParameterIsNotNull(Object, String)>
Intrinsics.checkParameterIsNotNull(((Object) (location1)), "location");
// 18 39:aload 13
// 19 41:ldc1 #100 <String "location">
// 20 43:invokestatic #131 <Method void Intrinsics.checkParameterIsNotNull(Object, String)>
super();
// 21 46:aload_0
// 22 47:invokespecial #133 <Method void Object()>
id = s;
// 23 50:aload_0
// 24 51:aload_1
// 25 52:putfield #135 <Field String id>
createdAt = date;
// 26 55:aload_0
// 27 56:aload_2
// 28 57:putfield #137 <Field Date createdAt>
actualCreatedAt = date1;
// 29 60:aload_0
// 30 61:aload_3
// 31 62:putfield #139 <Field Date actualCreatedAt>
live = flag;
// 32 65:aload_0
// 33 66:iload 4
// 34 68:putfield #141 <Field boolean live>
type = radareventtype;
// 35 71:aload_0
// 36 72:aload 5
// 37 74:putfield #143 <Field RadarEvent$RadarEventType type>
geofence = radargeofence;
// 38 77:aload_0
// 39 78:aload 6
// 40 80:putfield #145 <Field RadarGeofence geofence>
place = radarplace;
// 41 83:aload_0
// 42 84:aload 7
// 43 86:putfield #147 <Field RadarPlace place>
alternatePlaces = aradarplace;
// 44 89:aload_0
// 45 90:aload 8
// 46 92:putfield #149 <Field RadarPlace[] alternatePlaces>
verifiedPlace = radarplace1;
// 47 95:aload_0
// 48 96:aload 9
// 49 98:putfield #151 <Field RadarPlace verifiedPlace>
verification = radareventverification;
// 50 101:aload_0
// 51 102:aload 10
// 52 104:putfield #153 <Field RadarEvent$RadarEventVerification verification>
confidence = radareventconfidence;
// 53 107:aload_0
// 54 108:aload 11
// 55 110:putfield #155 <Field RadarEvent$RadarEventConfidence confidence>
duration = f;
// 56 113:aload_0
// 57 114:fload 12
// 58 116:putfield #157 <Field float duration>
location = location1;
// 59 119:aload_0
// 60 120:aload 13
// 61 122:putfield #159 <Field Location location>
// 62 125:return
}
public final Date getActualCreatedAt()
{
return actualCreatedAt;
// 0 0:aload_0
// 1 1:getfield #139 <Field Date actualCreatedAt>
// 2 4:areturn
}
public final RadarPlace[] getAlternatePlaces()
{
return alternatePlaces;
// 0 0:aload_0
// 1 1:getfield #149 <Field RadarPlace[] alternatePlaces>
// 2 4:areturn
}
public final RadarEventConfidence getConfidence()
{
return confidence;
// 0 0:aload_0
// 1 1:getfield #155 <Field RadarEvent$RadarEventConfidence confidence>
// 2 4:areturn
}
public final Date getCreatedAt()
{
return createdAt;
// 0 0:aload_0
// 1 1:getfield #137 <Field Date createdAt>
// 2 4:areturn
}
public final float getDuration()
{
return duration;
// 0 0:aload_0
// 1 1:getfield #157 <Field float duration>
// 2 4:freturn
}
public final RadarGeofence getGeofence()
{
return geofence;
// 0 0:aload_0
// 1 1:getfield #145 <Field RadarGeofence geofence>
// 2 4:areturn
}
public final String getId()
{
return id;
// 0 0:aload_0
// 1 1:getfield #135 <Field String id>
// 2 4:areturn
}
public final boolean getLive()
{
return live;
// 0 0:aload_0
// 1 1:getfield #141 <Field boolean live>
// 2 4:ireturn
}
public final Location getLocation()
{
return location;
// 0 0:aload_0
// 1 1:getfield #159 <Field Location location>
// 2 4:areturn
}
public final RadarPlace getPlace()
{
return place;
// 0 0:aload_0
// 1 1:getfield #147 <Field RadarPlace place>
// 2 4:areturn
}
public final RadarEventType getType()
{
return type;
// 0 0:aload_0
// 1 1:getfield #143 <Field RadarEvent$RadarEventType type>
// 2 4:areturn
}
public final RadarEventVerification getVerification()
{
return verification;
// 0 0:aload_0
// 1 1:getfield #153 <Field RadarEvent$RadarEventVerification verification>
// 2 4:areturn
}
public final RadarPlace getVerifiedPlace()
{
return verifiedPlace;
// 0 0:aload_0
// 1 1:getfield #151 <Field RadarPlace verifiedPlace>
// 2 4:areturn
}
public static final Companion Companion = new Companion(((DefaultConstructorMarker) (null)));
private static final String FIELD_ACTUAL_CREATED = "actualCreatedAt";
private static final String FIELD_ALTERNATE_PLACES = "alternatePlaces";
private static final String FIELD_CONFIDENCE = "confidence";
private static final String FIELD_COORDINATES = "coordinates";
private static final String FIELD_CREATED = "createdAt";
private static final String FIELD_DURATION = "duration";
private static final String FIELD_GEOFENCE = "geofence";
private static final String FIELD_ID = "_id";
private static final String FIELD_LIVE = "live";
private static final String FIELD_LOCATION = "location";
private static final String FIELD_LOCATION_ACCURACY = "locationAccuracy";
private static final String FIELD_PLACE = "place";
private static final String FIELD_TYPE = "type";
private static final String FIELD_VERIFICATION = "verification";
private static final String FIELD_VERIFIED_PLACE = "verifiedPlace";
private final Date actualCreatedAt;
private final RadarPlace alternatePlaces[];
private final RadarEventConfidence confidence;
private final Date createdAt;
private final float duration;
private final RadarGeofence geofence;
private final String id;
private final boolean live;
private final Location location;
private final RadarPlace place;
private final RadarEventType type;
private final RadarEventVerification verification;
private final RadarPlace verifiedPlace;
static
{
// 0 0:new #6 <Class RadarEvent$Companion>
// 1 3:dup
// 2 4:aconst_null
// 3 5:invokespecial #121 <Method void RadarEvent$Companion(DefaultConstructorMarker)>
// 4 8:putstatic #123 <Field RadarEvent$Companion Companion>
//* 5 11:return
}
}
|
3e01c1954ba43dbeed09c9f2c16a83f91c81f2e6 | 5,637 | java | Java | odcleanstore/webfrontend/src/main/java/cz/cuni/mff/odcleanstore/webfrontend/pages/transformers/dn/DNRuleDetailPage.java | ODCleanStore/ODCleanStore | 3a68c345c5b67349447add8d61d97ae59edd8d7d | [
"Apache-2.0"
] | 4 | 2015-11-16T10:30:21.000Z | 2021-04-16T16:16:36.000Z | odcleanstore/webfrontend/src/main/java/cz/cuni/mff/odcleanstore/webfrontend/pages/transformers/dn/DNRuleDetailPage.java | ODCleanStore/ODCleanStore | 3a68c345c5b67349447add8d61d97ae59edd8d7d | [
"Apache-2.0"
] | null | null | null | odcleanstore/webfrontend/src/main/java/cz/cuni/mff/odcleanstore/webfrontend/pages/transformers/dn/DNRuleDetailPage.java | ODCleanStore/ODCleanStore | 3a68c345c5b67349447add8d61d97ae59edd8d7d | [
"Apache-2.0"
] | null | null | null | 28.23 | 119 | 0.736451 | 742 | package cz.cuni.mff.odcleanstore.webfrontend.pages.transformers.dn;
import org.apache.log4j.Logger;
import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.IDataProvider;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import cz.cuni.mff.odcleanstore.webfrontend.bo.Role;
import cz.cuni.mff.odcleanstore.webfrontend.bo.dn.DNRule;
import cz.cuni.mff.odcleanstore.webfrontend.bo.dn.DNRuleComponent;
import cz.cuni.mff.odcleanstore.webfrontend.core.components.AuthorizedDeleteButton;
import cz.cuni.mff.odcleanstore.webfrontend.core.components.AuthorizedRedirectButton;
import cz.cuni.mff.odcleanstore.webfrontend.core.components.DeleteConfirmationMessage;
import cz.cuni.mff.odcleanstore.webfrontend.core.components.LimitedEditingForm;
import cz.cuni.mff.odcleanstore.webfrontend.core.components.RedirectWithParamButton;
import cz.cuni.mff.odcleanstore.webfrontend.core.components.TruncatedLabel;
import cz.cuni.mff.odcleanstore.webfrontend.core.components.UnobtrusivePagingNavigator;
import cz.cuni.mff.odcleanstore.webfrontend.core.models.DependentDataProvider;
import cz.cuni.mff.odcleanstore.webfrontend.dao.dn.DNRuleComponentDao;
import cz.cuni.mff.odcleanstore.webfrontend.dao.dn.DNRuleDao;
import cz.cuni.mff.odcleanstore.webfrontend.dao.exceptions.DaoException;
import cz.cuni.mff.odcleanstore.webfrontend.pages.LimitedEditingPage;
/**
* DN-rule-overview page component.
*
* @author Dušan Rychnovský ([email protected])
*
*/
@AuthorizeInstantiation({ Role.PIC })
public class DNRuleDetailPage extends LimitedEditingPage
{
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(DNRuleDetailPage.class);
private DNRuleDao dnRuleDao;
private DNRuleComponentDao dnRuleComponentDao;
/**
*
* @param ruleId
*/
public DNRuleDetailPage(final Integer ruleId)
{
super(
"Home > Backend > Data Normalization > Groups > Rules > Edit",
"Edit Data Normalization rule",
DNRuleDao.class,
ruleId
);
// prepare DAO objects
//
dnRuleDao = daoLookupFactory.getDao(DNRuleDao.class, isEditable());
dnRuleComponentDao = daoLookupFactory.getDao(DNRuleComponentDao.class, isEditable());
// register page components
//
DNRule rule = dnRuleDao.load(ruleId);
add(
new RedirectWithParamButton(
DNGroupDetailPage.class,
rule.getGroupId(),
"showDNGroupDetailPage"
)
);
addHelpWindow("dnRuleHelpWindow", "openDNRuleHelpWindow", new DNRuleHelpPanel("content"));
addHelpWindow("dnRuleComponentHelpWindow", "openDNRuleComponentHelpWindow", new DNRuleComponentHelpPanel("content"));
addEditDNRuleForm(rule);
addRuleComponentsSection(ruleId);
}
/**
*
* @param rule
*/
private void addEditDNRuleForm(final DNRule rule)
{
IModel<DNRule> formModel = new CompoundPropertyModel<DNRule>(rule);
Form<DNRule> form = new LimitedEditingForm<DNRule>("editDNRuleForm", formModel, isEditable())
{
private static final long serialVersionUID = 1L;
@Override
protected void onSubmitImpl()
{
DNRule rule = this.getModelObject();
try {
dnRuleDao.update(rule);
}
catch (DaoException ex)
{
logger.error(ex.getMessage(), ex);
getSession().error(ex.getMessage());
return;
}
catch (Exception ex)
{
logger.error(ex.getMessage(), ex);
getSession().error(
"The rule could not be updated due to an unexpected error."
);
return;
}
getSession().info("The rule was successfuly updated.");
}
};
form.add(createTextfield("label"));
form.add(createTextarea("description", false));
add(form);
}
/**
*
* @param ruleId
*/
private void addRuleComponentsSection(Integer ruleId)
{
add(
new AuthorizedRedirectButton(
NewDNRuleComponentPage.class,
ruleId,
isEditable(),
"addNewComponentLink"
)
);
addRuleComponentsTable(ruleId);
}
/**
*
* @param ruleId
*/
private void addRuleComponentsTable(Integer ruleId)
{
IDataProvider<DNRuleComponent> data = new DependentDataProvider<DNRuleComponent>(
dnRuleComponentDao,
"ruleId",
ruleId
);
DataView<DNRuleComponent> dataView = new DataView<DNRuleComponent>("dnComponentsTable", data)
{
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(Item<DNRuleComponent> item)
{
DNRuleComponent component = item.getModelObject();
item.setModel(new CompoundPropertyModel<DNRuleComponent>(component));
item.add(new Label("type", component.getType().getLabel()));
item.add(new TruncatedLabel("modification", MAX_LIST_COLUMN_TEXT_LENGTH));
item.add(new TruncatedLabel("description", MAX_LIST_COLUMN_TEXT_LENGTH));
item.add(
new AuthorizedDeleteButton<DNRuleComponent>
(
dnRuleComponentDao,
component.getId(),
isEditable(),
"component",
new DeleteConfirmationMessage("rule component"),
DNRuleDetailPage.this
)
);
item.add(
new RedirectWithParamButton
(
DNRuleComponentDetailPage.class,
component.getId(),
"showEditDNRuleComponentPage"
)
);
}
};
dataView.setItemsPerPage(ITEMS_PER_PAGE);
add(dataView);
add(new UnobtrusivePagingNavigator("navigator", dataView));
}
}
|
3e01c28e5d09c65cf8335856db39c0a752c5718d | 962 | java | Java | Java/src/main/java/baekjoonOnlineJudge/BOJ4949.java | leeheefull/Algorithms | 76efad534ce70200778c80341b5e3f99c5053e91 | [
"MIT"
] | null | null | null | Java/src/main/java/baekjoonOnlineJudge/BOJ4949.java | leeheefull/Algorithms | 76efad534ce70200778c80341b5e3f99c5053e91 | [
"MIT"
] | null | null | null | Java/src/main/java/baekjoonOnlineJudge/BOJ4949.java | leeheefull/Algorithms | 76efad534ce70200778c80341b5e3f99c5053e91 | [
"MIT"
] | null | null | null | 24.666667 | 75 | 0.565489 | 743 | package baekjoonOnlineJudge;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
public class BOJ4949 {// string
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Stack<Character> bracket = new Stack<>();
while (true) {
bracket.clear();
String line = br.readLine();
if (line.equals(".")) {
break;
}
for (int i = 0; i < line.length(); i++) {
char tmp = line.charAt(i);
if (tmp == '(' || tmp == '[') {
bracket.push(tmp);
} else if (tmp == ')' || tmp == ']') {
if (bracket.isEmpty() || (bracket.peek() == '(' && tmp == ']')
|| (bracket.peek() == '[' && tmp == ')')) {
bracket.push(tmp);
break;
}
bracket.pop();
}
}
if (bracket.isEmpty()) {
System.out.println("yes");
} else {
System.out.println("no");
}
}
}
} |
3e01c2a811d066870738c904ba4203b1c4446513 | 243 | java | Java | src/main/java/com/dagger4j/db/IModel.java | tcrct/dagger4j | af9bd45d4c874bd01988c3a5c56976956bf6670a | [
"Apache-2.0"
] | null | null | null | src/main/java/com/dagger4j/db/IModel.java | tcrct/dagger4j | af9bd45d4c874bd01988c3a5c56976956bf6670a | [
"Apache-2.0"
] | null | null | null | src/main/java/com/dagger4j/db/IModel.java | tcrct/dagger4j | af9bd45d4c874bd01988c3a5c56976956bf6670a | [
"Apache-2.0"
] | null | null | null | 16.2 | 38 | 0.580247 | 744 | package com.dagger4j.db;
/**
* @author Created by laotang
* @date createed in 2018/6/25.
*/
public interface IModel<T> {
/**
* 保存对象
* @param entity 待保存的对象
* @return 对象
*/
T save(T entity) throws Exception;
}
|
3e01c2c381d6ae9ea89ea2a850dd690ee57c3b94 | 788 | java | Java | src/main/java/org/iron/ultimate/model/AccountTypeDTO.java | jjf28/ultimate-iron | 879d77d13f5ece25aae62e66f7676c7ae631243f | [
"MIT"
] | null | null | null | src/main/java/org/iron/ultimate/model/AccountTypeDTO.java | jjf28/ultimate-iron | 879d77d13f5ece25aae62e66f7676c7ae631243f | [
"MIT"
] | null | null | null | src/main/java/org/iron/ultimate/model/AccountTypeDTO.java | jjf28/ultimate-iron | 879d77d13f5ece25aae62e66f7676c7ae631243f | [
"MIT"
] | null | null | null | 21.297297 | 54 | 0.727157 | 745 | package org.iron.ultimate.model;
import java.io.Serializable;
public class AccountTypeDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Long accountTypeId;
private String accountType;
private String displayName;
public AccountTypeDTO() {
super();
}
public Long getAccountTypeId() {
return accountTypeId;
}
public void setAccountTypeId(Long accountTypeId) {
this.accountTypeId = accountTypeId;
}
public String getAccountType() {
return accountType;
}
public void setAccountType(String accountType) {
this.accountType = accountType;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
}
|
3e01c32ceb74d9e201800167ff33f7228bb2b2f6 | 3,343 | java | Java | spring-security-oauth2/src/main/java/org/springframework/security/oauth2/config/annotation/web/configuration/AuthorizationServerConfigurer.java | jasonbiao1993/spring-security-oauth | 304c43bed142853442d1a76e5969e337cc887378 | [
"Apache-2.0"
] | 4,409 | 2015-01-04T04:45:14.000Z | 2022-03-27T12:24:04.000Z | spring-security-oauth2/src/main/java/org/springframework/security/oauth2/config/annotation/web/configuration/AuthorizationServerConfigurer.java | jasonbiao1993/spring-security-oauth | 304c43bed142853442d1a76e5969e337cc887378 | [
"Apache-2.0"
] | 1,594 | 2015-01-03T00:58:10.000Z | 2022-03-31T08:27:31.000Z | spring-security-oauth2/src/main/java/org/springframework/security/oauth2/config/annotation/web/configuration/AuthorizationServerConfigurer.java | jasonbiao1993/spring-security-oauth | 304c43bed142853442d1a76e5969e337cc887378 | [
"Apache-2.0"
] | 4,158 | 2015-01-02T08:27:03.000Z | 2022-03-31T06:12:39.000Z | 50.651515 | 167 | 0.788513 | 746 | /*
* Copyright 2013-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* https://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.springframework.security.oauth2.config.annotation.web.configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
import org.springframework.security.oauth2.provider.ClientDetailsService;
/**
* Convenient strategy for configuring an OAUth2 Authorization Server. Beans of this type are applied to the Spring
* context automatically if you {@link EnableAuthorizationServer @EnableAuthorizationServer}.
*
* <p>
* @deprecated See the <a href="https://github.com/spring-projects/spring-security/wiki/OAuth-2.0-Migration-Guide">OAuth 2.0 Migration Guide</a> for Spring Security 5.
*
* @author Dave Syer
*
*/
@Deprecated
public interface AuthorizationServerConfigurer {
/**
* Configure the security of the Authorization Server, which means in practical terms the /oauth/token endpoint. The
* /oauth/authorize endpoint also needs to be secure, but that is a normal user-facing endpoint and should be
* secured the same way as the rest of your UI, so is not covered here. The default settings cover the most common
* requirements, following recommendations from the OAuth2 spec, so you don't need to do anything here to get a
* basic server up and running.
*
* @param security a fluent configurer for security features
*/
void configure(AuthorizationServerSecurityConfigurer security) throws Exception;
/**
* Configure the {@link ClientDetailsService}, e.g. declaring individual clients and their properties. Note that
* password grant is not enabled (even if some clients are allowed it) unless an {@link AuthenticationManager} is
* supplied to the {@link #configure(AuthorizationServerEndpointsConfigurer)}. At least one client, or a fully
* formed custom {@link ClientDetailsService} must be declared or the server will not start.
*
* @param clients the client details configurer
*/
void configure(ClientDetailsServiceConfigurer clients) throws Exception;
/**
* Configure the non-security features of the Authorization Server endpoints, like token store, token
* customizations, user approvals and grant types. You shouldn't need to do anything by default, unless you need
* password grants, in which case you need to provide an {@link AuthenticationManager}.
*
* @param endpoints the endpoints configurer
*/
void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception;
}
|
3e01c3e24f53dbe30ff1927f44911a1c2b78bcdf | 13,282 | java | Java | src/main/java/org/basex/query/flwor/GFLWOR.java | rostam/basex | 6424d81435955289cc415efb7bf4e09afb29665c | [
"BSD-3-Clause"
] | 1 | 2018-12-24T14:16:13.000Z | 2018-12-24T14:16:13.000Z | src/main/java/org/basex/query/flwor/GFLWOR.java | rostam/basex | 6424d81435955289cc415efb7bf4e09afb29665c | [
"BSD-3-Clause"
] | null | null | null | src/main/java/org/basex/query/flwor/GFLWOR.java | rostam/basex | 6424d81435955289cc415efb7bf4e09afb29665c | [
"BSD-3-Clause"
] | null | null | null | 31.548694 | 91 | 0.565653 | 748 | package org.basex.query.flwor;
import static org.basex.query.QueryText.*;
import java.util.*;
import org.basex.query.*;
import org.basex.query.expr.*;
import org.basex.query.func.*;
import org.basex.query.iter.*;
import org.basex.query.path.*;
import org.basex.query.util.*;
import org.basex.query.value.item.*;
import org.basex.query.value.node.*;
import org.basex.query.value.seq.*;
import org.basex.query.value.type.*;
import org.basex.util.*;
import org.basex.util.list.*;
/**
* GFLWOR clause.
*
* @author BaseX Team 2005-12, BSD License
* @author Christian Gruen
*/
public class GFLWOR extends ParseExpr {
/** Return expression. */
Expr ret;
/** For/Let expression. */
ForLet[] fl;
/** Where clause. */
Expr where;
/** Order clause. */
private Order order;
/** Group by clause. */
private final Group group;
/**
* GFLWOR constructor.
* @param f variable inputs
* @param w where clause
* @param o order expression
* @param g group by expression
* @param r return expression
* @param ii input info
*/
GFLWOR(final ForLet[] f, final Expr w, final Order o, final Group g, final Expr r,
final InputInfo ii) {
super(ii);
ret = r;
fl = f;
where = w;
group = g;
order = o;
}
/**
* Returns a GFLWOR instance.
* @param fl variable inputs
* @param whr where clause
* @param ord order expression
* @param grp group-by expression
* @param ret return expression
* @param ii input info
* @return GFLWOR instance
*/
public static GFLWOR get(final ForLet[] fl, final Expr whr, final Order ord,
final Group grp, final Expr ret, final InputInfo ii) {
return ord == null && grp == null ? new FLWR(fl, whr, ret, ii) :
new GFLWOR(fl, whr, ord, grp, ret, ii);
}
@Override
public void checkUp() throws QueryException {
for(final ForLet f : fl) f.checkUp();
checkNoneUp(where, group, order);
ret.checkUp();
}
@Override
public Expr compile(final QueryContext ctx) throws QueryException {
compHoist(ctx);
compWhere(ctx);
final boolean grp = ctx.grouping;
ctx.grouping = group != null;
// optimize for/let clauses
final int vs = ctx.vars.size();
for(int f = 0; f < fl.length; ++f) {
final ForLet flt = fl[f].compile(ctx);
// bind variable if it contains a value or will only be evaluated once
boolean let = true;
for(int g = f + 1; g < fl.length; g++) let &= fl[g] instanceof Let;
if(flt.expr.isValue() || let && count(flt.var, f) == 1) flt.bind(ctx);
}
// optimize where clause
boolean empty = false;
if(where != null) {
where = where.compile(ctx).compEbv(ctx);
if(where.isValue()) {
// test is always false: no results
empty = !where.ebv(ctx, info).bool(info);
if(!empty) {
// always true: test can be skipped
ctx.compInfo(OPTREMOVE, description(), where);
where = null;
}
}
}
if(group != null) group.compile(ctx);
if(order != null) order.compile(ctx);
ret = ret.compile(ctx);
ctx.vars.size(vs);
ctx.grouping = grp;
// remove FLWOR expression if WHERE clause always returns false
if(empty) {
ctx.compInfo(OPTREMOVE, description(), where);
return Empty.SEQ;
}
// check if return always yields an empty sequence
if(ret == Empty.SEQ) {
ctx.compInfo(OPTFLWOR);
return Empty.SEQ;
}
// remove declarations of statically bound or unused variables
for(int f = 0; f < fl.length; ++f) {
final ForLet l = fl[f];
// do not optimize non-deterministic expressions. example:
// let $a := file:write('file', 'content') return ...
if(l.var.expr() != null || l.simple(true) && count(l.var, f) == 0 &&
!l.expr.uses(Use.NDT)) {
ctx.compInfo(OPTVAR, l.var);
fl = Array.delete(fl, f--);
}
}
// no clauses left: simplify expression
// an optional order clause can be safely ignored
if(fl.length == 0) {
// if where clause exists: where A return B -> if A then B else ()
// otherwise: return B -> B
ctx.compInfo(OPTFLWOR);
return where != null ? new If(info, where, ret, Empty.SEQ) : ret;
}
// remove FLWOR expression if a FOR clause yields an empty sequence
for(final ForLet f : fl) {
if(f instanceof For && f.size() == 0 && !f.expr.uses(Use.NDT)) {
ctx.compInfo(OPTFLWOR);
return Empty.SEQ;
}
}
// compute number of results to speed up count() operations
if(where == null && group == null) {
size = ret.size();
if(size != -1) {
// multiply loop runs
for(final ForLet f : fl) {
final long s = f.size();
if(s == -1) {
size = s;
break;
}
size *= s;
}
}
}
type = SeqType.get(ret.type().type, size);
compHoist(ctx);
return this;
}
/**
* Hoists loop-invariant code. Avoids repeated evaluation of independent
* variables that return a single value. This method is called twice
* (before and after all other optimizations).
* @param ctx query context
*/
private void compHoist(final QueryContext ctx) {
// modification counter
int m = 0;
for(int i = 1; i < fl.length; i++) {
final ForLet in = fl[i];
/* move clauses upwards that contain a single value.
non-deterministic expressions or fragment constructors creating
unique nodes are ignored. example:
for $a in 1 to 2 let $b := random:double() return $b
*/
if(in.size() != 1 || in.uses(Use.NDT) || in.uses(Use.CNS)) continue;
/* - find most outer clause that declares no variables used in the inner clause.
* example: let $x := <a/> for $i in 1 to 2 let $a := $x return $a
* - code will not be moved if all clauses are let clauses.
* example: let $x := <a/> let $i := <b/> let $a := $x return ($a, $i)
*/
int p = -1;
boolean f = false;
for(int o = i; o-- != 0 && in.count(fl[o]) == 0; p = o, f |= fl[o] instanceof For);
if(p == -1 || !f) continue;
// move clause
Array.move(fl, p, 1, i - p);
fl[p] = in;
if(m++ == 0) ctx.compInfo(OPTFORLET);
}
}
/**
* Rewrites a where clause to one or more predicates.
* @param ctx query context
*/
private void compWhere(final QueryContext ctx) {
// no where clause specified
if(where == null) return;
// check if all clauses are simple, and if variables are removable
for(final ForLet f : fl) {
if(f instanceof For && (!f.simple(false) || !where.removable(f.var))) return;
}
// create array with tests
final Expr[] tests = where instanceof And ? ((And) where).expr : new Expr[] { where };
// find which tests access which variables. if a test will not use any of
// the variables defined in the local context, they will be added to the
// first binding
final int[] tar = new int[tests.length];
for(int t = 0; t < tests.length; ++t) {
int fr = -1;
for(int f = fl.length - 1; f >= 0; --f) {
// remember index of most inner FOR clause
if(fl[f] instanceof For) fr = f;
// predicate is found that uses the current variable
if(tests[t].count(fl[f].var) != 0) {
// stop rewriting if no most inner FOR clause is defined
if(fr == -1) return;
// attach predicate to the corresponding FOR clause, and stop
tar[t] = fr;
break;
}
}
}
// convert where clause to predicate(s)
ctx.compInfo(OPTWHERE);
for(int f = 0; f < fl.length; ++f) {
final ForLet c = fl[f];
final ExprList el = new ExprList();
// find all tests that will be bound to the current clause
for(int t = 0; t < tests.length; ++t) {
if(tar[t] == f) el.add(tests[t].remove(c.var));
}
// none found: continue
if(el.isEmpty()) continue;
// attach predicates to axis path or filter, or create a new filter
final Expr a;
if(el.size() == 1) {
// one found: wrap with boolean function if value may be numeric
final Expr e = el.get(0);
a = e.type().mayBeNumber() ? Function.BOOLEAN.get(info, e) : e;
} else {
// more found: wrap with and expression
a = new And(info, el.finish());
}
// add to clause expression
if(c.expr instanceof AxisPath) {
c.expr = ((AxisPath) c.expr).addPreds(a);
} else if(c.expr instanceof Filter) {
c.expr = ((Filter) c.expr).addPred(a);
} else {
c.expr = new Filter(info, c.expr, a);
}
}
// eliminate where clause
where = null;
}
@Override
public Iter iter(final QueryContext ctx) throws QueryException {
final Iter[] iter = new Iter[fl.length];
final int vs = ctx.vars.size();
for(int f = 0; f < fl.length; ++f) iter[f] = ctx.iter(fl[f]);
// evaluate pre grouping tuples
ArrayList<Item[]> keys = null;
ValueList vals = null;
if(order != null) {
keys = new ArrayList<Item[]>();
vals = new ValueList();
}
if(group != null) group.init(order);
iter(ctx, iter, 0, keys, vals);
ctx.vars.size(vs);
for(final ForLet f : fl) ctx.vars.add(f.var);
// order != null, otherwise it would have been handled in group
final Iter ir = group != null ?
group.gp.ret(ctx, ret, keys, vals) : ctx.iter(order.set(keys, vals));
ctx.vars.size(vs);
return ir;
}
/**
* Performs a recursive iteration on the specified variable position.
* @param ctx query context
* @param it iterator
* @param p variable position
* @param ks sort keys
* @param vs values to sort
* @throws QueryException query exception
*/
private void iter(final QueryContext ctx, final Iter[] it, final int p,
final ArrayList<Item[]> ks, final ValueList vs) throws QueryException {
final boolean more = p + 1 != fl.length;
while(it[p].next() != null) {
if(more) {
iter(ctx, it, p + 1, ks, vs);
} else if(where == null || where.ebv(ctx, info).bool(info)) {
if(group != null) {
group.gp.add(ctx);
} else if(order != null) {
// order by will be handled in group by otherwise
order.add(ctx, ret, ks, vs);
}
}
}
}
@Override
public final boolean uses(final Use u) {
for(final ForLet f : fl) if(f.uses(u)) return true;
return where != null && where.uses(u) ||
order != null && order.uses(u) ||
group != null && group.uses(u) || ret.uses(u);
}
@Override
public final int count(final Var v) {
return count(v, 0);
}
/**
* Counts how often the specified variable is used, starting from the
* specified for/let index.
* @param v variable to be checked
* @param i index
* @return number of occurrences
*/
final int count(final Var v, final int i) {
int c = 0;
for(int f = i; f < fl.length; f++) c += fl[f].count(v);
if(where != null) c += where.count(v);
if(order != null) c += order.count(v);
if(group != null) c += group.count(v);
return c + ret.count(v);
}
@Override
public final boolean removable(final Var v) {
for(final ForLet f : fl) if(!f.removable(v)) return false;
return (where == null || where.removable(v)) &&
(order == null || order.removable(v)) &&
(group == null || group.removable(v)) && ret.removable(v);
}
@Override
public final Expr remove(final Var v) {
for(final ForLet f : fl) f.remove(v);
if(where != null) where = where.remove(v);
if(order != null) order = order.remove(v);
ret = ret.remove(v);
return this;
}
@Override
public boolean databases(final StringList db) {
for(final ForLet f : fl) if(!f.databases(db)) return false;
return (where == null || where.databases(db)) &&
(order == null || order.databases(db)) &&
(group == null || group.databases(db)) && ret.databases(db);
}
@Override
public boolean isVacuous() {
return ret.isVacuous();
}
@Override
public final void plan(final FElem plan) {
final FElem el = planElem();
addPlan(plan, el, fl);
if(where != null) addPlan(el, new FElem(WHR), where);
if(group != null) group.plan(el);
if(order != null) order.plan(el);
addPlan(el, new FElem(RET), ret);
}
@Override
public final String toString() {
final StringBuilder sb = new StringBuilder();
for(int i = 0; i != fl.length; ++i) sb.append(i != 0 ? " " : "").append(fl[i]);
if(where != null) sb.append(' ' + WHERE + ' ' + where);
if(group != null) sb.append(group);
if(order != null) sb.append(order);
return sb.append(' ' + RETURN + ' ' + ret).toString();
}
}
|
3e01c4882a42f834d403b6a58412372570fa6bec | 16,542 | java | Java | iast-inject/src/main/java/java/lang/iast/inject/Injecter.java | HXSecurity/DongTai-agent-java | 05453246dbc61154671441d05a7b8fc75a9f8b6d | [
"Apache-2.0"
] | 563 | 2021-04-01T03:16:19.000Z | 2022-03-31T15:33:16.000Z | iast-inject/src/main/java/java/lang/iast/inject/Injecter.java | HXSecurity/DongTai-agent-java | 05453246dbc61154671441d05a7b8fc75a9f8b6d | [
"Apache-2.0"
] | 95 | 2021-04-01T04:46:43.000Z | 2022-03-28T05:18:18.000Z | iast-inject/src/main/java/java/lang/iast/inject/Injecter.java | HXSecurity/DongTai-agent-java | 05453246dbc61154671441d05a7b8fc75a9f8b6d | [
"Apache-2.0"
] | 148 | 2021-04-01T03:18:41.000Z | 2022-03-28T09:27:18.000Z | 29.913201 | 113 | 0.568311 | 749 | package java.lang.iast.inject;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* 间谍类,藏匿在各个ClassLoader中
* <p>
* 从{@code 1.1.0}版本之后,修复了命名空间在Spy中不支持的问题
*/
public class Injecter {
/**
* 控制Spy是否在发生异常时主动对外抛出 T:主动对外抛出,会中断方法 F:不对外抛出,只将异常信息打印出来
*/
public static volatile boolean isSpyThrowException = false;
private static final Class<Ret> SPY_RET_CLASS = Ret.class;
private static MethodHook METHOD_HOOK_HANDLER;
/**
* 判断间谍类是否已经完成初始化
*
* @return TRUE:已完成初始化;FALSE:未完成初始化;
*/
public static boolean isInit() {
return null != METHOD_HOOK_HANDLER;
}
/**
* 初始化间谍
*
* @param ON_BEFORE_METHOD ON_BEFORE 回调
* @param ON_RETURN_METHOD ON_RETURN 回调
* @param ON_THROWS_METHOD ON_THROWS 回调
*/
public static void init(
final Method ON_BEFORE_METHOD,
final Method ON_RETURN_METHOD,
final Method ON_THROWS_METHOD,
final Method ENTER_PROPAGATOR,
final Method LEAVE_PROPAGATOR,
final Method IS_FIRST_LEVEL_PROPAGATOR,
final Method ENTER_SOURCE,
final Method LEAVE_SOURCE,
final Method IS_FIRST_LEVEL_SOURCE,
final Method ENTER_SINK,
final Method LEAVE_SINK,
final Method IS_FIRST_LEVEL_SINK,
final Method ENTER_HTTP,
final Method LEAVE_HTTP,
final Method IS_FIRST_LEVEL_HTTP,
final Method HAS_TAINT,
final Method CLONE_REQUEST,
final Method IS_REPLAY_REQUEST,
final Method CLONE_RESPONSE,
final Method ENTER_DUBBO,
final Method LEAVE_DUBBO,
final Method IS_FIRST_LEVEL_DUBBO
) {
if (null == METHOD_HOOK_HANDLER) {
return;
}
METHOD_HOOK_HANDLER = new MethodHook(
ON_BEFORE_METHOD,
ON_RETURN_METHOD,
ON_THROWS_METHOD,
ENTER_PROPAGATOR,
LEAVE_PROPAGATOR,
IS_FIRST_LEVEL_PROPAGATOR,
ENTER_SOURCE,
LEAVE_SOURCE,
IS_FIRST_LEVEL_SOURCE,
ENTER_SINK,
LEAVE_SINK,
IS_FIRST_LEVEL_SINK,
ENTER_HTTP,
LEAVE_HTTP,
IS_FIRST_LEVEL_HTTP,
HAS_TAINT,
CLONE_REQUEST,
IS_REPLAY_REQUEST,
CLONE_RESPONSE,
ENTER_DUBBO,
LEAVE_DUBBO,
IS_FIRST_LEVEL_DUBBO
);
}
/**
* 清理间谍钩子方法
*
*/
public static void clean() {
METHOD_HOOK_HANDLER = null;
}
private static void handleException(Throwable cause) throws Throwable {
if (isSpyThrowException) {
throw cause;
} //cause.printStackTrace();
}
public static void spyMethodOnBefore(final Object retValue,
final Object[] argumentArray,
final String framework,
final String javaClassName,
final String matchClassName,
final String javaMethodName,
final String javaMethodDesc,
final Object target,
final String signCode,
final boolean isStatic,
final int METHOD_HOOK_HANDLERType) throws Throwable {
try {
if (null != METHOD_HOOK_HANDLER) {
METHOD_HOOK_HANDLER.ON_BEFORE_METHOD
.invoke(null, framework, javaClassName, matchClassName, javaMethodName, javaMethodDesc,
target, argumentArray, retValue, signCode, isStatic, METHOD_HOOK_HANDLERType);
}
} catch (Throwable cause) {
handleException(cause);
}
}
public static void spyMethodOnReturn(final Object retValue,
final int listenerId
) throws Throwable {
try {
if (null != METHOD_HOOK_HANDLER) {
METHOD_HOOK_HANDLER.ON_RETURN_METHOD.invoke(null, listenerId, SPY_RET_CLASS, retValue);
}
} catch (Throwable cause) {
handleException(cause);
}
}
public static Ret spyMethodOnThrows(final Throwable throwable,
final int listenerId) throws Throwable {
try {
if (null == METHOD_HOOK_HANDLER) {
return Ret.RET_NONE;
}
return (Ret) METHOD_HOOK_HANDLER.ON_THROWS_METHOD.invoke(null, listenerId, SPY_RET_CLASS, throwable);
} catch (Throwable cause) {
handleException(cause);
return Ret.RET_NONE;
}
}
public static void spyMethodEnterPropagator() {
try {
if (null != METHOD_HOOK_HANDLER) {
METHOD_HOOK_HANDLER.ENTER_PROPAGATOR.invoke(null);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
public static void spyMethodLeavePropagator() {
try {
if (null != METHOD_HOOK_HANDLER) {
METHOD_HOOK_HANDLER.LEAVE_PROPAGATOR.invoke(null);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
public static boolean isFirstLevelPropagator() {
try {
if (null != METHOD_HOOK_HANDLER) {
return (Boolean) METHOD_HOOK_HANDLER.IS_TOP_LEVEL_PROPAGATOR.invoke(null);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return false;
}
public static boolean isFirstLevelSink() {
try {
if (null != METHOD_HOOK_HANDLER) {
return (Boolean) METHOD_HOOK_HANDLER.IS_TOP_LEVEL_SINK.invoke(null);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return false;
}
public static boolean hasTaint() {
try {
if (null != METHOD_HOOK_HANDLER) {
return (Boolean) METHOD_HOOK_HANDLER.HAS_TAINT.invoke(null);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return false;
}
public static void enterSink() {
try {
if (null != METHOD_HOOK_HANDLER) {
METHOD_HOOK_HANDLER.ENTER_SINK.invoke(null);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
public static void leaveSink() {
try {
if (null != METHOD_HOOK_HANDLER) {
METHOD_HOOK_HANDLER.LEAVE_SINK.invoke(null);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
public static boolean isFirstLevelSource() {
try {
if (null != METHOD_HOOK_HANDLER) {
return (Boolean) METHOD_HOOK_HANDLER.IS_TOP_LEVEL_SOURCE.invoke(null);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return false;
}
public static void enterSource() {
try {
if (null != METHOD_HOOK_HANDLER) {
METHOD_HOOK_HANDLER.ENTER_SOURCE.invoke(null);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
public static void leaveSource() {
try {
if (null != METHOD_HOOK_HANDLER) {
METHOD_HOOK_HANDLER.LEAVE_SOURCE.invoke(null);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
public static void enterHttp() {
try {
if (null != METHOD_HOOK_HANDLER) {
METHOD_HOOK_HANDLER.ENTER_HTTP.invoke(null);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
public static void leaveHttp(final Object response) {
try {
if (null != METHOD_HOOK_HANDLER) {
METHOD_HOOK_HANDLER.LEAVE_HTTP.invoke(null, response);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
public static boolean isFirstLevelHttp() {
try {
if (null != METHOD_HOOK_HANDLER) {
return (Boolean) METHOD_HOOK_HANDLER.IS_TOP_LEVEL_HTTP.invoke(null);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return false;
}
/**
* 克隆Request对象
*
* @param req
* @return
* @throws Throwable
*/
public static Object cloneRequest(Object req, boolean isJakarta) throws Throwable {
try {
if (null != METHOD_HOOK_HANDLER) {
return METHOD_HOOK_HANDLER.CLONE_REQUEST.invoke(null, req, isJakarta);
}
} catch (Throwable cause) {
handleException(cause);
}
return req;
}
public static boolean isReplayRequest() throws Throwable {
try {
if (null != METHOD_HOOK_HANDLER) {
return (Boolean) METHOD_HOOK_HANDLER.IS_REPLAY_REQUEST.invoke(null);
}
} catch (Throwable cause) {
handleException(cause);
}
return false;
}
/**
* 克隆Response对象
*
* @param response
* @return
* @throws Throwable
*/
public static Object cloneResponse(Object response, boolean isJakarta) throws Throwable {
try {
if (null != METHOD_HOOK_HANDLER) {
return METHOD_HOOK_HANDLER.CLONE_RESPONSE.invoke(null, response, isJakarta);
}
} catch (Throwable cause) {
handleException(cause);
}
return response;
}
/**
* 返回结果
*/
public static class Ret {
public static final int RET_STATE_NONE = 0;
public static final int RET_STATE_RETURN = 1;
public static final int RET_STATE_THROWS = 2;
private static final Ret RET_NONE = new Ret(RET_STATE_NONE, null);
/**
* 返回状态(0:NONE;1:RETURN;2:THROWS)
*/
public final int state;
/**
* 应答对象
*/
public final Object respond;
/**
* 构造返回结果
*
* @param state 返回状态
* @param respond 应答对象
*/
private Ret(int state, Object respond) {
this.state = state;
this.respond = respond;
}
public static Ret newInstanceForNone() {
return RET_NONE;
}
public static Ret newInstanceForReturn(Object object) {
return new Ret(RET_STATE_RETURN, object);
}
public static Ret newInstanceForThrows(Throwable throwable) {
return new Ret(RET_STATE_THROWS, throwable);
}
}
/**
* 回调方法钩子
*/
public static class MethodHook {
private final Method ON_BEFORE_METHOD;
private final Method ON_RETURN_METHOD;
private final Method ON_THROWS_METHOD;
private final Method ENTER_PROPAGATOR;
private final Method LEAVE_PROPAGATOR;
private final Method IS_TOP_LEVEL_PROPAGATOR;
private final Method ENTER_SOURCE;
private final Method LEAVE_SOURCE;
private final Method IS_TOP_LEVEL_SOURCE;
private final Method ENTER_SINK;
private final Method LEAVE_SINK;
private final Method IS_TOP_LEVEL_SINK;
private final Method ENTER_HTTP;
private final Method LEAVE_HTTP;
private final Method IS_TOP_LEVEL_HTTP;
private final Method HAS_TAINT;
private final Method CLONE_REQUEST;
private final Method IS_REPLAY_REQUEST;
private final Method CLONE_RESPONSE;
final Method ENTER_DUBBO;
final Method LEAVE_DUBBO;
final Method IS_FIRST_LEVEL_DUBBO;
public MethodHook(final Method on_before_method,
final Method on_return_method,
final Method on_throws_method,
final Method ENTER_PROPAGATOR,
final Method LEAVE_PROPAGATOR,
final Method IS_TOP_LEVEL_PROPAGATOR,
final Method ENTER_SOURCE,
final Method LEAVE_SOURCE,
final Method IS_TOP_LEVEL_SOURCE,
final Method ENTER_SINK,
final Method LEAVE_SINK,
final Method IS_TOP_LEVEL_SINK,
final Method ENTER_HTTP,
final Method LEAVE_HTTP,
final Method IS_TOP_LEVEL_HTTP,
final Method HAS_TAINT,
final Method CLONE_REQUEST,
final Method IS_REPLAY_REQUEST,
final Method CLONE_RESPONSE,
final Method ENTER_DUBBO,
final Method LEAVE_DUBBO,
final Method IS_FIRST_LEVEL_DUBBO) {
assert null != on_before_method;
assert null != on_return_method;
assert null != on_throws_method;
this.ON_BEFORE_METHOD = on_before_method;
this.ON_RETURN_METHOD = on_return_method;
this.ON_THROWS_METHOD = on_throws_method;
this.ENTER_PROPAGATOR = ENTER_PROPAGATOR;
this.LEAVE_PROPAGATOR = LEAVE_PROPAGATOR;
this.IS_TOP_LEVEL_PROPAGATOR = IS_TOP_LEVEL_PROPAGATOR;
this.IS_TOP_LEVEL_SOURCE = IS_TOP_LEVEL_SOURCE;
this.IS_TOP_LEVEL_SINK = IS_TOP_LEVEL_SINK;
this.ENTER_SOURCE = ENTER_SOURCE;
this.LEAVE_SOURCE = LEAVE_SOURCE;
this.ENTER_SINK = ENTER_SINK;
this.LEAVE_SINK = LEAVE_SINK;
this.ENTER_HTTP = ENTER_HTTP;
this.LEAVE_HTTP = LEAVE_HTTP;
this.IS_TOP_LEVEL_HTTP = IS_TOP_LEVEL_HTTP;
this.HAS_TAINT = HAS_TAINT;
this.CLONE_REQUEST = CLONE_REQUEST;
this.IS_REPLAY_REQUEST = IS_REPLAY_REQUEST;
this.CLONE_RESPONSE = CLONE_RESPONSE;
this.ENTER_DUBBO = ENTER_DUBBO;
this.LEAVE_DUBBO = LEAVE_DUBBO;
this.IS_FIRST_LEVEL_DUBBO = IS_FIRST_LEVEL_DUBBO;
}
}
/**
* enter Dubbo Method
*
* @since 1.2.0
*/
public static void enterDubbo() {
try {
if (null != METHOD_HOOK_HANDLER) {
METHOD_HOOK_HANDLER.ENTER_DUBBO.invoke(null);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
/**
* leave Dubbo Method
*
* @since 1.2.0
*/
public static void leaveDubbo() {
try {
if (null != METHOD_HOOK_HANDLER) {
METHOD_HOOK_HANDLER.LEAVE_DUBBO.invoke(null);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
public static boolean isFirstLevelDubbo() {
try {
if (null != METHOD_HOOK_HANDLER) {
return (Boolean) METHOD_HOOK_HANDLER.IS_FIRST_LEVEL_DUBBO.invoke(null);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return false;
}
}
|
3e01c51c5fcd79982a1ba4099acbf94808397c1e | 3,065 | java | Java | MenuUEM/src/main/java/br/org/pasqualino/menuuem/listadapter/NotaDaDisciplinaAdapter.java | ggpasqualino/menu-uem | a4c85a0ab6e291362a9f583a39edc352452a94cb | [
"MIT"
] | 1 | 2017-02-20T19:09:43.000Z | 2017-02-20T19:09:43.000Z | MenuUEM/src/main/java/br/org/pasqualino/menuuem/listadapter/NotaDaDisciplinaAdapter.java | ggpasqualino/menu-uem | a4c85a0ab6e291362a9f583a39edc352452a94cb | [
"MIT"
] | null | null | null | MenuUEM/src/main/java/br/org/pasqualino/menuuem/listadapter/NotaDaDisciplinaAdapter.java | ggpasqualino/menu-uem | a4c85a0ab6e291362a9f583a39edc352452a94cb | [
"MIT"
] | null | null | null | 29.190476 | 86 | 0.643067 | 750 | package br.org.pasqualino.menuuem.listadapter;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import br.org.pasqualino.menuuem.R;
import br.org.pasqualino.menuuem.core.LinhaDeNotas;
public class NotaDaDisciplinaAdapter extends BaseAdapter {
private Context context;
private LinhaDeNotas disciplina;
private List<Linha> linhas;
static private String corLinhaPar = "#dfdfdf";
static private String corLinhaImpar = "#efefef";
public NotaDaDisciplinaAdapter(Context context, LinhaDeNotas disciplina) {
this.context = context;
this.disciplina = disciplina;
disciplinaToLinhas();
}
private void disciplinaToLinhas() {
linhas = new ArrayList<Linha>();
for (int i = 0; i < disciplina.getNotas().size(); i++) {
linhas.add(new Linha(disciplina.getNotas().get(i),
disciplina.getFaltas().get(i),
disciplina.getAvaliacoes().get(i)));
}
}
@Override
public int getCount() {
return linhas.size();
}
@Override
public Object getItem(int i) {
return linhas.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
ViewHolder holder = null;
LayoutInflater mInflater = (LayoutInflater)
context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.row_nota_disciplina, null);
holder = new ViewHolder();
holder.nota = (TextView) convertView.findViewById(R.id.nota_tv);
holder.faltas = (TextView) convertView.findViewById(R.id.falta_tv);
holder.avaliacao = (TextView) convertView.findViewById(R.id.avaliacao_tv);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
Linha linha = (Linha) getItem(position);
holder.nota.setText(linha.nota);
holder.faltas.setText(linha.faltas);
holder.avaliacao.setText(linha.avaliacao);
if (position % 2 == 0)
convertView.setBackgroundColor(Color.parseColor(corLinhaPar));
else
convertView.setBackgroundColor(Color.parseColor(corLinhaImpar));
return convertView;
}
private class Linha {
String nota;
String faltas;
String avaliacao;
public Linha(String nota, String faltas, String avaliacao) {
this.nota = nota;
this.faltas = faltas;
this.avaliacao = avaliacao;
}
}
private class ViewHolder {
TextView nota;
TextView faltas;
TextView avaliacao;
}
}
|
3e01c53caff584b9425bc7e843682e6545c8206f | 2,765 | java | Java | lesson24IndexManager/src/main/java/org/walkgis/learngis/lesson24/utils/DrawUtil.java | polixiaohai/learn_gis | 293847056dc965d5063155a61d5971cb25ccb15d | [
"Apache-2.0"
] | 7 | 2019-12-02T16:39:31.000Z | 2021-05-25T01:54:43.000Z | lesson24IndexManager/src/main/java/org/walkgis/learngis/lesson24/utils/DrawUtil.java | polixiaohai/learn_gis | 293847056dc965d5063155a61d5971cb25ccb15d | [
"Apache-2.0"
] | null | null | null | lesson24IndexManager/src/main/java/org/walkgis/learngis/lesson24/utils/DrawUtil.java | polixiaohai/learn_gis | 293847056dc965d5063155a61d5971cb25ccb15d | [
"Apache-2.0"
] | 3 | 2021-02-02T12:33:35.000Z | 2022-03-31T06:11:20.000Z | 35.448718 | 79 | 0.555154 | 751 | package org.walkgis.learngis.lesson24.utils;
import javafx.scene.Cursor;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
/**
* 拉伸工具类
*
* @author Light
*/
public class DrawUtil {
//窗体拉伸属性
private static boolean isRight;// 是否处于右边界调整窗口状态
private static boolean isBottomRight;// 是否处于右下角调整窗口状态
private static boolean isBottom;// 是否处于下边界调整窗口状态
private final static int RESIZE_WIDTH = 5;// 判定是否为调整窗口状态的范围与边界距离
private final static double MIN_WIDTH = 300;// 窗口最小宽度
private final static double MIN_HEIGHT = 250;// 窗口最小高度
public static void addDrawFunc(Stage stage, VBox root) {
root.setOnMouseMoved((MouseEvent event) -> {
event.consume();
double x = event.getSceneX();
double y = event.getSceneY();
double width = stage.getWidth();
double height = stage.getHeight();
Cursor cursorType = Cursor.DEFAULT;// 鼠标光标初始为默认类型,若未进入调整窗口状态,保持默认类型
// 先将所有调整窗口状态重置
isRight = isBottomRight = isBottom = false;
if (y >= height - RESIZE_WIDTH) {
if (x <= RESIZE_WIDTH) {// 左下角调整窗口状态
} else if (x >= width - RESIZE_WIDTH) {// 右下角调整窗口状态
isBottomRight = true;
cursorType = Cursor.SE_RESIZE;
} else {// 下边界调整窗口状态
isBottom = true;
cursorType = Cursor.S_RESIZE;
}
} else if (x >= width - RESIZE_WIDTH) {// 右边界调整窗口状态
isRight = true;
cursorType = Cursor.E_RESIZE;
}
// 最后改变鼠标光标
root.setCursor(cursorType);
});
root.setOnMouseDragged((MouseEvent event) -> {
double x = event.getSceneX();
double y = event.getSceneY();
// 保存窗口改变后的x、y坐标和宽度、高度,用于预判是否会小于最小宽度、最小高度
double nextX = stage.getX();
double nextY = stage.getY();
double nextWidth = stage.getWidth();
double nextHeight = stage.getHeight();
if (isRight || isBottomRight) {// 所有右边调整窗口状态
nextWidth = x;
}
if (isBottomRight || isBottom) {// 所有下边调整窗口状态
nextHeight = y;
}
if (nextWidth <= MIN_WIDTH) {// 如果窗口改变后的宽度小于最小宽度,则宽度调整到最小宽度
nextWidth = MIN_WIDTH;
}
if (nextHeight <= MIN_HEIGHT) {// 如果窗口改变后的高度小于最小高度,则高度调整到最小高度
nextHeight = MIN_HEIGHT;
}
// 最后统一改变窗口的x、y坐标和宽度、高度,可以防止刷新频繁出现的屏闪情况
stage.setX(nextX);
stage.setY(nextY);
stage.setWidth(nextWidth);
stage.setHeight(nextHeight);
});
}
}
|
3e01c646d63b9a652bc330b7538b3227cfc2dc4a | 428 | java | Java | src/main/java/br/com/alura/interception/Logger.java | thalesneves/EJB-com-Java-EE-8-API-Rest-com-JBoss-WildFly | 3a5c39a2aa62f78c30b00405fa42ba76148ae876 | [
"Apache-2.0"
] | null | null | null | src/main/java/br/com/alura/interception/Logger.java | thalesneves/EJB-com-Java-EE-8-API-Rest-com-JBoss-WildFly | 3a5c39a2aa62f78c30b00405fa42ba76148ae876 | [
"Apache-2.0"
] | 1 | 2021-12-10T01:28:06.000Z | 2021-12-10T01:28:06.000Z | src/main/java/br/com/alura/interception/Logger.java | thalesneves/EJB-com-Java-EE-8-API-Rest-com-JBoss-WildFly | 3a5c39a2aa62f78c30b00405fa42ba76148ae876 | [
"Apache-2.0"
] | null | null | null | 23.777778 | 46 | 0.831776 | 752 | package br.com.alura.interception;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.interceptor.InterceptorBinding;
@InterceptorBinding
@Target({ElementType.TYPE,ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Logger {
}
|
3e01c78edca6caa398765d720172f750a5fc5b4e | 8,263 | java | Java | app/src/main/java/us/koller/cameraroll/data/provider/retriever/MediaStoreRetriever.java | ch4ndu/Camera-Roll-Android-App | 01f6fe8a5bec5c53fe01cf03d9526d1bdf6afd77 | [
"Apache-2.0"
] | 569 | 2017-02-11T03:42:15.000Z | 2022-03-09T03:32:43.000Z | app/src/main/java/us/koller/cameraroll/data/provider/retriever/MediaStoreRetriever.java | ch4ndu/Camera-Roll-Android-App | 01f6fe8a5bec5c53fe01cf03d9526d1bdf6afd77 | [
"Apache-2.0"
] | 236 | 2017-03-21T16:15:45.000Z | 2019-09-08T01:45:03.000Z | app/src/main/java/us/koller/cameraroll/data/provider/retriever/MediaStoreRetriever.java | ch4ndu/Camera-Roll-Android-App | 01f6fe8a5bec5c53fe01cf03d9526d1bdf6afd77 | [
"Apache-2.0"
] | 183 | 2017-03-24T22:37:42.000Z | 2022-03-10T06:31:45.000Z | 38.078341 | 109 | 0.53431 | 753 | package us.koller.cameraroll.data.provider.retriever;
import android.app.Activity;
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.provider.BaseColumns;
import android.provider.MediaStore;
import android.support.v4.content.CursorLoader;
import android.util.Log;
import android.widget.Toast;
import java.io.File;
import java.util.ArrayList;
import us.koller.cameraroll.data.fileOperations.FileOperation;
import us.koller.cameraroll.data.models.Album;
import us.koller.cameraroll.data.models.AlbumItem;
import us.koller.cameraroll.data.models.Video;
import us.koller.cameraroll.data.provider.MediaProvider;
//loading media through MediaStore
//advantage: speed, disadvantage: might be missing some items
public class MediaStoreRetriever extends Retriever {
private static final String[] projection = new String[]{
MediaStore.Files.FileColumns.DATA,
/*MediaStore.Files.FileColumns.PARENT,*/
MediaStore.Files.FileColumns.MIME_TYPE,
MediaStore.Images.ImageColumns.DATE_TAKEN,
MediaStore.Video.VideoColumns.DATE_TAKEN,
BaseColumns._ID};
@Override
void loadAlbums(final Activity context, boolean hiddenFolders) {
final long startTime = System.currentTimeMillis();
final ArrayList<Album> albums = new ArrayList<>();
// Return only video and image metadata.
String selection = MediaStore.Files.FileColumns.MEDIA_TYPE + "="
+ MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE
+ " OR "
+ MediaStore.Files.FileColumns.MEDIA_TYPE + "="
+ MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO;
Uri queryUri = MediaStore.Files.getContentUri("external");
CursorLoader cursorLoader = new CursorLoader(
context,
queryUri,
projection,
selection,
null, // Selection args (none).
MediaStore.Files.FileColumns.DATE_ADDED);
final Cursor cursor = cursorLoader.loadInBackground();
if (cursor == null) {
return;
}
//search hiddenFolders
if (hiddenFolders) {
ArrayList<Album> hiddenAlbums = checkHiddenFolders(context);
albums.addAll(hiddenAlbums);
}
AsyncTask.execute(new Runnable() {
@Override
public void run() {
if (cursor.moveToFirst()) {
String path;
long dateTaken, id;
int pathColumn = cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA);
int idColumn = cursor.getColumnIndex(BaseColumns._ID);
do {
path = cursor.getString(pathColumn);
AlbumItem albumItem = AlbumItem.getInstance(context, path);
if (albumItem != null) {
//set dateTaken
int dateTakenColumn = cursor.getColumnIndex(
!(albumItem instanceof Video) ?
MediaStore.Images.ImageColumns.DATE_TAKEN :
MediaStore.Video.VideoColumns.DATE_TAKEN);
dateTaken = cursor.getLong(dateTakenColumn);
albumItem.setDate(dateTaken);
id = cursor.getLong(idColumn);
Uri uri = ContentUris.withAppendedId(
MediaStore.Files.getContentUri("external"), id);
albumItem.setUri(uri);
//search bucket
boolean foundBucket = false;
for (int i = 0; i < albums.size(); i++) {
if (albums.get(i).getPath().equals(FileOperation.Util.getParentPath(path))) {
albums.get(i).getAlbumItems().add(0, albumItem);
foundBucket = true;
break;
}
}
if (!foundBucket) {
//no bucket found
String bucketPath = FileOperation.Util.getParentPath(path);
if (bucketPath != null) {
albums.add(new Album().setPath(bucketPath));
albums.get(albums.size() - 1).getAlbumItems().add(0, albumItem);
}
}
}
} while (cursor.moveToNext());
}
cursor.close();
//done loading media with content resolver
MediaProvider.OnMediaLoadedCallback callback = getCallback();
if (callback != null) {
callback.onMediaLoaded(albums);
}
Log.d("MediaStoreRetriever", "onMediaLoaded(): "
+ String.valueOf(System.currentTimeMillis() - startTime) + " ms");
}
});
}
@Override
public void onDestroy() {
}
private ArrayList<Album> checkHiddenFolders(final Activity context) {
ArrayList<Album> hiddenAlbums = new ArrayList<>();
// Scan all no Media files
String nonMediaCondition = MediaStore.Files.FileColumns.MEDIA_TYPE
+ "=" + MediaStore.Files.FileColumns.MEDIA_TYPE_NONE;
// Files with name contain .nomedia
String selection = nonMediaCondition + " AND "
+ MediaStore.Files.FileColumns.TITLE + " LIKE ?";
String[] params = new String[]{"%" + MediaProvider.FILE_TYPE_NO_MEDIA + "%"};
// make query for non media files with file title contain ".nomedia" as
// text on External Media URI
Cursor cursor = context.getContentResolver().query(
MediaStore.Files.getContentUri("external"),
new String[]{MediaStore.Files.FileColumns.DATA},
selection,
params,
MediaStore.Images.Media.DATE_TAKEN);
if (cursor == null || cursor.getCount() == 0) {
return hiddenAlbums;
}
if (cursor.moveToFirst()) {
int pathColumn = cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA);
do {
String path = cursor.getString(pathColumn);
path = path.replace(MediaProvider.FILE_TYPE_NO_MEDIA, "");
File dir = new File(path);
final Album album = new Album().setPath(path);
File[] files = dir.listFiles();
if (files != null) {
for (int i = 0; i < files.length; i++) {
AlbumItem albumItem = AlbumItem.getInstance(files[i].getPath());
if (albumItem != null) {
album.getAlbumItems().add(albumItem);
}
}
}
if (album.getAlbumItems().size() > 0) {
hiddenAlbums.add(album);
}
} while (cursor.moveToNext());
}
cursor.close();
return hiddenAlbums;
}
public static String getPathForUri(Context context, Uri uri) {
CursorLoader cursorLoader = new CursorLoader(
context, uri, new String[]{MediaStore.Files.FileColumns.DATA},
null, null, null);
try {
final Cursor cursor = cursorLoader.loadInBackground();
if (cursor != null && cursor.getCount() > 0) {
cursor.moveToFirst();
return cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.DATA));
}
return null;
} catch (SecurityException e) {
Toast.makeText(context, "Permission Error", Toast.LENGTH_SHORT).show();
return null;
}
}
}
|
3e01c9ac034da6917fef9a0b75035b104e7089c3 | 598 | java | Java | gulimall-product/src/main/java/com/wxy/gulimall/product/dao/AttrAttrgroupRelationDao.java | wangxye/Miyuan-gulimall | 57fd970e845fdc5b89cce4cc282980c215bc0df9 | [
"Apache-2.0"
] | null | null | null | gulimall-product/src/main/java/com/wxy/gulimall/product/dao/AttrAttrgroupRelationDao.java | wangxye/Miyuan-gulimall | 57fd970e845fdc5b89cce4cc282980c215bc0df9 | [
"Apache-2.0"
] | null | null | null | gulimall-product/src/main/java/com/wxy/gulimall/product/dao/AttrAttrgroupRelationDao.java | wangxye/Miyuan-gulimall | 57fd970e845fdc5b89cce4cc282980c215bc0df9 | [
"Apache-2.0"
] | null | null | null | 27.454545 | 93 | 0.768212 | 754 | package com.wxy.gulimall.product.dao;
import com.wxy.gulimall.product.entity.AttrAttrgroupRelationEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 属性&属性分组关联
*
* @author Wangxuanye
* @email [email protected]
* @date 2020-09-03 10:32:09
*/
@Mapper
public interface AttrAttrgroupRelationDao extends BaseMapper<AttrAttrgroupRelationEntity> {
void deleteBatchRelation(@Param("entities") List<AttrAttrgroupRelationEntity> entities);
}
|
3e01c9dc3cb71e0db1119f732a6743e3e72ab3f7 | 4,227 | java | Java | build/tmp/expandedArchives/forge-1.16.2-33.0.5_mapped_snapshot_20200514-1.16-sources.jar_9d07f867eb9352dbb54585a794282e64/net/minecraft/data/StockTextureAliases.java | twmicro/BedrockLanguage | 72b44d8b8dab1d6128fa2f4c51bfc247f95f94b0 | [
"Apache-2.0"
] | null | null | null | build/tmp/expandedArchives/forge-1.16.2-33.0.5_mapped_snapshot_20200514-1.16-sources.jar_9d07f867eb9352dbb54585a794282e64/net/minecraft/data/StockTextureAliases.java | twmicro/BedrockLanguage | 72b44d8b8dab1d6128fa2f4c51bfc247f95f94b0 | [
"Apache-2.0"
] | null | null | null | build/tmp/expandedArchives/forge-1.16.2-33.0.5_mapped_snapshot_20200514-1.16-sources.jar_9d07f867eb9352dbb54585a794282e64/net/minecraft/data/StockTextureAliases.java | twmicro/BedrockLanguage | 72b44d8b8dab1d6128fa2f4c51bfc247f95f94b0 | [
"Apache-2.0"
] | null | null | null | 60.385714 | 107 | 0.80388 | 755 | package net.minecraft.data;
import javax.annotation.Nullable;
public final class StockTextureAliases {
public static final StockTextureAliases field_240404_a_ = func_240431_a_("all");
public static final StockTextureAliases field_240405_b_ = func_240432_a_("texture", field_240404_a_);
public static final StockTextureAliases field_240406_c_ = func_240432_a_("particle", field_240405_b_);
public static final StockTextureAliases field_240407_d_ = func_240432_a_("end", field_240404_a_);
public static final StockTextureAliases field_240408_e_ = func_240432_a_("bottom", field_240407_d_);
public static final StockTextureAliases field_240409_f_ = func_240432_a_("top", field_240407_d_);
public static final StockTextureAliases field_240410_g_ = func_240432_a_("front", field_240404_a_);
public static final StockTextureAliases field_240411_h_ = func_240432_a_("back", field_240404_a_);
public static final StockTextureAliases field_240412_i_ = func_240432_a_("side", field_240404_a_);
public static final StockTextureAliases field_240413_j_ = func_240432_a_("north", field_240412_i_);
public static final StockTextureAliases field_240414_k_ = func_240432_a_("south", field_240412_i_);
public static final StockTextureAliases field_240415_l_ = func_240432_a_("east", field_240412_i_);
public static final StockTextureAliases field_240416_m_ = func_240432_a_("west", field_240412_i_);
public static final StockTextureAliases field_240417_n_ = func_240431_a_("up");
public static final StockTextureAliases field_240418_o_ = func_240431_a_("down");
public static final StockTextureAliases field_240419_p_ = func_240431_a_("cross");
public static final StockTextureAliases field_240420_q_ = func_240431_a_("plant");
public static final StockTextureAliases field_240421_r_ = func_240432_a_("wall", field_240404_a_);
public static final StockTextureAliases field_240422_s_ = func_240431_a_("rail");
public static final StockTextureAliases field_240423_t_ = func_240431_a_("wool");
public static final StockTextureAliases field_240424_u_ = func_240431_a_("pattern");
public static final StockTextureAliases field_240425_v_ = func_240431_a_("pane");
public static final StockTextureAliases field_240426_w_ = func_240431_a_("edge");
public static final StockTextureAliases field_240427_x_ = func_240431_a_("fan");
public static final StockTextureAliases field_240428_y_ = func_240431_a_("stem");
public static final StockTextureAliases field_240429_z_ = func_240431_a_("upperstem");
public static final StockTextureAliases field_240393_A_ = func_240431_a_("crop");
public static final StockTextureAliases field_240394_B_ = func_240431_a_("dirt");
public static final StockTextureAliases field_240395_C_ = func_240431_a_("fire");
public static final StockTextureAliases field_240396_D_ = func_240431_a_("lantern");
public static final StockTextureAliases field_240397_E_ = func_240431_a_("platform");
public static final StockTextureAliases field_240398_F_ = func_240431_a_("unsticky");
public static final StockTextureAliases field_240399_G_ = func_240431_a_("torch");
public static final StockTextureAliases field_240400_H_ = func_240431_a_("layer0");
public static final StockTextureAliases field_240401_I_ = func_240431_a_("lit_log");
private final String field_240402_J_;
@Nullable
private final StockTextureAliases field_240403_K_;
private static StockTextureAliases func_240431_a_(String p_240431_0_) {
return new StockTextureAliases(p_240431_0_, (StockTextureAliases)null);
}
private static StockTextureAliases func_240432_a_(String p_240432_0_, StockTextureAliases p_240432_1_) {
return new StockTextureAliases(p_240432_0_, p_240432_1_);
}
private StockTextureAliases(String p_i232547_1_, @Nullable StockTextureAliases p_i232547_2_) {
this.field_240402_J_ = p_i232547_1_;
this.field_240403_K_ = p_i232547_2_;
}
public String func_240430_a_() {
return this.field_240402_J_;
}
@Nullable
public StockTextureAliases func_240433_b_() {
return this.field_240403_K_;
}
public String toString() {
return "#" + this.field_240402_J_;
}
} |
3e01c9e247da2471dcd941bfaf5bb525f4b303b3 | 9,330 | java | Java | server/netty/src/main/java/com/riiablo/server/netty/ReliableChannelHandler.java | fredells/riiablo | 468ecf7201f67c63a6a150aab5ae4bbefb27c454 | [
"Apache-2.0"
] | 543 | 2019-03-30T23:50:39.000Z | 2022-03-29T09:45:29.000Z | server/netty/src/main/java/com/riiablo/server/netty/ReliableChannelHandler.java | fredells/riiablo | 468ecf7201f67c63a6a150aab5ae4bbefb27c454 | [
"Apache-2.0"
] | 127 | 2019-03-29T11:49:49.000Z | 2022-03-01T19:02:28.000Z | server/netty/src/main/java/com/riiablo/server/netty/ReliableChannelHandler.java | fredells/riiablo | 468ecf7201f67c63a6a150aab5ae4bbefb27c454 | [
"Apache-2.0"
] | 73 | 2019-04-01T16:35:11.000Z | 2022-03-29T10:16:47.000Z | 32.736842 | 148 | 0.681565 | 756 | package com.riiablo.server.netty;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.CompositeByteBuf;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandler;
import io.netty.channel.ChannelOutboundHandler;
import io.netty.channel.ChannelPromise;
import io.netty.channel.socket.DatagramPacket;
import io.netty.util.ReferenceCountUtil;
import io.netty.util.internal.TypeParameterMatcher;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import com.badlogic.gdx.Gdx;
import com.riiablo.net.packet.netty.Netty;
public class ReliableChannelHandler implements ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler {
private static final String TAG = "ReliableChannelHandler";
private static final boolean DEBUG = true;
private static final boolean DEBUG_SEQ = DEBUG && true;
private static final boolean DEBUG_OUTBOUND = DEBUG && true;
private static final boolean DEBUG_INBOUND = DEBUG && true;
private final TypeParameterMatcher matcher;
private static final int PROTOCOL = 0;
int seq = -1; // 0xFFFFFFFF
int ack = -1; // 0xFFFFFFFF
int ack_bits = 0;
ReliableChannelHandler() {
matcher = TypeParameterMatcher.get(DatagramPacket.class);
}
protected boolean accept(Object msg) throws Exception {
return matcher.match(msg);
}
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
InetSocketAddress sender = msg.sender();
Gdx.app.log(TAG, "channelRead0 Packet from " + sender.getHostName() + ":" + sender.getPort());
ByteBuf in = msg.content();
if (DEBUG_INBOUND) Gdx.app.log(TAG, " " + ByteBufUtil.hexDump(in));
try {
boolean valid = processHeader(ctx, in);
if (!valid) return;
ByteBuf content = Packet.Single.getContent(in);
if (DEBUG_INBOUND) Gdx.app.log(TAG, " " + ByteBufUtil.hexDump(content));
ByteBuffer buffer = content.nioBuffer();
PacketTuple packet = PacketTuple.obtain(0, buffer);
processPacket(ctx, packet.data);
} finally {
// in.release(); // Automatically released by channelRead() right now
}
}
protected boolean processHeader(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
int remoteProtocol = Packet.getProtocol(in);
if (remoteProtocol != PROTOCOL) {
Gdx.app.log(TAG, " rejected incoming PROTO:" + remoteProtocol);
return false;
}
int type = Packet.getType(in);
if (DEBUG_INBOUND) {
ByteBuf header = null;
switch (type) {
case Packet.SINGLE: header = Packet.Single.getHeader(in); break;
case Packet.FRAGMENTED: header = Packet.Fragmented.getHeader(in); break;
case Packet.SLICED: header = Packet.Sliced.getHeader(in); break;
case Packet.SLICEDACK: header = Packet.SlicedAck.getHeader(in); break;
default:
Gdx.app.log(TAG, " rejected incoming TYPE:" + type);
return false;
}
Gdx.app.log(TAG, " " + ByteBufUtil.hexDump(header));
}
switch (type) {
case Packet.SINGLE: {
int remoteSeq = Packet.getSEQ(in);
Gdx.app.log(TAG, " accepted incoming " + Packet.Single.toString(in));
if (ack < 0) {
ack = remoteSeq;
Gdx.app.log(TAG, " init ack=" + ack);
} else if (sequenceGreater(remoteSeq, ack)) {
int shift = difference(remoteSeq, ack);
Gdx.app.log(TAG, " remoteSeq=" + remoteSeq + "; ack=" + ack + "; shift=" + shift);
ack_bits <<= shift;
ack_bits |= (1 << (shift - 1));
ack = remoteSeq;
} else {
int diff = difference(ack, remoteSeq);
Gdx.app.log(TAG, " diff=" + diff);
if (diff <= Integer.SIZE) {
ack_bits |= (1 << (diff - 1));
}
}
Gdx.app.log(TAG, " " + String.format("ACK:%d ACK_BITS:%08x", ack, ack_bits));
break;
}
default:
throw new AssertionError();
}
return true;
}
protected static boolean sequenceGreater(int a, int b) {
return ((a > b) && (a - b <= Short.MAX_VALUE))
|| ((a < b) && (b - a > Short.MAX_VALUE));
}
protected static int difference(int a, int b) {
assert sequenceGreater(a, b) : a + "<" + b;
if ((a > b) && (a - b <= Short.MAX_VALUE)) {
return a - b;
} else {
return a + 0xFFFF - b + 1;
}
}
protected void processPacket(ChannelHandlerContext ctx, Netty netty) throws Exception {
}
protected int nextSequence() {
return seq = (seq + 1) & 0xFFFF;
}
protected Object channelWrite0(ChannelHandlerContext ctx, Object msg) throws Exception {
InetSocketAddress receiver = (InetSocketAddress) ctx.channel().remoteAddress();
Gdx.app.log(TAG, "channelWrite0 Packet to " + receiver.getHostName() + ":" + receiver.getPort());
ByteBuf header = ctx.alloc().buffer(); // TODO: worth sizing this correctly?
Packet.Single.createHeader(header, PROTOCOL, nextSequence(), ack, ack_bits);
if (DEBUG_SEQ) Gdx.app.log(TAG, " " + Packet.Single.toString(header));
if (DEBUG_OUTBOUND) Gdx.app.log(TAG, " " + ByteBufUtil.hexDump(header));
ByteBuf content = (ByteBuf) msg;
Packet.Single.setContentSize(header, content.readableBytes());
CompositeByteBuf composite = ctx.alloc().compositeBuffer(2)
.addComponent(true, header)
.addComponent(true, content);
if (DEBUG_OUTBOUND) Gdx.app.log(TAG, " " + ByteBufUtil.hexDump(content));
if (DEBUG_OUTBOUND) Gdx.app.log(TAG, " " + ByteBufUtil.hexDump(composite));
return composite;
}
@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
Gdx.app.debug(TAG, "channelRegistered");
ctx.fireChannelRegistered();
}
@Override
public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
Gdx.app.debug(TAG, "channelUnregistered");
ctx.fireChannelUnregistered();
}
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
Gdx.app.debug(TAG, "channelActive");
ctx.fireChannelActive();
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
Gdx.app.debug(TAG, "channelInactive");
ctx.fireChannelInactive();
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
Gdx.app.debug(TAG, "channelRead");
boolean release = true;
try {
if (accept(msg)) {
DatagramPacket datagramPacket = (DatagramPacket) msg;
channelRead0(ctx, datagramPacket);
} else {
release = false;
ctx.fireChannelRead(msg);
}
} finally {
if (release) ReferenceCountUtil.release(msg);
}
}
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
Gdx.app.debug(TAG, "channelReadComplete");
ctx.fireChannelReadComplete();
}
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
Gdx.app.debug(TAG, "userEventTriggered");
ctx.fireUserEventTriggered(evt);
}
@Override
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
Gdx.app.debug(TAG, "channelWritabilityChanged");
ctx.fireChannelWritabilityChanged();
}
@Override
public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception {
Gdx.app.debug(TAG, "bind");
ctx.bind(localAddress, promise);
}
@Override
public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception {
Gdx.app.debug(TAG, "connect");
ctx.connect(remoteAddress, localAddress, promise);
}
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
Gdx.app.debug(TAG, "disconnect");
ctx.disconnect(promise);
}
@Override
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
Gdx.app.debug(TAG, "close");
ctx.close(promise);
}
@Override
public void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
Gdx.app.debug(TAG, "deregister");
ctx.deregister(promise);
}
@Override
public void read(ChannelHandlerContext ctx) throws Exception {
Gdx.app.debug(TAG, "read");
ctx.read();
}
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
Gdx.app.debug(TAG, "write");
msg = channelWrite0(ctx, msg);
ctx.write(msg, promise);
}
@Override
public void flush(ChannelHandlerContext ctx) throws Exception {
Gdx.app.debug(TAG, "flush");
ctx.flush();
}
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
Gdx.app.debug(TAG, "handlerAdded");
}
@Override
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
Gdx.app.debug(TAG, "handlerRemoved");
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
Gdx.app.debug(TAG, "exceptionCaught");
ctx.fireExceptionCaught(cause);
}
}
|
3e01ca439716985eed62e7abf33ace3e69870489 | 2,030 | java | Java | kanjoto-android/src/summea/kanjoto/adapter/NotevalueAdapter.java | datanets/kanjoto | 011a2ddf6ab1b9641c5bb74cbb501ee30f716c49 | [
"MIT"
] | 1 | 2015-02-15T04:01:06.000Z | 2015-02-15T04:01:06.000Z | kanjoto-android/src/summea/kanjoto/adapter/NotevalueAdapter.java | summea/kanjoto | 011a2ddf6ab1b9641c5bb74cbb501ee30f716c49 | [
"MIT"
] | 136 | 2015-01-01T07:52:03.000Z | 2016-02-11T05:26:11.000Z | kanjoto-android/src/summea/kanjoto/adapter/NotevalueAdapter.java | datanets/otashu | 011a2ddf6ab1b9641c5bb74cbb501ee30f716c49 | [
"MIT"
] | null | null | null | 28.591549 | 97 | 0.693596 | 757 |
package summea.kanjoto.adapter;
import java.util.List;
import summea.kanjoto.model.NotevalueAndRelated;
import summea.kanjoto.R;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
public class NotevalueAdapter extends BaseAdapter {
private Context mContext;
private List<NotevalueAndRelated> notevaluesAndRelated;
public NotevalueAdapter(Context context, List<NotevalueAndRelated> allNotevaluesAndRelated) {
mContext = context;
notevaluesAndRelated = allNotevaluesAndRelated;
}
@Override
public int getCount() {
return notevaluesAndRelated.size();
}
@Override
public Object getItem(int position) {
return notevaluesAndRelated.get(position);
}
@Override
public long getItemId(int position) {
return notevaluesAndRelated.get(position).getNotevalue().getId();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = ((LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
R.layout.row_notevalue, null);
}
TextView notevalue = (TextView) convertView.findViewById(R.id.notevalue);
notevalue.setText(notevaluesAndRelated.get(position).getNotevalue().getNotelabel());
// set relevant background color, if available
if (notevaluesAndRelated.get(position).getLabel().getColor() != null) {
notevalue.setBackgroundColor(Color.parseColor(notevaluesAndRelated.get(position)
.getLabel().getColor()));
}
return convertView;
}
public Object removeItem(int position) {
return notevaluesAndRelated.remove(position);
}
public void clear() {
notevaluesAndRelated.clear();
}
}
|
3e01cb24c346170a984ddd19c6dba2ab1c7cccaf | 10,802 | java | Java | implementation/JCOOL/jcool/benchmark/src/main/java/cz/cvut/felk/cig/jcool/benchmark/method/ant/aco/ACOMethod.java | kordikp/AutoMLprediction | 6f87bd0b95ce78103c9f4f83ee85d831ab60a0a6 | [
"Apache-2.0"
] | 1 | 2018-03-22T12:45:32.000Z | 2018-03-22T12:45:32.000Z | implementation/JCOOL/jcool/benchmark/src/main/java/cz/cvut/felk/cig/jcool/benchmark/method/ant/aco/ACOMethod.java | kordikp/AutoMLprediction | 6f87bd0b95ce78103c9f4f83ee85d831ab60a0a6 | [
"Apache-2.0"
] | null | null | null | implementation/JCOOL/jcool/benchmark/src/main/java/cz/cvut/felk/cig/jcool/benchmark/method/ant/aco/ACOMethod.java | kordikp/AutoMLprediction | 6f87bd0b95ce78103c9f4f83ee85d831ab60a0a6 | [
"Apache-2.0"
] | null | null | null | 28.882353 | 167 | 0.639789 | 758 | package cz.cvut.felk.cig.jcool.benchmark.method.ant.aco;
import cz.cvut.felk.cig.jcool.benchmark.stopcondition.SimpleStopCondition;
import cz.cvut.felk.cig.jcool.core.*;
import cz.cvut.felk.cig.jcool.utils.MachineAccuracy;
import org.ytoh.configurations.annotations.Component;
import org.ytoh.configurations.annotations.Property;
import org.ytoh.configurations.annotations.Range;
import java.util.Arrays;
import java.util.Random;
/**
* ACO* optimization method class.
*/
@Component(name = "ACO*: Extended Ant Colony Optimization")
public class ACOMethod implements OptimizationMethod<ValuePointListTelemetry> {
private ObjectiveFunction function;
private SimpleStopCondition stopCondition;
private ValuePointListTelemetry telemetry;
private Consumer<? super ValuePointListTelemetry> consumer;
/**
* Number of ants.
*/
@Property(name = "Population Size", description = "Number of ants in the population")
@Range(from = 1, to = Integer.MAX_VALUE)
private int populationSize = 60; // number of ants
/**
* Deviation parameter Omega.
* Lower value - better solutions are strongly preferred.
*/
@Property(name = "Deviation Parameter: Omega", description = "Lower value - better solutions are strongly preferred")
@Range(from = 0.0, to = 1.0)
private double omega = 0.8; // deviation parameter. lower - better solutions are strongly preferred
/**
* Deviation parameter Sigma.
* Lower value - faster convergence.
*/
@Property(name = "Convergence Parameter: Sigma", description = "Lower value - faster convergence")
@Range(from = 0.0, to = 1.0)
private double sigma = 0.4; // from (0, 1): speed of convergence parameter. lower - faster convergence
/**
* Number of ants to replace in the population each iteration.
*/
@Property(name = "Number of Replaced Ants", description = "Number of ants to replace in the population")
@Range(from = 0, to = Integer.MAX_VALUE)
private int replace = 60; // number of ants to replace in one iteration
/**
* Whether standard deviation is used instead of average value.
*/
@Property(name = "Use Standard Deviation (otherwise use Average)")
private boolean standardDeviation = true; // use standard deviation? otherwise average is used
/**
* Limits the neighbourhood for the deviation computation by diversityLimit value.
*/
@Property(name = "Force Diversity", description = "Limit the neighbourhood for the deviation computation by diversityLimit")
private boolean forceDiversity = false; // limit neighbourhood for the deviation computation by diversityLimit
/**
* Neighborhood size used for Force diversity.
*/
@Property(name = "Neighborhood Size for Force Diversity")
@Range(from = 0.0, to = 1.0)
private double diversityLimit = 0.1; // size of neighborhood for forceDiversity
@Property(name = "Parameter Minimum - Limits the Search Space")
@Range(from = -Double.MAX_VALUE, to = Double.MAX_VALUE)
private double min = -10.0; // parameter minimum
@Property(name = "Parameter Maximum - Limits the Search Space")
@Range(from = -Double.MAX_VALUE, to = Double.MAX_VALUE)
private double max = 10.0; // parameter maximum
@Property(name = "Gradient Heuristic Weight")
@Range(from = 0.0, to = 1.0)
private double gradientWeight = 0.0; // gradient heuristic impact
private int dimension; // number of variables to optimize
/**
* Ants in the colony (population).
*/
private Ant[] ants; // ants in colony
private Random generator;
/**
* Globally best value point.
*/
private ValuePoint globalBest; // globaly best variables vector
/**
* Locally best value point.
*/
private ValuePoint localBest; // local best position
public ACOMethod() {
this.stopCondition = new SimpleStopCondition();
this.stopCondition.init(Double.POSITIVE_INFINITY, MachineAccuracy.EPSILON, MachineAccuracy.SQRT_EPSILON, 20);
this.telemetry = new ValuePointListTelemetry();
}
public void init(ObjectiveFunction function) {
this.function = function;
dimension = function.getDimension();
min = Math.max(min, function.getMinimum()[0]);
max = Math.min(max, function.getMaximum()[0]);
ants = new Ant[populationSize + replace];
for (int i = 0; i < populationSize + replace; i++)
ants[i] = new Ant(ValuePoint.at(Point.random(dimension, min, max), function));
generator = new Random();
globalBest = localBest = ValuePoint.at(Point.getDefault(), Double.POSITIVE_INFINITY);
stopCondition.setInitialValue(Double.POSITIVE_INFINITY);
sortAnts();
}
public StopCondition[] getStopConditions() {
return new StopCondition[]{stopCondition};
}
public void optimize() {
createNewAnts();
sortAnts();
telemetry = new ValuePointListTelemetry(Arrays.asList(getData()));
if (consumer != null)
consumer.notifyOf(this);
stopCondition.setValue(globalBest.getValue());
}
public void addConsumer(Consumer<? super ValuePointListTelemetry> consumer) {
this.consumer = consumer;
}
public ValuePoint[] getData() {
ValuePoint[] tmp = new ValuePoint[populationSize + replace];
for (int i = 0; i < populationSize + replace; i++)
tmp[i] = ants[i].getData();
return tmp;
}
public ValuePointListTelemetry getValue() {
return telemetry;
}
/**
* Updates global and local best values using the ant's value.
* @param ant Ant to be used for global/local information update.
*/
void countErrors(int ant) {
// local best solution
if (ants[ant].getValue() < localBest.getValue()) {
localBest = ants[ant].getData();
// global best solution
if (ants[ant].getValue() < globalBest.getValue())
globalBest = ants[ant].getData();
}
}
/**
* Sorts the ants according to their cost.
*/
private void sortAnts() {
for (int i = 0; i < populationSize + replace; i++)
countErrors(i);
Arrays.sort(ants);
}
/**
* Counts sum of weights for all ants.
*/
private double getWeightsSum() {
double sumWeights = 0.0;
for (int i = 0; i < populationSize; i++) {
ants[i].gradientWeight = ((1 / (omega * populationSize * Math.sqrt(2 * Math.PI))) * Math.exp(-(i * i) / (2 * omega * omega * populationSize * populationSize)));
sumWeights += ants[i].gradientWeight;
}
return sumWeights;
}
private void addGradient(double[] solution) {
double[] gradient = function.gradientAt(Point.at(solution)).toArray();
for (int d = 0; d < dimension; d++)
solution[d] -= gradientWeight * gradient[d];
}
/**
* Chooses ant from the population using the sum of weights as a probabilistic measure.
* @param sumWeights Sum of the ants' wights
* @return index of chosen ant.
*/
private int chooseAnt(double sumWeights) {
double ran = generator.nextDouble() * sumWeights;
double sum = 0.0;
int chosen = 0;
while (sum < ran)
sum += ants[chosen++].gradientWeight;
return --chosen;
}
/**
* Computes the standard deviation of the population.
* @param mean mean valu of the population
* @param i ith ant to be used for computation of the deviation.
* @return standard deviation or average of the populaiton.
*/
private double getDeviation(double mean, int i) {
double deviation = 0.0;
int nearestCount = 0;
for (int n = 0; n < populationSize; n++) {
double tmp = (ants[n].getPoint().toArray()[i] - mean);
if (!standardDeviation) {
if ((!forceDiversity) || (tmp < diversityLimit)) {
deviation += Math.abs(tmp);
nearestCount++;
}
} else {
if ((!forceDiversity) || (tmp < diversityLimit)) {
deviation += (tmp * tmp);
nearestCount++;
}
}
}
if (!standardDeviation)
deviation /= nearestCount;
else {
deviation /= (nearestCount - 1);
deviation = Math.sqrt(deviation);
}
deviation *= sigma;
return deviation;
}
/**
* Samples the weighted probabilistic funciton and creates new population.
*/
private void createNewAnts() {
double sumWeights = getWeightsSum();
for (int num = populationSize; num < populationSize + replace; num++) {
int chosen = chooseAnt(sumWeights);
double mean;
double deviation;
double[] newAntPos = new double[dimension];
for (int i = 0; i < dimension; i++) {
mean = ants[chosen].getPoint().toArray()[i];
deviation = getDeviation(mean, i);
// sample Xi -> new mi & sigma
double x = (generator.nextGaussian() * deviation) + mean;
newAntPos[i] = x;
}
// pheromone & gradient heuristic
if (gradientWeight != 0.0)
addGradient(newAntPos);
ants[num].setData(ValuePoint.at(Point.at(newAntPos), function));
}
}
public int getPopulationSize() {
return populationSize;
}
public void setPopulationSize(int populationSize) {
this.populationSize = populationSize;
}
public double getOmega() {
return omega;
}
public void setOmega(double omega) {
this.omega = omega;
}
public double getSigma() {
return sigma;
}
public void setSigma(double sigma) {
this.sigma = sigma;
}
public int getReplace() {
return replace;
}
public void setReplace(int replace) {
this.replace = replace;
}
public boolean isStandardDeviation() {
return standardDeviation;
}
public void setStandardDeviation(boolean standardDeviation) {
this.standardDeviation = standardDeviation;
}
public boolean isForceDiversity() {
return forceDiversity;
}
public void setForceDiversity(boolean forceDiversity) {
this.forceDiversity = forceDiversity;
}
public double getDiversityLimit() {
return diversityLimit;
}
public void setDiversityLimit(double diversityLimit) {
this.diversityLimit = diversityLimit;
}
public double getGradientWeight() {
return gradientWeight;
}
public void setGradientWeight(double gradientWeight) {
this.gradientWeight = gradientWeight;
}
public double getMin() {
return min;
}
public void setMin(double min) {
this.min = min;
}
public double getMax() {
return max;
}
public void setMax(double max) {
this.max = max;
}
}
|
3e01ccb044bc773cc604f42d35aea4dabeff0249 | 1,226 | java | Java | src/test/java/com/xsw/neo/service/simplecase/Demo12.java | shengwen-xue/neo-service | e6476f8e02c61c9707456b5266f3983a6cd6d083 | [
"MulanPSL-1.0"
] | null | null | null | src/test/java/com/xsw/neo/service/simplecase/Demo12.java | shengwen-xue/neo-service | e6476f8e02c61c9707456b5266f3983a6cd6d083 | [
"MulanPSL-1.0"
] | null | null | null | src/test/java/com/xsw/neo/service/simplecase/Demo12.java | shengwen-xue/neo-service | e6476f8e02c61c9707456b5266f3983a6cd6d083 | [
"MulanPSL-1.0"
] | null | null | null | 30.65 | 81 | 0.587276 | 759 | package com.xsw.neo.service.simplecase;
import cn.hutool.core.lang.Console;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/**
* @author xueshengwen
* @since 2021/2/2 13:39
*/
public class Demo12 {
public static void main(String[] args) throws IOException {
File file = new File("C:/mtn/783e4ef71d8b4b31a32cad87d2a8f401.txt");
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
String str = "";
int line = 1;
List<String> strings = new ArrayList<>();
BufferedWriter writer = null;
while ((str = bufferedReader.readLine()) != null) {
System.out.println("第" + line + "行:" + str);
String substring = str.substring(0, str.indexOf("||"));
System.out.println(substring);
File file1 = new File("C:/mtn/1.txt");
writer = new BufferedWriter(new FileWriter(file1.getPath(), true));
writer.write(substring + "\n");
writer.flush();
substring = "('" + substring + "')";
strings.add(substring);
line++;
}
System.out.println(strings.toString());
Console.log(strings.size());
}
}
|
3e01ccc4a2d7c226979bcb3b6204257cc149ae02 | 2,062 | java | Java | engine/src/test/java/org/camunda/bpm/engine/test/bpmn/exclusive/ExclusiveTimerEventTest.java | mrFranklin/camunda-bpm-platform | 7c5bf37307d3eeac3aee5724b6e4669a9992eaba | [
"Apache-2.0"
] | 2,577 | 2015-01-02T07:43:55.000Z | 2022-03-31T22:31:45.000Z | engine/src/test/java/org/camunda/bpm/engine/test/bpmn/exclusive/ExclusiveTimerEventTest.java | mrFranklin/camunda-bpm-platform | 7c5bf37307d3eeac3aee5724b6e4669a9992eaba | [
"Apache-2.0"
] | 839 | 2015-01-12T22:06:28.000Z | 2022-03-24T13:26:29.000Z | engine/src/test/java/org/camunda/bpm/engine/test/bpmn/exclusive/ExclusiveTimerEventTest.java | mrFranklin/camunda-bpm-platform | 7c5bf37307d3eeac3aee5724b6e4669a9992eaba | [
"Apache-2.0"
] | 1,270 | 2015-01-02T03:39:25.000Z | 2022-03-31T06:04:37.000Z | 36.821429 | 89 | 0.768186 | 760 | /*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership. Camunda licenses this file to you under the Apache License,
* Version 2.0; 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.camunda.bpm.engine.test.bpmn.exclusive;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.camunda.bpm.engine.impl.util.ClockUtil;
import org.camunda.bpm.engine.runtime.JobQuery;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.camunda.bpm.engine.test.Deployment;
import org.camunda.bpm.engine.test.util.PluggableProcessEngineTest;
import org.junit.Test;
public class ExclusiveTimerEventTest extends PluggableProcessEngineTest {
@Deployment
@Test
public void testCatchingTimerEvent() throws Exception {
// Set the clock fixed
Date startTime = new Date();
// After process start, there should be 3 timers created
ProcessInstance pi = runtimeService.startProcessInstanceByKey("exclusiveTimers");
JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());
assertEquals(3, jobQuery.count());
// After setting the clock to time '50minutes and 5 seconds', the timers should fire
ClockUtil.setCurrentTime(new Date(startTime.getTime() + ((50 * 60 * 1000) + 5000)));
testRule.waitForJobExecutorToProcessAllJobs(5000L);
assertEquals(0, jobQuery.count());
testRule.assertProcessEnded(pi.getProcessInstanceId());
}
} |
3e01ccc4f5246802e2e412a439ec9ec40e6f31c8 | 5,177 | java | Java | modules/base/platform-impl/src/main/java/com/intellij/internal/statistic/persistence/ApplicationStatisticsPersistenceComponent.java | MC-JY/consulo | ebd31008fcfd03e144b46a9408d2842d0b06ffc8 | [
"Apache-2.0"
] | 634 | 2015-01-01T19:14:25.000Z | 2022-03-22T11:42:50.000Z | modules/base/platform-impl/src/main/java/com/intellij/internal/statistic/persistence/ApplicationStatisticsPersistenceComponent.java | MC-JY/consulo | ebd31008fcfd03e144b46a9408d2842d0b06ffc8 | [
"Apache-2.0"
] | 410 | 2015-01-19T09:57:51.000Z | 2022-03-22T16:24:59.000Z | modules/base/platform-impl/src/main/java/com/intellij/internal/statistic/persistence/ApplicationStatisticsPersistenceComponent.java | MC-JY/consulo | ebd31008fcfd03e144b46a9408d2842d0b06ffc8 | [
"Apache-2.0"
] | 50 | 2015-03-10T04:14:49.000Z | 2022-03-22T07:08:45.000Z | 37.788321 | 146 | 0.697122 | 761 | /*
* Copyright 2000-2012 JetBrains s.r.o.
*
* 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.intellij.internal.statistic.persistence;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.components.*;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Function;
import jakarta.inject.Singleton;
import org.jdom.Element;
import javax.annotation.Nonnull;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@State(name = "StatisticsApplicationUsages", storages = @Storage(value = "statistics.application.usages.xml", roamingType = RoamingType.DISABLED))
@Singleton
public class ApplicationStatisticsPersistenceComponent extends ApplicationStatisticsPersistence implements PersistentStateComponent<Element> {
public static ApplicationStatisticsPersistenceComponent getInstance() {
return ServiceManager.getService(ApplicationStatisticsPersistenceComponent.class);
}
private static final String TOKENIZER = ",";
private static final String GROUP_TAG = "group";
private static final String GROUP_NAME_ATTR = "name";
private static final String PROJECT_TAG = "project";
private static final String PROJECT_ID_ATTR = "id";
private static final String VALUES_ATTR = "values";
@Override
public void loadState(final Element element) {
List<Element> groups = element.getChildren(GROUP_TAG);
for (Element groupElement : groups) {
String groupName = groupElement.getAttributeValue(GROUP_NAME_ATTR);
List<Element> projectsList = groupElement.getChildren(PROJECT_TAG);
for (Element projectElement : projectsList) {
String projectId = projectElement.getAttributeValue(PROJECT_ID_ATTR);
String frameworks = projectElement.getAttributeValue(VALUES_ATTR);
if (!StringUtil.isEmptyOrSpaces(projectId) && !StringUtil.isEmptyOrSpaces(frameworks)) {
Set<UsageDescriptor> frameworkDescriptors = new HashSet<UsageDescriptor>();
for (String key : StringUtil.split(frameworks, TOKENIZER)) {
final UsageDescriptor descriptor = getUsageDescriptor(key);
if (descriptor != null) frameworkDescriptors.add(descriptor);
}
getApplicationData(groupName).put(projectId, frameworkDescriptors);
}
}
}
}
@Override
public Element getState() {
Element element = new Element("state");
for (Map.Entry<String, Map<String, Set<UsageDescriptor>>> appData : getApplicationData().entrySet()) {
Element groupElement = new Element(GROUP_TAG);
groupElement.setAttribute(GROUP_NAME_ATTR, appData.getKey());
boolean isEmptyGroup = true;
for (Map.Entry<String, Set<UsageDescriptor>> projectData : appData.getValue().entrySet()) {
Element projectElement = new Element(PROJECT_TAG);
projectElement.setAttribute(PROJECT_ID_ATTR, projectData.getKey());
final Set<UsageDescriptor> projectDataValue = projectData.getValue();
if (!projectDataValue.isEmpty()) {
projectElement.setAttribute(VALUES_ATTR, joinUsages(projectDataValue));
groupElement.addContent(projectElement);
isEmptyGroup = false;
}
}
if (!isEmptyGroup) {
element.addContent(groupElement);
}
}
return element;
}
private static UsageDescriptor getUsageDescriptor(String usage) {
// for instance, usage can be: "_foo"(equals "_foo=1") or "_foo=2"
try {
final int i = usage.indexOf('=');
if (i > 0 && i < usage.length() - 1) {
String key = usage.substring(0, i).trim();
String value = usage.substring(i + 1).trim();
if (!StringUtil.isEmptyOrSpaces(key) && !StringUtil.isEmptyOrSpaces(value)) {
try {
final int count = Integer.parseInt(value);
if (count > 0) {
return new UsageDescriptor(key, count);
}
}
catch (NumberFormatException ignored) {
}
}
}
return new UsageDescriptor(usage, 1);
}
catch (AssertionError e) {
//escape loading of invalid usages
}
return null;
}
private static String joinUsages(@Nonnull Set<UsageDescriptor> usages) {
// for instance, usage can be: "_foo"(equals "_foo=1") or "_foo=2"
return StringUtil.join(usages, new Function<UsageDescriptor, String>() {
@Override
public String fun(UsageDescriptor usageDescriptor) {
final String key = usageDescriptor.getKey();
final int value = usageDescriptor.getValue();
return value > 1 ? key + "=" + value : key;
}
}, TOKENIZER);
}
}
|
3e01ccff28380f45b036f33b0a55716ee915b203 | 70,565 | java | Java | generated-tests/rmosa/tests/s1009/92_jcvi-javacommon/evosuite-tests/org/jcvi/jillion/core/Range_ESTest.java | blindsubmissions/icse19replication | 42a7c172efa86d7d01f7e74b58612cc255c6eb0f | [
"MIT"
] | null | null | null | generated-tests/rmosa/tests/s1009/92_jcvi-javacommon/evosuite-tests/org/jcvi/jillion/core/Range_ESTest.java | blindsubmissions/icse19replication | 42a7c172efa86d7d01f7e74b58612cc255c6eb0f | [
"MIT"
] | null | null | null | generated-tests/rmosa/tests/s1009/92_jcvi-javacommon/evosuite-tests/org/jcvi/jillion/core/Range_ESTest.java | blindsubmissions/icse19replication | 42a7c172efa86d7d01f7e74b58612cc255c6eb0f | [
"MIT"
] | null | null | null | 31.843412 | 176 | 0.65721 | 762 | /*
* This file was automatically generated by EvoSuite
* Thu Aug 23 09:21:06 GMT 2018
*/
package org.jcvi.jillion.core;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.evosuite.shaded.org.mockito.Mockito.*;
import static org.evosuite.runtime.EvoAssertions.*;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Consumer;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.evosuite.runtime.ViolatedAssumptionAnswer;
import org.jcvi.jillion.core.Range;
import org.junit.runner.RunWith;
@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true, useJEE = true)
public class Range_ESTest extends Range_ESTest_scaffolding {
/**
//Test case number: 0
/*Coverage entropy=1.0986122886681096
*/
@Test(timeout = 4000)
public void test000() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder(9223372036854775807L);
Range.Builder range_Builder1 = range_Builder0.shift(9223372036854775807L);
// Undeclared exception!
try {
range_Builder1.build();
fail("Expecting exception: IndexOutOfBoundsException");
} catch(IndexOutOfBoundsException e) {
//
// given length -3 would make range [9223372036854775807 - ? ] beyond max allowed end offset
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 1
/*Coverage entropy=-0.0
*/
@Test(timeout = 4000)
public void test001() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder(2147483647L);
Range.Builder range_Builder1 = null;
try {
range_Builder1 = new Range.Builder((-957L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// must be >=0
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 2
/*Coverage entropy=0.6931471805599453
*/
@Test(timeout = 4000)
public void test002() throws Throwable {
// Undeclared exception!
try {
Range.ofLength((-128L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// must be >=0
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 3
/*Coverage entropy=0.6931471805599453
*/
@Test(timeout = 4000)
public void test003() throws Throwable {
// Undeclared exception!
try {
Range.parseRange("DEPARTURE");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// can not parse DEPARTURE into a Range
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 4
/*Coverage entropy=2.767923626502885
*/
@Test(timeout = 4000)
public void test004() throws Throwable {
Range range0 = Range.ofLength(2147483647L);
range0.toString();
Long long0 = new Long(2147483647L);
boolean boolean0 = range0.equals("[ 0 .. 2147483646 ]/0B");
assertFalse(boolean0);
range0.getBegin();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
String string0 = range0.toString(range_CoordinateSystem0);
assertEquals("[ 0 .. 2147483647 ]/SB", string0);
}
/**
//Test case number: 5
/*Coverage entropy=2.833213344056216
*/
@Test(timeout = 4000)
public void test005() throws Throwable {
Range range0 = Range.ofLength(2147483673L);
assertFalse(range0.isEmpty());
}
/**
//Test case number: 6
/*Coverage entropy=2.1972245773362196
*/
@Test(timeout = 4000)
public void test006() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
long long0 = (-9223372036854775794L);
// Undeclared exception!
try {
Range.of(range_CoordinateSystem0, 344L, (-9223372036854775794L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// Range coordinates 344, -9223372036854775794 are not valid Space Based coordinates
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 7
/*Coverage entropy=2.902823587955807
*/
@Test(timeout = 4000)
public void test007() throws Throwable {
Range range0 = Range.of((-32768L));
range0.getBegin();
range0.equals("");
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
// Undeclared exception!
try {
Range.parseRange("&9IIYe2!", range_CoordinateSystem0);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// can not parse &9IIYe2! into a Range
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 8
/*Coverage entropy=2.8754478444593765
*/
@Test(timeout = 4000)
public void test008() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 65535L, 4294967295L);
range0.getBegin();
range0.equals("");
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.ZERO_BASED;
// Undeclared exception!
try {
Range.of(range_CoordinateSystem1, 4294967295L, 1500L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 9
/*Coverage entropy=2.772588722239781
*/
@Test(timeout = 4000)
public void test009() throws Throwable {
Range range0 = Range.ofLength(0L);
boolean boolean0 = range0.isSubRangeOf(range0);
assertFalse(range0.isEmpty());
assertTrue(boolean0);
}
/**
//Test case number: 10
/*Coverage entropy=2.9689526668537134
*/
@Test(timeout = 4000)
public void test010() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 65535L, 4294967295L);
range0.getBegin();
range0.toString();
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.RESIDUE_BASED;
Range range1 = Range.parseRange("[ 65535 .. 4294967295 ]/0B", range_CoordinateSystem1);
range1.isSubRangeOf(range0);
range1.equals(range0);
range0.equals(range1);
range0.getEnd();
// Undeclared exception!
try {
Range.Comparators.valueOf("[ 65535 .. 4294967295 ]/0B");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.Comparators.[ 65535 .. 4294967295 ]/0B
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 11
/*Coverage entropy=2.772588722239781
*/
@Test(timeout = 4000)
public void test011() throws Throwable {
Range range0 = Range.ofLength(0L);
range0.toString();
// Undeclared exception!
try {
range0.endsBefore((Range) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// Null Range used in range comparison operation.
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 12
/*Coverage entropy=1.0986122886681096
*/
@Test(timeout = 4000)
public void test012() throws Throwable {
Range.Builder range_Builder0 = null;
try {
range_Builder0 = new Range.Builder(0L, (-2497L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 13
/*Coverage entropy=1.3862943611198906
*/
@Test(timeout = 4000)
public void test013() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder();
range_Builder0.contractBegin((-511L));
long long0 = 0L;
range_Builder0.contractBegin(0L);
String string0 = "";
// Undeclared exception!
try {
Range.CoordinateSystem.valueOf("");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.CoordinateSystem.
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 14
/*Coverage entropy=2.1972245773362196
*/
@Test(timeout = 4000)
public void test014() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder();
range_Builder0.copy();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
// Undeclared exception!
try {
Range.parseRange("{V00l$N+Mo<5aDGYR{", range_CoordinateSystem0);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// can not parse {V00l$N+Mo<5aDGYR{ into a Range
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 15
/*Coverage entropy=2.966943486189354
*/
@Test(timeout = 4000)
public void test015() throws Throwable {
Range range0 = Range.of((-128L));
Consumer<Object> consumer0 = (Consumer<Object>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range0.forEach(consumer0);
Range.CoordinateSystem[] range_CoordinateSystemArray0 = Range.CoordinateSystem.values();
assertEquals(3, range_CoordinateSystemArray0.length);
}
/**
//Test case number: 16
/*Coverage entropy=2.8114194983013414
*/
@Test(timeout = 4000)
public void test016() throws Throwable {
Range range0 = Range.ofLength(0L);
String string0 = range0.toString();
assertEquals("[ 0 .. -1 ]/0B", string0);
Consumer<Long> consumer0 = (Consumer<Long>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range0.forEach(consumer0);
boolean boolean0 = range0.equals("4Ix");
assertFalse(boolean0);
}
/**
//Test case number: 17
/*Coverage entropy=1.0986122886681096
*/
@Test(timeout = 4000)
public void test017() throws Throwable {
// Undeclared exception!
try {
Range.of(259L, (-1191L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 18
/*Coverage entropy=1.3862943611198906
*/
@Test(timeout = 4000)
public void test018() throws Throwable {
Range range0 = null;
Range.Builder range_Builder0 = new Range.Builder();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.SPACE_BASED;
long long0 = 874L;
// Undeclared exception!
try {
range_Builder0.contractEnd(874L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 19
/*Coverage entropy=0.6931471805599453
*/
@Test(timeout = 4000)
public void test019() throws Throwable {
// Undeclared exception!
try {
Range.of((Range.CoordinateSystem) null, 9223372036854775777L, 9223372036854775777L);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// CoordinateSystem can not be null
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 20
/*Coverage entropy=2.8647385121905686
*/
@Test(timeout = 4000)
public void test020() throws Throwable {
Range range0 = Range.of((-128L));
Range range1 = Range.of((-128L));
range0.intersects(range1);
Range.CoordinateSystem.values();
Range.Comparators[] range_ComparatorsArray0 = Range.Comparators.values();
assertEquals(4, range_ComparatorsArray0.length);
}
/**
//Test case number: 21
/*Coverage entropy=2.9444389791664403
*/
@Test(timeout = 4000)
public void test021() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 344L, 344L);
Range range1 = range0.asRange();
assertTrue(range1.isEmpty());
}
/**
//Test case number: 22
/*Coverage entropy=2.6941537039844587
*/
@Test(timeout = 4000)
public void test022() throws Throwable {
Range range0 = Range.ofLength(0L);
String string0 = range0.toString();
assertEquals("[ 0 .. -1 ]/0B", string0);
boolean boolean0 = range0.equals("4Ix");
assertFalse(boolean0);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
long long0 = range0.getEnd(range_CoordinateSystem0);
assertEquals((-1L), long0);
}
/**
//Test case number: 23
/*Coverage entropy=2.833213344056216
*/
@Test(timeout = 4000)
public void test023() throws Throwable {
Range range0 = Range.ofLength(0L);
String string0 = range0.toString();
assertEquals("[ 0 .. -1 ]/0B", string0);
boolean boolean0 = range0.intersects(range0);
assertFalse(boolean0);
}
/**
//Test case number: 24
/*Coverage entropy=2.7920474405363453
*/
@Test(timeout = 4000)
public void test024() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 2147483647L, 2147483647L);
boolean boolean0 = range0.equals(range_CoordinateSystem0);
assertFalse(boolean0);
Range range1 = Range.of(range_CoordinateSystem0, 2147483647L, 2147483647L);
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.ZERO_BASED;
range0.getBegin(range_CoordinateSystem1);
range0.getBegin();
long long0 = range0.getBegin();
assertEquals(2147483647L, long0);
assertSame(range0, range1);
assertTrue(range0.isEmpty());
}
/**
//Test case number: 25
/*Coverage entropy=3.159725121247703
*/
@Test(timeout = 4000)
public void test025() throws Throwable {
Range range0 = Range.of(9223372036854775807L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range1 = Range.of(range_CoordinateSystem0, 9223372036854775807L, 9223372036854775807L);
Range range2 = range1.intersection(range0);
List<Range> list0 = range2.complement(range0);
assertTrue(list0.contains(range2));
range1.equals(range2);
long long0 = range2.getEnd();
assertEquals(9223372036854775806L, long0);
assertTrue(range1.equals((Object)range0));
assertFalse(range2.equals((Object)range1));
}
/**
//Test case number: 26
/*Coverage entropy=3.3684464578420763
*/
@Test(timeout = 4000)
public void test026() throws Throwable {
Range range0 = Range.of((-128L));
range0.getEnd();
Range range1 = Range.of((-128L), (-128L));
List<Range> list0 = range0.complement(range1);
assertEquals(1, list0.size());
assertFalse(list0.contains(range0));
Range.CoordinateSystem.values();
long long0 = range0.getEnd();
assertEquals((-128L), long0);
}
/**
//Test case number: 27
/*Coverage entropy=2.9444389791664403
*/
@Test(timeout = 4000)
public void test027() throws Throwable {
Range range0 = Range.ofLength(0L);
Range range1 = Range.ofLength(0L);
List<Range> list0 = range0.complement(range1);
range0.complementFrom(list0);
LinkedList<Range> linkedList0 = new LinkedList<Range>();
range0.complementFrom(linkedList0);
Range.CoordinateSystem.values();
Range.Comparators[] range_ComparatorsArray0 = Range.Comparators.values();
assertEquals(4, range_ComparatorsArray0.length);
}
/**
//Test case number: 28
/*Coverage entropy=2.737140718477016
*/
@Test(timeout = 4000)
public void test028() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 1123L, 1123L);
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.SPACE_BASED;
Range range1 = Range.of(range_CoordinateSystem1, 4820L, 4820L);
boolean boolean0 = range0.equals(range1);
assertFalse(range1.equals((Object)range0));
assertFalse(boolean0);
long long0 = range0.getBegin();
assertEquals(1123L, long0);
assertTrue(range0.isEmpty());
}
/**
//Test case number: 29
/*Coverage entropy=2.9007259676818085
*/
@Test(timeout = 4000)
public void test029() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 1089L, 1089L);
Range range1 = Range.of(range_CoordinateSystem0, 691L, 691L);
range1.intersects(range0);
Range range2 = range0.intersection(range1);
range1.equals(range2);
Range.CoordinateSystem.values();
// Undeclared exception!
try {
Range.CoordinateSystem.valueOf("3s/oA/ ews?");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.CoordinateSystem.3s/oA/ ews?
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 30
/*Coverage entropy=3.0445224377234217
*/
@Test(timeout = 4000)
public void test030() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder(9223372036854775807L);
range_Builder0.shift((-28L));
Range range0 = range_Builder0.build();
range0.getLength();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
// Undeclared exception!
try {
Range.parseRange((String) null, range_CoordinateSystem0);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// no message in exception (getMessage() returned null)
//
}
}
/**
//Test case number: 31
/*Coverage entropy=3.0445224377234217
*/
@Test(timeout = 4000)
public void test031() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range range0 = Range.of(range_CoordinateSystem0, (-3L), 344L);
assertFalse(range0.isEmpty());
}
/**
//Test case number: 32
/*Coverage entropy=1.7917594692280547
*/
@Test(timeout = 4000)
public void test032() throws Throwable {
Range.Comparators.values();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range.Builder range_Builder0 = new Range.Builder(range_CoordinateSystem0, 1449L, 1449L);
range_Builder0.expandEnd(1449L);
range_Builder0.expandEnd(1449L);
// Undeclared exception!
try {
Range.parseRange("", range_CoordinateSystem0);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// can not parse into a Range
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 33
/*Coverage entropy=1.0986122886681096
*/
@Test(timeout = 4000)
public void test033() throws Throwable {
Range.Builder range_Builder0 = new Range.Builder();
Range.Builder range_Builder1 = range_Builder0.expandBegin((-2172L));
assertSame(range_Builder1, range_Builder0);
}
/**
//Test case number: 34
/*Coverage entropy=3.332204510175204
*/
@Test(timeout = 4000)
public void test034() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 2147483647L, 2147483647L);
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.ZERO_BASED;
Range range1 = Range.of(range_CoordinateSystem1, 2147483647L, 2147483647L);
Range range2 = range1.intersection(range0);
range1.equals(range2);
// Undeclared exception!
try {
Range.Comparators.valueOf("l?FJfer");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.Comparators.l?FJfer
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 35
/*Coverage entropy=2.772588722239781
*/
@Test(timeout = 4000)
public void test035() throws Throwable {
Range range0 = Range.ofLength(0L);
// Undeclared exception!
try {
range0.startsBefore((Range) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// Null Range used in range comparison operation.
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 36
/*Coverage entropy=2.772588722239781
*/
@Test(timeout = 4000)
public void test036() throws Throwable {
Range range0 = Range.ofLength(0L);
// Undeclared exception!
try {
range0.split(0L);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// max splitLength must be >= 1
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 37
/*Coverage entropy=2.767923626502885
*/
@Test(timeout = 4000)
public void test037() throws Throwable {
Range range0 = Range.ofLength(9223372036854775807L);
Range range1 = Range.ofLength(9223372036854775807L);
range0.startsBefore(range1);
range0.getLength();
// Undeclared exception!
try {
range0.forEach((Consumer<? super Long>) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// no message in exception (getMessage() returned null)
//
verifyException("java.util.Objects", e);
}
}
/**
//Test case number: 38
/*Coverage entropy=2.694153703984459
*/
@Test(timeout = 4000)
public void test038() throws Throwable {
Range range0 = Range.ofLength(0L);
long long0 = range0.getLength();
assertEquals(0L, long0);
String string0 = range0.toString();
assertEquals("[ 0 .. -1 ]/0B", string0);
boolean boolean0 = range0.equals("4Ix");
assertFalse(boolean0);
}
/**
//Test case number: 39
/*Coverage entropy=3.2958368660043296
*/
@Test(timeout = 4000)
public void test039() throws Throwable {
Range range0 = Range.of(1684L);
Range range1 = Range.of(4080L);
List<Range> list0 = range1.complement(range0);
assertTrue(list0.contains(range1));
long long0 = range1.getBegin();
assertEquals(4080L, long0);
assertFalse(range1.isEmpty());
}
/**
//Test case number: 40
/*Coverage entropy=2.995732273553991
*/
@Test(timeout = 4000)
public void test040() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 1087L, 1087L);
Range range1 = Range.of(range_CoordinateSystem0, 702L, 702L);
range0.isSubRangeOf(range1);
// Undeclared exception!
try {
Range.parseRange("; ij>*W)LTW@Vyp7", range_CoordinateSystem0);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// can not parse ; ij>*W)LTW@Vyp7 into a Range
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 41
/*Coverage entropy=2.8444872614601695
*/
@Test(timeout = 4000)
public void test041() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 2147483647L, 2147483647L);
boolean boolean0 = range0.equals(range_CoordinateSystem0);
assertFalse(boolean0);
List<Range> list0 = range0.split(2147483647L);
assertTrue(list0.contains(range0));
range0.getBegin();
long long0 = range0.getBegin();
assertTrue(range0.isEmpty());
assertEquals(2147483647L, long0);
}
/**
//Test case number: 42
/*Coverage entropy=2.846323859467729
*/
@Test(timeout = 4000)
public void test042() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, (-2536L), (-2536L));
long long0 = range0.getLength();
assertEquals(0L, long0);
Object object0 = new Object();
range0.equals(object0);
boolean boolean0 = range0.equals(range_CoordinateSystem0);
assertFalse(boolean0);
}
/**
//Test case number: 43
/*Coverage entropy=-0.0
*/
@Test(timeout = 4000)
public void test043() throws Throwable {
Range range0 = null;
Range.Builder range_Builder0 = null;
try {
range_Builder0 = new Range.Builder((Range) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// range can not be null
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 44
/*Coverage entropy=2.833213344056216
*/
@Test(timeout = 4000)
public void test044() throws Throwable {
Range range0 = Range.ofLength(0L);
range0.toString();
Range range1 = Range.ofLength(0L);
range0.endsBefore(range1);
range0.equals("4Ix");
// Undeclared exception!
try {
Range.CoordinateSystem.valueOf("4Ix");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.CoordinateSystem.4Ix
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 45
/*Coverage entropy=3.332204510175204
*/
@Test(timeout = 4000)
public void test045() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 2147483647L, 2147483647L);
long long0 = range0.getEnd();
assertEquals(2147483646L, long0);
Range range1 = Range.of(range_CoordinateSystem0, 2147483647L, 2147483646L);
range0.intersects(range1);
boolean boolean0 = range0.endsBefore(range0);
assertNotSame(range0, range1);
assertTrue(boolean0);
assertTrue(range0.isEmpty());
}
/**
//Test case number: 46
/*Coverage entropy=2.9444389791664403
*/
@Test(timeout = 4000)
public void test046() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, (-2536L), (-2536L));
long long0 = new Long((-2536L));
Object object0 = new Object();
boolean boolean0 = range0.isEmpty();
assertTrue(boolean0);
}
/**
//Test case number: 47
/*Coverage entropy=2.7949796238706957
*/
@Test(timeout = 4000)
public void test047() throws Throwable {
Range range0 = Range.of((-1L));
range0.equals("/ e.i");
Long long0 = Long.valueOf((-1L));
Long.remainderUnsigned(1661L, (-1L));
range0.equals(long0);
assertFalse(range0.isEmpty());
}
/**
//Test case number: 48
/*Coverage entropy=3.0005998121061817
*/
@Test(timeout = 4000)
public void test048() throws Throwable {
Range range0 = Range.of(43L, 43L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range1 = Range.of(range_CoordinateSystem0, 43L, 43L);
range1.startsBefore(range0);
range0.equals(range1);
// Undeclared exception!
try {
Range.CoordinateSystem.valueOf((String) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// Name is null
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 49
/*Coverage entropy=2.87821830667085
*/
@Test(timeout = 4000)
public void test049() throws Throwable {
Range range0 = Range.of(9223372036854773947L);
Object object0 = new Object();
boolean boolean0 = range0.equals(object0);
assertFalse(boolean0);
long long0 = range0.getBegin();
assertEquals(9223372036854773947L, long0);
}
/**
//Test case number: 50
/*Coverage entropy=2.995732273553991
*/
@Test(timeout = 4000)
public void test050() throws Throwable {
Range range0 = Range.of(9223372036854775807L);
Range range1 = Range.of(9223372036854775807L);
range1.getLength();
Long long0 = new Long(1L);
range0.equals((Object) null);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
// Undeclared exception!
try {
Range.parseRange("'R2#-G~", range_CoordinateSystem0);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// can not parse 'R2#-G~ into a Range
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 51
/*Coverage entropy=3.0450382972958723
*/
@Test(timeout = 4000)
public void test051() throws Throwable {
Range range0 = Range.of(43L, 43L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range1 = Range.of(range_CoordinateSystem0, 43L, 43L);
range1.intersects(range0);
range0.equals(range1);
// Undeclared exception!
try {
Range.CoordinateSystem.valueOf((String) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// Name is null
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 52
/*Coverage entropy=3.1354942159291497
*/
@Test(timeout = 4000)
public void test052() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 344L, 9223372036854775807L);
// Undeclared exception!
try {
range0.split(9223372036854772689L);
fail("Expecting exception: IndexOutOfBoundsException");
} catch(IndexOutOfBoundsException e) {
//
// given length -5895 would make range [9223372036854773033 - ? ] beyond max allowed end offset
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 53
/*Coverage entropy=3.173768833930095
*/
@Test(timeout = 4000)
public void test053() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 788L, 1705L);
long long0 = range0.getEnd();
assertEquals(1705L, long0);
range0.iterator();
List<Range> list0 = range0.split(344L);
assertFalse(list0.contains(range0));
assertEquals(3, list0.size());
}
/**
//Test case number: 54
/*Coverage entropy=1.7917594692280547
*/
@Test(timeout = 4000)
public void test054() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
// Undeclared exception!
try {
Range.of(range_CoordinateSystem0, (-1L), (-2L));
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 55
/*Coverage entropy=2.995732273553991
*/
@Test(timeout = 4000)
public void test055() throws Throwable {
Range range0 = Range.of((-129L));
boolean boolean0 = range0.equals(range0);
assertTrue(boolean0);
assertFalse(range0.isEmpty());
}
/**
//Test case number: 56
/*Coverage entropy=2.890371757896165
*/
@Test(timeout = 4000)
public void test056() throws Throwable {
Range range0 = Range.ofLength(338L);
Object object0 = new Object();
Object object1 = new Object();
boolean boolean0 = range0.endsBefore(range0);
assertFalse(boolean0);
}
/**
//Test case number: 57
/*Coverage entropy=2.995732273553991
*/
@Test(timeout = 4000)
public void test057() throws Throwable {
Range range0 = Range.of((-129L));
boolean boolean0 = range0.equals((Object) null);
assertFalse(boolean0);
assertFalse(range0.isEmpty());
}
/**
//Test case number: 58
/*Coverage entropy=3.2188758248681983
*/
@Test(timeout = 4000)
public void test058() throws Throwable {
Range range0 = Range.of(1663L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range1 = Range.of(range_CoordinateSystem0, 1663L, 1663L);
long long0 = range1.getEnd();
assertEquals(1662L, long0);
boolean boolean0 = range0.intersects(range1);
assertFalse(range1.isEmpty());
assertFalse(boolean0);
}
/**
//Test case number: 59
/*Coverage entropy=2.890371757896165
*/
@Test(timeout = 4000)
public void test059() throws Throwable {
Range range0 = Range.ofLength(246L);
boolean boolean0 = range0.equals((Object) null);
assertFalse(boolean0);
assertFalse(range0.isEmpty());
}
/**
//Test case number: 60
/*Coverage entropy=2.9444389791664403
*/
@Test(timeout = 4000)
public void test060() throws Throwable {
Range range0 = Range.of(766L);
boolean boolean0 = range0.equals((Object) null);
assertFalse(boolean0);
}
/**
//Test case number: 61
/*Coverage entropy=2.929568618777601
*/
@Test(timeout = 4000)
public void test061() throws Throwable {
Range range0 = Range.ofLength(9223372036854775807L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Consumer<Object> consumer0 = (Consumer<Object>) mock(Consumer.class, new ViolatedAssumptionAnswer());
range0.forEach(consumer0);
String string0 = range0.toString(range_CoordinateSystem0);
assertEquals("[ 9223372036854775806 .. 9223372036854775807 ]/SB", string0);
range0.equals("[ 0 .. 9223372036854775807 ]/SB");
assertFalse(range0.isEmpty());
}
/**
//Test case number: 62
/*Coverage entropy=2.995732273553991
*/
@Test(timeout = 4000)
public void test062() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 4294967301L, 9223372036854774173L);
Long long0 = Long.valueOf(2400L);
range0.equals(long0);
range0.equals(range_CoordinateSystem0);
Range.Comparators[] range_ComparatorsArray0 = Range.Comparators.values();
assertEquals(4, range_ComparatorsArray0.length);
}
/**
//Test case number: 63
/*Coverage entropy=3.0910424533583143
*/
@Test(timeout = 4000)
public void test063() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 344L, 9223372036854775807L);
Range.Builder range_Builder0 = new Range.Builder(range0);
Range.Builder range_Builder1 = new Range.Builder(range_Builder0);
Range range1 = range_Builder1.build();
assertSame(range1, range0);
assertFalse(range1.isEmpty());
}
/**
//Test case number: 64
/*Coverage entropy=2.9444389791664403
*/
@Test(timeout = 4000)
public void test064() throws Throwable {
Range range0 = Range.of((-128L));
range0.equals((Object) null);
assertFalse(range0.isEmpty());
}
/**
//Test case number: 65
/*Coverage entropy=2.772588722239781
*/
@Test(timeout = 4000)
public void test065() throws Throwable {
Range range0 = Range.ofLength(0L);
range0.toString();
// Undeclared exception!
try {
range0.intersection((Range) null);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// Null Range used in intersection operation.
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 66
/*Coverage entropy=2.8754478444593765
*/
@Test(timeout = 4000)
public void test066() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 4294967295L, 9223372036854774157L);
Long long0 = Long.valueOf(2427L);
range0.equals(long0);
range0.equals(range_CoordinateSystem0);
Range.Comparators[] range_ComparatorsArray0 = Range.Comparators.values();
assertEquals(4, range_ComparatorsArray0.length);
}
/**
//Test case number: 67
/*Coverage entropy=2.890371757896165
*/
@Test(timeout = 4000)
public void test067() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range.of(range_CoordinateSystem0, 4294967295L, 4294967295L);
Long.valueOf(2427L);
Range.Comparators[] range_ComparatorsArray0 = Range.Comparators.values();
assertEquals(4, range_ComparatorsArray0.length);
}
/**
//Test case number: 68
/*Coverage entropy=2.972845711672121
*/
@Test(timeout = 4000)
public void test068() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 344L, 9223372036854775807L);
range0.iterator();
range0.equals((Object) null);
long long0 = range0.getLength();
assertEquals(9223372036854775463L, long0);
boolean boolean0 = range0.equals("r");
assertFalse(boolean0);
}
/**
//Test case number: 69
/*Coverage entropy=2.7920474405363453
*/
@Test(timeout = 4000)
public void test069() throws Throwable {
long long0 = 2147483647L;
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 2147483647L, 2147483647L);
// Undeclared exception!
try {
range0.isSubRangeOf((Range) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// range can not be null
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 70
/*Coverage entropy=2.954002719889012
*/
@Test(timeout = 4000)
public void test070() throws Throwable {
Range range0 = Range.of((-148L), (-148L));
Range range1 = Range.of((-320L), (-148L));
Long long0 = new Long((-320L));
range1.equals(range0);
Range.CoordinateSystem.values();
Range.Comparators[] range_ComparatorsArray0 = Range.Comparators.values();
assertEquals(4, range_ComparatorsArray0.length);
}
/**
//Test case number: 71
/*Coverage entropy=3.0254887803944674
*/
@Test(timeout = 4000)
public void test071() throws Throwable {
Range range0 = Range.of((-3091L), (-3091L));
Object object0 = new Object();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range1 = Range.of(range_CoordinateSystem0, (-3091L), (-3091L));
range0.equals(range1);
String string0 = null;
// Undeclared exception!
try {
Range.Comparators.valueOf((String) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// Name is null
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 72
/*Coverage entropy=2.8147041867002995
*/
@Test(timeout = 4000)
public void test072() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 1123L, 1123L);
long long0 = range0.getEnd(range_CoordinateSystem0);
assertEquals(1123L, long0);
Object object0 = new Object();
boolean boolean0 = range0.equals(object0);
assertFalse(boolean0);
assertTrue(range0.isEmpty());
}
/**
//Test case number: 73
/*Coverage entropy=2.6941537039844587
*/
@Test(timeout = 4000)
public void test073() throws Throwable {
Range range0 = Range.ofLength(0L);
range0.toString();
// Undeclared exception!
try {
range0.intersects((Range) null);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// Null Range used in intersection operation.
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 74
/*Coverage entropy=2.890371757896165
*/
@Test(timeout = 4000)
public void test074() throws Throwable {
Range range0 = Range.ofLength(331L);
String string0 = range0.toString();
assertEquals("[ 0 .. 330 ]/0B", string0);
boolean boolean0 = range0.equals(range0);
assertTrue(boolean0);
}
/**
//Test case number: 75
/*Coverage entropy=2.9444389791664403
*/
@Test(timeout = 4000)
public void test075() throws Throwable {
Range range0 = Range.of(9223372036854773971L);
Object object0 = new Object();
Range range1 = Range.of(9223372036854773971L);
boolean boolean0 = range0.equals(range1);
assertSame(range1, range0);
assertTrue(boolean0);
}
/**
//Test case number: 76
/*Coverage entropy=2.908318357393279
*/
@Test(timeout = 4000)
public void test076() throws Throwable {
Range range0 = Range.of((-2147483648L));
Long long0 = new Long(991L);
range0.equals(long0);
// Undeclared exception!
try {
Range.Comparators.valueOf("w]@K5'Z@@n<:I");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.Comparators.w]@K5'Z@@n<:I
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 77
/*Coverage entropy=3.097485138351399
*/
@Test(timeout = 4000)
public void test077() throws Throwable {
Range range0 = Range.of(9223372036854775807L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range1 = Range.of(range_CoordinateSystem0, 9223372036854775807L, 9223372036854775807L);
range0.iterator();
range1.spliterator();
range1.getLength();
boolean boolean0 = range1.equals(range0);
assertTrue(boolean0);
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.SPACE_BASED;
long long0 = range1.getEnd(range_CoordinateSystem1);
assertEquals(9223372036854775807L, long0);
}
/**
//Test case number: 78
/*Coverage entropy=2.890371757896165
*/
@Test(timeout = 4000)
public void test078() throws Throwable {
Range range0 = Range.ofLength(17L);
// Undeclared exception!
try {
range0.getBegin((Range.CoordinateSystem) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// CoordinateSystem can not be null
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 79
/*Coverage entropy=3.0445224377234217
*/
@Test(timeout = 4000)
public void test079() throws Throwable {
Range range0 = Range.of((-2147483648L));
long long0 = range0.getEnd();
assertEquals((-2147483648L), long0);
boolean boolean0 = range0.equals((Object) null);
assertFalse(range0.isEmpty());
assertFalse(boolean0);
}
/**
//Test case number: 80
/*Coverage entropy=2.9444389791664403
*/
@Test(timeout = 4000)
public void test080() throws Throwable {
Range range0 = Range.of(4294967295L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
range0.toString(range_CoordinateSystem0);
range0.equals(range0);
Range.Comparators[] range_ComparatorsArray0 = Range.Comparators.values();
assertEquals(4, range_ComparatorsArray0.length);
}
/**
//Test case number: 81
/*Coverage entropy=2.9444389791664403
*/
@Test(timeout = 4000)
public void test081() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, (-32768L), (-32768L));
boolean boolean0 = range0.equals((Object) null);
assertFalse(boolean0);
boolean boolean1 = range0.equals(range_CoordinateSystem0);
assertTrue(range0.isEmpty());
assertFalse(boolean1);
}
/**
//Test case number: 82
/*Coverage entropy=3.2811601791458487
*/
@Test(timeout = 4000)
public void test082() throws Throwable {
Range range0 = Range.of((-9223372036854775798L));
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
range0.getEnd(range_CoordinateSystem0);
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.RESIDUE_BASED;
Range range1 = Range.of(range_CoordinateSystem1, (-9223372036854775798L), (-9223372036854775798L));
Range range2 = range1.intersection(range0);
range2.complement(range0);
range1.equals(range2);
// Undeclared exception!
try {
Range.Comparators.valueOf("!KXR|BX'7G{()|WT");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.Comparators.!KXR|BX'7G{()|WT
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 83
/*Coverage entropy=2.890371757896165
*/
@Test(timeout = 4000)
public void test083() throws Throwable {
Range range0 = Range.ofLength(9223372036854775807L);
Consumer<Object> consumer0 = (Consumer<Object>) mock(Consumer.class, new ViolatedAssumptionAnswer());
boolean boolean0 = range0.equals((Object) null);
assertFalse(boolean0);
range0.getBegin();
long long0 = range0.getBegin();
assertFalse(range0.isEmpty());
assertEquals(0L, long0);
}
/**
//Test case number: 84
/*Coverage entropy=2.9444389791664403
*/
@Test(timeout = 4000)
public void test084() throws Throwable {
Range range0 = Range.of(1652L);
Object object0 = new Object();
Range range1 = Range.of(2385L);
boolean boolean0 = range1.equals(range0);
assertFalse(boolean0);
range0.equals(range0);
assertFalse(range0.equals((Object)range1));
}
/**
//Test case number: 85
/*Coverage entropy=2.978661183242022
*/
@Test(timeout = 4000)
public void test085() throws Throwable {
Range range0 = Range.of(3710L);
range0.getBegin();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range1 = Range.of(range_CoordinateSystem0, 3710L, 4032L);
range0.equals(range1);
range0.equals(range_CoordinateSystem0);
Range.CoordinateSystem[] range_CoordinateSystemArray0 = Range.CoordinateSystem.values();
assertEquals(3, range_CoordinateSystemArray0.length);
}
/**
//Test case number: 86
/*Coverage entropy=2.772588722239781
*/
@Test(timeout = 4000)
public void test086() throws Throwable {
Range range0 = Range.ofLength(0L);
boolean boolean0 = range0.equals((Object) null);
assertFalse(boolean0);
}
/**
//Test case number: 87
/*Coverage entropy=2.9444389791664403
*/
@Test(timeout = 4000)
public void test087() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 1123L, 1123L);
Object object0 = new Object();
range0.equals((Object) null);
assertTrue(range0.isEmpty());
}
/**
//Test case number: 88
/*Coverage entropy=2.890371757896165
*/
@Test(timeout = 4000)
public void test088() throws Throwable {
Range range0 = Range.ofLength(2147483647L);
boolean boolean0 = range0.equals((Object) null);
assertFalse(range0.isEmpty());
assertFalse(boolean0);
}
/**
//Test case number: 89
/*Coverage entropy=2.9444389791664403
*/
@Test(timeout = 4000)
public void test089() throws Throwable {
Range range0 = Range.of((-1L));
range0.equals(range0);
assertFalse(range0.isEmpty());
}
/**
//Test case number: 90
/*Coverage entropy=2.995732273553991
*/
@Test(timeout = 4000)
public void test090() throws Throwable {
Range range0 = Range.of((-128L));
Range range1 = Range.of((-1L));
range1.getEnd();
range1.isSubRangeOf(range1);
range0.equals(range1);
// Undeclared exception!
try {
Range.Comparators.valueOf((String) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// Name is null
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 91
/*Coverage entropy=2.890371757896165
*/
@Test(timeout = 4000)
public void test091() throws Throwable {
Range range0 = Range.ofLength(4294967295L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
range0.toString(range_CoordinateSystem0);
range0.equals(range0);
Range.Comparators[] range_ComparatorsArray0 = Range.Comparators.values();
assertEquals(4, range_ComparatorsArray0.length);
}
/**
//Test case number: 92
/*Coverage entropy=3.0445224377234217
*/
@Test(timeout = 4000)
public void test092() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 4294967297L, 9223372036854774157L);
Long long0 = Long.valueOf(2427L);
boolean boolean0 = range0.equals(long0);
boolean boolean1 = range0.equals((Object) null);
assertTrue(boolean1 == boolean0);
Range.Comparators.values();
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.SPACE_BASED;
long long1 = range0.getEnd(range_CoordinateSystem1);
assertEquals(9223372036854774157L, long1);
}
/**
//Test case number: 93
/*Coverage entropy=3.1354942159291497
*/
@Test(timeout = 4000)
public void test093() throws Throwable {
Range range0 = Range.ofLength(1406L);
range0.toString();
range0.equals("[ 0 .. 1405 ]/0B");
range0.getBegin();
Range range1 = Range.ofLength(0L);
Range range2 = Range.ofLength(0L);
range1.equals(range2);
// Undeclared exception!
try {
Range.Comparators.valueOf("");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.Comparators.
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 94
/*Coverage entropy=2.9444389791664403
*/
@Test(timeout = 4000)
public void test094() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 1123L, 1123L);
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.SPACE_BASED;
Range range1 = Range.of(range_CoordinateSystem1, 1123L, 1123L);
boolean boolean0 = range0.equals(range1);
assertTrue(boolean0);
long long0 = range0.getBegin();
assertTrue(range0.isEmpty());
assertEquals(1123L, long0);
assertSame(range0, range1);
}
/**
//Test case number: 95
/*Coverage entropy=2.70805020110221
*/
@Test(timeout = 4000)
public void test095() throws Throwable {
Range range0 = Range.ofLength(0L);
// Undeclared exception!
try {
range0.toString((Range.CoordinateSystem) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// coordinateSystem can not be null
//
verifyException("org.jcvi.jillion.core.Range", e);
}
}
/**
//Test case number: 96
/*Coverage entropy=2.995732273553991
*/
@Test(timeout = 4000)
public void test096() throws Throwable {
Range range0 = Range.ofLength(3070L);
Range range1 = Range.of(0L);
boolean boolean0 = range0.equals(range1);
assertFalse(range1.isEmpty());
assertFalse(boolean0);
}
/**
//Test case number: 97
/*Coverage entropy=3.0445224377234217
*/
@Test(timeout = 4000)
public void test097() throws Throwable {
Range range0 = Range.of((-2147483648L));
range0.equals(range0);
boolean boolean0 = range0.equals(range0);
assertFalse(range0.isEmpty());
assertTrue(boolean0);
}
/**
//Test case number: 98
/*Coverage entropy=2.995732273553991
*/
@Test(timeout = 4000)
public void test098() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, (-2536L), (-2536L));
long long0 = range0.getLength();
assertEquals(0L, long0);
Object object0 = new Object();
range0.equals(range0);
assertTrue(range0.isEmpty());
}
/**
//Test case number: 99
/*Coverage entropy=2.9444389791664403
*/
@Test(timeout = 4000)
public void test099() throws Throwable {
Range range0 = Range.of(2147483660L);
String string0 = range0.toString();
assertEquals("[ 2147483660 .. 2147483660 ]/0B", string0);
boolean boolean0 = range0.equals((Object) null);
assertFalse(boolean0);
}
/**
//Test case number: 100
/*Coverage entropy=2.938318769971462
*/
@Test(timeout = 4000)
public void test100() throws Throwable {
Range range0 = Range.of(4294967295L);
Object object0 = new Object();
boolean boolean0 = range0.equals(object0);
assertFalse(boolean0);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range1 = Range.of(range_CoordinateSystem0, 4294967295L, 4294967295L);
String string0 = range1.toString(range_CoordinateSystem0);
assertEquals("[ 4294967295 .. 4294967295 ]/RB", string0);
boolean boolean1 = range0.equals(range1);
assertFalse(boolean1);
long long0 = range1.getBegin();
assertEquals(4294967294L, long0);
}
/**
//Test case number: 101
/*Coverage entropy=3.0445224377234217
*/
@Test(timeout = 4000)
public void test101() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 4294967295L, 9223372036854774157L);
boolean boolean0 = range0.equals((Object) null);
assertFalse(boolean0);
range0.getBegin();
long long0 = range0.getBegin();
assertEquals(4294967294L, long0);
}
/**
//Test case number: 102
/*Coverage entropy=3.039384112231738
*/
@Test(timeout = 4000)
public void test102() throws Throwable {
Range range0 = Range.of((-2147483632L), (-168L));
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range range1 = Range.of(range_CoordinateSystem0, (-2147483632L), 405L);
Long long0 = new Long(405L);
range0.equals(range1);
range0.equals(long0);
Range.Comparators.values();
// Undeclared exception!
try {
Range.CoordinateSystem.valueOf("org.jcvi.jillion.core.Range$UnsignedShortStartLongLengthRange");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.CoordinateSystem.org.jcvi.jillion.core.Range$UnsignedShortStartLongLengthRange
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 103
/*Coverage entropy=2.9444389791664403
*/
@Test(timeout = 4000)
public void test103() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 2147483647L, 2147483647L);
boolean boolean0 = range0.equals(range_CoordinateSystem0);
boolean boolean1 = range0.equals((Object) null);
assertTrue(boolean1 == boolean0);
assertTrue(range0.isEmpty());
assertFalse(boolean1);
}
/**
//Test case number: 104
/*Coverage entropy=3.0867152724480524
*/
@Test(timeout = 4000)
public void test104() throws Throwable {
Range range0 = Range.ofLength(2147483647L);
range0.toString();
Long long0 = new Long(2147483647L);
range0.toString();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range1 = Range.parseRange("[ 0 .. 2147483646 ]/0B", range_CoordinateSystem0);
range0.equals(range1);
// Undeclared exception!
try {
Range.Comparators.valueOf("[ 0 .. 2147483646 ]/0B");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.Comparators.[ 0 .. 2147483646 ]/0B
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 105
/*Coverage entropy=3.0445224377234217
*/
@Test(timeout = 4000)
public void test105() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 65535L, 4294967295L);
range0.getBegin();
boolean boolean0 = range0.equals("");
range0.getLength();
boolean boolean1 = range0.equals((Object) null);
assertTrue(boolean1 == boolean0);
}
/**
//Test case number: 106
/*Coverage entropy=3.0445224377234217
*/
@Test(timeout = 4000)
public void test106() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 65535L, 4294967295L);
range0.getBegin();
range0.toString();
boolean boolean0 = range0.equals(range0);
assertTrue(boolean0);
}
/**
//Test case number: 107
/*Coverage entropy=3.332204510175204
*/
@Test(timeout = 4000)
public void test107() throws Throwable {
Range range0 = Range.of((-2147483658L), (-159L));
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range range1 = Range.of(range_CoordinateSystem0, (-2147483658L), (-1410L));
range1.getEnd(range_CoordinateSystem0);
range0.iterator();
Long long0 = new Long((-1410L));
long long1 = range0.getEnd();
assertEquals((-159L), long1);
boolean boolean0 = range0.equals(range1);
assertFalse(boolean0);
}
/**
//Test case number: 108
/*Coverage entropy=3.0910424533583143
*/
@Test(timeout = 4000)
public void test108() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 1123L, 1123L);
range0.iterator();
long long0 = new Long(1123L);
Range.of(range_CoordinateSystem0, 686L, 686L);
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.RESIDUE_BASED;
// Undeclared exception!
try {
Range.parseRange("x4`ieH=-9-3dj", range_CoordinateSystem1);
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// length can not be negative
//
verifyException("org.jcvi.jillion.core.Range$Builder", e);
}
}
/**
//Test case number: 109
/*Coverage entropy=3.178053830347946
*/
@Test(timeout = 4000)
public void test109() throws Throwable {
Range range0 = Range.of(4294967301L);
Object object0 = new Object();
range0.equals(object0);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range1 = Range.of(range_CoordinateSystem0, 4294967301L, 4294967301L);
String string0 = range1.toString(range_CoordinateSystem0);
assertEquals("[ 4294967301 .. 4294967301 ]/RB", string0);
boolean boolean0 = range0.equals(range1);
assertFalse(boolean0);
long long0 = range1.getBegin();
assertEquals(4294967300L, long0);
}
/**
//Test case number: 110
/*Coverage entropy=2.890371757896165
*/
@Test(timeout = 4000)
public void test110() throws Throwable {
Range range0 = Range.ofLength(9223372036854775807L);
Long.valueOf((-170L));
Range range1 = Range.ofLength(9223372036854774157L);
range0.equals(range1);
Long long0 = new Long(9223372036854774157L);
assertEquals(9223372036854774157L, (long)long0);
}
/**
//Test case number: 111
/*Coverage entropy=2.9444389791664403
*/
@Test(timeout = 4000)
public void test111() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 2147483647L, 2147483647L);
Range range1 = Range.of(range_CoordinateSystem0, 2147483647L, 2147483647L);
range1.equals(range0);
// Undeclared exception!
try {
Range.CoordinateSystem.valueOf((String) null);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// Name is null
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 112
/*Coverage entropy=3.0445224377234217
*/
@Test(timeout = 4000)
public void test112() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 4294967295L, 9223372036854774157L);
Long.valueOf(2427L);
range0.equals(range0);
Range.Comparators[] range_ComparatorsArray0 = Range.Comparators.values();
assertEquals(4, range_ComparatorsArray0.length);
}
/**
//Test case number: 113
/*Coverage entropy=3.0550323582838375
*/
@Test(timeout = 4000)
public void test113() throws Throwable {
Range range0 = Range.ofLength(9223372036854775807L);
range0.toString();
Long long0 = new Long(9223372036854775807L);
range0.toString();
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.SPACE_BASED;
Range range1 = Range.parseRange("[ 0 .. 9223372036854775806 ]/0B", range_CoordinateSystem0);
boolean boolean0 = range0.equals(range1);
String string0 = range1.toString(range_CoordinateSystem0);
assertEquals("[ 9223372036854775806 .. 9223372036854775806 ]/SB", string0);
boolean boolean1 = range1.equals(range0);
assertTrue(boolean1 == boolean0);
assertFalse(boolean1);
}
/**
//Test case number: 114
/*Coverage entropy=3.5263605246161633
*/
@Test(timeout = 4000)
public void test114() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 4294967295L, 9223372036854774157L);
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.SPACE_BASED;
Range range1 = Range.of(range_CoordinateSystem1, 9223372036854774157L, 9223372036854774157L);
Range range2 = range1.intersection(range0);
range2.complement(range0);
range2.getLength();
Object object0 = new Object();
range2.equals(object0);
// Undeclared exception!
try {
Range.Comparators.valueOf("");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.Comparators.
//
verifyException("java.lang.Enum", e);
}
}
/**
//Test case number: 115
/*Coverage entropy=3.178053830347946
*/
@Test(timeout = 4000)
public void test115() throws Throwable {
Range range0 = Range.ofLength(9223372036854775807L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range range1 = Range.of(range_CoordinateSystem0, 1L, 9223372036854775807L);
range1.endsBefore(range0);
range0.equals(range1);
range1.getBegin();
range1.getBegin();
Range.Comparators.values();
Range.CoordinateSystem[] range_CoordinateSystemArray0 = Range.CoordinateSystem.values();
assertEquals(3, range_CoordinateSystemArray0.length);
}
/**
//Test case number: 116
/*Coverage entropy=2.9503916010253115
*/
@Test(timeout = 4000)
public void test116() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 65535L, 4294967295L);
range0.getBegin();
range0.toString();
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.SPACE_BASED;
Range range1 = Range.parseRange("[ 65535 .. 4294967295 ]/0B", range_CoordinateSystem1);
range1.equals(range0);
boolean boolean0 = range0.equals(range1);
assertTrue(boolean0);
long long0 = range0.getEnd();
assertEquals(4294967295L, long0);
}
/**
//Test case number: 117
/*Coverage entropy=3.1354942159291497
*/
@Test(timeout = 4000)
public void test117() throws Throwable {
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.ZERO_BASED;
Range range0 = Range.of(range_CoordinateSystem0, 65562L, 4294967295L);
range0.getBegin();
String string0 = range0.toString();
assertEquals("[ 65562 .. 4294967295 ]/0B", string0);
Range.CoordinateSystem range_CoordinateSystem1 = Range.CoordinateSystem.SPACE_BASED;
Range range1 = Range.parseRange("[ 65562 .. 4294967295 ]/0B", range_CoordinateSystem1);
boolean boolean0 = range1.equals(range0);
assertFalse(boolean0);
boolean boolean1 = range0.equals(range1);
range0.getEnd();
boolean boolean2 = range1.equals("[ 65562 .. 4294967295 ]/0B");
assertFalse(range1.isEmpty());
assertTrue(boolean2 == boolean1);
long long0 = range0.getBegin();
assertEquals(65562L, long0);
}
/**
//Test case number: 118
/*Coverage entropy=3.7612001156935655
*/
@Test(timeout = 4000)
public void test118() throws Throwable {
Range range0 = Range.of(1652L);
Range.CoordinateSystem range_CoordinateSystem0 = Range.CoordinateSystem.RESIDUE_BASED;
Range range1 = Range.of(range_CoordinateSystem0, 1652L, 4080L);
range1.complement(range0);
Range.CoordinateSystem.values();
Range.Comparators.values();
range1.getBegin();
range1.getEnd();
Range.of(9223372036854774156L);
Range range2 = Range.parseRange("ZFD5,7@T)jo0M?kLS|");
range1.equals(range2);
// Undeclared exception!
try {
Range.Comparators.valueOf("");
fail("Expecting exception: IllegalArgumentException");
} catch(IllegalArgumentException e) {
//
// No enum constant org.jcvi.jillion.core.Range.Comparators.
//
verifyException("java.lang.Enum", e);
}
}
}
|
3e01cd090252c1a2634d120dc069901acba6688d | 1,039 | java | Java | 4.1-EstructuraMavenModelDaoSpringOracle/src/test/java/com/indra/formacio/EmployeeRepoTest.java | gpujol/formacio_Java_3 | dfa6c106c1d3d20078429e59fe02bc6980bfade6 | [
"MIT"
] | null | null | null | 4.1-EstructuraMavenModelDaoSpringOracle/src/test/java/com/indra/formacio/EmployeeRepoTest.java | gpujol/formacio_Java_3 | dfa6c106c1d3d20078429e59fe02bc6980bfade6 | [
"MIT"
] | null | null | null | 4.1-EstructuraMavenModelDaoSpringOracle/src/test/java/com/indra/formacio/EmployeeRepoTest.java | gpujol/formacio_Java_3 | dfa6c106c1d3d20078429e59fe02bc6980bfade6 | [
"MIT"
] | null | null | null | 28.081081 | 80 | 0.792108 | 763 | package com.indra.formacio;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;
import junit.framework.TestCase;
import com.indra.formacio.dao.EmployeeRepository;
import com.indra.formacio.model.Employee;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/applicationContextTest.xml" })
public class EmployeeRepoTest extends TestCase {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
@Autowired
EmployeeRepository erepo;
@Test
public void testFileInsertedData() throws ParseException {
List<Employee> res = erepo.findByName("Treballador 3");
assertFalse(res.isEmpty());
Employee e = res.get(0);
assertEquals(sdf.parse("01/10/1970"), sdf.parse(sdf.format(e.getBirthday())));
}
}
|
3e01cdadb32b99fcba350177483be94606915c7f | 2,174 | java | Java | JusticeFinder/src/app/utils/CommonUtils.java | SaurabhGujare/LawyerFinder | 91e1e7be42ee32f4274a19feaa981f07ac599ad3 | [
"MIT"
] | null | null | null | JusticeFinder/src/app/utils/CommonUtils.java | SaurabhGujare/LawyerFinder | 91e1e7be42ee32f4274a19feaa981f07ac599ad3 | [
"MIT"
] | null | null | null | JusticeFinder/src/app/utils/CommonUtils.java | SaurabhGujare/LawyerFinder | 91e1e7be42ee32f4274a19feaa981f07ac599ad3 | [
"MIT"
] | null | null | null | 33.446154 | 105 | 0.680313 | 764 | package app.utils;
import app.data.directories.Directory;
import app.entities.Rating;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
/**
*
* @author Ninad Subhedar
* This class stores all the common methods used across the project.
*/
public class CommonUtils {
private static final String mmddyyyyFormat = "mm/dd/yyyy";
private static final SimpleDateFormat sdf = new SimpleDateFormat(mmddyyyyFormat);
public static Date mmddyyyyParseDate(String dateString) throws ParseException{
if(dateString==null || dateString.equals(""))
return null;
return sdf.parse(dateString);
}
public static String mmddyyyyFormatDate(Date date){
if(date==null)
return "";
return sdf.format(date);
}
public static String formatCurrency(Double amount){
return String.format("$%.00f", amount);
}
public static void initPicPanel(String fileLoc, JLabel photoFrame) throws IOException {
int w = (photoFrame.getWidth() == 0)?photoFrame.getPreferredSize().width:photoFrame.getWidth();
int h = (photoFrame.getHeight()== 0)?photoFrame.getPreferredSize().height:photoFrame.getHeight();
ImageIcon imageIcon = new ImageIcon(fileLoc);
imageIcon.setImage(imageIcon.getImage().getScaledInstance(w-2, h-2, Image.SCALE_DEFAULT));
photoFrame.setIcon(imageIcon);
}
public static void initPicPanel(BufferedImage image, JLabel photoFrame) throws IOException {
int w = (photoFrame.getWidth() == 0)?photoFrame.getPreferredSize().width:photoFrame.getWidth();
int h = (photoFrame.getHeight()== 0)?photoFrame.getPreferredSize().height:photoFrame.getHeight();
ImageIcon imageIcon = new ImageIcon(image);
imageIcon.setImage(imageIcon.getImage().getScaledInstance(w-2, h-2, Image.SCALE_DEFAULT));
photoFrame.setIcon(imageIcon);
}
}
|
3e01ce957755dc989e2ebaf0ea5af203831bd362 | 9,777 | java | Java | JAVA/Projects/les fichiers/src/fichier_nbrpair_impair_recupere_diaze.java | Zed-M/dzcode.talk | 7da4e0e83aa58597f30a61384370c3ae41926894 | [
"Unlicense"
] | 12 | 2019-04-22T10:16:54.000Z | 2022-01-08T02:44:19.000Z | JAVA/Projects/les fichiers/src/fichier_nbrpair_impair_recupere_diaze.java | Zed-M/dzcode.talk | 7da4e0e83aa58597f30a61384370c3ae41926894 | [
"Unlicense"
] | null | null | null | JAVA/Projects/les fichiers/src/fichier_nbrpair_impair_recupere_diaze.java | Zed-M/dzcode.talk | 7da4e0e83aa58597f30a61384370c3ae41926894 | [
"Unlicense"
] | 3 | 2019-05-14T11:24:42.000Z | 2019-08-08T16:13:09.000Z | 40.234568 | 229 | 0.548328 | 765 | import java.io.*;
public class fichier_nbrpair_impair_recupere_diaze extends javax.swing.JFrame {
FileReader fr; BufferedReader bf;
File f;
public fichier_nbrpair_impair_recupere_diaze() {
initComponents();
}
public String aff(String t){
String im="",p="";
for (int i = 0; i <t.length(); i++) {
int a=Integer.parseInt(t.substring(i,i+1));
if(a%2==0){
p+=a;
}else{
im+=a;
}
}
return (t+" ces paires "+p+" et ces impaires "+im);
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
b1 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
t1 = new javax.swing.JTextArea();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
b1.setText("1er methode");
b1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
b1ActionPerformed(evt);
}
});
t1.setColumns(20);
t1.setRows(5);
jScrollPane1.setViewportView(t1);
jButton1.setText("2eme methode");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("3eme");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 591, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(b1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(69, 69, 69))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(77, 77, 77)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(b1, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(61, 61, 61)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(40, 40, 40)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 294, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(66, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void b1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b1ActionPerformed
try{
int a; String k="",s="";
f = new File("/home/amine/Desktop/exo1.txt");
fr= new FileReader(f);
bf= new BufferedReader(fr);
String l=bf.readLine();
String t []=l.split("#");
for (int j = 0; j <t.length; j++) { //1234#5445#66668#2223#
for (int i = 0; i <t[j].length(); i++) { //1 2 3 4, //5 4 4 5
a=Integer.parseInt(t[j].substring(i,i+1)); //ils sont des entiers donc on les convert puis on fais un substring bl wahda c.a.d 1 a 2 omb3d mn 2 a 3 w hiya rayha w tcomparer
if(a%2==0 ){
s+=a;
}else{
k+=a;
}
}
t1.append(" voici le nombre "+j+" "+t[j]+" ces paires sont "+s+" ces impaires sont "+k+" \n");
s="";k="";
}
}catch(Exception e){}
}//GEN-LAST:event_b1ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
try{
f = new File("/home/amine/Desktop/exo1.txt");
fr=new FileReader(f);
bf= new BufferedReader(fr);
String l=bf.readLine();
String t []=l.split("#");
for (int i = 0; i <t.length; i++) {
t1.append(" le nombre est "+i+" : "+aff(t[i])+"\n" );
}
}catch(Exception e){}
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
pair_impair_2 s=new pair_impair_2();
this.dispose();
s.setVisible(true);
/*
public class pair_impair_2 extends javax.swing.JFrame {
File f;
BufferedReader bf;
FileReader fr;
String [] t;
String msg;
public pair_impair_2() {
initComponents();
afficher(); //on utilise directement les methode dans notre interface on lappelant ici
resultat();
}
public void afficher(){
try{
f=new File("/home/amine/Desktop/exo1.txt");
fr=new FileReader(f);
bf=new BufferedReader(fr);
msg=bf.readLine();
}catch(Exception e){
}
}
public void diviser(String x){
String p="",im="";
for (int i = 0; i <x.length(); i++) {
if((int)(x.charAt(i))%2==0){
p+=x.charAt(i);
}else{
im+=x.charAt(i);
}
}
if(p.equals("")){
p="0";
}
if(im.equals("")){
im="0";
}
t1.append(x+"-->paire "+p+",impaire= "+im+"\n");
}
public void resultat(){
t=msg.split("#");
for (int i = 0; i <t.length; i++) {
diviser(t[i]);
}
}
*/
}//GEN-LAST:event_jButton2ActionPerformed
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(fichier_nbrpair_impair_recupere_diaze.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(fichier_nbrpair_impair_recupere_diaze.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(fichier_nbrpair_impair_recupere_diaze.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(fichier_nbrpair_impair_recupere_diaze.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new fichier_nbrpair_impair_recupere_diaze().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton b1;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea t1;
// End of variables declaration//GEN-END:variables
}
|
3e01cef4331e814de6622c0576ff9a1431165fee | 3,679 | java | Java | src/test/java/fr/esiea/glpoo/kamui/AbstractCsvTirageDaoTest.java | Ginuis/GLPOO_ESIEA_1718_Kamui_Groupe-OBAMI | dc5c326dc9d3705d240563643561516e9f069cbe | [
"Apache-2.0"
] | null | null | null | src/test/java/fr/esiea/glpoo/kamui/AbstractCsvTirageDaoTest.java | Ginuis/GLPOO_ESIEA_1718_Kamui_Groupe-OBAMI | dc5c326dc9d3705d240563643561516e9f069cbe | [
"Apache-2.0"
] | null | null | null | src/test/java/fr/esiea/glpoo/kamui/AbstractCsvTirageDaoTest.java | Ginuis/GLPOO_ESIEA_1718_Kamui_Groupe-OBAMI | dc5c326dc9d3705d240563643561516e9f069cbe | [
"Apache-2.0"
] | null | null | null | 26.65942 | 87 | 0.694754 | 766 | package fr.esiea.glpoo.kamui;
import static org.junit.Assert.assertEquals;
import java.util.List;
import org.apache.log4j.Logger;
import org.junit.Assert;
import org.junit.Test;
import fr.esiea.kamui.dao.CsvTirageDao;
import fr.esiea.kamui.domain.Tirage;
public abstract class AbstractCsvTirageDaoTest {
private static final Logger LOGGER = Logger.getLogger(AbstractCsvTirageDaoTest.class);
protected CsvTirageDao dao;
@Test
public void testTailleEntetes() {
LOGGER.debug("testTailleEntetes Debut");
// Act
final List<String> entetes = dao.getEntetes();
final int tailleAttendue = 75;
// Assert
assertEquals(tailleAttendue, entetes.size());
LOGGER.debug("testTailleEntetes Fin");
}
@Test
public void testPremierEntetes() {
LOGGER.debug("testPremierEntetes Debut");
// Act
final List<String> entetes = dao.getEntetes();
final String enteteAttendue = "annee_numero_de_tirage";
final int position = 0;
// Assert
assertEquals(enteteAttendue, entetes.get(position));
LOGGER.debug("testPremierEntetes Fin");
}
@Test
public void testDeuxiemeEntetes() {
LOGGER.debug("testDeuxiemeEntetes Debut");
// Act
final List<String> entetes = dao.getEntetes();
final String enteteAttendue = "jour_de_tirage";
final int position = 1;
// Assert
assertEquals(enteteAttendue, entetes.get(position));
LOGGER.debug("testDeuxiemeEntetes Fin");
}
@Test
public void testBoule1() throws Exception {
LOGGER.debug("testBoule1 Debut");
//Arrange
final int bouleAttendue = 41;
// Act
final List<Tirage> tirages = dao.findAllTirage();
// Assert
Assert.assertEquals(bouleAttendue, tirages.get(0).getBoule1());
LOGGER.debug("testBoule1 Fin");
}
@Test
public void testBoule2() throws Exception {
LOGGER.debug("testBoule2 Debut");
//Arrange
final int bouleAttendue = 6;
// Act
final List<Tirage> tirages = dao.findAllTirage();
// Assert
Assert.assertEquals(bouleAttendue, tirages.get(0).getBoule2());
LOGGER.debug("testBoule2 Fin");
}
@Test
public void testBoule3() throws Exception {
LOGGER.debug("testBoule3 Debut");
//Arrange
final int bouleAttendue = 13;
// Act
final List<Tirage> tirages = dao.findAllTirage();
// Assert
Assert.assertEquals(bouleAttendue, tirages.get(0).getBoule3());
LOGGER.debug("testBoule3 Fin");
}
@Test
public void testBoule4() throws Exception {
LOGGER.debug("testBoule4 Debut");
//Arrange
final int bouleAttendue = 39;
// Act
final List<Tirage> tirages = dao.findAllTirage();
// Assert
Assert.assertEquals(bouleAttendue, tirages.get(0).getBoule4());
LOGGER.debug("testBoule4 Fin");
}
@Test
public void testBoule5() {
LOGGER.debug("testBoule5 Debut");
//Arrange
final int bouleAttendue = 9;
// Act
final List<Tirage> tirages = dao.findAllTirage();
// Assert
Assert.assertEquals(bouleAttendue, tirages.get(0).getBoule5());
LOGGER.debug("testBoule5 fin");
}
@Test
public void testEtoile1() throws Exception {
LOGGER.debug("testEtoile1 Debut");
//Arrange
final int etoileAttendue = 2;
// Act
final List<Tirage> tirages = dao.findAllTirage();
// Assert
Assert.assertEquals(etoileAttendue, tirages.get(0).getEtoile1());
LOGGER.debug("testEtoile1 fin");
}
@Test
public void testEtoile2() throws Exception {
LOGGER.debug("testEtoile2 Debut");
//Arrange
final int etoileAttendue = 12;
// Act
final List<Tirage> tirages = dao.findAllTirage();
// Assert
Assert.assertEquals(etoileAttendue, tirages.get(0).getEtoile2());
LOGGER.debug("testEtoile2 Fin");
}
}
|
3e01cf905a22e8092c694ede62d4ee9d50f9cb8b | 4,165 | java | Java | src/test/java/org/redkale/test/convert/InnerCoderEntity.java | redkale/redkale | f0ac042b3c359aa8194cbb5221c8c981396bc58a | [
"Apache-2.0"
] | 433 | 2016-01-29T02:32:57.000Z | 2022-02-25T01:44:35.000Z | src/test/java/org/redkale/test/convert/InnerCoderEntity.java | redkale/redkale | f0ac042b3c359aa8194cbb5221c8c981396bc58a | [
"Apache-2.0"
] | 7 | 2016-01-29T06:53:41.000Z | 2021-07-30T08:04:49.000Z | src/test/java/org/redkale/test/convert/InnerCoderEntity.java | redkale/redkale | f0ac042b3c359aa8194cbb5221c8c981396bc58a | [
"Apache-2.0"
] | 144 | 2016-01-29T02:56:26.000Z | 2022-03-30T07:22:50.000Z | 34.708333 | 136 | 0.606242 | 767 | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.redkale.test.convert;
import org.redkale.convert.*;
import org.redkale.convert.bson.*;
import org.redkale.convert.json.*;
import org.redkale.util.*;
/**
*
* @author zhangjx
*/
public class InnerCoderEntity {
private final String val;
private final int id;
private InnerCoderEntity(int id, String value) {
this.id = id;
this.val = value;
}
public static InnerCoderEntity create(int id, String value) {
return new InnerCoderEntity(id, value);
}
/**
* 该方法提供给Convert组件自动加载。
* 1) 方法名可以随意。
2) 方法必须是static
3)方法的参数有且只能有一个, 且必须是org.redkale.convert.ConvertFactory或子类。
—3.1) 参数类型为org.redkale.convert.ConvertFactory 表示适合JSON和BSON。
—3.2) 参数类型为org.redkale.convert.json.JsonFactory 表示仅适合JSON。
—3.3) 参数类型为org.redkale.convert.bson.BsonFactory 表示仅适合BSON。
4)方法的返回类型必须是org.redkale.convert.Decodeable/org.redkale.convert.Encodeable/org.redkale.convert.SimpledCoder
若返回类型不是org.redkale.convert.SimpledCoder, 就必须提供两个方法: 一个返回Decodeable 一个返回 Encodeable。
*
* @param factory
* @return
*/
private static SimpledCoder<Reader, Writer, InnerCoderEntity> createConvertCoder(final org.redkale.convert.ConvertFactory factory) {
return new SimpledCoder<Reader, Writer, InnerCoderEntity>() {
//必须与EnMember[] 顺序一致
private final DeMember[] deMembers = new DeMember[]{
DeMember.create(factory, InnerCoderEntity.class, "id"),
DeMember.create(factory, InnerCoderEntity.class, "val")};
//必须与DeMember[] 顺序一致
private final EnMember[] enMembers = new EnMember[]{
EnMember.create(factory, InnerCoderEntity.class, "id"),
EnMember.create(factory, InnerCoderEntity.class, "val")};
@Override
public void convertTo(Writer out, InnerCoderEntity value) {
if (value == null) {
out.writeObjectNull(InnerCoderEntity.class);
return;
}
out.writeObjectB(value);
for (EnMember member : enMembers) {
out.writeObjectField(member, value);
}
out.writeObjectE(value);
}
@Override
public InnerCoderEntity convertFrom(Reader in) {
if (in.readObjectB(InnerCoderEntity.class) == null) return null;
int index = 0;
final Object[] params = new Object[deMembers.length];
while (in.hasNext()) {
DeMember member = in.readFieldName(deMembers); //读取字段名
in.readBlank(); //读取字段名与字段值之间的间隔符,JSON则是跳过冒号:
if (member == null) {
in.skipValue(); //跳过不存在的字段的值, 一般不会发生
} else {
params[index++] = member.read(in);
}
}
in.readObjectE(InnerCoderEntity.class);
return InnerCoderEntity.create(params[0] == null ? 0 : (Integer) params[0], (String) params[1]);
}
};
}
public int getId() {
return id;
}
public String getVal() {
return val;
}
@Override
public String toString() {
return JsonConvert.root().convertTo(this);
}
public static void main(String[] args) throws Exception {
InnerCoderEntity record = InnerCoderEntity.create(200, "haha");
final JsonConvert convert = JsonConvert.root();
String json = convert.convertTo(record);
System.out.println(json);
System.out.println(convert.convertFrom(InnerCoderEntity.class, json).toString());
final BsonConvert convert2 = BsonFactory.root().getConvert();
byte[] bs = convert2.convertTo(InnerCoderEntity.class, null);
Utility.println("--", bs);
InnerCoderEntity r = convert2.convertFrom(InnerCoderEntity.class, bs);
System.out.println(r);
}
}
|
3e01cfd14c09daa188771ab92608a7a6dd397456 | 169 | java | Java | app/src/main/java/com/stylingandroid/vizualiser/renderer/WaveformRenderer.java | RishabRanga/VisualizerSplitScreen | b228b6061f0827872b920450c03a008ede64641f | [
"Apache-2.0"
] | 10 | 2016-01-29T11:12:45.000Z | 2021-07-29T01:53:56.000Z | app/src/main/java/com/stylingandroid/vizualiser/renderer/WaveformRenderer.java | RishabRanga/VisualizerSplitScreen | b228b6061f0827872b920450c03a008ede64641f | [
"Apache-2.0"
] | 2 | 2016-01-31T20:53:57.000Z | 2017-06-28T07:31:47.000Z | app/src/main/java/com/stylingandroid/vizualiser/renderer/WaveformRenderer.java | RishabRanga/VisualizerSplitScreen | b228b6061f0827872b920450c03a008ede64641f | [
"Apache-2.0"
] | 3 | 2016-08-19T10:42:12.000Z | 2022-01-03T14:28:41.000Z | 21.125 | 48 | 0.792899 | 768 | package com.stylingandroid.vizualiser.renderer;
import android.graphics.Canvas;
public interface WaveformRenderer {
void render(Canvas canvas, byte[] waveform);
}
|
3e01d101f93d639b532bebaf1eebef60c0cbf5a3 | 550 | java | Java | src/main/java/org/abondarev/visual/states/State.java | alex-d-bondarev/learn-java-2d | 0afdf99174c02f8a4020ad028c45d46823c9b0e9 | [
"MIT"
] | null | null | null | src/main/java/org/abondarev/visual/states/State.java | alex-d-bondarev/learn-java-2d | 0afdf99174c02f8a4020ad028c45d46823c9b0e9 | [
"MIT"
] | null | null | null | src/main/java/org/abondarev/visual/states/State.java | alex-d-bondarev/learn-java-2d | 0afdf99174c02f8a4020ad028c45d46823c9b0e9 | [
"MIT"
] | null | null | null | 18.965517 | 45 | 0.683636 | 769 | package org.abondarev.visual.states;
import org.abondarev.visual.Game;
import org.abondarev.visual.Handler;
import java.awt.*;
public abstract class State {
private static State currentState = null;
protected Handler handler;
public State(Handler handler) {
this.handler = handler;
}
public abstract void tick();
public abstract void render(Graphics g);
public static void setState(State state){
currentState = state;
}
public static State getState(){
return currentState;
}
}
|
3e01d1302299e91e90ae217b510fb7a21870029b | 197,258 | java | Java | src/test/java/issues/gh100/FromJoinWhereTest.java | redmark/mybatis-dynamic-sql | 734718248d5fecb93eb3851bd2be5a9d98b37e20 | [
"ECL-2.0",
"Apache-2.0"
] | 816 | 2017-12-18T04:47:44.000Z | 2022-03-31T12:27:13.000Z | src/test/java/issues/gh100/FromJoinWhereTest.java | redmark/mybatis-dynamic-sql | 734718248d5fecb93eb3851bd2be5a9d98b37e20 | [
"ECL-2.0",
"Apache-2.0"
] | 432 | 2018-01-03T14:39:29.000Z | 2022-03-31T13:03:31.000Z | src/test/java/issues/gh100/FromJoinWhereTest.java | redmark/mybatis-dynamic-sql | 734718248d5fecb93eb3851bd2be5a9d98b37e20 | [
"ECL-2.0",
"Apache-2.0"
] | 175 | 2017-12-18T06:48:32.000Z | 2022-03-13T12:13:58.000Z | 50.180107 | 150 | 0.690187 | 770 | /*
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package issues.gh100;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mybatis.dynamic.sql.SqlBuilder.*;
import org.junit.jupiter.api.Test;
import org.mybatis.dynamic.sql.render.RenderingStrategies;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.select.SelectDSL;
import org.mybatis.dynamic.sql.select.SelectModel;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
class FromJoinWhereTest {
@Test
void testNormalUsage() {
SelectStatementProvider selectStatement = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student)
.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid))
.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"))
.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student)
.orderBy(StudentDynamicSqlSupport.id)
.limit(3)
.offset(2)
.build()
.render(RenderingStrategies.MYBATIS3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFrom() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
String expected = "select id, name, idcard"
+ " from student";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testfromJoinWhereB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testfromJoinWhereB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testfromJoinWhereB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionUnionB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student)
.where(StudentDynamicSqlSupport.id, isNotNull());
builder4.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student)
.where(StudentDynamicSqlSupport.id, isNull());
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " where id is not null"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " where id is null";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionUnionB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student)
.where(StudentDynamicSqlSupport.id, isNotNull());
builder4.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student)
.where(StudentDynamicSqlSupport.id, isNull());
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " where id is not null"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " where id is null";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionUnionB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student)
.where(StudentDynamicSqlSupport.id, isNotNull());
builder4.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student)
.where(StudentDynamicSqlSupport.id, isNull());
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " where id is not null"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " where id is null";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionUnionB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student)
.where(StudentDynamicSqlSupport.id, isNotNull());
builder4.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student)
.where(StudentDynamicSqlSupport.id, isNull());
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " where id is not null"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " where id is null";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionUnionB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student)
.where(StudentDynamicSqlSupport.id, isNotNull());
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder5 = builder4.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student)
.where(StudentDynamicSqlSupport.id, isNull());
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " where id is not null"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " where id is null";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
builder4.orderBy(StudentDynamicSqlSupport.id);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
builder4.orderBy(StudentDynamicSqlSupport.id);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
builder4.orderBy(StudentDynamicSqlSupport.id);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
builder4.orderBy(StudentDynamicSqlSupport.id);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByLimitB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
builder5.limit(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByLimitB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
builder5.limit(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByLimitB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
builder5.limit(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByLimitB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
builder5.limit(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByLimitB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
builder5.limit(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByLimitB6() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.LimitFinisher builder6 = builder5.limit(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder6.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByLimitOffsetB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.LimitFinisher builder6 = builder5.limit(3);
builder6.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByLimitOffsetB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.LimitFinisher builder6 = builder5.limit(3);
builder6.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByLimitOffsetB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.LimitFinisher builder6 = builder5.limit(3);
builder6.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByLimitOffsetB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.LimitFinisher builder6 = builder5.limit(3);
builder6.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByLimitOffsetB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.LimitFinisher builder6 = builder5.limit(3);
builder6.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByLimitOffsetB6() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.LimitFinisher builder6 = builder5.limit(3);
builder6.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder6.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByLimitOffsetB7() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.LimitFinisher builder6 = builder5.limit(3);
SelectDSL<SelectModel>.OffsetFinisher builder7 = builder6.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder7.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByOffsetB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByOffsetB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByOffsetB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByOffsetB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByOffsetB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByOffsetB6() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.OffsetFirstFinisher builder6 = builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder6.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByOffsetFetchFirstB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.OffsetFirstFinisher builder6 = builder5.offset(2);
builder6.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByOffsetFetchFirstB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.OffsetFirstFinisher builder6 = builder5.offset(2);
builder6.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByOffsetFetchFirstB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.OffsetFirstFinisher builder6 = builder5.offset(2);
builder6.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByOffsetFetchFirstB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.OffsetFirstFinisher builder6 = builder5.offset(2);
builder6.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByOffsetFetchFirstB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.OffsetFirstFinisher builder6 = builder5.offset(2);
builder6.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByOffsetFetchFirstB6() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.OffsetFirstFinisher builder6 = builder5.offset(2);
builder6.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder6.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByOffsetFetchFirstB7() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.OffsetFirstFinisher builder6 = builder5.offset(2);
SelectDSL<SelectModel>.RowsOnlyFinisher builder7 = builder6.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder7.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByFetchFirstB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
builder5.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByFetchFirstB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
builder5.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByFetchFirstB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
builder5.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByFetchFirstB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
builder5.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByFetchFirstB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
builder5.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOrderByFetchFirstB6() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel> builder5 = builder4.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.RowsOnlyFinisher builder6 = builder5.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " order by id"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder6.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionLimitB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
builder4.limit(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionLimitB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
builder4.limit(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionLimitB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
builder4.limit(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionLimitB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
builder4.limit(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionLimitB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel>.LimitFinisher builder5 = builder4.limit(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionLimitOffsetB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel>.LimitFinisher builder5 = builder4.limit(3);
builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionLimitOffsetB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel>.LimitFinisher builder5 = builder4.limit(3);
builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionLimitOffsetB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel>.LimitFinisher builder5 = builder4.limit(3);
builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionLimitOffsetB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel>.LimitFinisher builder5 = builder4.limit(3);
builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionLimitOffsetB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel>.LimitFinisher builder5 = builder4.limit(3);
builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionLimitOffsetB6() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel>.LimitFinisher builder5 = builder4.limit(3);
SelectDSL<SelectModel>.OffsetFinisher builder6 = builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder6.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOffsetB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
builder4.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOffsetB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
builder4.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOffsetB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
builder4.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOffsetB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
builder4.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOffsetB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel>.OffsetFirstFinisher builder5 = builder4.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOffsetFetchFirstB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel>.OffsetFirstFinisher builder5 = builder4.offset(2);
builder5.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOffsetFetchFirstB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel>.OffsetFirstFinisher builder5 = builder4.offset(2);
builder5.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOffsetFetchFirstB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel>.OffsetFirstFinisher builder5 = builder4.offset(2);
builder5.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOffsetFetchFirstB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel>.OffsetFirstFinisher builder5 = builder4.offset(2);
builder5.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOffsetFetchFirstB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel>.OffsetFirstFinisher builder5 = builder4.offset(2);
builder5.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionOffsetFetchFirstB6() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel>.OffsetFirstFinisher builder5 = builder4.offset(2);
SelectDSL<SelectModel>.RowsOnlyFinisher builder6 = builder5.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder6.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionFetchFirstB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
builder4.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionFetchFirstB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
builder4.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionFetchFirstB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
builder4.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionFetchFirstB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
builder4.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereUnionFetchFirstB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
QueryExpressionDSL<SelectModel> builder4 = builder3.union()
.select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
SelectDSL<SelectModel>.RowsOnlyFinisher builder5 = builder4.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " union"
+ " select id, name, idcard"
+ " from student"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
builder3.orderBy(StudentDynamicSqlSupport.id);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
builder3.orderBy(StudentDynamicSqlSupport.id);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
builder3.orderBy(StudentDynamicSqlSupport.id);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByLimitB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
builder4.limit(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByLimitB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
builder4.limit(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByLimitB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
builder4.limit(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByLimitB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
builder4.limit(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByLimitB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.LimitFinisher builder5 = builder4.limit(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByLimitOffsetB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.LimitFinisher builder5 = builder4.limit(3);
builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByLimitOffsetB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.LimitFinisher builder5 = builder4.limit(3);
builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByLimitOffsetB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.LimitFinisher builder5 = builder4.limit(3);
builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByLimitOffsetB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.LimitFinisher builder5 = builder4.limit(3);
builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByLimitOffsetB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.LimitFinisher builder5 = builder4.limit(3);
builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByLimitOffsetB6() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.LimitFinisher builder5 = builder4.limit(3);
SelectDSL<SelectModel>.OffsetFinisher builder6 = builder5.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder6.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByOffsetB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
builder4.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByOffsetB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
builder4.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByOffsetB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
builder4.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByOffsetB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
builder4.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByOffsetB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.OffsetFirstFinisher builder5 = builder4.offset(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByOffsetFetchFirstB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.OffsetFirstFinisher builder5 = builder4.offset(2);
builder5.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByOffsetFetchFirstB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.OffsetFirstFinisher builder5 = builder4.offset(2);
builder5.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByOffsetFetchFirstB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.OffsetFirstFinisher builder5 = builder4.offset(2);
builder5.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByOffsetFetchFirstB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.OffsetFirstFinisher builder5 = builder4.offset(2);
builder5.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByOffsetFetchFirstB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.OffsetFirstFinisher builder5 = builder4.offset(2);
builder5.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByOffsetFetchFirstB6() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.OffsetFirstFinisher builder5 = builder4.offset(2);
SelectDSL<SelectModel>.RowsOnlyFinisher builder6 = builder5.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder6.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByFetchFirstB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
builder4.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByFetchFirstB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
builder4.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByFetchFirstB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
builder4.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByFetchFirstB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
builder4.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOrderByFetchFirstB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel> builder4 = builder3.orderBy(StudentDynamicSqlSupport.id);
SelectDSL<SelectModel>.RowsOnlyFinisher builder5 = builder4.fetchFirst(3).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " order by id"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereLimitB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
builder3.limit(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereLimitB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
builder3.limit(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereLimitB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
builder3.limit(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereLimitB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel>.LimitFinisher builder4 = builder3.limit(2);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " limit #{parameters.p2}";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereLimitOffsetB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel>.LimitFinisher builder4 = builder3.limit(2);
builder4.offset(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereLimitOffsetB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel>.LimitFinisher builder4 = builder3.limit(2);
builder4.offset(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereLimitOffsetB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel>.LimitFinisher builder4 = builder3.limit(2);
builder4.offset(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereLimitOffsetB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel>.LimitFinisher builder4 = builder3.limit(2);
builder4.offset(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereLimitOffsetB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel>.LimitFinisher builder4 = builder3.limit(2);
SelectDSL<SelectModel>.OffsetFinisher builder5 = builder4.offset(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " limit #{parameters.p2}"
+ " offset #{parameters.p3}";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOffsetB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
builder3.offset(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOffsetB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
builder3.offset(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOffsetB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
builder3.offset(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOffsetB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel>.OffsetFirstFinisher builder4 = builder3.offset(3);
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " offset #{parameters.p2} rows";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOffsetFetchFirstB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel>.OffsetFirstFinisher builder4 = builder3.offset(3);
builder4.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOffsetFetchFirstB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel>.OffsetFirstFinisher builder4 = builder3.offset(3);
builder4.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOffsetFetchFirstB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel>.OffsetFirstFinisher builder4 = builder3.offset(3);
builder4.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOffsetFetchFirstB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel>.OffsetFirstFinisher builder4 = builder3.offset(3);
builder4.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereOffsetFetchFirstB5() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel>.OffsetFirstFinisher builder4 = builder3.offset(3);
SelectDSL<SelectModel>.RowsOnlyFinisher builder5 = builder4.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " offset #{parameters.p2} rows"
+ " fetch first #{parameters.p3} rows only";
SelectStatementProvider selectStatement = builder5.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereFetchFirstB1() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
builder3.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder1.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereFetchFirstB2() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
builder3.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder2.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereFetchFirstB3() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
builder3.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder3.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
@Test
void testFromJoinWhereFetchFirstB4() {
QueryExpressionDSL<SelectModel> builder1 = select(StudentDynamicSqlSupport.id, StudentDynamicSqlSupport.name, StudentDynamicSqlSupport.idcard)
.from(StudentDynamicSqlSupport.student);
QueryExpressionDSL<SelectModel>.JoinSpecificationFinisher builder2 = builder1.join(StudentRegDynamicSqlSupport.studentReg)
.on(StudentDynamicSqlSupport.id, equalTo(StudentRegDynamicSqlSupport.studentid));
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder3 = builder2.where(StudentDynamicSqlSupport.idcard, isEqualTo("fred"));
SelectDSL<SelectModel>.RowsOnlyFinisher builder4 = builder3.fetchFirst(2).rowsOnly();
String expected = "select student.id, student.name, student.idcard"
+ " from student"
+ " join student_reg on student.id = student_reg.studentId"
+ " where student.idcard = #{parameters.p1}"
+ " fetch first #{parameters.p2} rows only";
SelectStatementProvider selectStatement = builder4.build().render(RenderingStrategies.MYBATIS3);
assertThat(selectStatement.getSelectStatement()).isEqualTo(expected);
}
}
|
3e01d1b9afd7f471ca724d6c92cd3f9645125e21 | 358 | java | Java | elarian-common/src/main/java/com/elarian/model/VoiceCallInput.java | ElarianLtd/java-sdk | 9cfeb681f872396a29a4705a9da81d8864f5b860 | [
"MIT"
] | 3 | 2021-03-19T12:43:40.000Z | 2021-05-27T23:16:47.000Z | elarian-common/src/main/java/com/elarian/model/VoiceCallInput.java | ElarianLtd/java-sdk | 9cfeb681f872396a29a4705a9da81d8864f5b860 | [
"MIT"
] | 1 | 2021-11-05T21:22:46.000Z | 2021-11-05T21:34:35.000Z | elarian-common/src/main/java/com/elarian/model/VoiceCallInput.java | ElarianLtd/java-sdk | 9cfeb681f872396a29a4705a9da81d8864f5b860 | [
"MIT"
] | 2 | 2021-06-15T17:36:29.000Z | 2021-12-05T20:37:48.000Z | 27.538462 | 44 | 0.782123 | 771 | package com.elarian.model;
public final class VoiceCallInput {
public VoiceCallDirection direction;
public VoiceCallStatus status;
public VoiceCallHangupCause hangupCause;
public long startedAt;
public String dtmfDigits;
public String recordingUrl;
public VoiceCallDialInput dialData;
public VoiceCallQueueInput queueData;
}
|
3e01d2aaa794368355ca29cecb0fe7a830f47a68 | 10,403 | java | Java | reactive-vaadin-addon/src/test/java/org/vaadin/addons/reactive/command/create/ProgressFromObservableBiFunctionSpecification.java | dohnala/reactive-mvvm | b09737221630853a10c7a4eec50301b07e6bf958 | [
"Apache-2.0"
] | 2 | 2018-11-14T20:44:52.000Z | 2018-11-14T20:55:04.000Z | reactive-vaadin-addon/src/test/java/org/vaadin/addons/reactive/command/create/ProgressFromObservableBiFunctionSpecification.java | dohnala/reactive-vaadin | b09737221630853a10c7a4eec50301b07e6bf958 | [
"Apache-2.0"
] | 1 | 2018-04-22T18:14:16.000Z | 2018-04-23T15:59:34.000Z | reactive-vaadin-addon/src/test/java/org/vaadin/addons/reactive/command/create/ProgressFromObservableBiFunctionSpecification.java | dohnala/reactive-vaadin | b09737221630853a10c7a4eec50301b07e6bf958 | [
"Apache-2.0"
] | null | null | null | 34.909396 | 114 | 0.605787 | 772 | /*
* Copyright (c) 2018-present, reactive-mvvm Contributors.
*
* 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.vaadin.addons.reactive.command.create;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.function.BiFunction;
import io.reactivex.Observable;
import io.reactivex.Scheduler;
import io.reactivex.observers.TestObserver;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.schedulers.TestScheduler;
import io.reactivex.subjects.PublishSubject;
import io.reactivex.subjects.ReplaySubject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.vaadin.addons.reactive.ProgressContext;
import org.vaadin.addons.reactive.ReactiveCommand;
import org.vaadin.addons.reactive.ReactiveCommandExtension;
import org.vaadin.addons.reactive.command.CanExecuteEmitsValueSpecification;
import org.vaadin.addons.reactive.command.CreateSpecification;
import org.vaadin.addons.reactive.command.ExecuteSpecification;
/**
* Tests for {@link ReactiveCommand} created by
* {@link ReactiveCommandExtension#createProgressCommandFromObservable(BiFunction, Scheduler)}
* {@link ReactiveCommandExtension#createProgressCommandFromObservable(Observable, BiFunction, Scheduler)}
*
* @author dohnal
*/
public interface ProgressFromObservableBiFunctionSpecification extends
CreateSpecification,
ExecuteSpecification,
CanExecuteEmitsValueSpecification
{
abstract class AbstractProgressFromObservableBiFunctionWithSchedulerSpecification extends
AbstractCreateSpecification<Integer, Integer> implements ReactiveCommandExtension
{
protected ReplaySubject<ReactiveCommand<?, ?>> capturedCommands;
protected BiFunction<ProgressContext, Integer, Observable<Integer>> execution;
protected ReactiveCommand<Integer, Integer> command;
@BeforeEach
@SuppressWarnings("unchecked")
void create()
{
capturedCommands = ReplaySubject.create();
execution = Mockito.mock(BiFunction.class);
command = createProgressCommandFromObservable(execution, Schedulers.from(Runnable::run));
}
@Nonnull
@Override
public <T, R> ReactiveCommand<T, R> onCreateCommand(final @Nonnull ReactiveCommand<T, R> command)
{
final ReactiveCommand<T, R> created = ReactiveCommandExtension.super.onCreateCommand(command);
capturedCommands.onNext(created);
return created;
}
@Test
@DisplayName("Created command should be captured")
public void testCreatedCommand()
{
capturedCommands.test().assertValue(command);
}
@Nonnull
@Override
public ReactiveCommand<Integer, Integer> getCommand()
{
return command;
}
@Test
@DisplayName("Execution should not be run")
public void testExecution()
{
Mockito.verify(execution, Mockito.never()).apply(Mockito.any(), Mockito.anyInt());
}
@Nested
@DisplayName("When command is executed with no input")
class ExecuteWithNoInput
{
@Test
@DisplayName("Error observable shout emit NullPointerException")
public void testExecute()
{
final TestObserver<Throwable> testObserver = command.getError().test();
command.execute().subscribe();
testObserver.assertValue(error -> error.getClass().equals(NullPointerException.class));
}
}
@Nested
@DisplayName("Execute specification")
class Execute extends AbstractExecuteSpecification<Integer, Integer>
{
private final Integer INPUT = 5;
private final Integer RESULT = 7;
private final Throwable ERROR = new RuntimeException("Error");
@Nonnull
@Override
public ReactiveCommand<Integer, Integer> getCommand()
{
return command;
}
@Nonnull
@Override
protected Observable<Integer> execute()
{
Mockito.doAnswer(invocation -> {
final ProgressContext progressContext = invocation.getArgument(0);
return Observable.just(0.0f, 0.25f, 0.5f, 0.75f, 1.0f)
.doOnNext(progressContext::set)
.ignoreElements()
.toObservable()
.concatWith(Observable.just(RESULT));
}).when(execution).apply(Mockito.any(ProgressContext.class), Mockito.eq(INPUT));
return command.execute(INPUT);
}
@Nonnull
protected Float[] getProgress()
{
return new Float[]{0.0f, 0.25f, 0.5f, 0.75f, 1.0f};
}
@Nonnull
@Override
protected Observable<Integer> executeWithError()
{
Mockito.doAnswer(invocation -> {
final ProgressContext progressContext = invocation.getArgument(0);
return Observable.just(0.0f, 0.25f, 0.5f)
.doOnNext(progressContext::set)
.ignoreElements()
.toObservable()
.concatWith(Observable.error(ERROR));
}).when(execution).apply(Mockito.any(ProgressContext.class), Mockito.eq(INPUT));
return command.execute(INPUT);
}
@Nonnull
protected Float[] getErrorProgress()
{
return new Float[]{0.0f, 0.25f, 0.5f, 1.0f};
}
@Nullable
@Override
protected Integer getResult()
{
return RESULT;
}
@Nullable
@Override
protected Throwable getError()
{
return ERROR;
}
@Override
@SuppressWarnings("unchecked")
protected void clearExecution()
{
Mockito.clearInvocations(execution);
}
@Override
protected void verifyExecution()
{
Mockito.verify(execution).apply(Mockito.any(ProgressContext.class), Mockito.eq(INPUT));
}
}
}
abstract class AbstractProgressFromObservableBiFunctionWithCanExecuteAndSchedulerSpecification
extends AbstractCreateSpecification<Integer, Integer> implements ReactiveCommandExtension
{
protected ReplaySubject<ReactiveCommand<?, ?>> capturedCommands;
protected BiFunction<ProgressContext, Integer, Observable<Integer>> execution;
protected TestScheduler testScheduler;
protected PublishSubject<Boolean> testSubject;
protected ReactiveCommand<Integer, Integer> command;
@BeforeEach
@SuppressWarnings("unchecked")
void create()
{
capturedCommands = ReplaySubject.create();
execution = Mockito.mock(BiFunction.class);
testScheduler = new TestScheduler();
testSubject = PublishSubject.create();
testSubject.observeOn(testScheduler);
command = createProgressCommandFromObservable(testSubject, execution, Schedulers.from(Runnable::run));
}
@Nonnull
@Override
public <T, R> ReactiveCommand<T, R> onCreateCommand(final @Nonnull ReactiveCommand<T, R> command)
{
final ReactiveCommand<T, R> created = ReactiveCommandExtension.super.onCreateCommand(command);
capturedCommands.onNext(created);
return created;
}
@Test
@DisplayName("Created command should be captured")
public void testCreatedCommand()
{
capturedCommands.test().assertValue(command);
}
@Nonnull
@Override
public ReactiveCommand<Integer, Integer> getCommand()
{
return command;
}
@Nested
@DisplayName("CanExecute emits value specification")
class CanExecuteEmitsValue extends AbstractCanExecuteEmitsValueSpecification<Integer, Integer>
{
private final Integer INPUT = 5;
private final Integer RESULT = 7;
@Nonnull
@Override
public ReactiveCommand<Integer, Integer> getCommand()
{
return command;
}
@Override
protected void emitValue(final @Nonnull Boolean value)
{
testSubject.onNext(value);
testScheduler.triggerActions();
}
@Override
protected void emitError(final @Nonnull Throwable error)
{
testSubject.onError(error);
testScheduler.triggerActions();
}
@Nonnull
@Override
protected Observable<Integer> execute()
{
Mockito.doAnswer(invocation -> {
final ProgressContext progressContext = invocation.getArgument(0);
return Observable.just(0.0f, 0.25f, 0.5f, 0.75f, 1.0f)
.doOnNext(progressContext::set)
.ignoreElements()
.toObservable()
.concatWith(Observable.just(RESULT));
}).when(execution).apply(Mockito.any(ProgressContext.class), Mockito.eq(INPUT));
return command.execute(INPUT);
}
}
}
}
|
3e01d2ac7f1dc3a5563d02d30c75d8a3ddf3fa06 | 1,241 | java | Java | app/src/main/java/com/xuncl/selfimproveproject/activities/AlarmActivity.java | xuncl/SelfImproveProject | 5c0eda2811ab7b0994b76b47e0843df3ec76266b | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/xuncl/selfimproveproject/activities/AlarmActivity.java | xuncl/SelfImproveProject | 5c0eda2811ab7b0994b76b47e0843df3ec76266b | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/xuncl/selfimproveproject/activities/AlarmActivity.java | xuncl/SelfImproveProject | 5c0eda2811ab7b0994b76b47e0843df3ec76266b | [
"Apache-2.0"
] | null | null | null | 25.854167 | 73 | 0.649476 | 773 | package com.xuncl.selfimproveproject.activities;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.media.MediaPlayer;
import android.os.Bundle;
import com.xuncl.selfimproveproject.R;
public class AlarmActivity extends BaseActivity {
private MediaPlayer player;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
player = MediaPlayer.create(this, R.raw.alarm_fairytail_short);
//显示对话框
new AlertDialog.Builder(AlarmActivity.this).
setTitle("IT'S TIME TO").//设置标题
setMessage("CHALLENGE YOURSELF!").//设置内容
setPositiveButton("WILL DO", new OnClickListener(){//设置按钮
public void onClick(DialogInterface dialog, int which) {
//TODO Record what challenge user has accepted.
stopRing();
AlarmActivity.this.finish();//关闭Activity
}
}).create().show();
ringAlarm();
}
private void stopRing() {
player.stop();
}
private void ringAlarm() {
player.start();
}
} |
3e01d39a3e2925e39439d46df7743405b3fca515 | 638 | java | Java | src/main/java/de/hsbremen/chat/network/transferableObjects/ServerInfo.java | cschaf/multithreaded-java-chat | 0c9b73efb733200868e0f9a4e71c80717a4a12e6 | [
"MIT"
] | null | null | null | src/main/java/de/hsbremen/chat/network/transferableObjects/ServerInfo.java | cschaf/multithreaded-java-chat | 0c9b73efb733200868e0f9a4e71c80717a4a12e6 | [
"MIT"
] | 6 | 2015-03-28T17:10:44.000Z | 2015-03-29T14:14:25.000Z | src/main/java/de/hsbremen/chat/network/transferableObjects/ServerInfo.java | cschaf/multithreaded-java-chat | 0c9b73efb733200868e0f9a4e71c80717a4a12e6 | [
"MIT"
] | null | null | null | 22.785714 | 57 | 0.733542 | 774 | package de.hsbremen.chat.network.transferableObjects;
import de.hsbremen.chat.core.ClientJListItem;
import de.hsbremen.chat.network.ITransferable;
import de.hsbremen.chat.network.TransferableType;
import java.util.ArrayList;
/**
* Created by cschaf on 01.04.2015.
*/
public class ServerInfo extends TransferableObject {
private ArrayList<ClientJListItem> users;
public ServerInfo(ArrayList<ClientJListItem> users) {
this.users = users;
}
public TransferableType getType() {
return TransferableType.ServerInfo;
}
public ArrayList<ClientJListItem> getUsers() {
return users;
}
}
|
3e01d39b25b90ab2a88235e5ee48a39fc227b675 | 94 | java | Java | factory/abstractFactory/book/Book.java | Bronya0/design-pattern | 6480f22c0acc2039eb1ae4896f3da36a121737ab | [
"MIT"
] | null | null | null | factory/abstractFactory/book/Book.java | Bronya0/design-pattern | 6480f22c0acc2039eb1ae4896f3da36a121737ab | [
"MIT"
] | null | null | null | factory/abstractFactory/book/Book.java | Bronya0/design-pattern | 6480f22c0acc2039eb1ae4896f3da36a121737ab | [
"MIT"
] | null | null | null | 9.4 | 37 | 0.638298 | 775 | package factory.abstractFactory.book;
/**
*
*/
public interface Book {
void read();
}
|
3e01d3a0dc565627604d7dee269e7c09695817f7 | 1,347 | java | Java | web/src/main/java/com/futurewei/alcor/web/entity/ip/IpAddrUpdateRequest.java | pkommoju/alcor | ded81987e3750d8f518ff2e0d899f010747691a7 | [
"MIT"
] | 28 | 2020-02-21T19:54:00.000Z | 2022-03-28T20:41:46.000Z | web/src/main/java/com/futurewei/alcor/web/entity/ip/IpAddrUpdateRequest.java | pkommoju/alcor | ded81987e3750d8f518ff2e0d899f010747691a7 | [
"MIT"
] | 481 | 2020-02-20T01:26:54.000Z | 2022-02-26T16:40:08.000Z | web/src/main/java/com/futurewei/alcor/web/entity/ip/IpAddrUpdateRequest.java | pkommoju/alcor | ded81987e3750d8f518ff2e0d899f010747691a7 | [
"MIT"
] | 54 | 2020-02-27T19:23:00.000Z | 2022-03-21T09:29:06.000Z | 49.888889 | 165 | 0.778768 | 776 | /*
MIT License
Copyright(c) 2020 Futurewei Cloud
Permission is hereby granted,
free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.futurewei.alcor.web.entity.ip;
import lombok.Data;
import java.util.List;
@Data
public class IpAddrUpdateRequest {
private List<IpAddrRequest> oldIpAddrRequests;
private List<IpAddrRequest> newIpAddrRequests;
}
|
3e01d59ebb277108f07aed192181184a61486745 | 8,408 | java | Java | choerodon-maven-plugin/src/main/java/io/choerodon/plugin/maven/ConvertMojo.java | logsin37/choerodon-starters | 44bdfa2be6d1587cd21ebb97dc87e77d5ad35d4e | [
"Apache-2.0"
] | null | null | null | choerodon-maven-plugin/src/main/java/io/choerodon/plugin/maven/ConvertMojo.java | logsin37/choerodon-starters | 44bdfa2be6d1587cd21ebb97dc87e77d5ad35d4e | [
"Apache-2.0"
] | null | null | null | choerodon-maven-plugin/src/main/java/io/choerodon/plugin/maven/ConvertMojo.java | logsin37/choerodon-starters | 44bdfa2be6d1587cd21ebb97dc87e77d5ad35d4e | [
"Apache-2.0"
] | null | null | null | 42.464646 | 128 | 0.642008 | 777 | package io.choerodon.plugin.maven;
import static io.choerodon.plugin.maven.ExtractMojo.CHOERODON_FOLDER_IN_JAR;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
import javax.inject.Inject;
import org.apache.commons.io.FileUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbookFactory;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
@Mojo(name = "convert", defaultPhase = LifecyclePhase.PROCESS_RESOURCES, requiresDependencyResolution = ResolutionScope.COMPILE)
public class ConvertMojo extends AbstractMojo {
private static final int SKIP_ROW_NUMBER = 6;
private static final int SKIP_CELL_NUMBER = 4;
private static final String CONVERT_FILE_NAME = "script/meta/micro-service-init-data.xlsx";
private static final String MERGE_FILE_NAME = CHOERODON_FOLDER_IN_JAR + "/micro-service-init-data.json";
private ObjectMapper objectMapper = new ObjectMapper();
@Inject
private MavenProject mavenProject;
@Parameter(property = "serviceBuild", defaultValue = "false")
private boolean serviceBuild;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
File target = new File(mavenProject.getBuild().getOutputDirectory());
if (!target.exists() || !target.isDirectory()) {
getLog().info("skip convert classes not found. run mvn compile first.");
return;
}
try {
ObjectNode objectNode = convertFormDirectory(target.getAbsolutePath());
if (objectNode == null) {
objectNode = JsonNodeFactory.instance.objectNode();
}
if (serviceBuild) {
mergeDependency(objectNode);
}
File outputFile = new File(target.getAbsolutePath() + File.separator + MERGE_FILE_NAME);
FileUtils.forceMkdirParent(outputFile);
FileUtils.writeStringToFile(outputFile, objectNode.toString(), StandardCharsets.UTF_8);
} catch (Exception e) {
throw new MojoExecutionException("convert exception", e);
}
}
private void mergeDependency(ObjectNode root) throws IOException {
ArtifactFilter artifactFilter = new ScopeArtifactFilter(Artifact.SCOPE_COMPILE);
mavenProject.setArtifactFilter(artifactFilter);
for (Artifact artifact : mavenProject.getArtifacts()) {
File file = artifact.getFile();
if (file != null) {
if (file.isDirectory()) {
mergeFormDirectory(file.getAbsolutePath(), root);
} else {
mergeFormJar(file.getAbsolutePath(), root);
}
}
}
}
private void mergeFormJar(String target, ObjectNode root) throws IOException {
try (JarFile jarFile = new JarFile(target)) {
ZipEntry entry = jarFile.getEntry(MERGE_FILE_NAME);
if (entry != null) {
getLog().info("Merge: " + target);
mergeFormInputStream(jarFile.getInputStream(entry), root);
}
}
}
private void mergeFormDirectory(String target, ObjectNode root) throws IOException {
File convertFile = new File(target + File.separator + MERGE_FILE_NAME);
if (convertFile.isFile()) {
getLog().info("Merge: " + target);
mergeFormInputStream(new FileInputStream(convertFile), root);
}
}
private ObjectNode convertFormDirectory(String target) throws IOException {
File convertFile = new File(target + File.separator + CONVERT_FILE_NAME);
if (convertFile.isFile()) {
getLog().info("Convert: " + target);
return convertFormInputStream(new FileInputStream(convertFile));
} else {
getLog().warn("No files found that need to be converted " + CONVERT_FILE_NAME);
}
return null;
}
private ObjectNode convertFormInputStream(InputStream inputStream) throws IOException {
ObjectNode result = JsonNodeFactory.instance.objectNode();
try (Workbook workbook = XSSFWorkbookFactory.create(inputStream)) {
workbook.getCreationHelper().createFormulaEvaluator().evaluateAll();
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
Sheet sheet = workbook.getSheetAt(i);
result.set(sheet.getSheetName(), convertFormSheet(sheet));
}
}
return result;
}
private ArrayNode convertFormSheet(Sheet sheet) {
Row headerRow = sheet.getRow(SKIP_ROW_NUMBER);
ArrayNode sheetNode = JsonNodeFactory.instance.arrayNode();
String[] columns = new String[headerRow.getLastCellNum() - SKIP_CELL_NUMBER + 1];
for (int cellIndex = SKIP_CELL_NUMBER; cellIndex < headerRow.getLastCellNum(); cellIndex++) {
columns[cellIndex - SKIP_CELL_NUMBER] = headerRow.getCell(cellIndex).getStringCellValue();
}
for (int rowIndex = SKIP_ROW_NUMBER + 1; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
Row dataRow = sheet.getRow(rowIndex);
if (dataRow == null) {
getLog().warn(String.format("row is null break: %s, %d", sheet.getSheetName(), rowIndex));
break;
}
ObjectNode rowNode = JsonNodeFactory.instance.objectNode();
boolean isValida = false;
for (int cellIndex = SKIP_CELL_NUMBER; cellIndex < headerRow.getLastCellNum(); cellIndex++) {
String columnName = columns[cellIndex - SKIP_CELL_NUMBER];
Cell cell = dataRow.getCell(cellIndex);
if (cell == null) {
rowNode.putNull(columnName);
continue;
}
if (cell.getCellType().equals(CellType.NUMERIC)) {
isValida = true;
rowNode.put(columnName, cell.getNumericCellValue());
} else {
String value = cell.getStringCellValue();
if (value != null && value.length() != 0){
isValida = true;
}
rowNode.put(columnName, value);
}
}
if (!isValida) {
break;
}
sheetNode.add(rowNode);
}
return sheetNode;
}
private void mergeFormInputStream(InputStream inputStream, ObjectNode root) throws IOException {
JsonNode inputRoot = objectMapper.readTree(inputStream);
Iterator<String> tableNames = inputRoot.fieldNames();
while (tableNames.hasNext()) {
String tableName = tableNames.next();
JsonNode oldNode = root.get(tableName);
if (oldNode == null) {
root.set(tableName, inputRoot.get(tableName));
} else {
root.set(tableName, mergeTableJsonObject(oldNode, inputRoot.get(tableName)));
}
}
}
private ArrayNode mergeTableJsonObject(JsonNode oldNode, JsonNode newNode) {
ArrayNode tableNode = JsonNodeFactory.instance.arrayNode();
for (int i = 0; i < oldNode.size(); i++) {
tableNode.add(oldNode.get(i));
}
for (int i = 0; i < newNode.size(); i++) {
tableNode.add(newNode.get(i));
}
return tableNode;
}
}
|
3e01d608c0d588c1b31dfdf743d387100691349f | 5,252 | java | Java | datax-modules/data-market-service-parent/data-market-service/src/main/java/cn/datax/service/data/market/controller/ApiMaskController.java | 312075478/datax-cloud | 065d91d929abfa9ed754092c1df7b666e1aed705 | [
"Apache-2.0"
] | 10 | 2021-12-10T07:23:35.000Z | 2022-03-30T08:31:58.000Z | datax-modules/data-market-service-parent/data-market-service/src/main/java/cn/datax/service/data/market/controller/ApiMaskController.java | inlovingrest/datax-cloud | 79bf0728b3a57d103c92ec72a71ffa5c2e2c9c39 | [
"Apache-2.0"
] | 2 | 2022-02-01T00:49:18.000Z | 2022-02-28T09:14:04.000Z | datax-modules/data-market-service-parent/data-market-service/src/main/java/cn/datax/service/data/market/controller/ApiMaskController.java | inlovingrest/datax-cloud | 79bf0728b3a57d103c92ec72a71ffa5c2e2c9c39 | [
"Apache-2.0"
] | 10 | 2021-12-10T06:24:39.000Z | 2022-03-28T14:42:54.000Z | 36.22069 | 137 | 0.68374 | 778 | package cn.datax.service.data.market.controller;
import cn.datax.common.base.BaseController;
import cn.datax.common.core.JsonPage;
import cn.datax.common.core.R;
import cn.datax.common.validate.ValidationGroups;
import cn.datax.service.data.market.api.dto.ApiMaskDto;
import cn.datax.service.data.market.api.entity.ApiMaskEntity;
import cn.datax.service.data.market.api.query.ApiMaskQuery;
import cn.datax.service.data.market.api.vo.ApiMaskVo;
import cn.datax.service.data.market.mapstruct.ApiMaskMapper;
import cn.datax.service.data.market.service.ApiMaskService;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
* 数据API脱敏信息表 前端控制器
* </p>
*
* @author yuwei
* @since 2020-04-14
*/
@Api(tags = {"数据API脱敏信息表"})
@RestController
@RequestMapping("/apiMasks")
public class ApiMaskController extends BaseController {
@Autowired
private ApiMaskService apiMaskService;
@Autowired
private ApiMaskMapper apiMaskMapper;
/**
* 通过ID查询信息
*
* @param id
* @return
*/
@ApiOperation(value = "获取详细信息", notes = "根据url的id来获取详细信息")
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path")
@GetMapping("/{id}")
public R getApiMaskById(@PathVariable String id) {
ApiMaskEntity apiMaskEntity = apiMaskService.getApiMaskById(id);
return R.ok().setData(apiMaskMapper.toVO(apiMaskEntity));
}
/**
* 通过ID查询信息
*
* @param id
* @return
*/
@ApiOperation(value = "获取详细信息", notes = "根据url的id来获取详细信息")
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path")
@GetMapping("/api/{id}")
public R getApiMaskByApiId(@PathVariable String id) {
ApiMaskEntity apiMaskEntity = apiMaskService.getApiMaskByApiId(id);
return R.ok().setData(apiMaskMapper.toVO(apiMaskEntity));
}
/**
* 分页查询信息
*
* @param apiMaskQuery
* @return
*/
@ApiOperation(value = "分页查询", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "apiMaskQuery", value = "查询实体apiMaskQuery", required = true, dataTypeClass = ApiMaskQuery.class)
})
@GetMapping("/page")
public R getApiMaskPage(ApiMaskQuery apiMaskQuery) {
QueryWrapper<ApiMaskEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.like(StrUtil.isNotBlank(apiMaskQuery.getMaskName()), "mask_name", apiMaskQuery.getMaskName());
IPage<ApiMaskEntity> page = apiMaskService.page(new Page<>(apiMaskQuery.getPageNum(), apiMaskQuery.getPageSize()), queryWrapper);
List<ApiMaskVo> collect = page.getRecords().stream().map(apiMaskMapper::toVO).collect(Collectors.toList());
JsonPage<ApiMaskVo> jsonPage = new JsonPage<>(page.getCurrent(), page.getSize(), page.getTotal(), collect);
return R.ok().setData(jsonPage);
}
/**
* 添加
* @param apiMask
* @return
*/
@ApiOperation(value = "添加信息", notes = "根据apiMask对象添加信息")
@ApiImplicitParam(name = "apiMask", value = "详细实体apiMask", required = true, dataType = "ApiMaskDto")
@PostMapping()
public R saveApiMask(@RequestBody @Validated({ValidationGroups.Insert.class}) ApiMaskDto apiMask) {
apiMaskService.saveApiMask(apiMask);
return R.ok();
}
/**
* 修改
* @param apiMask
* @return
*/
@ApiOperation(value = "修改信息", notes = "根据url的id来指定修改对象,并根据传过来的信息来修改详细信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path"),
@ApiImplicitParam(name = "apiMask", value = "详细实体apiMask", required = true, dataType = "ApiMaskDto")
})
@PutMapping("/{id}")
public R updateApiMask(@PathVariable String id, @RequestBody @Validated({ValidationGroups.Update.class}) ApiMaskDto apiMask) {
apiMaskService.updateApiMask(apiMask);
return R.ok();
}
/**
* 删除
* @param id
* @return
*/
@ApiOperation(value = "删除", notes = "根据url的id来指定删除对象")
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path")
@DeleteMapping("/{id}")
public R deleteApiMaskById(@PathVariable String id) {
apiMaskService.deleteApiMaskById(id);
return R.ok();
}
@ApiOperation(value = "批量删除", notes = "根据url的ids来批量删除对象")
@ApiImplicitParam(name = "ids", value = "ID集合", required = true, dataType = "List", paramType = "path")
@DeleteMapping("/batch/{ids}")
public R deleteApiMaskBatch(@PathVariable List<String> ids) {
apiMaskService.deleteApiMaskBatch(ids);
return R.ok();
}
}
|
3e01d672ec0aae0c6738998b629792af9fed37ce | 410 | java | Java | src/main/java/com/service/OrderFormService.java | KRTBS/Fd-BackEnd | 095a84eca5011917c962b0cdc77bf702ca55f5e2 | [
"Apache-2.0"
] | 1 | 2022-01-07T18:00:17.000Z | 2022-01-07T18:00:17.000Z | src/main/java/com/service/OrderFormService.java | KRTBS/Fd-BackEnd | 095a84eca5011917c962b0cdc77bf702ca55f5e2 | [
"Apache-2.0"
] | 1 | 2022-01-24T07:50:34.000Z | 2022-01-24T07:50:34.000Z | src/main/java/com/service/OrderFormService.java | KRTBS/Fd-BackEnd | 095a84eca5011917c962b0cdc77bf702ca55f5e2 | [
"Apache-2.0"
] | 1 | 2022-01-21T06:59:19.000Z | 2022-01-21T06:59:19.000Z | 20.5 | 57 | 0.782927 | 779 | package com.service;
import com.pojo.OrderForm;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public interface OrderFormService {
int addNewOrderForm(OrderForm orderForm);
List<OrderForm> getUserOrderFormByUserID(int userID);
List<OrderForm> queryAllOrderForm();
OrderForm queryOrderFormByID(int id);
int changeOrderFormState(OrderForm orderForm);
}
|
3e01d73d34eb411289a56edd2d1580f9427f4b91 | 2,170 | java | Java | test/codegen_expect/interface_type_profile/B7.java | google/dart2java | 294925bf3650adbd80639c8520ab598ee384b8ba | [
"Apache-2.0"
] | 57 | 2016-09-28T17:42:02.000Z | 2022-02-28T04:50:01.000Z | test/codegen_expect/interface_type_profile/B7.java | google/dart2java | 294925bf3650adbd80639c8520ab598ee384b8ba | [
"Apache-2.0"
] | 17 | 2016-10-03T22:04:32.000Z | 2021-09-18T06:06:04.000Z | test/codegen_expect/interface_type_profile/B7.java | google/dart2java | 294925bf3650adbd80639c8520ab598ee384b8ba | [
"Apache-2.0"
] | 16 | 2016-10-01T07:00:46.000Z | 2021-10-12T03:39:45.000Z | 65.757576 | 211 | 0.807834 | 780 | package interface_type_profile;
public class B7 extends dart._runtime.base.DartObject implements interface_type_profile.B7_interface, interface_type_profile.A2_interface, interface_type_profile.A1_interface, interface_type_profile.A0_interface
{
public static dart._runtime.types.simple.InterfaceTypeInfo dart2java$typeInfo = new dart._runtime.types.simple.InterfaceTypeInfo(interface_type_profile.B7.class, interface_type_profile.B7_interface.class);
private static dart._runtime.types.simple.InterfaceTypeExpr dart2java$typeExpr_Object = new dart._runtime.types.simple.InterfaceTypeExpr(dart._runtime.helpers.ObjectHelper.dart2java$typeInfo);
private static dart._runtime.types.simple.InterfaceTypeExpr dart2java$typeExpr_A2 = new dart._runtime.types.simple.InterfaceTypeExpr(interface_type_profile.A2.dart2java$typeInfo);
private static dart._runtime.types.simple.InterfaceTypeExpr dart2java$typeExpr_A1 = new dart._runtime.types.simple.InterfaceTypeExpr(interface_type_profile.A1.dart2java$typeInfo);
private static dart._runtime.types.simple.InterfaceTypeExpr dart2java$typeExpr_A0 = new dart._runtime.types.simple.InterfaceTypeExpr(interface_type_profile.A0.dart2java$typeInfo);
static {
interface_type_profile.B7.dart2java$typeInfo.superclass = dart2java$typeExpr_Object;
interface_type_profile.B7.dart2java$typeInfo.interfaces = new dart._runtime.types.simple.InterfaceTypeExpr[] {dart2java$typeExpr_A2, dart2java$typeExpr_A1, dart2java$typeExpr_A0};
}
public B7(dart._runtime.helpers.ConstructorHelper.EmptyConstructorMarker arg, dart._runtime.types.simple.Type type)
{
super(arg, type);
}
public void _constructor()
{
final dart._runtime.types.simple.TypeEnvironment dart2java$localTypeEnv = this.dart2java$type.env;
super._constructor();
}
public static interface_type_profile.B7_interface _new_B7$(dart._runtime.types.simple.Type type)
{
interface_type_profile.B7 result;
result = new interface_type_profile.B7(((dart._runtime.helpers.ConstructorHelper.EmptyConstructorMarker) null), type);
result._constructor();
return result;
}
}
|
3e01d766e3b592ef6f033e18a9ef2304ba1936ea | 1,585 | java | Java | libcore/src/test/java/com/mapbox/android/core/metrics/MetricsImplTest.java | karanveer0802/flightmaptelematry | 557658895d9bdcb0d147ca83d58858aee63126ef | [
"MIT"
] | 56 | 2017-11-27T09:26:17.000Z | 2022-01-27T03:45:50.000Z | libcore/src/test/java/com/mapbox/android/core/metrics/MetricsImplTest.java | karanveer0802/flightmaptelematry | 557658895d9bdcb0d147ca83d58858aee63126ef | [
"MIT"
] | 365 | 2017-11-16T19:46:27.000Z | 2022-03-24T13:32:49.000Z | libcore/src/test/java/com/mapbox/android/core/metrics/MetricsImplTest.java | karanveer0802/flightmaptelematry | 557658895d9bdcb0d147ca83d58858aee63126ef | [
"MIT"
] | 52 | 2017-11-18T11:08:42.000Z | 2022-02-08T16:59:12.000Z | 26.864407 | 90 | 0.71041 | 781 | package com.mapbox.android.core.metrics;
import android.os.SystemClock;
import org.junit.Test;
import java.util.concurrent.TimeUnit;
import static org.assertj.core.api.Assertions.assertThat;
public class MetricsImplTest {
@Test
public void wrongSpan() {
long startTime = SystemClock.elapsedRealtime();
long endTime = startTime + TimeUnit.HOURS.toMillis(24);
Metrics metrics = new MetricsImpl(endTime, startTime);
assertThat(metrics.getStart()).isEqualTo(startTime);
assertThat(metrics.getEnd()).isEqualTo(endTime);
}
@Test
public void add() {
Metrics metrics = getMetrics();
metrics.add(100L);
assertThat(metrics.getValue()).isEqualTo(100L);
}
@Test
public void subtract() {
Metrics metrics = getMetrics();
metrics.add(-100L);
assertThat(metrics.getValue()).isEqualTo(-100L);
}
@Test
public void getValue() {
Metrics metrics = getMetrics();
assertThat(metrics.getValue()).isEqualTo(0L);
}
@Test
public void getStart() {
long startTime = SystemClock.elapsedRealtime();
Metrics metrics = new MetricsImpl(startTime, startTime + TimeUnit.HOURS.toMillis(24));
assertThat(metrics.getStart()).isEqualTo(startTime);
}
@Test
public void getEnd() {
long endTime = SystemClock.elapsedRealtime();
Metrics metrics = new MetricsImpl(0, endTime);
assertThat(metrics.getStart()).isEqualTo(endTime);
}
private static Metrics getMetrics() {
long startTime = SystemClock.elapsedRealtime();
return new MetricsImpl(startTime, startTime + TimeUnit.HOURS.toMillis(24));
}
} |
3e01d8df7d0a5056ba4781a775fe0ae531dd9e54 | 485 | java | Java | shared/src/main/java/shared/model/Chat.java | bdemann/ticket-to-ride | 2540fc3c853fa1bd0b86bed2f3ad23895ec881d9 | [
"MIT"
] | null | null | null | shared/src/main/java/shared/model/Chat.java | bdemann/ticket-to-ride | 2540fc3c853fa1bd0b86bed2f3ad23895ec881d9 | [
"MIT"
] | 2 | 2018-01-31T23:23:40.000Z | 2018-01-31T23:27:45.000Z | shared/src/main/java/shared/model/Chat.java | bdemann/ticket-to-ride | 2540fc3c853fa1bd0b86bed2f3ad23895ec881d9 | [
"MIT"
] | null | null | null | 19.4 | 61 | 0.690722 | 782 | package shared.model;
import java.io.Serializable;
import shared.model.interfaces.IPlayer;
import shared.model.interfaces.Message;
/**
* Created by Ben on 2/6/2018.
*/
public class Chat extends Message implements Serializable {
private IPlayer speaker;
public Chat(IPlayer speaker, String message, long time) {
super(speaker.getUsername(), message, time);
this.speaker = speaker;
}
public IPlayer getSpeaker() {
return speaker;
}
}
|
3e01d929067f9d6bc3a45263d60056bed4a7db26 | 1,668 | java | Java | FarmusApp/app/src/main/java/thegreymanshow/farmus/CustomAdapter.java | TheGreymanShow/FarmUS | 6dd5beeb20805de03f1c5d9286f8fc2c27ce0d84 | [
"MIT"
] | null | null | null | FarmusApp/app/src/main/java/thegreymanshow/farmus/CustomAdapter.java | TheGreymanShow/FarmUS | 6dd5beeb20805de03f1c5d9286f8fc2c27ce0d84 | [
"MIT"
] | null | null | null | FarmusApp/app/src/main/java/thegreymanshow/farmus/CustomAdapter.java | TheGreymanShow/FarmUS | 6dd5beeb20805de03f1c5d9286f8fc2c27ce0d84 | [
"MIT"
] | null | null | null | 27.344262 | 106 | 0.708633 | 783 | package thegreymanshow.farmus;
import android.content.Context;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import java.util.List;
/**
* Created by Parth on 1/28/2017.
*/
public class CustomAdapter extends RecyclerView.Adapter<CustomAdapter.ViewHolder> {
private Context context;
private List<Mydata> my_data;
public CustomAdapter(Context context, List<Mydata> my_data) {
this.context = context;
this.my_data = my_data;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_view,parent,false);
return new ViewHolder(itemView);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.description.setText(my_data.get(position).getDescription());
Glide.with(context).load(my_data.get(position).getImage()).into(holder.imageView);
}
@Override
public int getItemCount() {
return my_data.size();
}
public class ViewHolder extends RecyclerView.ViewHolder{
public TextView description;
public ImageView imageView;
public ViewHolder(View itemView) {
super(itemView);
description = (TextView) itemView.findViewById(R.id.description);
imageView = (ImageView) itemView.findViewById(R.id.image);
}
}
} |
3e01d9abffacc9a66e7a8d5945365c9b71c2487b | 249 | java | Java | lp-springboot-gateway/lp-test-service-1/src/main/java/com/cn/lp/base/ApiVersion.java | lpppph/lp-demo | 6bc1bacacac9171c8cd18f7e4dfc36d58f3b8ce5 | [
"Apache-2.0"
] | null | null | null | lp-springboot-gateway/lp-test-service-1/src/main/java/com/cn/lp/base/ApiVersion.java | lpppph/lp-demo | 6bc1bacacac9171c8cd18f7e4dfc36d58f3b8ce5 | [
"Apache-2.0"
] | null | null | null | lp-springboot-gateway/lp-test-service-1/src/main/java/com/cn/lp/base/ApiVersion.java | lpppph/lp-demo | 6bc1bacacac9171c8cd18f7e4dfc36d58f3b8ce5 | [
"Apache-2.0"
] | null | null | null | 15.5625 | 47 | 0.686747 | 784 | package com.cn.lp.base;
import java.lang.annotation.*;
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ApiVersion {
/**
* 标识版本号,从1开始
*/
int value() default 1;
}
|
3e01da5e6ceb4ffa8e9fc21097ff41267bfc7094 | 724 | java | Java | sword2offer/problem6_print_linkedlist_reversely/PrintListReversely_iteratively.java | amos-hsu/algorithms | 893a27a39ea9815ab2614151f2d2862482d4e1cd | [
"Apache-2.0"
] | null | null | null | sword2offer/problem6_print_linkedlist_reversely/PrintListReversely_iteratively.java | amos-hsu/algorithms | 893a27a39ea9815ab2614151f2d2862482d4e1cd | [
"Apache-2.0"
] | null | null | null | sword2offer/problem6_print_linkedlist_reversely/PrintListReversely_iteratively.java | amos-hsu/algorithms | 893a27a39ea9815ab2614151f2d2862482d4e1cd | [
"Apache-2.0"
] | null | null | null | 21.294118 | 74 | 0.549724 | 785 | /*
输入一个链表,从尾到头打印链表每个节点的值。
( 不允许修改数据 )
*/
/**
* public class ListNode {
* int val;
* ListNode next = null;
*
* ListNode(int val) {
* this.val = val;
* }
* }
*
*/
//使用栈,迭代输出
import java.util.ArrayList;
import java.util.Stack;
public class Solution {
public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {
//if(listNode == null) return null;
Stack<Integer> stack = new Stack<>();
while(listNode != null){
stack.push(listNode.val);
listNode = listNode.next;
}
ArrayList<Integer> ret = new ArrayList<>();
while(!stack.isEmpty())
ret.add(stack.pop());
return ret;
}
} |
3e01da72503d0cc5a60e1d1f4ca0b8d13da58132 | 3,396 | java | Java | ec-api/src/test/java/eventcenter/api/TestLoadListenerFilter.java | KingHimma/event-center | fa84ff4ad35e903afd7889d96dc6dd74a9e3dcc5 | [
"MIT"
] | 1 | 2018-08-02T10:12:50.000Z | 2018-08-02T10:12:50.000Z | ec-api/src/test/java/eventcenter/api/TestLoadListenerFilter.java | github-ygy-project/event-center | fa84ff4ad35e903afd7889d96dc6dd74a9e3dcc5 | [
"MIT"
] | null | null | null | ec-api/src/test/java/eventcenter/api/TestLoadListenerFilter.java | github-ygy-project/event-center | fa84ff4ad35e903afd7889d96dc6dd74a9e3dcc5 | [
"MIT"
] | 1 | 2022-01-08T13:33:47.000Z | 2022-01-08T13:33:47.000Z | 30.594595 | 86 | 0.671967 | 786 | package eventcenter.api;
import eventcenter.api.annotation.EventFilterable;
import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
/**
* test load listener filters in {@link EventCenterConfig}
* Created by liumingjian on 16/1/26.
*/
public class TestLoadListenerFilter {
@Test
public void test1(){
EventCenterConfig config = new EventCenterConfig();
Map<String, ListenerFilter> filterMap = new HashMap<String, ListenerFilter>();
filterMap.put("addFilterableFilter", new AddFilterableFilter());
config.loadListenerFilter(filterMap);
Assert.assertTrue(config.getListenerFilters().containsKey("test"));
}
@Test
public void test2(){
EventCenterConfig config = new EventCenterConfig();
Map<String, ListenerFilter> filterMap = new HashMap<String, ListenerFilter>();
filterMap.put("addMultiFilterableFilter", new AddMultiFilterableFilter());
config.loadListenerFilter(filterMap);
Assert.assertTrue(config.getListenerFilters().containsKey("test1"));
Assert.assertTrue(config.getListenerFilters().containsKey("test2"));
Assert.assertTrue(config.getListenerFilters().containsKey("test3"));
}
@Test
public void test3(){
EventCenterConfig config = new EventCenterConfig();
Map<String, ListenerFilter> filterMap = new HashMap<String, ListenerFilter>();
filterMap.put("addGlobalFilter", new AddGlobalFilter());
config.loadListenerFilter(filterMap);
Assert.assertTrue(config.getListenerFilters().size() == 0);
Assert.assertEquals(1, config.getGlobalFilters().size());
}
@Test
public void test4(){
EventCenterConfig config = new EventCenterConfig();
Map<String, ListenerFilter> filterMap = new HashMap<String, ListenerFilter>();
filterMap.put("nonFilterableFilter", new NonFilterableFilter());
config.loadListenerFilter(filterMap);
Assert.assertTrue(config.getListenerFilters().size() == 0);
Assert.assertEquals(0, config.getGlobalFilters().size());
}
public class NonFilterableFilter implements ListenerFilter {
@Override
public boolean before(EventListener listener, CommonEventSource evt) {
return true;
}
@Override
public void after(ListenerReceipt receipt) {
}
}
@EventFilterable(value="test")
class AddFilterableFilter implements ListenerFilter {
@Override
public boolean before(EventListener listener, CommonEventSource evt) {
return true;
}
@Override
public void after(ListenerReceipt receipt) {
}
}
@EventFilterable(value="test1,test2,test3")
public class AddMultiFilterableFilter implements ListenerFilter {
@Override
public boolean before(EventListener listener, CommonEventSource evt) {
return true;
}
@Override
public void after(ListenerReceipt receipt) {
}
}
@EventFilterable(isGlobal = true)
public class AddGlobalFilter implements ListenerFilter {
@Override
public boolean before(EventListener listener, CommonEventSource evt) {
return true;
}
@Override
public void after(ListenerReceipt receipt) {
}
}
}
|
3e01db328ba1a4284e17b9245e3451f0972bfeea | 4,610 | java | Java | src/test/java/uk/ac/ebi/pride/jmztab/utils/errors/WikiRun.java | bigbio/jmzTab | d955f97ab09ee31aad454b3831ae8b26c138895d | [
"Apache-2.0"
] | 1 | 2021-08-17T18:37:23.000Z | 2021-08-17T18:37:23.000Z | src/test/java/uk/ac/ebi/pride/jmztab/utils/errors/WikiRun.java | bigbio/jmzTab | d955f97ab09ee31aad454b3831ae8b26c138895d | [
"Apache-2.0"
] | null | null | null | src/test/java/uk/ac/ebi/pride/jmztab/utils/errors/WikiRun.java | bigbio/jmzTab | d955f97ab09ee31aad454b3831ae8b26c138895d | [
"Apache-2.0"
] | null | null | null | 40.438596 | 132 | 0.593059 | 787 | package uk.ac.ebi.pride.jmztab.utils.errors;
import uk.ac.ebi.pride.jmztab.model.MZTabConstants;
import java.io.*;
/**
* @author qingwei
* @since 05/11/13
*/
public class WikiRun {
private OutputStream out = System.out;
private void writeLine(String content) throws IOException {
out.write(content.getBytes());
out.write(MZTabConstants.NEW_LINE.getBytes());
}
/**
* print all error messages to wiki document.
*/
private void printErrorMessage() throws Exception {
MZTabErrorTypeMap errorMap = new MZTabErrorTypeMap();
for (MZTabErrorType errorType : errorMap.getTypeMap().values()) {
writeLine("|| * Code*: || " + errorType.getCode() + " ||");
writeLine("|| * Level*: || " + errorType.getLevel() + " ||");
writeLine("|| *Original*: || " + errorType.getOriginal() + " ||");
writeLine("|| * Cause*: || " + errorType.getCause() + " ||");
writeLine("|| || ||");
writeLine("|| || ||");
}
}
private void printTabSplitFile(String header, String inFile) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(inFile));
String line;
String[] items;
writeLine("|| *" + header + "* || *Identification* || *Quantification* ||");
while ((line = reader.readLine()) != null) {
items = line.split("\t");
if (items.length == 1) {
writeLine("|| || || " + items[0] + " ||");
} else if (items.length == 2){
writeLine("|| || " + items[0] + " || " + items[1] + " ||");
}
}
reader.close();
}
/**
* print summary table file to wiki document.
*/
private void printSummaryTable() throws Exception {
printTabSplitFile("Protein Section", "testset/protein_columns_in_summary.txt");
writeLine("|| || || || ");
printTabSplitFile("Peptide Section", "testset/peptide_columns_in_summary.txt");
writeLine("|| || || || ");
printTabSplitFile("PSM Section", "testset/psm_columns_in_summary.txt");
writeLine("|| || || || ");
printTabSplitFile("Small Molecule Section", "testset/smallmolecule_columns_in_summary.txt");
writeLine("");
writeLine("*Table 2*. Mandatory columns in mzTab 'Summary' files. Where noted, these columns " +
"are mandatory for every study_variable[1-n] or every ms_run[1-n] reported in the file. Note" +
" - any Quantification file type MAY include any of the Columns or Sections required for an Identification file type.");
writeLine("");
writeLine("");
}
/**
* print complete table file to wiki document.
*/
private void printCompleteTable() throws Exception {
printTabSplitFile("Protein Section", "testset/protein_columns_in_complete.txt");
writeLine("|| || || || ");
printTabSplitFile("Peptide Section", "testset/peptide_columns_in_complete.txt");
writeLine("|| || || || ");
printTabSplitFile("Small Molecule Section", "testset/smallmolecule_columns_in_complete.txt");
writeLine("");
writeLine("*Table 3*. Mandatory columns in mzTab 'Complete' files. In addition, 'Complete' files " +
"MUST also have all the items that are MANDATORY in a 'Summary' file (Table 2 above). Where noted, " +
"these columns are mandatory for every assay[1-n], ms_run[1-n] or study_variable[1-n] reported in the file.");
writeLine("");
writeLine("");
}
/**
* print optional table file to wiki document.
*/
private void printOptionalTable() throws Exception {
printTabSplitFile("Protein Section", "testset/protein_columns_in_optional.txt");
writeLine("|| || || || ");
printTabSplitFile("Peptide Section", "testset/peptide_columns_in_optional.txt");
writeLine("|| || || || ");
printTabSplitFile("PSM Section", "testset/psm_columns_in_optional.txt");
writeLine("|| || || || ");
printTabSplitFile("Small Molecule Section", "testset/smallmolecule_columns_in_optional.txt");
writeLine("");
writeLine("*Table 4*. Optional fields in mzTab 'Complete' and 'Summary' files. ");
writeLine("");
writeLine("");
}
public static void main(String[] args) throws Exception {
WikiRun run = new WikiRun();
run.printErrorMessage();
// run.printSummaryTable();
// run.printCompleteTable();
// run.printOptionalTable();
}
}
|
3e01dc19c7475173a1c7ca0d9ed063cfbba62180 | 4,153 | java | Java | opensrp-ecap-chw-core/src/main/java/org/smartregister/chw/core/fragment/CoreAllClientsRegisterFragment.java | BlueCodeSystems/opensrp-client-ecap-chw-core | d9685c3cb1bd8437ea5a729d287b59b547a4e530 | [
"Apache-2.0"
] | null | null | null | opensrp-ecap-chw-core/src/main/java/org/smartregister/chw/core/fragment/CoreAllClientsRegisterFragment.java | BlueCodeSystems/opensrp-client-ecap-chw-core | d9685c3cb1bd8437ea5a729d287b59b547a4e530 | [
"Apache-2.0"
] | 21 | 2019-10-08T08:45:23.000Z | 2021-04-20T12:08:51.000Z | opensrp-ecap-chw-core/src/main/java/org/smartregister/chw/core/fragment/CoreAllClientsRegisterFragment.java | BlueCodeSystems/opensrp-client-ecap-chw-core | d9685c3cb1bd8437ea5a729d287b59b547a4e530 | [
"Apache-2.0"
] | 5 | 2019-11-20T10:55:11.000Z | 2020-10-30T04:15:57.000Z | 34.322314 | 123 | 0.708885 | 788 | package org.smartregister.chw.core.fragment;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import org.smartregister.chw.core.R;
import org.smartregister.chw.core.custom_views.NavigationMenu;
import org.smartregister.chw.core.presenter.CoreAllClientsRegisterFragmentPresenter;
import org.smartregister.commonregistry.CommonPersonObjectClient;
import org.smartregister.opd.fragment.BaseOpdRegisterFragment;
import org.smartregister.opd.model.OpdRegisterFragmentModel;
import org.smartregister.view.customcontrols.CustomFontTextView;
public class CoreAllClientsRegisterFragment extends BaseOpdRegisterFragment {
private static final Object DUE_FILTER_TAG = "PRESSED";
private Toolbar toolbar;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return super.onCreateView(inflater, container, savedInstanceState);
}
@Override
public void setupViews(View view) {
super.setupViews(view);
toolbar = view.findViewById(org.smartregister.R.id.register_toolbar);
toolbar.setContentInsetsAbsolute(0, 0);
toolbar.setContentInsetsRelative(0, 0);
toolbar.setContentInsetStartWithNavigation(0);
NavigationMenu.getInstance(getActivity(), null, toolbar);
CustomFontTextView titleView = view.findViewById(R.id.txt_title_label);
if (titleView != null) {
titleView.setPadding(0, titleView.getTop(), titleView.getPaddingRight(), titleView.getPaddingBottom());
titleView.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
}
if (getSearchView() != null) {
getSearchView().setHint(R.string.search_name_or_id);
}
}
@Override
protected void startRegistration() {
//Implemented but not required for Health Facility app
}
@Override
protected void performPatientAction(@NonNull CommonPersonObjectClient commonPersonObjectClient) {
//Overridden
}
@Override
public void onResume() {
super.onResume();
NavigationMenu.getInstance(getActivity(), null, toolbar);
}
@Override
protected void goToClientDetailActivity(@NonNull CommonPersonObjectClient commonPersonObjectClient) {
//implement
}
@Override
public void toggleFilterSelection(View dueOnlyLayout) {
if (dueOnlyLayout != null) {
if (dueOnlyLayout.getTag() == null) {
dueFilter(dueOnlyLayout);
} else if (dueOnlyLayout.getTag().toString().equals(DUE_FILTER_TAG)) {
normalFilter(dueOnlyLayout);
}
}
}
private void normalFilter(View dueOnlyLayout) {
filter(searchText(), "", mainCondition);
dueOnlyLayout.setTag(null);
switchViews(dueOnlyLayout, false);
}
private void dueFilter(View dueOnlyLayout) {
filter(searchText(), "", presenter().getDueFilterCondition());
dueOnlyLayout.setTag(DUE_FILTER_TAG);
switchViews(dueOnlyLayout, true);
}
private String searchText() {
return (getSearchView() == null) ? "" : getSearchView().getText().toString();
}
private void switchViews(View dueOnlyLayout, boolean isPress) {
TextView dueOnlyTextView = dueOnlyLayout.findViewById(R.id.due_only_text_view);
if (isPress) {
dueOnlyTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_due_filter_on, 0);
} else {
dueOnlyTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_due_filter_off, 0);
}
}
@Override
protected void initializePresenter() {
presenter = new CoreAllClientsRegisterFragmentPresenter(this, new OpdRegisterFragmentModel());
}
@Override
protected int getToolBarTitle() {
return R.string.menu_all_clients;
}
}
|
3e01dc4259931233d8d68a001d8ded5ee632405d | 4,962 | java | Java | plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPvlanSetupCommandWrapper.java | FilippoProjetto/cloudstack | 5471802f862dd617f63d12eb56c9aa62759e4309 | [
"Apache-2.0"
] | 14 | 2015-01-12T13:46:12.000Z | 2021-07-19T19:33:28.000Z | plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPvlanSetupCommandWrapper.java | FilippoProjetto/cloudstack | 5471802f862dd617f63d12eb56c9aa62759e4309 | [
"Apache-2.0"
] | 11 | 2020-11-16T17:19:02.000Z | 2022-02-01T01:05:59.000Z | plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPvlanSetupCommandWrapper.java | FilippoProjetto/cloudstack | 5471802f862dd617f63d12eb56c9aa62759e4309 | [
"Apache-2.0"
] | 8 | 2015-07-17T12:36:51.000Z | 2018-08-09T16:23:40.000Z | 45.944444 | 150 | 0.647924 | 789 | //
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
package com.cloud.hypervisor.kvm.resource.wrapper;
import java.util.List;
import org.apache.log4j.Logger;
import org.joda.time.Duration;
import org.libvirt.Connect;
import org.libvirt.LibvirtException;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.PvlanSetupCommand;
import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef;
import com.cloud.resource.CommandWrapper;
import com.cloud.resource.ResourceWrapper;
import com.cloud.utils.script.Script;
@ResourceWrapper(handles = PvlanSetupCommand.class)
public final class LibvirtPvlanSetupCommandWrapper extends CommandWrapper<PvlanSetupCommand, Answer, LibvirtComputingResource> {
private static final Logger s_logger = Logger.getLogger(LibvirtPvlanSetupCommandWrapper.class);
@Override
public Answer execute(final PvlanSetupCommand command, final LibvirtComputingResource libvirtComputingResource) {
final String primaryPvlan = command.getPrimary();
final String isolatedPvlan = command.getIsolated();
final String op = command.getOp();
final String dhcpName = command.getDhcpName();
final String dhcpMac = command.getDhcpMac();
final String vmMac = command.getVmMac();
final String dhcpIp = command.getDhcpIp();
boolean add = true;
String opr = "-A";
if (op.equals("delete")) {
opr = "-D";
add = false;
}
String result = null;
try {
final String guestBridgeName = libvirtComputingResource.getGuestBridgeName();
final Duration timeout = libvirtComputingResource.getTimeout();
if (command.getType() == PvlanSetupCommand.Type.DHCP) {
final String ovsPvlanDhcpHostPath = libvirtComputingResource.getOvsPvlanDhcpHostPath();
final Script script = new Script(ovsPvlanDhcpHostPath, timeout, s_logger);
if (add) {
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper();
final Connect conn = libvirtUtilitiesHelper.getConnectionByVmName(dhcpName);
final List<InterfaceDef> ifaces = libvirtComputingResource.getInterfaces(conn, dhcpName);
final InterfaceDef guestNic = ifaces.get(0);
script.add(opr, "-b", guestBridgeName, "-p", primaryPvlan, "-i", isolatedPvlan, "-n", dhcpName, "-d", dhcpIp, "-m", dhcpMac, "-I",
guestNic.getDevName());
} else {
script.add(opr, "-b", guestBridgeName, "-p", primaryPvlan, "-i", isolatedPvlan, "-n", dhcpName, "-d", dhcpIp, "-m", dhcpMac);
}
result = script.execute();
if (result != null) {
s_logger.warn("Failed to program pvlan for dhcp server with mac " + dhcpMac);
return new Answer(command, false, result);
} else {
s_logger.info("Programmed pvlan for dhcp server with mac " + dhcpMac);
}
} else if (command.getType() == PvlanSetupCommand.Type.VM) {
final String ovsPvlanVmPath = libvirtComputingResource.getOvsPvlanVmPath();
final Script script = new Script(ovsPvlanVmPath, timeout, s_logger);
script.add(opr, "-b", guestBridgeName, "-p", primaryPvlan, "-i", isolatedPvlan, "-v", vmMac);
result = script.execute();
if (result != null) {
s_logger.warn("Failed to program pvlan for vm with mac " + vmMac);
return new Answer(command, false, result);
} else {
s_logger.info("Programmed pvlan for vm with mac " + vmMac);
}
}
} catch (final LibvirtException e) {
s_logger.error("Error whislt executing OVS Setup command! ==> " + e.getMessage());
return new Answer(command, false, e.getMessage());
}
return new Answer(command, true, result);
}
} |
3e01dc8e3a0f30c578001989968c84e28eb348ff | 221 | java | Java | personendemo/src/test/java/de/gothaer/personendemo/PersonendemoApplicationTests.java | LimagoHub/CCGothaerJun20 | 8b009ab4d7edf97882d5a69a6f99bcb375528c9e | [
"Apache-2.0"
] | null | null | null | personendemo/src/test/java/de/gothaer/personendemo/PersonendemoApplicationTests.java | LimagoHub/CCGothaerJun20 | 8b009ab4d7edf97882d5a69a6f99bcb375528c9e | [
"Apache-2.0"
] | null | null | null | personendemo/src/test/java/de/gothaer/personendemo/PersonendemoApplicationTests.java | LimagoHub/CCGothaerJun20 | 8b009ab4d7edf97882d5a69a6f99bcb375528c9e | [
"Apache-2.0"
] | null | null | null | 15.785714 | 60 | 0.79638 | 790 | package de.gothaer.personendemo;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class PersonendemoApplicationTests {
@Test
void contextLoads() {
}
}
|
3e01dd17c024c0c9bd13f9cdc28b55aeb9b374d2 | 3,911 | java | Java | worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomPatternParser.java | Will33ELS/FastAsyncWorldEdit | b0c068988722e4cc7769bca590c97997cf1ea3f3 | [
"BSD-3-Clause"
] | null | null | null | worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomPatternParser.java | Will33ELS/FastAsyncWorldEdit | b0c068988722e4cc7769bca590c97997cf1ea3f3 | [
"BSD-3-Clause"
] | null | null | null | worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomPatternParser.java | Will33ELS/FastAsyncWorldEdit | b0c068988722e4cc7769bca590c97997cf1ea3f3 | [
"BSD-3-Clause"
] | 1 | 2021-06-07T12:51:31.000Z | 2021-06-07T12:51:31.000Z | 39.11 | 133 | 0.628484 | 791 | /*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extension.factory.parser.pattern;
import com.boydti.fawe.config.Caption;
import com.sk89q.util.StringUtil;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.RandomPattern;
import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import java.util.List;
import java.util.stream.Stream;
public class RandomPatternParser extends InputParser<Pattern> {
public RandomPatternParser(WorldEdit worldEdit) {
super(worldEdit);
}
@Override
public Stream<String> getSuggestions(String input) {
List<String> patterns = StringUtil.split(input, ',', '[', ']');
/*String[] splits = input.split(",", -1);
List<String> patterns = StringUtil.parseListInQuotes(splits, ',', '[', ']', true);*/
if (patterns.size() == 1) {
return Stream.empty();
}
// get suggestions for the last token only
String token = patterns.get(patterns.size() - 1);
String previous = String.join(",", patterns.subList(0, patterns.size() - 1));
if (token.matches("[0-9]+(\\.[0-9]*)?%.*")) {
String[] p = token.split("%");
if (p.length < 2) {
return Stream.empty();
} else {
token = p[1];
}
}
final List<String> innerSuggestions = worldEdit.getPatternFactory().getSuggestions(token);
return innerSuggestions.stream().map(s -> previous + "," + s);
}
@Override
public Pattern parseFromInput(String input, ParserContext context) throws InputParseException {
RandomPattern randomPattern = new RandomPattern();
List<String> patterns = StringUtil.split(input, ',', '[', ']');
/*String[] splits = input.split(",", -1);
List<String> patterns = StringUtil.parseListInQuotes(splits, ',', '[', ']', true);*/
if (patterns.size() == 1) {
return null; // let a 'single'-pattern parser handle it
}
for (String token : patterns) {
double chance;
Pattern innerPattern;
// Parse special percentage syntax
if (token.matches("[0-9]+(\\.[0-9]*)?%.*")) {
String[] p = token.split("%", 2);
if (p.length < 2) {
throw new InputParseException(Caption.of("worldedit.error.parser.missing-random-type", TextComponent.of(input)));
} else {
chance = Double.parseDouble(p[0]);
innerPattern = worldEdit.getPatternFactory().parseFromInput(p[1], context);
}
} else {
chance = 1;
innerPattern = worldEdit.getPatternFactory().parseFromInput(token, context);
}
randomPattern.add(innerPattern, chance);
}
return randomPattern;
}
}
|
3e01de8ec011e54bc224aa6d43a3d696b0d0df2c | 1,898 | java | Java | storage/src/main/java/com/linkedpipes/etl/storage/template/TemplateLoader.java | opendata-mvcr/etl | 24f0fbaa3187a3f383b76d53a890b00c3db0c636 | [
"MIT"
] | 117 | 2016-02-24T21:40:46.000Z | 2022-03-31T09:57:14.000Z | storage/src/main/java/com/linkedpipes/etl/storage/template/TemplateLoader.java | opendata-mvcr/etl | 24f0fbaa3187a3f383b76d53a890b00c3db0c636 | [
"MIT"
] | 874 | 2016-01-18T12:47:05.000Z | 2022-03-09T08:43:10.000Z | storage/src/main/java/com/linkedpipes/etl/storage/template/TemplateLoader.java | opendata-mvcr/etl | 24f0fbaa3187a3f383b76d53a890b00c3db0c636 | [
"MIT"
] | 35 | 2016-05-11T13:15:27.000Z | 2022-03-30T07:25:28.000Z | 33.892857 | 76 | 0.688093 | 792 | package com.linkedpipes.etl.storage.template;
import com.linkedpipes.etl.storage.BaseException;
import com.linkedpipes.etl.storage.rdf.PojoLoader;
import com.linkedpipes.etl.storage.template.repository.RepositoryReference;
import com.linkedpipes.etl.storage.template.repository.TemplateRepository;
import org.eclipse.rdf4j.model.Statement;
import java.util.Collection;
/**
* Load templates into {@link TemplateManager}.
*/
class TemplateLoader {
private final TemplateRepository repository;
public TemplateLoader(TemplateRepository repository) {
this.repository = repository;
}
public Template loadTemplate(RepositoryReference reference)
throws BaseException {
switch (reference.getType()) {
case JAR_TEMPLATE:
return loadJarTemplate(reference);
case REFERENCE_TEMPLATE:
return loadReferenceTemplate(reference);
default:
throw new BaseException("No template find for: {}",
reference.getId());
}
}
public JarTemplate loadJarTemplate(
RepositoryReference reference) throws BaseException {
Collection<Statement> definition =
repository.getDefinition(reference);
JarTemplate template = new JarTemplate();
template.setId(reference.getId());
PojoLoader.loadOfType(definition, JarTemplate.TYPE, template);
return template;
}
public ReferenceTemplate loadReferenceTemplate(
RepositoryReference reference) throws BaseException {
Collection<Statement> definition =
repository.getDefinition(reference);
ReferenceTemplate template = new ReferenceTemplate();
template.setId(reference.getId());
PojoLoader.loadOfType(definition, ReferenceTemplate.TYPE, template);
return template;
}
}
|
3e01df0669a7b756535a41a076f8cda2e56939e5 | 1,756 | java | Java | com.zutubi.validation.annotations/src/java/com/zutubi/validation/annotations/Numeric.java | Zutubi/pulse | 6a41105ae8438018b055611268c20dac5585f890 | [
"Apache-2.0"
] | 11 | 2017-04-14T16:58:09.000Z | 2019-06-27T09:44:31.000Z | com.zutubi.validation.annotations/src/java/com/zutubi/validation/annotations/Numeric.java | Zutubi/pulse | 6a41105ae8438018b055611268c20dac5585f890 | [
"Apache-2.0"
] | null | null | null | com.zutubi.validation.annotations/src/java/com/zutubi/validation/annotations/Numeric.java | Zutubi/pulse | 6a41105ae8438018b055611268c20dac5585f890 | [
"Apache-2.0"
] | 7 | 2017-07-02T04:32:32.000Z | 2022-03-10T07:49:52.000Z | 29.266667 | 75 | 0.720387 | 793 | /* Copyright 2017 Zutubi Pty Ltd
*
* 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.zutubi.validation.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This annotation marks the field as a numeric field. Optionally, the
* numeric value can be constrained by the min and max constraints.
* <p>
* This annotation can be applied to integral and string fields.
* <p>
* For example:
*
* <pre><code>@Numeric(min = 0, max = 100)
* public String getNumber()
* {
* return "093";
* }</code></pre>
*/
@Constraint("com.zutubi.validation.validators.NumericValidator")
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Numeric
{
String DEFAULT_defaultKeySuffix = "";
boolean DEFAULT_shortCircuit = true;
int DEFAULT_max = Integer.MAX_VALUE;
int DEFAULT_min = Integer.MIN_VALUE;
String defaultKeySuffix() default DEFAULT_defaultKeySuffix;
boolean shortCircuit() default DEFAULT_shortCircuit;
int max() default DEFAULT_max;
int min() default DEFAULT_min;
}
|
3e01df17f2925bf9f8b2ece6116b2ea75e066be9 | 3,185 | java | Java | form/core/src/main/java/org/opensingular/form/type/country/brazil/STypeAddress.java | opensingular/singular-core | ecaf7eafc5de0354f422a4c5d19be6887c86adc0 | [
"Apache-2.0"
] | 5 | 2016-10-07T16:43:05.000Z | 2018-09-20T22:12:29.000Z | form/core/src/main/java/org/opensingular/form/type/country/brazil/STypeAddress.java | opensingular/singular-core | ecaf7eafc5de0354f422a4c5d19be6887c86adc0 | [
"Apache-2.0"
] | 2 | 2016-12-04T20:58:51.000Z | 2016-12-14T14:06:33.000Z | form/core/src/main/java/org/opensingular/form/type/country/brazil/STypeAddress.java | opensingular/singular-core | ecaf7eafc5de0354f422a4c5d19be6887c86adc0 | [
"Apache-2.0"
] | null | null | null | 39.8125 | 137 | 0.704239 | 794 | /*
* Copyright (C) 2016 Singular Studios (a.k.a Atom Tecnologia) - www.opensingular.com
*
* 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.opensingular.form.type.country.brazil;
import org.opensingular.form.SIComposite;
import org.opensingular.form.SInfoType;
import org.opensingular.form.SInstance;
import org.opensingular.form.STypeComposite;
import org.opensingular.form.TypeBuilder;
import org.opensingular.form.type.core.STypeString;
import org.opensingular.lib.commons.util.Loggable;
import java.util.function.Predicate;
@SInfoType(name = "EnderecoCompleto", spackage = SPackageCountryBrazil.class)
public class STypeAddress extends STypeComposite<SIComposite> implements Loggable {
public STypeString logradouro;
public STypeString complemento;
public STypeString cidade;
public STypeCEP cep;
public STypeString numero;
public STypeUF estado;
public STypeString bairro;
@Override
protected void onLoadType(TypeBuilder tb) {
asAtr().displayString("${logradouro!}, ${complemento!}, ${numero!}, ${bairro!}, CEP: ${cep!} - ${cidade!} - [${estado.sigla!}]");
cep = this.addField("cep", STypeCEP.class);
cep.asAtrBootstrap().colPreference(2);
cep.asAtrIndex().indexed(Boolean.TRUE);
cep.asAtr().required(requiredChildrenWhenParentIsRequired());
logradouro = this.addFieldString("logradouro");
logradouro.asAtr().label("Logradouro").required(requiredChildrenWhenParentIsRequired()).asAtrBootstrap().colPreference(8);
logradouro.asAtrIndex().indexed(Boolean.TRUE);
numero = this.addFieldString("numero");
numero
.asAtr()
.maxLength(20)
.label("Número")
.asAtrBootstrap()
.colPreference(2);
numero.asAtrIndex().indexed(Boolean.TRUE);
complemento = this.addFieldString("complemento");
complemento.asAtr().label("Complemento").asAtrBootstrap().colPreference(6);
bairro = this.addFieldString("bairro");
bairro.asAtr().label("Bairro").required(requiredChildrenWhenParentIsRequired()).asAtrBootstrap().colPreference(6);
cidade = this.addFieldString("cidade");
cidade.asAtr().label("Cidade").required(requiredChildrenWhenParentIsRequired()).asAtrBootstrap().colPreference(6);
estado = this.addField("estado", STypeUF.class);
estado.asAtrIndex().indexed(Boolean.TRUE);
estado.asAtr().required(requiredChildrenWhenParentIsRequired());
}
private Predicate<SInstance> requiredChildrenWhenParentIsRequired() {
return s -> s.getParent().isRequired();
}
}
|
3e01df9ce6d804885f1a0dc61a304d70e8258f59 | 237 | java | Java | src/main/java/uk/co/nakedelement/bufferclient/http/HttpClientException.java | NakedElement/naked-buffer-client | 8b454244f83895aeef1df93b5b3d50b40161a463 | [
"Apache-2.0"
] | null | null | null | src/main/java/uk/co/nakedelement/bufferclient/http/HttpClientException.java | NakedElement/naked-buffer-client | 8b454244f83895aeef1df93b5b3d50b40161a463 | [
"Apache-2.0"
] | null | null | null | src/main/java/uk/co/nakedelement/bufferclient/http/HttpClientException.java | NakedElement/naked-buffer-client | 8b454244f83895aeef1df93b5b3d50b40161a463 | [
"Apache-2.0"
] | null | null | null | 19.75 | 67 | 0.805907 | 795 | package uk.co.nakedelement.bufferclient.http;
public class HttpClientException extends RuntimeException
{
private static final long serialVersionUID = 1260107944251503113L;
public HttpClientException(Throwable t)
{
super(t);
}
}
|
3e01e006661142bebdf9c9e7dbb50953bcb7a6b3 | 8,296 | java | Java | src/main/java/com/cristph/advent/solution/Day04.java | cristph/advent-of-code-2020 | c60d17fa47f3acdee110d7bed985dfe187e6fe6e | [
"MIT"
] | null | null | null | src/main/java/com/cristph/advent/solution/Day04.java | cristph/advent-of-code-2020 | c60d17fa47f3acdee110d7bed985dfe187e6fe6e | [
"MIT"
] | null | null | null | src/main/java/com/cristph/advent/solution/Day04.java | cristph/advent-of-code-2020 | c60d17fa47f3acdee110d7bed985dfe187e6fe6e | [
"MIT"
] | null | null | null | 28.905923 | 97 | 0.481557 | 796 | package com.cristph.advent.solution;
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.stream.Collectors;
import static com.cristph.advent.constants.Constans.LINE_SEPARATOR;
public class Day04 extends AbstractDaySolve {
private static final HashSet<String> necessaryKeySet = new HashSet<>();
static {
necessaryKeySet.add("byr");
necessaryKeySet.add("iyr");
necessaryKeySet.add("eyr");
necessaryKeySet.add("hgt");
necessaryKeySet.add("hcl");
necessaryKeySet.add("ecl");
necessaryKeySet.add("pid");
necessaryKeySet.add("cid");
}
@Override
protected String solvePuzzle1(String[] args) {
String fileName = args[0];
int count = 0;
try (BufferedReader br = Files.newBufferedReader(Paths.get(fileName))) {
String line;
Set<String> keySet = new HashSet<>();
while ((line = br.readLine()) != null) {
if (isNewLine(line)) {
if (keySet.isEmpty() || (keySet.size() == 1 && keySet.contains("cid"))) {
count++;
}
keySet = new HashSet<>(necessaryKeySet);
} else {
Map<String, String> kv = resolve(line);
if (kv != null) {
keySet.removeAll(kv.keySet());
}
}
}
if (keySet.isEmpty() || (keySet.size() == 1 && keySet.contains("cid"))) {
count++;
}
} catch (IOException e) {
e.printStackTrace();
}
return String.valueOf(count);
}
@Override
protected String solvePuzzle2(String[] args) {
String fileName = args[0];
int count = 0;
try (BufferedReader br = Files.newBufferedReader(Paths.get(fileName))) {
String line;
Set<String> keySet = new HashSet<>();
boolean checkPass = true;
while ((line = br.readLine()) != null) {
if (isNewLine(line)) {
if (checkPass) {
if (keySet.isEmpty() || (keySet.size() == 1 && keySet.contains("cid"))) {
count++;
}
}
keySet = new HashSet<>(necessaryKeySet);
checkPass = true;
} else {
Map<String, String> kv = resolve(line);
boolean satisfy = true;
for (Map.Entry<String, String> entry : kv.entrySet()) {
satisfy = satisfy && CheckHelper.check(entry.getKey(), entry.getValue());
}
if (kv != null && satisfy) {
keySet.removeAll(kv.keySet());
}
checkPass = checkPass && satisfy;
}
}
if (checkPass) {
if (keySet.isEmpty() || (keySet.size() == 1 && keySet.contains("cid"))) {
count++;
}
}
} catch (IOException e) {
e.printStackTrace();
}
return String.valueOf(count);
}
private boolean isNewLine(String line) {
if (line == null) {
return false;
}
String str = line.trim();
return LINE_SEPARATOR.equals(line) || str.length() == 0;
}
private Map<String, String> resolve(String line) {
if (line == null || line.length() == 0) {
return null;
}
String str = line.trim();
String[] tmp = str.split("\\s");
if (tmp.length > 0) {
return Arrays.stream(tmp)
.map(s -> s.split(":"))
.collect(Collectors.toMap(arr -> arr[0], arr -> arr[1]));
}
return null;
}
public static class CheckHelper {
private static Map<String, Check> checkMap = new HashMap<>();
static {
checkMap.put("byr", new BYRCheck());
checkMap.put("iyr", new IYRCheck());
checkMap.put("eyr", new EYRCheck());
checkMap.put("hgt", new HGTCheck());
checkMap.put("hcl", new HCLCheck());
checkMap.put("ecl", new ECLCheck());
checkMap.put("pid", new PIDCheck());
checkMap.put("cid", new CIDCheck());
}
public static boolean check(String k, String v) {
Check check = checkMap.get(k);
if (check == null) {
return false;
} else {
return check.checkValid(v);
}
}
}
public interface Check {
boolean checkValid(String str);
}
public static class BYRCheck implements Check {
@Override
public boolean checkValid(String str) {
return inRange(str, 1920, 2002);
}
}
public static class IYRCheck implements Check {
@Override
public boolean checkValid(String str) {
return inRange(str, 2010, 2020);
}
}
public static class EYRCheck implements Check {
@Override
public boolean checkValid(String str) {
return inRange(str, 2020, 2030);
}
}
public static class HGTCheck implements Check {
@Override
public boolean checkValid(String str) {
if (isEmpty(str)) {
return false;
}
if (str.endsWith("cm")) {
return inRange(str.substring(0, str.length() - 2), 150, 193);
} else if (str.endsWith("in")) {
return inRange(str.substring(0, str.length() - 2), 59, 76);
}
return false;
}
}
public static class HCLCheck implements Check {
@Override
public boolean checkValid(String str) {
if (isEmpty(str) || str.length() != 7) {
return false;
}
if (str.startsWith("#")) {
for (int i = 1; i < str.length(); i++) {
char c = str.charAt(i);
if (!isDigit(c) && !isLittleAlphabet(c)) {
return false;
}
}
return true;
}
return false;
}
}
public static class ECLCheck implements Check {
List<String> validECL = Arrays.asList("amb", "blu", "brn", "gry", "grn", "hzl", "oth");
@Override
public boolean checkValid(String str) {
return inRange(str, validECL);
}
}
public static class PIDCheck implements Check {
@Override
public boolean checkValid(String str) {
if (!isDigits(str) || str.length() != 9) {
return false;
}
return true;
}
}
public static class CIDCheck implements Check {
@Override
public boolean checkValid(String str) {
return true;
}
}
private static boolean isDigits(String str) {
if (isEmpty(str)) {
return false;
}
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (!isDigit(c)) {
return false;
}
}
return true;
}
private static boolean isDigit(char c) {
if (c < 48 || c > 57) {
return false;
}
return true;
}
private static boolean isLittleAlphabet(char c) {
if (c < 97 || c > 102) {
return false;
}
return true;
}
private static boolean isEmpty(String str) {
return str == null || str.length() == 0;
}
private static boolean inRange(String str, int low, int high) {
if (isDigits(str)) {
Integer n = Integer.parseInt(str);
return low <= n && high >= n;
}
return false;
}
private static boolean inRange(String str, Collection<String> enums) {
if (isEmpty(str)) {
return false;
}
return enums.contains(str);
}
}
|
3e01e032026e6a4434d6c75502b6b193555cfbcf | 8,812 | java | Java | src/main/java/me/andre111/mambience/fabric/config/ConfigScreen.java | IPECTER/mambience | 8ee025a434dc82a1b95505c497da0b1fa0c6d8d4 | [
"Apache-2.0"
] | 1 | 2022-03-17T01:26:56.000Z | 2022-03-17T01:26:56.000Z | src/main/java/me/andre111/mambience/fabric/config/ConfigScreen.java | IPECTER/mambience | 8ee025a434dc82a1b95505c497da0b1fa0c6d8d4 | [
"Apache-2.0"
] | 1 | 2022-03-15T10:50:55.000Z | 2022-03-15T10:50:55.000Z | src/main/java/me/andre111/mambience/fabric/config/ConfigScreen.java | IPECTER/mambience | 8ee025a434dc82a1b95505c497da0b1fa0c6d8d4 | [
"Apache-2.0"
] | 1 | 2022-03-16T02:00:41.000Z | 2022-03-16T02:00:41.000Z | 46.136126 | 128 | 0.727531 | 797 | /*
* Copyright (c) 2022 Andre Schweiger
*
* 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 me.andre111.mambience.fabric.config;
import java.io.IOException;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import me.andre111.mambience.MAmbience;
import me.andre111.mambience.config.Config;
import me.shedaniel.clothconfig2.api.ConfigBuilder;
import me.shedaniel.clothconfig2.api.ConfigCategory;
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
import net.minecraft.text.TranslatableText;
public class ConfigScreen implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> {
ConfigBuilder builder = ConfigBuilder.create();
builder.setParentScreen(parent);
builder.setTitle(new TranslatableText("mambience.config.title"));
ConfigEntryBuilder entryBuilder = builder.entryBuilder();
builder.setSavingRunnable(() -> {
try {
Config.save();
} catch(IOException e) {
MAmbience.getLogger().error("Exception saving/applying config: "+e);
e.printStackTrace();
}
});
ConfigCategory generalCat = builder.getOrCreateCategory(new TranslatableText("mambience.config.general"));
{
generalCat.addEntry(entryBuilder.startTextDescription(new TranslatableText("mambience.config.general.note")).build());
generalCat.addEntry(entryBuilder
.startBooleanToggle(new TranslatableText("mambience.config.general.debug"), Config.debugLogging())
.setTooltip(new TranslatableText("mambience.config.general.debug.tooltip"))
.setDefaultValue(false)
.setSaveConsumer(b -> { Config.setDebugLogging(b); })
.build());
}
ConfigCategory ambientEventsCat = builder.getOrCreateCategory(new TranslatableText("mambience.config.ambient"));
{
ambientEventsCat.addEntry(entryBuilder.startTextDescription(new TranslatableText("mambience.config.ambient.note")).build());
ambientEventsCat.addEntry(entryBuilder
.startBooleanToggle(new TranslatableText("mambience.config.enable"), Config.ambientEvents().isEnabled())
.setDefaultValue(Config.AmbientEventsConfig.DEFAULT_ENABLED)
.setSaveConsumer(b -> { Config.ambientEvents().setEnabled(b); })
.build());
ambientEventsCat.addEntry(entryBuilder
.startIntSlider(new TranslatableText("mambience.config.volume"), (int) (Config.ambientEvents().getVolume()*100), 0, 100)
.setDefaultValue((int) (Config.AmbientEventsConfig.DEFAULT_VOLUME*100))
.setSaveConsumer(i -> { Config.ambientEvents().setVolume(i/100.0f); })
.build());
ambientEventsCat.addEntry(entryBuilder
.startBooleanToggle(new TranslatableText("mambience.config.ambient.stop"), Config.ambientEvents().isStopSounds())
.setTooltip(new TranslatableText("mambience.config.ambient.stop.tooltip"))
.setDefaultValue(Config.AmbientEventsConfig.DEFAULT_STOP_SOUNDS)
.setSaveConsumer(b -> { Config.ambientEvents().setStopSounds(b); })
.build());
ambientEventsCat.addEntry(entryBuilder
.startBooleanToggle(new TranslatableText("mambience.config.ambient.disable_wind"), Config.ambientEvents().isDisableWind())
.setTooltip(new TranslatableText("mambience.config.ambient.disable_wind.tooltip"))
.setDefaultValue(Config.AmbientEventsConfig.DEFAULT_DISABLE_WIND)
.setSaveConsumer(b -> { Config.ambientEvents().setDisableWind(b); })
.build());
}
ConfigCategory effectsCat = builder.getOrCreateCategory(new TranslatableText("mambience.config.effects"));
{
effectsCat.addEntry(entryBuilder.startTextDescription(new TranslatableText("mambience.config.effects.note")).build());
effectsCat.addEntry(entryBuilder
.startBooleanToggle(new TranslatableText("mambience.config.enable"), Config.effects().isEnabled())
.setDefaultValue(Config.EffectsConfig.DEFAULT_ENABLED)
.setSaveConsumer(b -> { Config.effects().setEnabled(b); })
.build());
effectsCat.addEntry(entryBuilder
.startIntField(new TranslatableText("mambience.config.sizex"), Config.effects().getSizeX())
.setTooltip(new TranslatableText("mambience.config.sizex.tooltip"))
.setDefaultValue(Config.EffectsConfig.DEFAULT_SIZE_X)
.setMin(3)
.setMax(65)
.setSaveConsumer(i -> { Config.effects().setSizeX(i); })
.build());
effectsCat.addEntry(entryBuilder
.startIntField(new TranslatableText("mambience.config.sizey"), Config.effects().getSizeY())
.setTooltip(new TranslatableText("mambience.config.sizey.tooltip"))
.setDefaultValue(Config.EffectsConfig.DEFAULT_SIZE_Y)
.setMin(3)
.setMax(65)
.setSaveConsumer(i -> { Config.effects().setSizeY(i); })
.build());
effectsCat.addEntry(entryBuilder
.startIntField(new TranslatableText("mambience.config.sizez"), Config.effects().getSizeZ())
.setTooltip(new TranslatableText("mambience.config.sizez.tooltip"))
.setDefaultValue(Config.EffectsConfig.DEFAULT_SIZE_Z)
.setMin(3)
.setMax(65)
.setSaveConsumer(i -> { Config.effects().setSizeZ(i); })
.build());
effectsCat.addEntry(entryBuilder
.startIntField(new TranslatableText("mambience.config.effects.ticks"), Config.effects().getRandomTicks())
.setTooltip(new TranslatableText("mambience.config.effects.ticks.tooltip"))
.setDefaultValue(Config.EffectsConfig.DEFAULT_RANDOM_TICKS)
.setMin(1)
.setMax(1024)
.setSaveConsumer(i -> { Config.effects().setRandomTicks(i); })
.build());
}
ConfigCategory footstepsCat = builder.getOrCreateCategory(new TranslatableText("mambience.config.footsteps"));
{
footstepsCat.addEntry(entryBuilder.startTextDescription(new TranslatableText("mambience.config.footsteps.note")).build());
footstepsCat.addEntry(entryBuilder
.startBooleanToggle(new TranslatableText("mambience.config.enable"), Config.footsteps().isEnabled())
.setDefaultValue(Config.FootstepConfig.DEFAULT_ENABLED)
.setSaveConsumer(b -> { Config.footsteps().setEnabled(b); })
.build());
footstepsCat.addEntry(entryBuilder
.startIntSlider(new TranslatableText("mambience.config.volume"), (int) (Config.footsteps().getVolume()*100), 0, 100)
.setDefaultValue((int) (Config.FootstepConfig.DEFAULT_VOLUME*100))
.setSaveConsumer(i -> { Config.footsteps().setVolume(i/100.0f); })
.build());
}
ConfigCategory scannerCat = builder.getOrCreateCategory(new TranslatableText("mambience.config.scanner"));
{
scannerCat.addEntry(entryBuilder.startTextDescription(new TranslatableText("mambience.config.scanner.note")).build());
scannerCat.addEntry(entryBuilder
.startIntField(new TranslatableText("mambience.config.sizex"), Config.scanner().getSizeX())
.setTooltip(new TranslatableText("mambience.config.sizex.tooltip"))
.setDefaultValue(Config.ScannerConfig.DEFAULT_SIZE_X)
.setMin(3)
.setMax(65)
.setSaveConsumer(i -> { Config.scanner().setSizeX(i); })
.build());
scannerCat.addEntry(entryBuilder
.startIntField(new TranslatableText("mambience.config.sizey"), Config.scanner().getSizeY())
.setTooltip(new TranslatableText("mambience.config.sizey.tooltip"))
.setDefaultValue(Config.ScannerConfig.DEFAULT_SIZE_Y)
.setMin(3)
.setMax(65)
.setSaveConsumer(i -> { Config.scanner().setSizeY(i); })
.build());
scannerCat.addEntry(entryBuilder
.startIntField(new TranslatableText("mambience.config.sizez"), Config.scanner().getSizeZ())
.setTooltip(new TranslatableText("mambience.config.sizez.tooltip"))
.setDefaultValue(Config.ScannerConfig.DEFAULT_SIZE_Z)
.setMin(3)
.setMax(65)
.setSaveConsumer(i -> { Config.scanner().setSizeZ(i); })
.build());
scannerCat.addEntry(entryBuilder
.startIntField(new TranslatableText("mambience.config.scanner.interval"), Config.scanner().getInterval())
.setTooltip(new TranslatableText("mambience.config.scanner.interval.tooltip"))
.setDefaultValue(Config.ScannerConfig.DEFAULT_INTERVAL)
.setMin(1)
.setMax(200)
.setSaveConsumer(i -> { Config.scanner().setInterval(i); })
.build());
}
return builder.build();
};
}
}
|
3e01e15e492304b87777f2fec56aaf1a104acfe5 | 2,353 | java | Java | presto-orc/src/main/java/io/prestosql/orc/RowIndexCacheStatsLister.java | chandana496/hetu-core | f6976233f7d44d33b8ed1d0befd582f151beecff | [
"Apache-2.0"
] | 476 | 2020-06-30T14:24:39.000Z | 2022-03-29T13:13:33.000Z | presto-orc/src/main/java/io/prestosql/orc/RowIndexCacheStatsLister.java | chandana496/hetu-core | f6976233f7d44d33b8ed1d0befd582f151beecff | [
"Apache-2.0"
] | 316 | 2020-06-30T11:44:52.000Z | 2022-03-30T11:08:04.000Z | presto-orc/src/main/java/io/prestosql/orc/RowIndexCacheStatsLister.java | chandana496/hetu-core | f6976233f7d44d33b8ed1d0befd582f151beecff | [
"Apache-2.0"
] | 326 | 2020-06-30T11:40:14.000Z | 2022-03-31T07:55:03.000Z | 21.587156 | 78 | 0.642159 | 798 | /*
* Copyright (C) 2018-2020. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.prestosql.orc;
import com.google.common.cache.Cache;
import com.google.inject.Inject;
import org.weakref.jmx.Managed;
public class RowIndexCacheStatsLister
{
private final Cache<?, ?> cache;
@Inject
public RowIndexCacheStatsLister(OrcCacheStore orcCacheStore)
{
this.cache = orcCacheStore.getRowIndexCache();
}
@Managed
public long getEvictionCount()
{
return cache.stats().evictionCount();
}
@Managed
public long getHitCount()
{
return cache.stats().hitCount();
}
@Managed
public double getHitRate()
{
return cache.stats().hitRate();
}
@Managed
public long getLoadCount()
{
return cache.stats().loadCount();
}
@Managed
public long getLoadExceptionCount()
{
return cache.stats().loadExceptionCount();
}
@Managed
public long getLoadSuccessCount()
{
return cache.stats().loadSuccessCount();
}
@Managed
public double getLoadExceptionRate()
{
return cache.stats().loadExceptionRate();
}
@Managed
public double getAverageLoadPenalty()
{
return cache.stats().averageLoadPenalty();
}
@Managed
public long getMissCount()
{
return cache.stats().missCount();
}
@Managed
public double getMissRate()
{
return cache.stats().missRate();
}
@Managed
public long getRequestCount()
{
return cache.stats().requestCount();
}
@Managed
public long getTotalLoadTime()
{
return cache.stats().totalLoadTime();
}
@Managed
public long getSize()
{
return cache.size();
}
}
|
3e01e1e8f39250dbbc778a2e7b7c95996fe0e913 | 611 | java | Java | domain/src/main/java/oxim/digital/reedly/domain/interactor/feed/DeleteFeedUseCase.java | abarrile/Reedly | aafa972ccaa7e439388dbb32925b8a7ef257f7fc | [
"Apache-2.0"
] | 15 | 2020-06-30T13:22:39.000Z | 2022-01-11T04:35:43.000Z | domain/src/main/java/oxim/digital/reedly/domain/interactor/feed/DeleteFeedUseCase.java | abarrile/Reedly | aafa972ccaa7e439388dbb32925b8a7ef257f7fc | [
"Apache-2.0"
] | null | null | null | domain/src/main/java/oxim/digital/reedly/domain/interactor/feed/DeleteFeedUseCase.java | abarrile/Reedly | aafa972ccaa7e439388dbb32925b8a7ef257f7fc | [
"Apache-2.0"
] | 1 | 2020-07-11T19:49:21.000Z | 2020-07-11T19:49:21.000Z | 30.55 | 90 | 0.793781 | 799 | package oxim.digital.reedly.domain.interactor.feed;
import oxim.digital.reedly.domain.interactor.type.CompletableUseCaseWithParameter;
import oxim.digital.reedly.domain.repository.FeedRepository;
import rx.Completable;
public final class DeleteFeedUseCase implements CompletableUseCaseWithParameter<Integer> {
private final FeedRepository feedRepository;
public DeleteFeedUseCase(final FeedRepository feedRepository) {
this.feedRepository = feedRepository;
}
@Override
public Completable execute(final Integer feedId) {
return feedRepository.deleteFeed(feedId);
}
}
|
3e01e1ee6bb127b306735f5872733e644d9fb04a | 398 | java | Java | core/src/main/java/com/ahmed/GuessCount.java | DEV-A7med/Javaspring-Guess-Game | c893f49063edf8fd6349184ce3cf7d43374b087c | [
"MIT"
] | null | null | null | core/src/main/java/com/ahmed/GuessCount.java | DEV-A7med/Javaspring-Guess-Game | c893f49063edf8fd6349184ce3cf7d43374b087c | [
"MIT"
] | null | null | null | core/src/main/java/com/ahmed/GuessCount.java | DEV-A7med/Javaspring-Guess-Game | c893f49063edf8fd6349184ce3cf7d43374b087c | [
"MIT"
] | null | null | null | 26.533333 | 71 | 0.831658 | 800 | package com.ahmed;
import org.springframework.beans.factory.annotation.Qualifier;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public @interface GuessCount {
}
|
3e01e24930a67c25da7a3691c3b1a4c265a0dda8 | 871 | java | Java | flyme-admin/src/main/java/com/goldencis/flyme/web/controller/monitor/ServerController.java | UniqueSuccess/Flyme-Vue | 15eae94e833a77a458fa963ad7d756ee3fac3d7f | [
"MIT"
] | 2 | 2020-10-14T06:47:38.000Z | 2020-10-14T08:01:24.000Z | flyme-admin/src/main/java/com/goldencis/flyme/web/controller/monitor/ServerController.java | UniqueSuccess/Flyme-Vue | 15eae94e833a77a458fa963ad7d756ee3fac3d7f | [
"MIT"
] | null | null | null | flyme-admin/src/main/java/com/goldencis/flyme/web/controller/monitor/ServerController.java | UniqueSuccess/Flyme-Vue | 15eae94e833a77a458fa963ad7d756ee3fac3d7f | [
"MIT"
] | null | null | null | 30.034483 | 65 | 0.768083 | 801 | package com.goldencis.flyme.web.controller.monitor;
import com.goldencis.flyme.common.core.controller.BaseController;
import com.goldencis.flyme.common.core.domain.AjaxResult;
import com.goldencis.flyme.framework.web.domain.Server;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 服务器监控
*
* @author flyme
*/
@RestController
@RequestMapping("/monitor/server")
public class ServerController extends BaseController
{
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
@GetMapping()
public AjaxResult getInfo() throws Exception
{
Server server = new Server();
server.copyTo();
return AjaxResult.success(server);
}
}
|
3e01e267713a5b876af64fab98c221f9b93475e2 | 262 | java | Java | Android/app/src/main/java/com/company/survey/PotholeResponse.java | akshatsoni15/Inter-IIT-Coding-Hackathon | ba2fdb524a690feef73b83b43064b0d0163a90cb | [
"MIT"
] | null | null | null | Android/app/src/main/java/com/company/survey/PotholeResponse.java | akshatsoni15/Inter-IIT-Coding-Hackathon | ba2fdb524a690feef73b83b43064b0d0163a90cb | [
"MIT"
] | 7 | 2020-10-03T20:29:04.000Z | 2022-02-18T17:29:00.000Z | Android/app/src/main/java/com/company/survey/PotholeResponse.java | akshatsoni15/Inter-IIT-Coding-Hackathon | ba2fdb524a690feef73b83b43064b0d0163a90cb | [
"MIT"
] | 2 | 2020-09-30T18:44:48.000Z | 2020-09-30T18:53:15.000Z | 14.555556 | 43 | 0.625954 | 802 | package com.company.survey;
public class PotholeResponse
{
String result;
public PotholeResponse(String result) {
this.result = result;
}
public String getResult() {
return result;
}
public PotholeResponse() {
}
}
|
Subsets and Splits