repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
grahamedgecombe/android-ssl | mitm-test-sni-client/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/testclient/SniClient.java | // Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/PermissiveTrustManager.java
// public final class PermissiveTrustManager extends X509ExtendedTrustManager {
// @Override
// public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
// /* empty */
// }
//
// @Override
// public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
// /* empty */
// }
//
// @Override
// public X509Certificate[] getAcceptedIssuers() {
// return new X509Certificate[0];
// }
//
// @Override
// public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException {
// /* empty */
// }
//
// @Override
// public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException {
// /* empty */
// }
//
// @Override
// public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException {
// /* empty */
// }
//
// @Override
// public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException {
// /* empty */
// }
// }
//
// Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateUtils.java
// public final class CertificateUtils {
// private static final String[] EMPTY_STRING_ARRAY = new String[0];
//
// public static X509Certificate readCertificate(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readCertificate(reader);
// }
// }
//
// public static X509Certificate readCertificate(Reader reader) throws IOException {
// // TODO share with CertificateAuthority's own implementation
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof X509CertificateHolder))
// throw new IOException("File does not contain a certificate");
//
// X509CertificateHolder certificate = (X509CertificateHolder) object;
// return new JcaX509CertificateConverter().getCertificate(certificate);
// } catch (CertificateException ex) {
// throw new IOException(ex);
// }
// }
//
// public static String extractCn(X509Certificate certificate) {
// X500Name dn = JcaX500NameUtil.getSubject(certificate);
// for (RDN rdn : dn.getRDNs()) {
// AttributeTypeAndValue first = rdn.getFirst();
// if (first.getType().equals(BCStyle.CN)) {
// return first.getValue().toString();
// }
// }
//
// throw new IllegalArgumentException("certificate subject has no common name (CN)");
// }
//
// public static String[] extractSans(X509Certificate certificate) {
// try {
// Collection<List<?>> pairs = certificate.getSubjectAlternativeNames();
// if (pairs == null)
// return EMPTY_STRING_ARRAY;
//
// List<String> sans = new ArrayList<>();
// for (List<?> pair : pairs) {
// int type = (Integer) pair.get(0);
// if (type == 2) { // TODO fix magic number!
// String san = (String) pair.get(1);
// sans.add(san);
// }
// }
// return sans.toArray(EMPTY_STRING_ARRAY);
// } catch (CertificateParsingException ex) {
// throw new IllegalArgumentException(ex); // TODO ideal?
// }
// }
//
// private CertificateUtils() {
// /* to prevent instantiation */
// }
// }
| import java.util.Arrays;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.PermissiveTrustManager;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateUtils;
import javax.net.ssl.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate; | /*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.mitm.testclient;
public final class SniClient {
public static void main(String[] args) throws KeyManagementException, NoSuchAlgorithmException, IOException {
System.setProperty("java.net.preferIPv4Stack", "true");
String host = args.length >= 1 ? args[0] : null;
SniClient client = new SniClient(new InetSocketAddress("127.0.0.1", 12345), host);
client.start();
}
private final InetSocketAddress address;
private final String host;
private final SSLSocketFactory factory;
public SniClient(InetSocketAddress address, String host) throws NoSuchAlgorithmException, KeyManagementException {
this.address = address;
this.host = host;
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, new TrustManager[] { | // Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/PermissiveTrustManager.java
// public final class PermissiveTrustManager extends X509ExtendedTrustManager {
// @Override
// public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
// /* empty */
// }
//
// @Override
// public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
// /* empty */
// }
//
// @Override
// public X509Certificate[] getAcceptedIssuers() {
// return new X509Certificate[0];
// }
//
// @Override
// public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException {
// /* empty */
// }
//
// @Override
// public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException {
// /* empty */
// }
//
// @Override
// public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException {
// /* empty */
// }
//
// @Override
// public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException {
// /* empty */
// }
// }
//
// Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateUtils.java
// public final class CertificateUtils {
// private static final String[] EMPTY_STRING_ARRAY = new String[0];
//
// public static X509Certificate readCertificate(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readCertificate(reader);
// }
// }
//
// public static X509Certificate readCertificate(Reader reader) throws IOException {
// // TODO share with CertificateAuthority's own implementation
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof X509CertificateHolder))
// throw new IOException("File does not contain a certificate");
//
// X509CertificateHolder certificate = (X509CertificateHolder) object;
// return new JcaX509CertificateConverter().getCertificate(certificate);
// } catch (CertificateException ex) {
// throw new IOException(ex);
// }
// }
//
// public static String extractCn(X509Certificate certificate) {
// X500Name dn = JcaX500NameUtil.getSubject(certificate);
// for (RDN rdn : dn.getRDNs()) {
// AttributeTypeAndValue first = rdn.getFirst();
// if (first.getType().equals(BCStyle.CN)) {
// return first.getValue().toString();
// }
// }
//
// throw new IllegalArgumentException("certificate subject has no common name (CN)");
// }
//
// public static String[] extractSans(X509Certificate certificate) {
// try {
// Collection<List<?>> pairs = certificate.getSubjectAlternativeNames();
// if (pairs == null)
// return EMPTY_STRING_ARRAY;
//
// List<String> sans = new ArrayList<>();
// for (List<?> pair : pairs) {
// int type = (Integer) pair.get(0);
// if (type == 2) { // TODO fix magic number!
// String san = (String) pair.get(1);
// sans.add(san);
// }
// }
// return sans.toArray(EMPTY_STRING_ARRAY);
// } catch (CertificateParsingException ex) {
// throw new IllegalArgumentException(ex); // TODO ideal?
// }
// }
//
// private CertificateUtils() {
// /* to prevent instantiation */
// }
// }
// Path: mitm-test-sni-client/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/testclient/SniClient.java
import java.util.Arrays;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.PermissiveTrustManager;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateUtils;
import javax.net.ssl.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
/*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.mitm.testclient;
public final class SniClient {
public static void main(String[] args) throws KeyManagementException, NoSuchAlgorithmException, IOException {
System.setProperty("java.net.preferIPv4Stack", "true");
String host = args.length >= 1 ? args[0] : null;
SniClient client = new SniClient(new InetSocketAddress("127.0.0.1", 12345), host);
client.start();
}
private final InetSocketAddress address;
private final String host;
private final SSLSocketFactory factory;
public SniClient(InetSocketAddress address, String host) throws NoSuchAlgorithmException, KeyManagementException {
this.address = address;
this.host = host;
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, new TrustManager[] { | new PermissiveTrustManager() |
grahamedgecombe/android-ssl | mitm-test-sni-client/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/testclient/SniClient.java | // Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/PermissiveTrustManager.java
// public final class PermissiveTrustManager extends X509ExtendedTrustManager {
// @Override
// public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
// /* empty */
// }
//
// @Override
// public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
// /* empty */
// }
//
// @Override
// public X509Certificate[] getAcceptedIssuers() {
// return new X509Certificate[0];
// }
//
// @Override
// public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException {
// /* empty */
// }
//
// @Override
// public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException {
// /* empty */
// }
//
// @Override
// public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException {
// /* empty */
// }
//
// @Override
// public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException {
// /* empty */
// }
// }
//
// Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateUtils.java
// public final class CertificateUtils {
// private static final String[] EMPTY_STRING_ARRAY = new String[0];
//
// public static X509Certificate readCertificate(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readCertificate(reader);
// }
// }
//
// public static X509Certificate readCertificate(Reader reader) throws IOException {
// // TODO share with CertificateAuthority's own implementation
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof X509CertificateHolder))
// throw new IOException("File does not contain a certificate");
//
// X509CertificateHolder certificate = (X509CertificateHolder) object;
// return new JcaX509CertificateConverter().getCertificate(certificate);
// } catch (CertificateException ex) {
// throw new IOException(ex);
// }
// }
//
// public static String extractCn(X509Certificate certificate) {
// X500Name dn = JcaX500NameUtil.getSubject(certificate);
// for (RDN rdn : dn.getRDNs()) {
// AttributeTypeAndValue first = rdn.getFirst();
// if (first.getType().equals(BCStyle.CN)) {
// return first.getValue().toString();
// }
// }
//
// throw new IllegalArgumentException("certificate subject has no common name (CN)");
// }
//
// public static String[] extractSans(X509Certificate certificate) {
// try {
// Collection<List<?>> pairs = certificate.getSubjectAlternativeNames();
// if (pairs == null)
// return EMPTY_STRING_ARRAY;
//
// List<String> sans = new ArrayList<>();
// for (List<?> pair : pairs) {
// int type = (Integer) pair.get(0);
// if (type == 2) { // TODO fix magic number!
// String san = (String) pair.get(1);
// sans.add(san);
// }
// }
// return sans.toArray(EMPTY_STRING_ARRAY);
// } catch (CertificateParsingException ex) {
// throw new IllegalArgumentException(ex); // TODO ideal?
// }
// }
//
// private CertificateUtils() {
// /* to prevent instantiation */
// }
// }
| import java.util.Arrays;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.PermissiveTrustManager;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateUtils;
import javax.net.ssl.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate; | SSLContext context = SSLContext.getInstance("TLS");
context.init(null, new TrustManager[] {
new PermissiveTrustManager()
}, null);
this.factory = context.getSocketFactory();
}
public void start() throws IOException {
InetAddress ip = address.getAddress();
int port = address.getPort();
try (SSLSocket socket = (SSLSocket) factory.createSocket(new Socket(ip, port), host, port, true)) {
if (host != null) {
SSLParameters params = socket.getSSLParameters();
params.setServerNames(Arrays.<SNIServerName>asList(new SNIHostName(host)));
socket.setSSLParameters(params);
}
socket.startHandshake();
try (InputStream is = socket.getInputStream();
OutputStream os = socket.getOutputStream()) {
os.write(0xFF);
if (is.read() != 0xFF)
throw new IOException("Server did not echo back 0xFF byte");
}
Certificate[] chain = socket.getSession().getPeerCertificates();
X509Certificate leaf = (X509Certificate) chain[0]; | // Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/PermissiveTrustManager.java
// public final class PermissiveTrustManager extends X509ExtendedTrustManager {
// @Override
// public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
// /* empty */
// }
//
// @Override
// public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
// /* empty */
// }
//
// @Override
// public X509Certificate[] getAcceptedIssuers() {
// return new X509Certificate[0];
// }
//
// @Override
// public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException {
// /* empty */
// }
//
// @Override
// public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException {
// /* empty */
// }
//
// @Override
// public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException {
// /* empty */
// }
//
// @Override
// public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException {
// /* empty */
// }
// }
//
// Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateUtils.java
// public final class CertificateUtils {
// private static final String[] EMPTY_STRING_ARRAY = new String[0];
//
// public static X509Certificate readCertificate(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readCertificate(reader);
// }
// }
//
// public static X509Certificate readCertificate(Reader reader) throws IOException {
// // TODO share with CertificateAuthority's own implementation
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof X509CertificateHolder))
// throw new IOException("File does not contain a certificate");
//
// X509CertificateHolder certificate = (X509CertificateHolder) object;
// return new JcaX509CertificateConverter().getCertificate(certificate);
// } catch (CertificateException ex) {
// throw new IOException(ex);
// }
// }
//
// public static String extractCn(X509Certificate certificate) {
// X500Name dn = JcaX500NameUtil.getSubject(certificate);
// for (RDN rdn : dn.getRDNs()) {
// AttributeTypeAndValue first = rdn.getFirst();
// if (first.getType().equals(BCStyle.CN)) {
// return first.getValue().toString();
// }
// }
//
// throw new IllegalArgumentException("certificate subject has no common name (CN)");
// }
//
// public static String[] extractSans(X509Certificate certificate) {
// try {
// Collection<List<?>> pairs = certificate.getSubjectAlternativeNames();
// if (pairs == null)
// return EMPTY_STRING_ARRAY;
//
// List<String> sans = new ArrayList<>();
// for (List<?> pair : pairs) {
// int type = (Integer) pair.get(0);
// if (type == 2) { // TODO fix magic number!
// String san = (String) pair.get(1);
// sans.add(san);
// }
// }
// return sans.toArray(EMPTY_STRING_ARRAY);
// } catch (CertificateParsingException ex) {
// throw new IllegalArgumentException(ex); // TODO ideal?
// }
// }
//
// private CertificateUtils() {
// /* to prevent instantiation */
// }
// }
// Path: mitm-test-sni-client/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/testclient/SniClient.java
import java.util.Arrays;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.PermissiveTrustManager;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateUtils;
import javax.net.ssl.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, new TrustManager[] {
new PermissiveTrustManager()
}, null);
this.factory = context.getSocketFactory();
}
public void start() throws IOException {
InetAddress ip = address.getAddress();
int port = address.getPort();
try (SSLSocket socket = (SSLSocket) factory.createSocket(new Socket(ip, port), host, port, true)) {
if (host != null) {
SSLParameters params = socket.getSSLParameters();
params.setServerNames(Arrays.<SNIServerName>asList(new SNIHostName(host)));
socket.setSSLParameters(params);
}
socket.startHandshake();
try (InputStream is = socket.getInputStream();
OutputStream os = socket.getOutputStream()) {
os.write(0xFF);
if (is.read() != 0xFF)
throw new IOException("Server did not echo back 0xFF byte");
}
Certificate[] chain = socket.getSession().getPeerCertificates();
X509Certificate leaf = (X509Certificate) chain[0]; | System.out.println(CertificateUtils.extractCn(leaf)); |
grahamedgecombe/android-ssl | mitm/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/ui/Session.java | // Path: mitm/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateKey.java
// public final class CertificateKey {
// private final String cn;
// private final String[] sans;
//
// public CertificateKey(String cn, String[] sans) {
// this.cn = cn;
// this.sans = sans;
// }
//
// public String getCn() {
// return cn;
// }
//
// public String[] getSans() {
// return sans;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// CertificateKey that = (CertificateKey) o;
//
// if (!cn.equals(that.cn)) return false;
// if (!Arrays.equals(sans, that.sans)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = cn.hashCode();
// result = 31 * result + Arrays.hashCode(sans);
// return result;
// }
// }
| import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateKey;
import java.awt.*;
import java.net.InetSocketAddress; | /*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.mitm.ui;
public final class Session {
public enum State {
OPEN(Color.GREEN, "Open"),
CLOSED(Color.GRAY, "Closed"),
FAILED(Color.RED, "Failed"),
MAYBE_FAILED(Color.ORANGE, "Maybe Failed"); /* means connection closed without sending data */
private final Color color;
private final String description;
private State(Color color, String description) {
this.color = color;
this.description = description;
}
public Color getColor() {
return color;
}
@Override
public String toString() {
return description;
}
}
private final InetSocketAddress source, destination;
private State state = State.OPEN;
private Throwable failureReason; | // Path: mitm/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateKey.java
// public final class CertificateKey {
// private final String cn;
// private final String[] sans;
//
// public CertificateKey(String cn, String[] sans) {
// this.cn = cn;
// this.sans = sans;
// }
//
// public String getCn() {
// return cn;
// }
//
// public String[] getSans() {
// return sans;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// CertificateKey that = (CertificateKey) o;
//
// if (!cn.equals(that.cn)) return false;
// if (!Arrays.equals(sans, that.sans)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = cn.hashCode();
// result = 31 * result + Arrays.hashCode(sans);
// return result;
// }
// }
// Path: mitm/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/ui/Session.java
import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateKey;
import java.awt.*;
import java.net.InetSocketAddress;
/*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.mitm.ui;
public final class Session {
public enum State {
OPEN(Color.GREEN, "Open"),
CLOSED(Color.GRAY, "Closed"),
FAILED(Color.RED, "Failed"),
MAYBE_FAILED(Color.ORANGE, "Maybe Failed"); /* means connection closed without sending data */
private final Color color;
private final String description;
private State(Color color, String description) {
this.color = color;
this.description = description;
}
public Color getColor() {
return color;
}
@Override
public String toString() {
return description;
}
}
private final InetSocketAddress source, destination;
private State state = State.OPEN;
private Throwable failureReason; | private CertificateKey realKey, key; |
grahamedgecombe/android-ssl | mitm/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/hostname/StandardHostnameFinder.java | // Path: mitm/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateKey.java
// public final class CertificateKey {
// private final String cn;
// private final String[] sans;
//
// public CertificateKey(String cn, String[] sans) {
// this.cn = cn;
// this.sans = sans;
// }
//
// public String getCn() {
// return cn;
// }
//
// public String[] getSans() {
// return sans;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// CertificateKey that = (CertificateKey) o;
//
// if (!cn.equals(that.cn)) return false;
// if (!Arrays.equals(sans, that.sans)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = cn.hashCode();
// result = 31 * result + Arrays.hashCode(sans);
// return result;
// }
// }
//
// Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateUtils.java
// public final class CertificateUtils {
// private static final String[] EMPTY_STRING_ARRAY = new String[0];
//
// public static X509Certificate readCertificate(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readCertificate(reader);
// }
// }
//
// public static X509Certificate readCertificate(Reader reader) throws IOException {
// // TODO share with CertificateAuthority's own implementation
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof X509CertificateHolder))
// throw new IOException("File does not contain a certificate");
//
// X509CertificateHolder certificate = (X509CertificateHolder) object;
// return new JcaX509CertificateConverter().getCertificate(certificate);
// } catch (CertificateException ex) {
// throw new IOException(ex);
// }
// }
//
// public static String extractCn(X509Certificate certificate) {
// X500Name dn = JcaX500NameUtil.getSubject(certificate);
// for (RDN rdn : dn.getRDNs()) {
// AttributeTypeAndValue first = rdn.getFirst();
// if (first.getType().equals(BCStyle.CN)) {
// return first.getValue().toString();
// }
// }
//
// throw new IllegalArgumentException("certificate subject has no common name (CN)");
// }
//
// public static String[] extractSans(X509Certificate certificate) {
// try {
// Collection<List<?>> pairs = certificate.getSubjectAlternativeNames();
// if (pairs == null)
// return EMPTY_STRING_ARRAY;
//
// List<String> sans = new ArrayList<>();
// for (List<?> pair : pairs) {
// int type = (Integer) pair.get(0);
// if (type == 2) { // TODO fix magic number!
// String san = (String) pair.get(1);
// sans.add(san);
// }
// }
// return sans.toArray(EMPTY_STRING_ARRAY);
// } catch (CertificateParsingException ex) {
// throw new IllegalArgumentException(ex); // TODO ideal?
// }
// }
//
// private CertificateUtils() {
// /* to prevent instantiation */
// }
// }
| import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateKey;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateUtils;
import java.security.cert.X509Certificate; | /*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.mitm.crypto.hostname;
public final class StandardHostnameFinder extends HostnameFinder {
@Override | // Path: mitm/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateKey.java
// public final class CertificateKey {
// private final String cn;
// private final String[] sans;
//
// public CertificateKey(String cn, String[] sans) {
// this.cn = cn;
// this.sans = sans;
// }
//
// public String getCn() {
// return cn;
// }
//
// public String[] getSans() {
// return sans;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// CertificateKey that = (CertificateKey) o;
//
// if (!cn.equals(that.cn)) return false;
// if (!Arrays.equals(sans, that.sans)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = cn.hashCode();
// result = 31 * result + Arrays.hashCode(sans);
// return result;
// }
// }
//
// Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateUtils.java
// public final class CertificateUtils {
// private static final String[] EMPTY_STRING_ARRAY = new String[0];
//
// public static X509Certificate readCertificate(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readCertificate(reader);
// }
// }
//
// public static X509Certificate readCertificate(Reader reader) throws IOException {
// // TODO share with CertificateAuthority's own implementation
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof X509CertificateHolder))
// throw new IOException("File does not contain a certificate");
//
// X509CertificateHolder certificate = (X509CertificateHolder) object;
// return new JcaX509CertificateConverter().getCertificate(certificate);
// } catch (CertificateException ex) {
// throw new IOException(ex);
// }
// }
//
// public static String extractCn(X509Certificate certificate) {
// X500Name dn = JcaX500NameUtil.getSubject(certificate);
// for (RDN rdn : dn.getRDNs()) {
// AttributeTypeAndValue first = rdn.getFirst();
// if (first.getType().equals(BCStyle.CN)) {
// return first.getValue().toString();
// }
// }
//
// throw new IllegalArgumentException("certificate subject has no common name (CN)");
// }
//
// public static String[] extractSans(X509Certificate certificate) {
// try {
// Collection<List<?>> pairs = certificate.getSubjectAlternativeNames();
// if (pairs == null)
// return EMPTY_STRING_ARRAY;
//
// List<String> sans = new ArrayList<>();
// for (List<?> pair : pairs) {
// int type = (Integer) pair.get(0);
// if (type == 2) { // TODO fix magic number!
// String san = (String) pair.get(1);
// sans.add(san);
// }
// }
// return sans.toArray(EMPTY_STRING_ARRAY);
// } catch (CertificateParsingException ex) {
// throw new IllegalArgumentException(ex); // TODO ideal?
// }
// }
//
// private CertificateUtils() {
// /* to prevent instantiation */
// }
// }
// Path: mitm/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/hostname/StandardHostnameFinder.java
import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateKey;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateUtils;
import java.security.cert.X509Certificate;
/*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.mitm.crypto.hostname;
public final class StandardHostnameFinder extends HostnameFinder {
@Override | public CertificateKey getHostname(X509Certificate certificate) { |
grahamedgecombe/android-ssl | mitm/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/hostname/StandardHostnameFinder.java | // Path: mitm/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateKey.java
// public final class CertificateKey {
// private final String cn;
// private final String[] sans;
//
// public CertificateKey(String cn, String[] sans) {
// this.cn = cn;
// this.sans = sans;
// }
//
// public String getCn() {
// return cn;
// }
//
// public String[] getSans() {
// return sans;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// CertificateKey that = (CertificateKey) o;
//
// if (!cn.equals(that.cn)) return false;
// if (!Arrays.equals(sans, that.sans)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = cn.hashCode();
// result = 31 * result + Arrays.hashCode(sans);
// return result;
// }
// }
//
// Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateUtils.java
// public final class CertificateUtils {
// private static final String[] EMPTY_STRING_ARRAY = new String[0];
//
// public static X509Certificate readCertificate(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readCertificate(reader);
// }
// }
//
// public static X509Certificate readCertificate(Reader reader) throws IOException {
// // TODO share with CertificateAuthority's own implementation
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof X509CertificateHolder))
// throw new IOException("File does not contain a certificate");
//
// X509CertificateHolder certificate = (X509CertificateHolder) object;
// return new JcaX509CertificateConverter().getCertificate(certificate);
// } catch (CertificateException ex) {
// throw new IOException(ex);
// }
// }
//
// public static String extractCn(X509Certificate certificate) {
// X500Name dn = JcaX500NameUtil.getSubject(certificate);
// for (RDN rdn : dn.getRDNs()) {
// AttributeTypeAndValue first = rdn.getFirst();
// if (first.getType().equals(BCStyle.CN)) {
// return first.getValue().toString();
// }
// }
//
// throw new IllegalArgumentException("certificate subject has no common name (CN)");
// }
//
// public static String[] extractSans(X509Certificate certificate) {
// try {
// Collection<List<?>> pairs = certificate.getSubjectAlternativeNames();
// if (pairs == null)
// return EMPTY_STRING_ARRAY;
//
// List<String> sans = new ArrayList<>();
// for (List<?> pair : pairs) {
// int type = (Integer) pair.get(0);
// if (type == 2) { // TODO fix magic number!
// String san = (String) pair.get(1);
// sans.add(san);
// }
// }
// return sans.toArray(EMPTY_STRING_ARRAY);
// } catch (CertificateParsingException ex) {
// throw new IllegalArgumentException(ex); // TODO ideal?
// }
// }
//
// private CertificateUtils() {
// /* to prevent instantiation */
// }
// }
| import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateKey;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateUtils;
import java.security.cert.X509Certificate; | /*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.mitm.crypto.hostname;
public final class StandardHostnameFinder extends HostnameFinder {
@Override
public CertificateKey getHostname(X509Certificate certificate) { | // Path: mitm/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateKey.java
// public final class CertificateKey {
// private final String cn;
// private final String[] sans;
//
// public CertificateKey(String cn, String[] sans) {
// this.cn = cn;
// this.sans = sans;
// }
//
// public String getCn() {
// return cn;
// }
//
// public String[] getSans() {
// return sans;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// CertificateKey that = (CertificateKey) o;
//
// if (!cn.equals(that.cn)) return false;
// if (!Arrays.equals(sans, that.sans)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = cn.hashCode();
// result = 31 * result + Arrays.hashCode(sans);
// return result;
// }
// }
//
// Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateUtils.java
// public final class CertificateUtils {
// private static final String[] EMPTY_STRING_ARRAY = new String[0];
//
// public static X509Certificate readCertificate(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readCertificate(reader);
// }
// }
//
// public static X509Certificate readCertificate(Reader reader) throws IOException {
// // TODO share with CertificateAuthority's own implementation
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof X509CertificateHolder))
// throw new IOException("File does not contain a certificate");
//
// X509CertificateHolder certificate = (X509CertificateHolder) object;
// return new JcaX509CertificateConverter().getCertificate(certificate);
// } catch (CertificateException ex) {
// throw new IOException(ex);
// }
// }
//
// public static String extractCn(X509Certificate certificate) {
// X500Name dn = JcaX500NameUtil.getSubject(certificate);
// for (RDN rdn : dn.getRDNs()) {
// AttributeTypeAndValue first = rdn.getFirst();
// if (first.getType().equals(BCStyle.CN)) {
// return first.getValue().toString();
// }
// }
//
// throw new IllegalArgumentException("certificate subject has no common name (CN)");
// }
//
// public static String[] extractSans(X509Certificate certificate) {
// try {
// Collection<List<?>> pairs = certificate.getSubjectAlternativeNames();
// if (pairs == null)
// return EMPTY_STRING_ARRAY;
//
// List<String> sans = new ArrayList<>();
// for (List<?> pair : pairs) {
// int type = (Integer) pair.get(0);
// if (type == 2) { // TODO fix magic number!
// String san = (String) pair.get(1);
// sans.add(san);
// }
// }
// return sans.toArray(EMPTY_STRING_ARRAY);
// } catch (CertificateParsingException ex) {
// throw new IllegalArgumentException(ex); // TODO ideal?
// }
// }
//
// private CertificateUtils() {
// /* to prevent instantiation */
// }
// }
// Path: mitm/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/hostname/StandardHostnameFinder.java
import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateKey;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateUtils;
import java.security.cert.X509Certificate;
/*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.mitm.crypto.hostname;
public final class StandardHostnameFinder extends HostnameFinder {
@Override
public CertificateKey getHostname(X509Certificate certificate) { | String cn = CertificateUtils.extractCn(certificate); |
grahamedgecombe/android-ssl | mitm-test-sni-server/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/testserver/SniServer.java | // Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateUtils.java
// public final class CertificateUtils {
// private static final String[] EMPTY_STRING_ARRAY = new String[0];
//
// public static X509Certificate readCertificate(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readCertificate(reader);
// }
// }
//
// public static X509Certificate readCertificate(Reader reader) throws IOException {
// // TODO share with CertificateAuthority's own implementation
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof X509CertificateHolder))
// throw new IOException("File does not contain a certificate");
//
// X509CertificateHolder certificate = (X509CertificateHolder) object;
// return new JcaX509CertificateConverter().getCertificate(certificate);
// } catch (CertificateException ex) {
// throw new IOException(ex);
// }
// }
//
// public static String extractCn(X509Certificate certificate) {
// X500Name dn = JcaX500NameUtil.getSubject(certificate);
// for (RDN rdn : dn.getRDNs()) {
// AttributeTypeAndValue first = rdn.getFirst();
// if (first.getType().equals(BCStyle.CN)) {
// return first.getValue().toString();
// }
// }
//
// throw new IllegalArgumentException("certificate subject has no common name (CN)");
// }
//
// public static String[] extractSans(X509Certificate certificate) {
// try {
// Collection<List<?>> pairs = certificate.getSubjectAlternativeNames();
// if (pairs == null)
// return EMPTY_STRING_ARRAY;
//
// List<String> sans = new ArrayList<>();
// for (List<?> pair : pairs) {
// int type = (Integer) pair.get(0);
// if (type == 2) { // TODO fix magic number!
// String san = (String) pair.get(1);
// sans.add(san);
// }
// }
// return sans.toArray(EMPTY_STRING_ARRAY);
// } catch (CertificateParsingException ex) {
// throw new IllegalArgumentException(ex); // TODO ideal?
// }
// }
//
// private CertificateUtils() {
// /* to prevent instantiation */
// }
// }
//
// Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/key/KeyUtils.java
// public final class KeyUtils {
// public static PrivateKey readPrivateKey(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readPrivateKey(reader);
// }
// }
//
// public static PrivateKey readPrivateKey(Reader reader) throws IOException {
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof PEMKeyPair))
// throw new IOException("File does not contain a key");
//
// PEMKeyPair pair = (PEMKeyPair) object;
//
// // TODO merge messy conversion logic with that below */
// AsymmetricKeyParameter privateKey = PrivateKeyFactory.createKey(pair.getPrivateKeyInfo());
// PrivateKeyInfo privateKeyInfo = PrivateKeyInfoFactory.createPrivateKeyInfo(privateKey);
// KeyFactory keyFactory = new DefaultJcaJceHelper().createKeyFactory("RSA"); // TODO should we really assume RSA?
// return keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKeyInfo.getEncoded()));
// } catch (NoSuchAlgorithmException | InvalidKeySpecException ex) {
// throw new IOException(ex);
// }
// }
//
// public static KeyPair convertToJca(AsymmetricCipherKeyPair keyPair) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
// SubjectPublicKeyInfo publicKey = SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(keyPair.getPublic());
// PrivateKeyInfo privateKey = PrivateKeyInfoFactory.createPrivateKeyInfo(keyPair.getPrivate());
//
// KeyFactory keyFactory = new DefaultJcaJceHelper().createKeyFactory("RSA"); // TODO should we really assume RSA?
// return new KeyPair(
// keyFactory.generatePublic(new X509EncodedKeySpec(publicKey.getEncoded())),
// keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKey.getEncoded()))
// );
// }
//
// private KeyUtils() {
// /* to prevent instantiation */
// }
// }
| import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateUtils;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.key.KeyUtils;
import javax.net.ssl.*;
import java.io.IOException;
import java.nio.file.Paths;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.Collections;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors; | /*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.mitm.testserver;
public final class SniServer {
public static void main(String[] args) throws IOException, NoSuchAlgorithmException, KeyManagementException {
System.setProperty("java.net.preferIPv4Stack", "true");
| // Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateUtils.java
// public final class CertificateUtils {
// private static final String[] EMPTY_STRING_ARRAY = new String[0];
//
// public static X509Certificate readCertificate(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readCertificate(reader);
// }
// }
//
// public static X509Certificate readCertificate(Reader reader) throws IOException {
// // TODO share with CertificateAuthority's own implementation
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof X509CertificateHolder))
// throw new IOException("File does not contain a certificate");
//
// X509CertificateHolder certificate = (X509CertificateHolder) object;
// return new JcaX509CertificateConverter().getCertificate(certificate);
// } catch (CertificateException ex) {
// throw new IOException(ex);
// }
// }
//
// public static String extractCn(X509Certificate certificate) {
// X500Name dn = JcaX500NameUtil.getSubject(certificate);
// for (RDN rdn : dn.getRDNs()) {
// AttributeTypeAndValue first = rdn.getFirst();
// if (first.getType().equals(BCStyle.CN)) {
// return first.getValue().toString();
// }
// }
//
// throw new IllegalArgumentException("certificate subject has no common name (CN)");
// }
//
// public static String[] extractSans(X509Certificate certificate) {
// try {
// Collection<List<?>> pairs = certificate.getSubjectAlternativeNames();
// if (pairs == null)
// return EMPTY_STRING_ARRAY;
//
// List<String> sans = new ArrayList<>();
// for (List<?> pair : pairs) {
// int type = (Integer) pair.get(0);
// if (type == 2) { // TODO fix magic number!
// String san = (String) pair.get(1);
// sans.add(san);
// }
// }
// return sans.toArray(EMPTY_STRING_ARRAY);
// } catch (CertificateParsingException ex) {
// throw new IllegalArgumentException(ex); // TODO ideal?
// }
// }
//
// private CertificateUtils() {
// /* to prevent instantiation */
// }
// }
//
// Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/key/KeyUtils.java
// public final class KeyUtils {
// public static PrivateKey readPrivateKey(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readPrivateKey(reader);
// }
// }
//
// public static PrivateKey readPrivateKey(Reader reader) throws IOException {
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof PEMKeyPair))
// throw new IOException("File does not contain a key");
//
// PEMKeyPair pair = (PEMKeyPair) object;
//
// // TODO merge messy conversion logic with that below */
// AsymmetricKeyParameter privateKey = PrivateKeyFactory.createKey(pair.getPrivateKeyInfo());
// PrivateKeyInfo privateKeyInfo = PrivateKeyInfoFactory.createPrivateKeyInfo(privateKey);
// KeyFactory keyFactory = new DefaultJcaJceHelper().createKeyFactory("RSA"); // TODO should we really assume RSA?
// return keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKeyInfo.getEncoded()));
// } catch (NoSuchAlgorithmException | InvalidKeySpecException ex) {
// throw new IOException(ex);
// }
// }
//
// public static KeyPair convertToJca(AsymmetricCipherKeyPair keyPair) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
// SubjectPublicKeyInfo publicKey = SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(keyPair.getPublic());
// PrivateKeyInfo privateKey = PrivateKeyInfoFactory.createPrivateKeyInfo(keyPair.getPrivate());
//
// KeyFactory keyFactory = new DefaultJcaJceHelper().createKeyFactory("RSA"); // TODO should we really assume RSA?
// return new KeyPair(
// keyFactory.generatePublic(new X509EncodedKeySpec(publicKey.getEncoded())),
// keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKey.getEncoded()))
// );
// }
//
// private KeyUtils() {
// /* to prevent instantiation */
// }
// }
// Path: mitm-test-sni-server/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/testserver/SniServer.java
import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateUtils;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.key.KeyUtils;
import javax.net.ssl.*;
import java.io.IOException;
import java.nio.file.Paths;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.Collections;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
/*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.mitm.testserver;
public final class SniServer {
public static void main(String[] args) throws IOException, NoSuchAlgorithmException, KeyManagementException {
System.setProperty("java.net.preferIPv4Stack", "true");
| PrivateKey key = KeyUtils.readPrivateKey(Paths.get("cert.key")); |
grahamedgecombe/android-ssl | mitm-test-sni-server/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/testserver/SniServer.java | // Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateUtils.java
// public final class CertificateUtils {
// private static final String[] EMPTY_STRING_ARRAY = new String[0];
//
// public static X509Certificate readCertificate(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readCertificate(reader);
// }
// }
//
// public static X509Certificate readCertificate(Reader reader) throws IOException {
// // TODO share with CertificateAuthority's own implementation
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof X509CertificateHolder))
// throw new IOException("File does not contain a certificate");
//
// X509CertificateHolder certificate = (X509CertificateHolder) object;
// return new JcaX509CertificateConverter().getCertificate(certificate);
// } catch (CertificateException ex) {
// throw new IOException(ex);
// }
// }
//
// public static String extractCn(X509Certificate certificate) {
// X500Name dn = JcaX500NameUtil.getSubject(certificate);
// for (RDN rdn : dn.getRDNs()) {
// AttributeTypeAndValue first = rdn.getFirst();
// if (first.getType().equals(BCStyle.CN)) {
// return first.getValue().toString();
// }
// }
//
// throw new IllegalArgumentException("certificate subject has no common name (CN)");
// }
//
// public static String[] extractSans(X509Certificate certificate) {
// try {
// Collection<List<?>> pairs = certificate.getSubjectAlternativeNames();
// if (pairs == null)
// return EMPTY_STRING_ARRAY;
//
// List<String> sans = new ArrayList<>();
// for (List<?> pair : pairs) {
// int type = (Integer) pair.get(0);
// if (type == 2) { // TODO fix magic number!
// String san = (String) pair.get(1);
// sans.add(san);
// }
// }
// return sans.toArray(EMPTY_STRING_ARRAY);
// } catch (CertificateParsingException ex) {
// throw new IllegalArgumentException(ex); // TODO ideal?
// }
// }
//
// private CertificateUtils() {
// /* to prevent instantiation */
// }
// }
//
// Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/key/KeyUtils.java
// public final class KeyUtils {
// public static PrivateKey readPrivateKey(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readPrivateKey(reader);
// }
// }
//
// public static PrivateKey readPrivateKey(Reader reader) throws IOException {
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof PEMKeyPair))
// throw new IOException("File does not contain a key");
//
// PEMKeyPair pair = (PEMKeyPair) object;
//
// // TODO merge messy conversion logic with that below */
// AsymmetricKeyParameter privateKey = PrivateKeyFactory.createKey(pair.getPrivateKeyInfo());
// PrivateKeyInfo privateKeyInfo = PrivateKeyInfoFactory.createPrivateKeyInfo(privateKey);
// KeyFactory keyFactory = new DefaultJcaJceHelper().createKeyFactory("RSA"); // TODO should we really assume RSA?
// return keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKeyInfo.getEncoded()));
// } catch (NoSuchAlgorithmException | InvalidKeySpecException ex) {
// throw new IOException(ex);
// }
// }
//
// public static KeyPair convertToJca(AsymmetricCipherKeyPair keyPair) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
// SubjectPublicKeyInfo publicKey = SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(keyPair.getPublic());
// PrivateKeyInfo privateKey = PrivateKeyInfoFactory.createPrivateKeyInfo(keyPair.getPrivate());
//
// KeyFactory keyFactory = new DefaultJcaJceHelper().createKeyFactory("RSA"); // TODO should we really assume RSA?
// return new KeyPair(
// keyFactory.generatePublic(new X509EncodedKeySpec(publicKey.getEncoded())),
// keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKey.getEncoded()))
// );
// }
//
// private KeyUtils() {
// /* to prevent instantiation */
// }
// }
| import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateUtils;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.key.KeyUtils;
import javax.net.ssl.*;
import java.io.IOException;
import java.nio.file.Paths;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.Collections;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors; | /*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.mitm.testserver;
public final class SniServer {
public static void main(String[] args) throws IOException, NoSuchAlgorithmException, KeyManagementException {
System.setProperty("java.net.preferIPv4Stack", "true");
PrivateKey key = KeyUtils.readPrivateKey(Paths.get("cert.key"));
| // Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateUtils.java
// public final class CertificateUtils {
// private static final String[] EMPTY_STRING_ARRAY = new String[0];
//
// public static X509Certificate readCertificate(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readCertificate(reader);
// }
// }
//
// public static X509Certificate readCertificate(Reader reader) throws IOException {
// // TODO share with CertificateAuthority's own implementation
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof X509CertificateHolder))
// throw new IOException("File does not contain a certificate");
//
// X509CertificateHolder certificate = (X509CertificateHolder) object;
// return new JcaX509CertificateConverter().getCertificate(certificate);
// } catch (CertificateException ex) {
// throw new IOException(ex);
// }
// }
//
// public static String extractCn(X509Certificate certificate) {
// X500Name dn = JcaX500NameUtil.getSubject(certificate);
// for (RDN rdn : dn.getRDNs()) {
// AttributeTypeAndValue first = rdn.getFirst();
// if (first.getType().equals(BCStyle.CN)) {
// return first.getValue().toString();
// }
// }
//
// throw new IllegalArgumentException("certificate subject has no common name (CN)");
// }
//
// public static String[] extractSans(X509Certificate certificate) {
// try {
// Collection<List<?>> pairs = certificate.getSubjectAlternativeNames();
// if (pairs == null)
// return EMPTY_STRING_ARRAY;
//
// List<String> sans = new ArrayList<>();
// for (List<?> pair : pairs) {
// int type = (Integer) pair.get(0);
// if (type == 2) { // TODO fix magic number!
// String san = (String) pair.get(1);
// sans.add(san);
// }
// }
// return sans.toArray(EMPTY_STRING_ARRAY);
// } catch (CertificateParsingException ex) {
// throw new IllegalArgumentException(ex); // TODO ideal?
// }
// }
//
// private CertificateUtils() {
// /* to prevent instantiation */
// }
// }
//
// Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/key/KeyUtils.java
// public final class KeyUtils {
// public static PrivateKey readPrivateKey(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readPrivateKey(reader);
// }
// }
//
// public static PrivateKey readPrivateKey(Reader reader) throws IOException {
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof PEMKeyPair))
// throw new IOException("File does not contain a key");
//
// PEMKeyPair pair = (PEMKeyPair) object;
//
// // TODO merge messy conversion logic with that below */
// AsymmetricKeyParameter privateKey = PrivateKeyFactory.createKey(pair.getPrivateKeyInfo());
// PrivateKeyInfo privateKeyInfo = PrivateKeyInfoFactory.createPrivateKeyInfo(privateKey);
// KeyFactory keyFactory = new DefaultJcaJceHelper().createKeyFactory("RSA"); // TODO should we really assume RSA?
// return keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKeyInfo.getEncoded()));
// } catch (NoSuchAlgorithmException | InvalidKeySpecException ex) {
// throw new IOException(ex);
// }
// }
//
// public static KeyPair convertToJca(AsymmetricCipherKeyPair keyPair) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
// SubjectPublicKeyInfo publicKey = SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(keyPair.getPublic());
// PrivateKeyInfo privateKey = PrivateKeyInfoFactory.createPrivateKeyInfo(keyPair.getPrivate());
//
// KeyFactory keyFactory = new DefaultJcaJceHelper().createKeyFactory("RSA"); // TODO should we really assume RSA?
// return new KeyPair(
// keyFactory.generatePublic(new X509EncodedKeySpec(publicKey.getEncoded())),
// keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKey.getEncoded()))
// );
// }
//
// private KeyUtils() {
// /* to prevent instantiation */
// }
// }
// Path: mitm-test-sni-server/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/testserver/SniServer.java
import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateUtils;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.key.KeyUtils;
import javax.net.ssl.*;
import java.io.IOException;
import java.nio.file.Paths;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.Collections;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
/*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.mitm.testserver;
public final class SniServer {
public static void main(String[] args) throws IOException, NoSuchAlgorithmException, KeyManagementException {
System.setProperty("java.net.preferIPv4Stack", "true");
PrivateKey key = KeyUtils.readPrivateKey(Paths.get("cert.key"));
| X509Certificate ca = CertificateUtils.readCertificate(Paths.get("ca.crt")); |
grahamedgecombe/android-ssl | analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/tag/VulnerabilityTag.java | // Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/VulnerabilityState.java
// public enum VulnerabilityState {
// VULNERABLE,
// SAFE,
// UNKNOWN
// }
| import soot.tagkit.Tag;
import uk.ac.cam.gpe21.droidssl.analysis.VulnerabilityState; | /*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.analysis.tag;
public abstract class VulnerabilityTag implements Tag {
private final String name; | // Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/VulnerabilityState.java
// public enum VulnerabilityState {
// VULNERABLE,
// SAFE,
// UNKNOWN
// }
// Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/tag/VulnerabilityTag.java
import soot.tagkit.Tag;
import uk.ac.cam.gpe21.droidssl.analysis.VulnerabilityState;
/*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.analysis.tag;
public abstract class VulnerabilityTag implements Tag {
private final String name; | private final VulnerabilityState state; |
grahamedgecombe/android-ssl | mitm-test-client/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/testclient/TestClient.java | // Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateUtils.java
// public final class CertificateUtils {
// private static final String[] EMPTY_STRING_ARRAY = new String[0];
//
// public static X509Certificate readCertificate(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readCertificate(reader);
// }
// }
//
// public static X509Certificate readCertificate(Reader reader) throws IOException {
// // TODO share with CertificateAuthority's own implementation
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof X509CertificateHolder))
// throw new IOException("File does not contain a certificate");
//
// X509CertificateHolder certificate = (X509CertificateHolder) object;
// return new JcaX509CertificateConverter().getCertificate(certificate);
// } catch (CertificateException ex) {
// throw new IOException(ex);
// }
// }
//
// public static String extractCn(X509Certificate certificate) {
// X500Name dn = JcaX500NameUtil.getSubject(certificate);
// for (RDN rdn : dn.getRDNs()) {
// AttributeTypeAndValue first = rdn.getFirst();
// if (first.getType().equals(BCStyle.CN)) {
// return first.getValue().toString();
// }
// }
//
// throw new IllegalArgumentException("certificate subject has no common name (CN)");
// }
//
// public static String[] extractSans(X509Certificate certificate) {
// try {
// Collection<List<?>> pairs = certificate.getSubjectAlternativeNames();
// if (pairs == null)
// return EMPTY_STRING_ARRAY;
//
// List<String> sans = new ArrayList<>();
// for (List<?> pair : pairs) {
// int type = (Integer) pair.get(0);
// if (type == 2) { // TODO fix magic number!
// String san = (String) pair.get(1);
// sans.add(san);
// }
// }
// return sans.toArray(EMPTY_STRING_ARRAY);
// } catch (CertificateParsingException ex) {
// throw new IllegalArgumentException(ex); // TODO ideal?
// }
// }
//
// private CertificateUtils() {
// /* to prevent instantiation */
// }
// }
| import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateUtils;
import javax.net.ssl.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.nio.file.Paths;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate; | /*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.mitm.testclient;
public final class TestClient {
public static void main(String[] args) throws NoSuchAlgorithmException, KeyManagementException, IOException, KeyStoreException, CertificateException {
System.setProperty("java.net.preferIPv4Stack" ,"true");
Certificate[] certificateAuthorities = { | // Path: mitm-common/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/crypto/cert/CertificateUtils.java
// public final class CertificateUtils {
// private static final String[] EMPTY_STRING_ARRAY = new String[0];
//
// public static X509Certificate readCertificate(Path path) throws IOException {
// try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
// return readCertificate(reader);
// }
// }
//
// public static X509Certificate readCertificate(Reader reader) throws IOException {
// // TODO share with CertificateAuthority's own implementation
// try (PEMParser parser = new PEMParser(reader)) {
// Object object = parser.readObject();
// if (!(object instanceof X509CertificateHolder))
// throw new IOException("File does not contain a certificate");
//
// X509CertificateHolder certificate = (X509CertificateHolder) object;
// return new JcaX509CertificateConverter().getCertificate(certificate);
// } catch (CertificateException ex) {
// throw new IOException(ex);
// }
// }
//
// public static String extractCn(X509Certificate certificate) {
// X500Name dn = JcaX500NameUtil.getSubject(certificate);
// for (RDN rdn : dn.getRDNs()) {
// AttributeTypeAndValue first = rdn.getFirst();
// if (first.getType().equals(BCStyle.CN)) {
// return first.getValue().toString();
// }
// }
//
// throw new IllegalArgumentException("certificate subject has no common name (CN)");
// }
//
// public static String[] extractSans(X509Certificate certificate) {
// try {
// Collection<List<?>> pairs = certificate.getSubjectAlternativeNames();
// if (pairs == null)
// return EMPTY_STRING_ARRAY;
//
// List<String> sans = new ArrayList<>();
// for (List<?> pair : pairs) {
// int type = (Integer) pair.get(0);
// if (type == 2) { // TODO fix magic number!
// String san = (String) pair.get(1);
// sans.add(san);
// }
// }
// return sans.toArray(EMPTY_STRING_ARRAY);
// } catch (CertificateParsingException ex) {
// throw new IllegalArgumentException(ex); // TODO ideal?
// }
// }
//
// private CertificateUtils() {
// /* to prevent instantiation */
// }
// }
// Path: mitm-test-client/src/main/java/uk/ac/cam/gpe21/droidssl/mitm/testclient/TestClient.java
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import uk.ac.cam.gpe21.droidssl.mitm.crypto.cert.CertificateUtils;
import javax.net.ssl.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.nio.file.Paths;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
/*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.mitm.testclient;
public final class TestClient {
public static void main(String[] args) throws NoSuchAlgorithmException, KeyManagementException, IOException, KeyStoreException, CertificateException {
System.setProperty("java.net.preferIPv4Stack" ,"true");
Certificate[] certificateAuthorities = { | CertificateUtils.readCertificate(Paths.get("ca.crt")), |
grahamedgecombe/android-ssl | analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/trans/InitHostnameVerifierAnalyser.java | // Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/Vulnerability.java
// public final class Vulnerability {
// private final SootClass clazz;
// private final SootMethod method;
// private final VulnerabilityType type;
// private final VulnerabilityState state;
//
// public Vulnerability(SootClass clazz, VulnerabilityType type, VulnerabilityState state) {
// this.clazz = clazz;
// this.method = null;
// this.type = type;
// this.state = state;
// }
//
// public Vulnerability(SootMethod method, VulnerabilityType type, VulnerabilityState state) {
// this.clazz = method.getDeclaringClass();
// this.method = method;
// this.type = type;
// this.state = state;
// }
//
// public SootClass getClazz() {
// return clazz;
// }
//
// public SootMethod getMethod() {
// return method;
// }
//
// public VulnerabilityType getType() {
// return type;
// }
//
// public VulnerabilityState getState() {
// return state;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Vulnerability that = (Vulnerability) o;
//
// if (!clazz.equals(that.clazz)) return false;
// if (method != null ? !method.equals(that.method) : that.method != null) return false;
// if (state != that.state) return false;
// if (type != that.type) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = clazz.hashCode();
// result = 31 * result + (method != null ? method.hashCode() : 0);
// result = 31 * result + type.hashCode();
// result = 31 * result + state.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// if (method == null) {
// return clazz.getName() + "\t" + type + "\t" + state;
// } else {
// return clazz.getName() + "::" + method.getName() + "\t" + type + "\t" + state;
// }
// }
// }
//
// Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/VulnerabilityType.java
// public enum VulnerabilityType {
// PERMISSIVE_HOSTNAME_VERIFIER,
// PERMISSIVE_TRUST_MANAGER,
// INIT_HOSTNAME_VERIFIER,
// INIT_TRUST_MANAGER,
// HTTPS_CONNECTION_DEFAULT_HOSTNAME_VERIFIER,
// HTTPS_CONNECTION_USES_HOSTNAME_VERIFIER,
// SOCKET_USES_PERMISSIVE_TRUST_MANAGER
// }
//
// Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/tag/HostnameVerifierTag.java
// public final class HostnameVerifierTag extends VulnerabilityTag {
// public static final String NAME = "hostname_verifier";
//
// public HostnameVerifierTag(VulnerabilityState state) {
// super(NAME, state);
// }
// }
| import soot.*;
import soot.jimple.AbstractJimpleValueSwitch;
import soot.jimple.NewExpr;
import uk.ac.cam.gpe21.droidssl.analysis.Vulnerability;
import uk.ac.cam.gpe21.droidssl.analysis.VulnerabilityType;
import uk.ac.cam.gpe21.droidssl.analysis.tag.HostnameVerifierTag;
import java.util.Set; | /*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.analysis.trans;
public final class InitHostnameVerifierAnalyser extends IntraProceduralAnalyser {
public InitHostnameVerifierAnalyser(Set<Vulnerability> vulnerabilities) {
super(vulnerabilities);
}
@Override
protected void analyse(SootClass clazz, final SootMethod method, Body body) {
for (Unit unit : body.getUnits()) {
for (ValueBox valueBox : unit.getUseBoxes()) {
valueBox.getValue().apply(new AbstractJimpleValueSwitch() {
@Override
public void caseNewExpr(NewExpr value) {
SootClass type = value.getBaseType().getSootClass(); | // Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/Vulnerability.java
// public final class Vulnerability {
// private final SootClass clazz;
// private final SootMethod method;
// private final VulnerabilityType type;
// private final VulnerabilityState state;
//
// public Vulnerability(SootClass clazz, VulnerabilityType type, VulnerabilityState state) {
// this.clazz = clazz;
// this.method = null;
// this.type = type;
// this.state = state;
// }
//
// public Vulnerability(SootMethod method, VulnerabilityType type, VulnerabilityState state) {
// this.clazz = method.getDeclaringClass();
// this.method = method;
// this.type = type;
// this.state = state;
// }
//
// public SootClass getClazz() {
// return clazz;
// }
//
// public SootMethod getMethod() {
// return method;
// }
//
// public VulnerabilityType getType() {
// return type;
// }
//
// public VulnerabilityState getState() {
// return state;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Vulnerability that = (Vulnerability) o;
//
// if (!clazz.equals(that.clazz)) return false;
// if (method != null ? !method.equals(that.method) : that.method != null) return false;
// if (state != that.state) return false;
// if (type != that.type) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = clazz.hashCode();
// result = 31 * result + (method != null ? method.hashCode() : 0);
// result = 31 * result + type.hashCode();
// result = 31 * result + state.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// if (method == null) {
// return clazz.getName() + "\t" + type + "\t" + state;
// } else {
// return clazz.getName() + "::" + method.getName() + "\t" + type + "\t" + state;
// }
// }
// }
//
// Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/VulnerabilityType.java
// public enum VulnerabilityType {
// PERMISSIVE_HOSTNAME_VERIFIER,
// PERMISSIVE_TRUST_MANAGER,
// INIT_HOSTNAME_VERIFIER,
// INIT_TRUST_MANAGER,
// HTTPS_CONNECTION_DEFAULT_HOSTNAME_VERIFIER,
// HTTPS_CONNECTION_USES_HOSTNAME_VERIFIER,
// SOCKET_USES_PERMISSIVE_TRUST_MANAGER
// }
//
// Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/tag/HostnameVerifierTag.java
// public final class HostnameVerifierTag extends VulnerabilityTag {
// public static final String NAME = "hostname_verifier";
//
// public HostnameVerifierTag(VulnerabilityState state) {
// super(NAME, state);
// }
// }
// Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/trans/InitHostnameVerifierAnalyser.java
import soot.*;
import soot.jimple.AbstractJimpleValueSwitch;
import soot.jimple.NewExpr;
import uk.ac.cam.gpe21.droidssl.analysis.Vulnerability;
import uk.ac.cam.gpe21.droidssl.analysis.VulnerabilityType;
import uk.ac.cam.gpe21.droidssl.analysis.tag.HostnameVerifierTag;
import java.util.Set;
/*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.analysis.trans;
public final class InitHostnameVerifierAnalyser extends IntraProceduralAnalyser {
public InitHostnameVerifierAnalyser(Set<Vulnerability> vulnerabilities) {
super(vulnerabilities);
}
@Override
protected void analyse(SootClass clazz, final SootMethod method, Body body) {
for (Unit unit : body.getUnits()) {
for (ValueBox valueBox : unit.getUseBoxes()) {
valueBox.getValue().apply(new AbstractJimpleValueSwitch() {
@Override
public void caseNewExpr(NewExpr value) {
SootClass type = value.getBaseType().getSootClass(); | if (type.hasTag(HostnameVerifierTag.NAME)) { |
grahamedgecombe/android-ssl | analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/trans/InitHostnameVerifierAnalyser.java | // Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/Vulnerability.java
// public final class Vulnerability {
// private final SootClass clazz;
// private final SootMethod method;
// private final VulnerabilityType type;
// private final VulnerabilityState state;
//
// public Vulnerability(SootClass clazz, VulnerabilityType type, VulnerabilityState state) {
// this.clazz = clazz;
// this.method = null;
// this.type = type;
// this.state = state;
// }
//
// public Vulnerability(SootMethod method, VulnerabilityType type, VulnerabilityState state) {
// this.clazz = method.getDeclaringClass();
// this.method = method;
// this.type = type;
// this.state = state;
// }
//
// public SootClass getClazz() {
// return clazz;
// }
//
// public SootMethod getMethod() {
// return method;
// }
//
// public VulnerabilityType getType() {
// return type;
// }
//
// public VulnerabilityState getState() {
// return state;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Vulnerability that = (Vulnerability) o;
//
// if (!clazz.equals(that.clazz)) return false;
// if (method != null ? !method.equals(that.method) : that.method != null) return false;
// if (state != that.state) return false;
// if (type != that.type) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = clazz.hashCode();
// result = 31 * result + (method != null ? method.hashCode() : 0);
// result = 31 * result + type.hashCode();
// result = 31 * result + state.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// if (method == null) {
// return clazz.getName() + "\t" + type + "\t" + state;
// } else {
// return clazz.getName() + "::" + method.getName() + "\t" + type + "\t" + state;
// }
// }
// }
//
// Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/VulnerabilityType.java
// public enum VulnerabilityType {
// PERMISSIVE_HOSTNAME_VERIFIER,
// PERMISSIVE_TRUST_MANAGER,
// INIT_HOSTNAME_VERIFIER,
// INIT_TRUST_MANAGER,
// HTTPS_CONNECTION_DEFAULT_HOSTNAME_VERIFIER,
// HTTPS_CONNECTION_USES_HOSTNAME_VERIFIER,
// SOCKET_USES_PERMISSIVE_TRUST_MANAGER
// }
//
// Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/tag/HostnameVerifierTag.java
// public final class HostnameVerifierTag extends VulnerabilityTag {
// public static final String NAME = "hostname_verifier";
//
// public HostnameVerifierTag(VulnerabilityState state) {
// super(NAME, state);
// }
// }
| import soot.*;
import soot.jimple.AbstractJimpleValueSwitch;
import soot.jimple.NewExpr;
import uk.ac.cam.gpe21.droidssl.analysis.Vulnerability;
import uk.ac.cam.gpe21.droidssl.analysis.VulnerabilityType;
import uk.ac.cam.gpe21.droidssl.analysis.tag.HostnameVerifierTag;
import java.util.Set; | /*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.analysis.trans;
public final class InitHostnameVerifierAnalyser extends IntraProceduralAnalyser {
public InitHostnameVerifierAnalyser(Set<Vulnerability> vulnerabilities) {
super(vulnerabilities);
}
@Override
protected void analyse(SootClass clazz, final SootMethod method, Body body) {
for (Unit unit : body.getUnits()) {
for (ValueBox valueBox : unit.getUseBoxes()) {
valueBox.getValue().apply(new AbstractJimpleValueSwitch() {
@Override
public void caseNewExpr(NewExpr value) {
SootClass type = value.getBaseType().getSootClass();
if (type.hasTag(HostnameVerifierTag.NAME)) {
HostnameVerifierTag tag = (HostnameVerifierTag) type.getTag(HostnameVerifierTag.NAME); | // Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/Vulnerability.java
// public final class Vulnerability {
// private final SootClass clazz;
// private final SootMethod method;
// private final VulnerabilityType type;
// private final VulnerabilityState state;
//
// public Vulnerability(SootClass clazz, VulnerabilityType type, VulnerabilityState state) {
// this.clazz = clazz;
// this.method = null;
// this.type = type;
// this.state = state;
// }
//
// public Vulnerability(SootMethod method, VulnerabilityType type, VulnerabilityState state) {
// this.clazz = method.getDeclaringClass();
// this.method = method;
// this.type = type;
// this.state = state;
// }
//
// public SootClass getClazz() {
// return clazz;
// }
//
// public SootMethod getMethod() {
// return method;
// }
//
// public VulnerabilityType getType() {
// return type;
// }
//
// public VulnerabilityState getState() {
// return state;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Vulnerability that = (Vulnerability) o;
//
// if (!clazz.equals(that.clazz)) return false;
// if (method != null ? !method.equals(that.method) : that.method != null) return false;
// if (state != that.state) return false;
// if (type != that.type) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = clazz.hashCode();
// result = 31 * result + (method != null ? method.hashCode() : 0);
// result = 31 * result + type.hashCode();
// result = 31 * result + state.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// if (method == null) {
// return clazz.getName() + "\t" + type + "\t" + state;
// } else {
// return clazz.getName() + "::" + method.getName() + "\t" + type + "\t" + state;
// }
// }
// }
//
// Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/VulnerabilityType.java
// public enum VulnerabilityType {
// PERMISSIVE_HOSTNAME_VERIFIER,
// PERMISSIVE_TRUST_MANAGER,
// INIT_HOSTNAME_VERIFIER,
// INIT_TRUST_MANAGER,
// HTTPS_CONNECTION_DEFAULT_HOSTNAME_VERIFIER,
// HTTPS_CONNECTION_USES_HOSTNAME_VERIFIER,
// SOCKET_USES_PERMISSIVE_TRUST_MANAGER
// }
//
// Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/tag/HostnameVerifierTag.java
// public final class HostnameVerifierTag extends VulnerabilityTag {
// public static final String NAME = "hostname_verifier";
//
// public HostnameVerifierTag(VulnerabilityState state) {
// super(NAME, state);
// }
// }
// Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/trans/InitHostnameVerifierAnalyser.java
import soot.*;
import soot.jimple.AbstractJimpleValueSwitch;
import soot.jimple.NewExpr;
import uk.ac.cam.gpe21.droidssl.analysis.Vulnerability;
import uk.ac.cam.gpe21.droidssl.analysis.VulnerabilityType;
import uk.ac.cam.gpe21.droidssl.analysis.tag.HostnameVerifierTag;
import java.util.Set;
/*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.analysis.trans;
public final class InitHostnameVerifierAnalyser extends IntraProceduralAnalyser {
public InitHostnameVerifierAnalyser(Set<Vulnerability> vulnerabilities) {
super(vulnerabilities);
}
@Override
protected void analyse(SootClass clazz, final SootMethod method, Body body) {
for (Unit unit : body.getUnits()) {
for (ValueBox valueBox : unit.getUseBoxes()) {
valueBox.getValue().apply(new AbstractJimpleValueSwitch() {
@Override
public void caseNewExpr(NewExpr value) {
SootClass type = value.getBaseType().getSootClass();
if (type.hasTag(HostnameVerifierTag.NAME)) {
HostnameVerifierTag tag = (HostnameVerifierTag) type.getTag(HostnameVerifierTag.NAME); | vulnerabilities.add(new Vulnerability(method, VulnerabilityType.INIT_HOSTNAME_VERIFIER, tag.getState())); |
grahamedgecombe/android-ssl | analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/tag/TrustManagerTag.java | // Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/VulnerabilityState.java
// public enum VulnerabilityState {
// VULNERABLE,
// SAFE,
// UNKNOWN
// }
| import uk.ac.cam.gpe21.droidssl.analysis.VulnerabilityState; | /*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.analysis.tag;
public final class TrustManagerTag extends VulnerabilityTag {
public static final String NAME = "trust_manager";
| // Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/VulnerabilityState.java
// public enum VulnerabilityState {
// VULNERABLE,
// SAFE,
// UNKNOWN
// }
// Path: analysis/src/main/java/uk/ac/cam/gpe21/droidssl/analysis/tag/TrustManagerTag.java
import uk.ac.cam.gpe21.droidssl.analysis.VulnerabilityState;
/*
* Copyright 2013-2014 Graham Edgecombe
*
* 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 uk.ac.cam.gpe21.droidssl.analysis.tag;
public final class TrustManagerTag extends VulnerabilityTag {
public static final String NAME = "trust_manager";
| public TrustManagerTag(VulnerabilityState state) { |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/dependencies/modules/ApplicationModule.java | // Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/whatever/java/com/pacoworks/dereference/FlavourInitialiser.java
// public class FlavourInitialiser {
// public FlavourInitialiser(DereferenceApplication application) {
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/MainInitialiser.java
// public class MainInitialiser {
// private final Application.ActivityLifecycleCallbacks initialiserCallbacks = new Application.ActivityLifecycleCallbacks() {
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// };
//
// public MainInitialiser(DereferenceApplication application, OkHttpClient okHttpClient) {
// application.registerActivityLifecycleCallbacks(initialiserCallbacks);
// LeakCanary.install(application);
// if (BuildConfig.DEBUG) {
// // FIXME no stetho for now
// // Stetho.initialize(Stetho.newInitializerBuilder(application)
// // .enableDumpapp(Stetho.defaultDumperPluginsProvider(application)).build());
// LumberYard lumberYard = LumberYard.getInstance(application);
// lumberYard.cleanUp();
// Timber.plant(lumberYard.tree());
// Timber.plant(new Timber.DebugTree());
// }
// }
// }
| import javax.inject.Singleton;
import android.content.Context;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.FlavourInitialiser;
import com.pacoworks.dereference.MainInitialiser;
import com.squareup.okhttp.OkHttpClient;
import dagger.Module;
import dagger.Provides; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies.modules;
@Module
public class ApplicationModule { | // Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/whatever/java/com/pacoworks/dereference/FlavourInitialiser.java
// public class FlavourInitialiser {
// public FlavourInitialiser(DereferenceApplication application) {
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/MainInitialiser.java
// public class MainInitialiser {
// private final Application.ActivityLifecycleCallbacks initialiserCallbacks = new Application.ActivityLifecycleCallbacks() {
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// };
//
// public MainInitialiser(DereferenceApplication application, OkHttpClient okHttpClient) {
// application.registerActivityLifecycleCallbacks(initialiserCallbacks);
// LeakCanary.install(application);
// if (BuildConfig.DEBUG) {
// // FIXME no stetho for now
// // Stetho.initialize(Stetho.newInitializerBuilder(application)
// // .enableDumpapp(Stetho.defaultDumperPluginsProvider(application)).build());
// LumberYard lumberYard = LumberYard.getInstance(application);
// lumberYard.cleanUp();
// Timber.plant(lumberYard.tree());
// Timber.plant(new Timber.DebugTree());
// }
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/modules/ApplicationModule.java
import javax.inject.Singleton;
import android.content.Context;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.FlavourInitialiser;
import com.pacoworks.dereference.MainInitialiser;
import com.squareup.okhttp.OkHttpClient;
import dagger.Module;
import dagger.Provides;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies.modules;
@Module
public class ApplicationModule { | DereferenceApplication application; |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/dependencies/modules/ApplicationModule.java | // Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/whatever/java/com/pacoworks/dereference/FlavourInitialiser.java
// public class FlavourInitialiser {
// public FlavourInitialiser(DereferenceApplication application) {
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/MainInitialiser.java
// public class MainInitialiser {
// private final Application.ActivityLifecycleCallbacks initialiserCallbacks = new Application.ActivityLifecycleCallbacks() {
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// };
//
// public MainInitialiser(DereferenceApplication application, OkHttpClient okHttpClient) {
// application.registerActivityLifecycleCallbacks(initialiserCallbacks);
// LeakCanary.install(application);
// if (BuildConfig.DEBUG) {
// // FIXME no stetho for now
// // Stetho.initialize(Stetho.newInitializerBuilder(application)
// // .enableDumpapp(Stetho.defaultDumperPluginsProvider(application)).build());
// LumberYard lumberYard = LumberYard.getInstance(application);
// lumberYard.cleanUp();
// Timber.plant(lumberYard.tree());
// Timber.plant(new Timber.DebugTree());
// }
// }
// }
| import javax.inject.Singleton;
import android.content.Context;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.FlavourInitialiser;
import com.pacoworks.dereference.MainInitialiser;
import com.squareup.okhttp.OkHttpClient;
import dagger.Module;
import dagger.Provides; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies.modules;
@Module
public class ApplicationModule {
DereferenceApplication application;
public ApplicationModule(DereferenceApplication app) {
application = app;
}
@Provides
@Singleton
DereferenceApplication provideApplication() {
return application;
}
@Provides
@Singleton
Context provideContext() {
return application;
}
@Provides
@Singleton | // Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/whatever/java/com/pacoworks/dereference/FlavourInitialiser.java
// public class FlavourInitialiser {
// public FlavourInitialiser(DereferenceApplication application) {
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/MainInitialiser.java
// public class MainInitialiser {
// private final Application.ActivityLifecycleCallbacks initialiserCallbacks = new Application.ActivityLifecycleCallbacks() {
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// };
//
// public MainInitialiser(DereferenceApplication application, OkHttpClient okHttpClient) {
// application.registerActivityLifecycleCallbacks(initialiserCallbacks);
// LeakCanary.install(application);
// if (BuildConfig.DEBUG) {
// // FIXME no stetho for now
// // Stetho.initialize(Stetho.newInitializerBuilder(application)
// // .enableDumpapp(Stetho.defaultDumperPluginsProvider(application)).build());
// LumberYard lumberYard = LumberYard.getInstance(application);
// lumberYard.cleanUp();
// Timber.plant(lumberYard.tree());
// Timber.plant(new Timber.DebugTree());
// }
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/modules/ApplicationModule.java
import javax.inject.Singleton;
import android.content.Context;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.FlavourInitialiser;
import com.pacoworks.dereference.MainInitialiser;
import com.squareup.okhttp.OkHttpClient;
import dagger.Module;
import dagger.Provides;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies.modules;
@Module
public class ApplicationModule {
DereferenceApplication application;
public ApplicationModule(DereferenceApplication app) {
application = app;
}
@Provides
@Singleton
DereferenceApplication provideApplication() {
return application;
}
@Provides
@Singleton
Context provideContext() {
return application;
}
@Provides
@Singleton | MainInitialiser provideMainInitialiser(DereferenceApplication application, |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/dependencies/modules/ApplicationModule.java | // Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/whatever/java/com/pacoworks/dereference/FlavourInitialiser.java
// public class FlavourInitialiser {
// public FlavourInitialiser(DereferenceApplication application) {
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/MainInitialiser.java
// public class MainInitialiser {
// private final Application.ActivityLifecycleCallbacks initialiserCallbacks = new Application.ActivityLifecycleCallbacks() {
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// };
//
// public MainInitialiser(DereferenceApplication application, OkHttpClient okHttpClient) {
// application.registerActivityLifecycleCallbacks(initialiserCallbacks);
// LeakCanary.install(application);
// if (BuildConfig.DEBUG) {
// // FIXME no stetho for now
// // Stetho.initialize(Stetho.newInitializerBuilder(application)
// // .enableDumpapp(Stetho.defaultDumperPluginsProvider(application)).build());
// LumberYard lumberYard = LumberYard.getInstance(application);
// lumberYard.cleanUp();
// Timber.plant(lumberYard.tree());
// Timber.plant(new Timber.DebugTree());
// }
// }
// }
| import javax.inject.Singleton;
import android.content.Context;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.FlavourInitialiser;
import com.pacoworks.dereference.MainInitialiser;
import com.squareup.okhttp.OkHttpClient;
import dagger.Module;
import dagger.Provides; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies.modules;
@Module
public class ApplicationModule {
DereferenceApplication application;
public ApplicationModule(DereferenceApplication app) {
application = app;
}
@Provides
@Singleton
DereferenceApplication provideApplication() {
return application;
}
@Provides
@Singleton
Context provideContext() {
return application;
}
@Provides
@Singleton
MainInitialiser provideMainInitialiser(DereferenceApplication application,
OkHttpClient okHttpClient) {
return new MainInitialiser(application, okHttpClient);
}
@Provides
@Singleton | // Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/whatever/java/com/pacoworks/dereference/FlavourInitialiser.java
// public class FlavourInitialiser {
// public FlavourInitialiser(DereferenceApplication application) {
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/MainInitialiser.java
// public class MainInitialiser {
// private final Application.ActivityLifecycleCallbacks initialiserCallbacks = new Application.ActivityLifecycleCallbacks() {
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// };
//
// public MainInitialiser(DereferenceApplication application, OkHttpClient okHttpClient) {
// application.registerActivityLifecycleCallbacks(initialiserCallbacks);
// LeakCanary.install(application);
// if (BuildConfig.DEBUG) {
// // FIXME no stetho for now
// // Stetho.initialize(Stetho.newInitializerBuilder(application)
// // .enableDumpapp(Stetho.defaultDumperPluginsProvider(application)).build());
// LumberYard lumberYard = LumberYard.getInstance(application);
// lumberYard.cleanUp();
// Timber.plant(lumberYard.tree());
// Timber.plant(new Timber.DebugTree());
// }
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/modules/ApplicationModule.java
import javax.inject.Singleton;
import android.content.Context;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.FlavourInitialiser;
import com.pacoworks.dereference.MainInitialiser;
import com.squareup.okhttp.OkHttpClient;
import dagger.Module;
import dagger.Provides;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies.modules;
@Module
public class ApplicationModule {
DereferenceApplication application;
public ApplicationModule(DereferenceApplication app) {
application = app;
}
@Provides
@Singleton
DereferenceApplication provideApplication() {
return application;
}
@Provides
@Singleton
Context provideContext() {
return application;
}
@Provides
@Singleton
MainInitialiser provideMainInitialiser(DereferenceApplication application,
OkHttpClient okHttpClient) {
return new MainInitialiser(application, okHttpClient);
}
@Provides
@Singleton | FlavourInitialiser provideFlavourInitialiser(DereferenceApplication application) { |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/screens/songkickdetails/SongkickDetailsState.java | // Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimpleBaseState.java
// public abstract class ZimpleBaseState implements Serializable {
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.pacoworks.dereference.dependencies.skeleton.ZimpleBaseState;
import com.pacoworks.dereference.model.Artist; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkickdetails;
@Data
@EqualsAndHashCode(callSuper = false) | // Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimpleBaseState.java
// public abstract class ZimpleBaseState implements Serializable {
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/screens/songkickdetails/SongkickDetailsState.java
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.pacoworks.dereference.dependencies.skeleton.ZimpleBaseState;
import com.pacoworks.dereference.model.Artist;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkickdetails;
@Data
@EqualsAndHashCode(callSuper = false) | public class SongkickDetailsState extends ZimpleBaseState { |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/screens/songkickdetails/SongkickDetailsState.java | // Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimpleBaseState.java
// public abstract class ZimpleBaseState implements Serializable {
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.pacoworks.dereference.dependencies.skeleton.ZimpleBaseState;
import com.pacoworks.dereference.model.Artist; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkickdetails;
@Data
@EqualsAndHashCode(callSuper = false)
public class SongkickDetailsState extends ZimpleBaseState { | // Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimpleBaseState.java
// public abstract class ZimpleBaseState implements Serializable {
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/screens/songkickdetails/SongkickDetailsState.java
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.pacoworks.dereference.dependencies.skeleton.ZimpleBaseState;
import com.pacoworks.dereference.model.Artist;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkickdetails;
@Data
@EqualsAndHashCode(callSuper = false)
public class SongkickDetailsState extends ZimpleBaseState { | private List<Artist> cached; |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/screens/songkicklist/ISongkickListUI.java | // Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/IUi.java
// public interface IUi {
// Action1<? super Boolean> showOfflineOverlay();
//
// Action1<Throwable> toastError();
//
// Action1<String> toastMessage();
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
| import java.util.List;
import rx.Observable;
import rx.functions.Action1;
import com.pacoworks.dereference.dependencies.skeleton.IUi;
import com.pacoworks.dereference.model.Artist; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkicklist;
public interface ISongkickListUI extends IUi {
<T> Action1<T> showLoading();
<T> Action1<T> hideLoading();
| // Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/IUi.java
// public interface IUi {
// Action1<? super Boolean> showOfflineOverlay();
//
// Action1<Throwable> toastError();
//
// Action1<String> toastMessage();
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/screens/songkicklist/ISongkickListUI.java
import java.util.List;
import rx.Observable;
import rx.functions.Action1;
import com.pacoworks.dereference.dependencies.skeleton.IUi;
import com.pacoworks.dereference.model.Artist;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkicklist;
public interface ISongkickListUI extends IUi {
<T> Action1<T> showLoading();
<T> Action1<T> hideLoading();
| Observable<Artist> getArtistClicks(); |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/screens/songkicklist/SongkickListInjectionComponent.java | // Path: app/src/whatever/java/com/pacoworks/dereference/ApplicationInjectionComponent.java
// @Singleton
// @Component(modules = {
// ApplicationModule.class, SerializationModule.class, NetworkModule.class
// })
// public interface ApplicationInjectionComponent extends DependencyDescription {
// final class Initializer {
// /* 10 MiB */
// private static final long CACHE_SIZE = 10 * 1024 * 1024;
//
// private Initializer() {
// /* No instances. */
// }
//
// static ApplicationInjectionComponent init(DereferenceApplication app) {
// return DaggerApplicationInjectionComponent
// .builder()
// .applicationModule(new ApplicationModule(app))
// .serializationModule(new SerializationModule())
// .networkModule(
// new NetworkModule(BuildConfig.ENDPOINT, app.getCacheDir(), CACHE_SIZE))
// .build();
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/ActivityInjectionComponent.java
// public interface ActivityInjectionComponent<T extends ZimplBasePresenter> {
// void inject(T presenter);
//
// void inject(ZimplBaseActivity activity);
//
// Activity activity();
//
// ZimplBasePresenter presenter();
//
// Picasso picasso();
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/modules/ActivityModule.java
// @Module
// public class ActivityModule {
// private final Activity activity;
//
// private final Downloader okHttpDownloader;
//
// public ActivityModule(Activity activity, Downloader okHttpDownloader) {
// this.activity = activity;
// this.okHttpDownloader = okHttpDownloader;
// }
//
// @Provides
// @ForActivity
// Activity provideActivity() {
// return activity;
// }
//
// @Provides
// @ForActivity
// Picasso providePicasso() {
// return new Picasso.Builder(activity).downloader(okHttpDownloader).build();
// }
//
// @Provides
// @ForActivity
// Observable<ConnectivityStatus> provideReactiveNetwork() {
// return new ReactiveNetwork().observeConnectivity(activity);
// }
// }
| import com.pacoworks.dereference.ApplicationInjectionComponent;
import com.pacoworks.dereference.dependencies.ActivityInjectionComponent;
import com.pacoworks.dereference.dependencies.ForActivity;
import com.pacoworks.dereference.dependencies.modules.ActivityModule;
import dagger.Component; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkicklist;
@ForActivity
@Component(dependencies = ApplicationInjectionComponent.class, modules = { | // Path: app/src/whatever/java/com/pacoworks/dereference/ApplicationInjectionComponent.java
// @Singleton
// @Component(modules = {
// ApplicationModule.class, SerializationModule.class, NetworkModule.class
// })
// public interface ApplicationInjectionComponent extends DependencyDescription {
// final class Initializer {
// /* 10 MiB */
// private static final long CACHE_SIZE = 10 * 1024 * 1024;
//
// private Initializer() {
// /* No instances. */
// }
//
// static ApplicationInjectionComponent init(DereferenceApplication app) {
// return DaggerApplicationInjectionComponent
// .builder()
// .applicationModule(new ApplicationModule(app))
// .serializationModule(new SerializationModule())
// .networkModule(
// new NetworkModule(BuildConfig.ENDPOINT, app.getCacheDir(), CACHE_SIZE))
// .build();
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/ActivityInjectionComponent.java
// public interface ActivityInjectionComponent<T extends ZimplBasePresenter> {
// void inject(T presenter);
//
// void inject(ZimplBaseActivity activity);
//
// Activity activity();
//
// ZimplBasePresenter presenter();
//
// Picasso picasso();
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/modules/ActivityModule.java
// @Module
// public class ActivityModule {
// private final Activity activity;
//
// private final Downloader okHttpDownloader;
//
// public ActivityModule(Activity activity, Downloader okHttpDownloader) {
// this.activity = activity;
// this.okHttpDownloader = okHttpDownloader;
// }
//
// @Provides
// @ForActivity
// Activity provideActivity() {
// return activity;
// }
//
// @Provides
// @ForActivity
// Picasso providePicasso() {
// return new Picasso.Builder(activity).downloader(okHttpDownloader).build();
// }
//
// @Provides
// @ForActivity
// Observable<ConnectivityStatus> provideReactiveNetwork() {
// return new ReactiveNetwork().observeConnectivity(activity);
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/screens/songkicklist/SongkickListInjectionComponent.java
import com.pacoworks.dereference.ApplicationInjectionComponent;
import com.pacoworks.dereference.dependencies.ActivityInjectionComponent;
import com.pacoworks.dereference.dependencies.ForActivity;
import com.pacoworks.dereference.dependencies.modules.ActivityModule;
import dagger.Component;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkicklist;
@ForActivity
@Component(dependencies = ApplicationInjectionComponent.class, modules = { | ActivityModule.class, SongkickListModule.class |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/screens/songkicklist/SongkickListInjectionComponent.java | // Path: app/src/whatever/java/com/pacoworks/dereference/ApplicationInjectionComponent.java
// @Singleton
// @Component(modules = {
// ApplicationModule.class, SerializationModule.class, NetworkModule.class
// })
// public interface ApplicationInjectionComponent extends DependencyDescription {
// final class Initializer {
// /* 10 MiB */
// private static final long CACHE_SIZE = 10 * 1024 * 1024;
//
// private Initializer() {
// /* No instances. */
// }
//
// static ApplicationInjectionComponent init(DereferenceApplication app) {
// return DaggerApplicationInjectionComponent
// .builder()
// .applicationModule(new ApplicationModule(app))
// .serializationModule(new SerializationModule())
// .networkModule(
// new NetworkModule(BuildConfig.ENDPOINT, app.getCacheDir(), CACHE_SIZE))
// .build();
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/ActivityInjectionComponent.java
// public interface ActivityInjectionComponent<T extends ZimplBasePresenter> {
// void inject(T presenter);
//
// void inject(ZimplBaseActivity activity);
//
// Activity activity();
//
// ZimplBasePresenter presenter();
//
// Picasso picasso();
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/modules/ActivityModule.java
// @Module
// public class ActivityModule {
// private final Activity activity;
//
// private final Downloader okHttpDownloader;
//
// public ActivityModule(Activity activity, Downloader okHttpDownloader) {
// this.activity = activity;
// this.okHttpDownloader = okHttpDownloader;
// }
//
// @Provides
// @ForActivity
// Activity provideActivity() {
// return activity;
// }
//
// @Provides
// @ForActivity
// Picasso providePicasso() {
// return new Picasso.Builder(activity).downloader(okHttpDownloader).build();
// }
//
// @Provides
// @ForActivity
// Observable<ConnectivityStatus> provideReactiveNetwork() {
// return new ReactiveNetwork().observeConnectivity(activity);
// }
// }
| import com.pacoworks.dereference.ApplicationInjectionComponent;
import com.pacoworks.dereference.dependencies.ActivityInjectionComponent;
import com.pacoworks.dereference.dependencies.ForActivity;
import com.pacoworks.dereference.dependencies.modules.ActivityModule;
import dagger.Component; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkicklist;
@ForActivity
@Component(dependencies = ApplicationInjectionComponent.class, modules = {
ActivityModule.class, SongkickListModule.class
})
public interface SongkickListInjectionComponent extends | // Path: app/src/whatever/java/com/pacoworks/dereference/ApplicationInjectionComponent.java
// @Singleton
// @Component(modules = {
// ApplicationModule.class, SerializationModule.class, NetworkModule.class
// })
// public interface ApplicationInjectionComponent extends DependencyDescription {
// final class Initializer {
// /* 10 MiB */
// private static final long CACHE_SIZE = 10 * 1024 * 1024;
//
// private Initializer() {
// /* No instances. */
// }
//
// static ApplicationInjectionComponent init(DereferenceApplication app) {
// return DaggerApplicationInjectionComponent
// .builder()
// .applicationModule(new ApplicationModule(app))
// .serializationModule(new SerializationModule())
// .networkModule(
// new NetworkModule(BuildConfig.ENDPOINT, app.getCacheDir(), CACHE_SIZE))
// .build();
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/ActivityInjectionComponent.java
// public interface ActivityInjectionComponent<T extends ZimplBasePresenter> {
// void inject(T presenter);
//
// void inject(ZimplBaseActivity activity);
//
// Activity activity();
//
// ZimplBasePresenter presenter();
//
// Picasso picasso();
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/modules/ActivityModule.java
// @Module
// public class ActivityModule {
// private final Activity activity;
//
// private final Downloader okHttpDownloader;
//
// public ActivityModule(Activity activity, Downloader okHttpDownloader) {
// this.activity = activity;
// this.okHttpDownloader = okHttpDownloader;
// }
//
// @Provides
// @ForActivity
// Activity provideActivity() {
// return activity;
// }
//
// @Provides
// @ForActivity
// Picasso providePicasso() {
// return new Picasso.Builder(activity).downloader(okHttpDownloader).build();
// }
//
// @Provides
// @ForActivity
// Observable<ConnectivityStatus> provideReactiveNetwork() {
// return new ReactiveNetwork().observeConnectivity(activity);
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/screens/songkicklist/SongkickListInjectionComponent.java
import com.pacoworks.dereference.ApplicationInjectionComponent;
import com.pacoworks.dereference.dependencies.ActivityInjectionComponent;
import com.pacoworks.dereference.dependencies.ForActivity;
import com.pacoworks.dereference.dependencies.modules.ActivityModule;
import dagger.Component;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkicklist;
@ForActivity
@Component(dependencies = ApplicationInjectionComponent.class, modules = {
ActivityModule.class, SongkickListModule.class
})
public interface SongkickListInjectionComponent extends | ActivityInjectionComponent<SongkickListPresenter> { |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/screens/songkicklist/SongkickListState.java | // Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimpleBaseState.java
// public abstract class ZimpleBaseState implements Serializable {
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.pacoworks.dereference.dependencies.skeleton.ZimpleBaseState;
import com.pacoworks.dereference.model.Artist; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkicklist;
@EqualsAndHashCode(callSuper = false)
@Data | // Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimpleBaseState.java
// public abstract class ZimpleBaseState implements Serializable {
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/screens/songkicklist/SongkickListState.java
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.pacoworks.dereference.dependencies.skeleton.ZimpleBaseState;
import com.pacoworks.dereference.model.Artist;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkicklist;
@EqualsAndHashCode(callSuper = false)
@Data | public class SongkickListState extends ZimpleBaseState { |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/screens/songkicklist/SongkickListState.java | // Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimpleBaseState.java
// public abstract class ZimpleBaseState implements Serializable {
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.pacoworks.dereference.dependencies.skeleton.ZimpleBaseState;
import com.pacoworks.dereference.model.Artist; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkicklist;
@EqualsAndHashCode(callSuper = false)
@Data
public class SongkickListState extends ZimpleBaseState { | // Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimpleBaseState.java
// public abstract class ZimpleBaseState implements Serializable {
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/screens/songkicklist/SongkickListState.java
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.pacoworks.dereference.dependencies.skeleton.ZimpleBaseState;
import com.pacoworks.dereference.model.Artist;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkicklist;
@EqualsAndHashCode(callSuper = false)
@Data
public class SongkickListState extends ZimpleBaseState { | private List<Artist> cached = new ArrayList<>(); |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/ui/delegates/RelatedArtistDelegate.java | // Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
| import java.util.List;
import android.support.annotation.NonNull;
import com.pacoworks.dereference.model.Artist; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.ui.delegates;
public class RelatedArtistDelegate extends ArtistDelegate {
public static final int TYPE = 98845;
@Override | // Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/ui/delegates/RelatedArtistDelegate.java
import java.util.List;
import android.support.annotation.NonNull;
import com.pacoworks.dereference.model.Artist;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.ui.delegates;
public class RelatedArtistDelegate extends ArtistDelegate {
public static final int TYPE = 98845;
@Override | public boolean isForViewType(@NonNull List<Artist> items, int position) { |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/screens/songkicklist/SongkickListModule.java | // Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimplBasePresenter.java
// public abstract class ZimplBasePresenter<T extends IUi, U extends ZimpleBaseState> {
// private final Class<U> stateClass;
//
// private final List<Subscription> pauseSubscriptions = new ArrayList<>();
//
// private final List<Subscription> destroySubscriptions = new ArrayList<>();
//
// @Inject
// @Getter(AccessLevel.PROTECTED)
// Gson gson;
//
// @Getter(AccessLevel.PROTECTED)
// private T ui;
//
// @Getter(AccessLevel.PROTECTED)
// private U state;
//
// public ZimplBasePresenter(Class<U> stateClass) {
// this.stateClass = stateClass;
// }
//
// // DEPENDENCY BINDING METHODS
// final void bindUi(T activity) {
// ui = activity;
// }
//
// final void unbindUi() {
// ui = null;
// }
//
// final void restoreState(String restoredState) {
// if (restoredState == null || restoredState.isEmpty()) {
// state = createNewState();
// } else {
// state = gson.fromJson(restoredState, stateClass);
// }
// }
//
// final String saveState() {
// return gson.toJson(state);
// }
//
// // LIFECYCLE
// final void createBase() {
// create();
// }
//
// final void resumeBase() {
// resume();
// }
//
// final void pauseBase() {
// unsubscribeAll(pauseSubscriptions);
// pause();
// }
//
// final void destroyBase() {
// unsubscribeAll(destroySubscriptions);
// destroy();
// }
//
// private void unsubscribeAll(List<Subscription> subscriptions) {
// for (Subscription subscription : subscriptions) {
// subscription.unsubscribe();
// }
// subscriptions.clear();
// }
//
// // PUBLIC API
// public void bindUntilPause(Subscription... subscriptions) {
// if (null != subscriptions) {
// Collections.addAll(pauseSubscriptions, subscriptions);
// }
// }
//
// public void bindUntilDestroy(Subscription... subscriptions) {
// if (null != subscriptions) {
// Collections.addAll(destroySubscriptions, subscriptions);
// }
// }
//
// // ABSTRACTS
// protected abstract U createNewState();
//
// public abstract void create();
//
// public abstract void resume();
//
// public abstract void pause();
//
// public abstract void destroy();
// }
| import com.pacoworks.dereference.dependencies.skeleton.ZimplBasePresenter;
import dagger.Module;
import dagger.Provides; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkicklist;
@Module
public class SongkickListModule {
@Provides | // Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimplBasePresenter.java
// public abstract class ZimplBasePresenter<T extends IUi, U extends ZimpleBaseState> {
// private final Class<U> stateClass;
//
// private final List<Subscription> pauseSubscriptions = new ArrayList<>();
//
// private final List<Subscription> destroySubscriptions = new ArrayList<>();
//
// @Inject
// @Getter(AccessLevel.PROTECTED)
// Gson gson;
//
// @Getter(AccessLevel.PROTECTED)
// private T ui;
//
// @Getter(AccessLevel.PROTECTED)
// private U state;
//
// public ZimplBasePresenter(Class<U> stateClass) {
// this.stateClass = stateClass;
// }
//
// // DEPENDENCY BINDING METHODS
// final void bindUi(T activity) {
// ui = activity;
// }
//
// final void unbindUi() {
// ui = null;
// }
//
// final void restoreState(String restoredState) {
// if (restoredState == null || restoredState.isEmpty()) {
// state = createNewState();
// } else {
// state = gson.fromJson(restoredState, stateClass);
// }
// }
//
// final String saveState() {
// return gson.toJson(state);
// }
//
// // LIFECYCLE
// final void createBase() {
// create();
// }
//
// final void resumeBase() {
// resume();
// }
//
// final void pauseBase() {
// unsubscribeAll(pauseSubscriptions);
// pause();
// }
//
// final void destroyBase() {
// unsubscribeAll(destroySubscriptions);
// destroy();
// }
//
// private void unsubscribeAll(List<Subscription> subscriptions) {
// for (Subscription subscription : subscriptions) {
// subscription.unsubscribe();
// }
// subscriptions.clear();
// }
//
// // PUBLIC API
// public void bindUntilPause(Subscription... subscriptions) {
// if (null != subscriptions) {
// Collections.addAll(pauseSubscriptions, subscriptions);
// }
// }
//
// public void bindUntilDestroy(Subscription... subscriptions) {
// if (null != subscriptions) {
// Collections.addAll(destroySubscriptions, subscriptions);
// }
// }
//
// // ABSTRACTS
// protected abstract U createNewState();
//
// public abstract void create();
//
// public abstract void resume();
//
// public abstract void pause();
//
// public abstract void destroy();
// }
// Path: app/src/main/java/com/pacoworks/dereference/screens/songkicklist/SongkickListModule.java
import com.pacoworks.dereference.dependencies.skeleton.ZimplBasePresenter;
import dagger.Module;
import dagger.Provides;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkicklist;
@Module
public class SongkickListModule {
@Provides | ZimplBasePresenter providePresenter() { |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/dependencies/DependencyDescription.java | // Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/whatever/java/com/pacoworks/dereference/FlavourInitialiser.java
// public class FlavourInitialiser {
// public FlavourInitialiser(DereferenceApplication application) {
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/MainInitialiser.java
// public class MainInitialiser {
// private final Application.ActivityLifecycleCallbacks initialiserCallbacks = new Application.ActivityLifecycleCallbacks() {
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// };
//
// public MainInitialiser(DereferenceApplication application, OkHttpClient okHttpClient) {
// application.registerActivityLifecycleCallbacks(initialiserCallbacks);
// LeakCanary.install(application);
// if (BuildConfig.DEBUG) {
// // FIXME no stetho for now
// // Stetho.initialize(Stetho.newInitializerBuilder(application)
// // .enableDumpapp(Stetho.defaultDumperPluginsProvider(application)).build());
// LumberYard lumberYard = LumberYard.getInstance(application);
// lumberYard.cleanUp();
// Timber.plant(lumberYard.tree());
// Timber.plant(new Timber.DebugTree());
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/network/SongkickApi.java
// public interface SongkickApi {
// @GET("search/artists.json")
// Observable<SearchResult> getSearchResult(@Query("apikey") String apikey,
// @Query("query") String url);
//
// @GET("artists/{artist_id}/similar_artists.json")
// Observable<SearchResult> getRelatedArtists(@Path("artist_id") String artistId,
// @Query("apikey") String apikey);
// }
| import com.squareup.picasso.OkHttpDownloader;
import javax.inject.Named;
import retrofit.Retrofit;
import android.content.Context;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.FlavourInitialiser;
import com.pacoworks.dereference.MainInitialiser;
import com.pacoworks.dereference.network.SongkickApi;
import com.squareup.okhttp.OkHttpClient; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies;
public interface DependencyDescription {
void inject(DereferenceApplication application);
DereferenceApplication application();
Context baseContext();
| // Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/whatever/java/com/pacoworks/dereference/FlavourInitialiser.java
// public class FlavourInitialiser {
// public FlavourInitialiser(DereferenceApplication application) {
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/MainInitialiser.java
// public class MainInitialiser {
// private final Application.ActivityLifecycleCallbacks initialiserCallbacks = new Application.ActivityLifecycleCallbacks() {
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// };
//
// public MainInitialiser(DereferenceApplication application, OkHttpClient okHttpClient) {
// application.registerActivityLifecycleCallbacks(initialiserCallbacks);
// LeakCanary.install(application);
// if (BuildConfig.DEBUG) {
// // FIXME no stetho for now
// // Stetho.initialize(Stetho.newInitializerBuilder(application)
// // .enableDumpapp(Stetho.defaultDumperPluginsProvider(application)).build());
// LumberYard lumberYard = LumberYard.getInstance(application);
// lumberYard.cleanUp();
// Timber.plant(lumberYard.tree());
// Timber.plant(new Timber.DebugTree());
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/network/SongkickApi.java
// public interface SongkickApi {
// @GET("search/artists.json")
// Observable<SearchResult> getSearchResult(@Query("apikey") String apikey,
// @Query("query") String url);
//
// @GET("artists/{artist_id}/similar_artists.json")
// Observable<SearchResult> getRelatedArtists(@Path("artist_id") String artistId,
// @Query("apikey") String apikey);
// }
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/DependencyDescription.java
import com.squareup.picasso.OkHttpDownloader;
import javax.inject.Named;
import retrofit.Retrofit;
import android.content.Context;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.FlavourInitialiser;
import com.pacoworks.dereference.MainInitialiser;
import com.pacoworks.dereference.network.SongkickApi;
import com.squareup.okhttp.OkHttpClient;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies;
public interface DependencyDescription {
void inject(DereferenceApplication application);
DereferenceApplication application();
Context baseContext();
| MainInitialiser initialiser(); |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/dependencies/DependencyDescription.java | // Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/whatever/java/com/pacoworks/dereference/FlavourInitialiser.java
// public class FlavourInitialiser {
// public FlavourInitialiser(DereferenceApplication application) {
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/MainInitialiser.java
// public class MainInitialiser {
// private final Application.ActivityLifecycleCallbacks initialiserCallbacks = new Application.ActivityLifecycleCallbacks() {
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// };
//
// public MainInitialiser(DereferenceApplication application, OkHttpClient okHttpClient) {
// application.registerActivityLifecycleCallbacks(initialiserCallbacks);
// LeakCanary.install(application);
// if (BuildConfig.DEBUG) {
// // FIXME no stetho for now
// // Stetho.initialize(Stetho.newInitializerBuilder(application)
// // .enableDumpapp(Stetho.defaultDumperPluginsProvider(application)).build());
// LumberYard lumberYard = LumberYard.getInstance(application);
// lumberYard.cleanUp();
// Timber.plant(lumberYard.tree());
// Timber.plant(new Timber.DebugTree());
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/network/SongkickApi.java
// public interface SongkickApi {
// @GET("search/artists.json")
// Observable<SearchResult> getSearchResult(@Query("apikey") String apikey,
// @Query("query") String url);
//
// @GET("artists/{artist_id}/similar_artists.json")
// Observable<SearchResult> getRelatedArtists(@Path("artist_id") String artistId,
// @Query("apikey") String apikey);
// }
| import com.squareup.picasso.OkHttpDownloader;
import javax.inject.Named;
import retrofit.Retrofit;
import android.content.Context;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.FlavourInitialiser;
import com.pacoworks.dereference.MainInitialiser;
import com.pacoworks.dereference.network.SongkickApi;
import com.squareup.okhttp.OkHttpClient; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies;
public interface DependencyDescription {
void inject(DereferenceApplication application);
DereferenceApplication application();
Context baseContext();
MainInitialiser initialiser();
| // Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/whatever/java/com/pacoworks/dereference/FlavourInitialiser.java
// public class FlavourInitialiser {
// public FlavourInitialiser(DereferenceApplication application) {
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/MainInitialiser.java
// public class MainInitialiser {
// private final Application.ActivityLifecycleCallbacks initialiserCallbacks = new Application.ActivityLifecycleCallbacks() {
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// };
//
// public MainInitialiser(DereferenceApplication application, OkHttpClient okHttpClient) {
// application.registerActivityLifecycleCallbacks(initialiserCallbacks);
// LeakCanary.install(application);
// if (BuildConfig.DEBUG) {
// // FIXME no stetho for now
// // Stetho.initialize(Stetho.newInitializerBuilder(application)
// // .enableDumpapp(Stetho.defaultDumperPluginsProvider(application)).build());
// LumberYard lumberYard = LumberYard.getInstance(application);
// lumberYard.cleanUp();
// Timber.plant(lumberYard.tree());
// Timber.plant(new Timber.DebugTree());
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/network/SongkickApi.java
// public interface SongkickApi {
// @GET("search/artists.json")
// Observable<SearchResult> getSearchResult(@Query("apikey") String apikey,
// @Query("query") String url);
//
// @GET("artists/{artist_id}/similar_artists.json")
// Observable<SearchResult> getRelatedArtists(@Path("artist_id") String artistId,
// @Query("apikey") String apikey);
// }
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/DependencyDescription.java
import com.squareup.picasso.OkHttpDownloader;
import javax.inject.Named;
import retrofit.Retrofit;
import android.content.Context;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.FlavourInitialiser;
import com.pacoworks.dereference.MainInitialiser;
import com.pacoworks.dereference.network.SongkickApi;
import com.squareup.okhttp.OkHttpClient;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies;
public interface DependencyDescription {
void inject(DereferenceApplication application);
DereferenceApplication application();
Context baseContext();
MainInitialiser initialiser();
| FlavourInitialiser flavourInitialiser(); |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/dependencies/DependencyDescription.java | // Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/whatever/java/com/pacoworks/dereference/FlavourInitialiser.java
// public class FlavourInitialiser {
// public FlavourInitialiser(DereferenceApplication application) {
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/MainInitialiser.java
// public class MainInitialiser {
// private final Application.ActivityLifecycleCallbacks initialiserCallbacks = new Application.ActivityLifecycleCallbacks() {
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// };
//
// public MainInitialiser(DereferenceApplication application, OkHttpClient okHttpClient) {
// application.registerActivityLifecycleCallbacks(initialiserCallbacks);
// LeakCanary.install(application);
// if (BuildConfig.DEBUG) {
// // FIXME no stetho for now
// // Stetho.initialize(Stetho.newInitializerBuilder(application)
// // .enableDumpapp(Stetho.defaultDumperPluginsProvider(application)).build());
// LumberYard lumberYard = LumberYard.getInstance(application);
// lumberYard.cleanUp();
// Timber.plant(lumberYard.tree());
// Timber.plant(new Timber.DebugTree());
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/network/SongkickApi.java
// public interface SongkickApi {
// @GET("search/artists.json")
// Observable<SearchResult> getSearchResult(@Query("apikey") String apikey,
// @Query("query") String url);
//
// @GET("artists/{artist_id}/similar_artists.json")
// Observable<SearchResult> getRelatedArtists(@Path("artist_id") String artistId,
// @Query("apikey") String apikey);
// }
| import com.squareup.picasso.OkHttpDownloader;
import javax.inject.Named;
import retrofit.Retrofit;
import android.content.Context;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.FlavourInitialiser;
import com.pacoworks.dereference.MainInitialiser;
import com.pacoworks.dereference.network.SongkickApi;
import com.squareup.okhttp.OkHttpClient; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies;
public interface DependencyDescription {
void inject(DereferenceApplication application);
DereferenceApplication application();
Context baseContext();
MainInitialiser initialiser();
FlavourInitialiser flavourInitialiser();
Gson gsonDefault();
@Named("default")
ObjectMapper jacksonDefault();
@Named("unknown")
ObjectMapper jacksonUnknown();
@Named("fields")
ObjectMapper jacksonFieldsOnly();
OkHttpClient okHttpClient();
OkHttpDownloader okHttpDownloader();
@Named("songkick")
Retrofit getSongkickRetrofit();
| // Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/whatever/java/com/pacoworks/dereference/FlavourInitialiser.java
// public class FlavourInitialiser {
// public FlavourInitialiser(DereferenceApplication application) {
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/MainInitialiser.java
// public class MainInitialiser {
// private final Application.ActivityLifecycleCallbacks initialiserCallbacks = new Application.ActivityLifecycleCallbacks() {
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// };
//
// public MainInitialiser(DereferenceApplication application, OkHttpClient okHttpClient) {
// application.registerActivityLifecycleCallbacks(initialiserCallbacks);
// LeakCanary.install(application);
// if (BuildConfig.DEBUG) {
// // FIXME no stetho for now
// // Stetho.initialize(Stetho.newInitializerBuilder(application)
// // .enableDumpapp(Stetho.defaultDumperPluginsProvider(application)).build());
// LumberYard lumberYard = LumberYard.getInstance(application);
// lumberYard.cleanUp();
// Timber.plant(lumberYard.tree());
// Timber.plant(new Timber.DebugTree());
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/network/SongkickApi.java
// public interface SongkickApi {
// @GET("search/artists.json")
// Observable<SearchResult> getSearchResult(@Query("apikey") String apikey,
// @Query("query") String url);
//
// @GET("artists/{artist_id}/similar_artists.json")
// Observable<SearchResult> getRelatedArtists(@Path("artist_id") String artistId,
// @Query("apikey") String apikey);
// }
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/DependencyDescription.java
import com.squareup.picasso.OkHttpDownloader;
import javax.inject.Named;
import retrofit.Retrofit;
import android.content.Context;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.FlavourInitialiser;
import com.pacoworks.dereference.MainInitialiser;
import com.pacoworks.dereference.network.SongkickApi;
import com.squareup.okhttp.OkHttpClient;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies;
public interface DependencyDescription {
void inject(DereferenceApplication application);
DereferenceApplication application();
Context baseContext();
MainInitialiser initialiser();
FlavourInitialiser flavourInitialiser();
Gson gsonDefault();
@Named("default")
ObjectMapper jacksonDefault();
@Named("unknown")
ObjectMapper jacksonUnknown();
@Named("fields")
ObjectMapper jacksonFieldsOnly();
OkHttpClient okHttpClient();
OkHttpDownloader okHttpDownloader();
@Named("songkick")
Retrofit getSongkickRetrofit();
| SongkickApi songkickApi(); |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/dependencies/modules/NetworkModule.java | // Path: app/src/main/java/com/pacoworks/dereference/network/LoggerInterceptor.java
// public class LoggerInterceptor implements Interceptor {
// @Override
// public Response intercept(Chain chain) throws IOException {
// Timber.d("Started request ==> %s", chain.request().url().toString());
// return chain.proceed(chain.request());
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/network/SongkickApi.java
// public interface SongkickApi {
// @GET("search/artists.json")
// Observable<SearchResult> getSearchResult(@Query("apikey") String apikey,
// @Query("query") String url);
//
// @GET("artists/{artist_id}/similar_artists.json")
// Observable<SearchResult> getRelatedArtists(@Path("artist_id") String artistId,
// @Query("apikey") String apikey);
// }
| import com.pacoworks.dereference.network.SongkickApi;
import com.squareup.okhttp.Cache;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.picasso.OkHttpDownloader;
import dagger.Module;
import dagger.Provides;
import java.io.File;
import java.util.concurrent.TimeUnit;
import javax.inject.Named;
import javax.inject.Singleton;
import retrofit.GsonConverterFactory;
import retrofit.Retrofit;
import retrofit.RxJavaCallAdapterFactory;
import com.facebook.stetho.okhttp.StethoInterceptor;
import com.google.gson.Gson;
import com.pacoworks.dereference.network.LoggerInterceptor; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies.modules;
@Module(includes = SerializationModule.class)
public class NetworkModule {
static final int DEFAULT_READ_TIMEOUT_MILLIS = 20 * 1000; // 20s
static final int DEFAULT_WRITE_TIMEOUT_MILLIS = 20 * 1000; // 20s
static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = 15 * 1000; // 15s
private final String endpointUrl;
private final long cacheSize;
private File cacheDir;
public NetworkModule(String endpointUrl, File cacheDir, long cacheSize) {
this.cacheDir = cacheDir;
this.endpointUrl = endpointUrl;
this.cacheSize = cacheSize;
}
@Provides
@Singleton | // Path: app/src/main/java/com/pacoworks/dereference/network/LoggerInterceptor.java
// public class LoggerInterceptor implements Interceptor {
// @Override
// public Response intercept(Chain chain) throws IOException {
// Timber.d("Started request ==> %s", chain.request().url().toString());
// return chain.proceed(chain.request());
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/network/SongkickApi.java
// public interface SongkickApi {
// @GET("search/artists.json")
// Observable<SearchResult> getSearchResult(@Query("apikey") String apikey,
// @Query("query") String url);
//
// @GET("artists/{artist_id}/similar_artists.json")
// Observable<SearchResult> getRelatedArtists(@Path("artist_id") String artistId,
// @Query("apikey") String apikey);
// }
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/modules/NetworkModule.java
import com.pacoworks.dereference.network.SongkickApi;
import com.squareup.okhttp.Cache;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.picasso.OkHttpDownloader;
import dagger.Module;
import dagger.Provides;
import java.io.File;
import java.util.concurrent.TimeUnit;
import javax.inject.Named;
import javax.inject.Singleton;
import retrofit.GsonConverterFactory;
import retrofit.Retrofit;
import retrofit.RxJavaCallAdapterFactory;
import com.facebook.stetho.okhttp.StethoInterceptor;
import com.google.gson.Gson;
import com.pacoworks.dereference.network.LoggerInterceptor;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies.modules;
@Module(includes = SerializationModule.class)
public class NetworkModule {
static final int DEFAULT_READ_TIMEOUT_MILLIS = 20 * 1000; // 20s
static final int DEFAULT_WRITE_TIMEOUT_MILLIS = 20 * 1000; // 20s
static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = 15 * 1000; // 15s
private final String endpointUrl;
private final long cacheSize;
private File cacheDir;
public NetworkModule(String endpointUrl, File cacheDir, long cacheSize) {
this.cacheDir = cacheDir;
this.endpointUrl = endpointUrl;
this.cacheSize = cacheSize;
}
@Provides
@Singleton | OkHttpClient provideOkHttp(final Cache cache, LoggerInterceptor loggerInterceptor, |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/dependencies/modules/NetworkModule.java | // Path: app/src/main/java/com/pacoworks/dereference/network/LoggerInterceptor.java
// public class LoggerInterceptor implements Interceptor {
// @Override
// public Response intercept(Chain chain) throws IOException {
// Timber.d("Started request ==> %s", chain.request().url().toString());
// return chain.proceed(chain.request());
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/network/SongkickApi.java
// public interface SongkickApi {
// @GET("search/artists.json")
// Observable<SearchResult> getSearchResult(@Query("apikey") String apikey,
// @Query("query") String url);
//
// @GET("artists/{artist_id}/similar_artists.json")
// Observable<SearchResult> getRelatedArtists(@Path("artist_id") String artistId,
// @Query("apikey") String apikey);
// }
| import com.pacoworks.dereference.network.SongkickApi;
import com.squareup.okhttp.Cache;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.picasso.OkHttpDownloader;
import dagger.Module;
import dagger.Provides;
import java.io.File;
import java.util.concurrent.TimeUnit;
import javax.inject.Named;
import javax.inject.Singleton;
import retrofit.GsonConverterFactory;
import retrofit.Retrofit;
import retrofit.RxJavaCallAdapterFactory;
import com.facebook.stetho.okhttp.StethoInterceptor;
import com.google.gson.Gson;
import com.pacoworks.dereference.network.LoggerInterceptor; |
@Provides
@Singleton
Cache provideCache() {
return new Cache(cacheDir, cacheSize);
}
@Provides
@Singleton
StethoInterceptor stethoInterceptor() {
return new StethoInterceptor();
}
@Provides
@Singleton
LoggerInterceptor loggerInterceptor() {
return new LoggerInterceptor();
}
@Provides
@Named("songkick")
@Singleton
Retrofit provideRetrofitSongkick(OkHttpClient client, Gson gson) {
return new Retrofit.Builder().client(client).baseUrl(endpointUrl)
.addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJavaCallAdapterFactory.create()).build();
}
@Provides
@Singleton | // Path: app/src/main/java/com/pacoworks/dereference/network/LoggerInterceptor.java
// public class LoggerInterceptor implements Interceptor {
// @Override
// public Response intercept(Chain chain) throws IOException {
// Timber.d("Started request ==> %s", chain.request().url().toString());
// return chain.proceed(chain.request());
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/network/SongkickApi.java
// public interface SongkickApi {
// @GET("search/artists.json")
// Observable<SearchResult> getSearchResult(@Query("apikey") String apikey,
// @Query("query") String url);
//
// @GET("artists/{artist_id}/similar_artists.json")
// Observable<SearchResult> getRelatedArtists(@Path("artist_id") String artistId,
// @Query("apikey") String apikey);
// }
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/modules/NetworkModule.java
import com.pacoworks.dereference.network.SongkickApi;
import com.squareup.okhttp.Cache;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.picasso.OkHttpDownloader;
import dagger.Module;
import dagger.Provides;
import java.io.File;
import java.util.concurrent.TimeUnit;
import javax.inject.Named;
import javax.inject.Singleton;
import retrofit.GsonConverterFactory;
import retrofit.Retrofit;
import retrofit.RxJavaCallAdapterFactory;
import com.facebook.stetho.okhttp.StethoInterceptor;
import com.google.gson.Gson;
import com.pacoworks.dereference.network.LoggerInterceptor;
@Provides
@Singleton
Cache provideCache() {
return new Cache(cacheDir, cacheSize);
}
@Provides
@Singleton
StethoInterceptor stethoInterceptor() {
return new StethoInterceptor();
}
@Provides
@Singleton
LoggerInterceptor loggerInterceptor() {
return new LoggerInterceptor();
}
@Provides
@Named("songkick")
@Singleton
Retrofit provideRetrofitSongkick(OkHttpClient client, Gson gson) {
return new Retrofit.Builder().client(client).baseUrl(endpointUrl)
.addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJavaCallAdapterFactory.create()).build();
}
@Provides
@Singleton | SongkickApi provideSongkickApi(@Named("songkick") Retrofit retrofit) { |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/screens/songkickdetails/SongkickDetailsModule.java | // Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimplBasePresenter.java
// public abstract class ZimplBasePresenter<T extends IUi, U extends ZimpleBaseState> {
// private final Class<U> stateClass;
//
// private final List<Subscription> pauseSubscriptions = new ArrayList<>();
//
// private final List<Subscription> destroySubscriptions = new ArrayList<>();
//
// @Inject
// @Getter(AccessLevel.PROTECTED)
// Gson gson;
//
// @Getter(AccessLevel.PROTECTED)
// private T ui;
//
// @Getter(AccessLevel.PROTECTED)
// private U state;
//
// public ZimplBasePresenter(Class<U> stateClass) {
// this.stateClass = stateClass;
// }
//
// // DEPENDENCY BINDING METHODS
// final void bindUi(T activity) {
// ui = activity;
// }
//
// final void unbindUi() {
// ui = null;
// }
//
// final void restoreState(String restoredState) {
// if (restoredState == null || restoredState.isEmpty()) {
// state = createNewState();
// } else {
// state = gson.fromJson(restoredState, stateClass);
// }
// }
//
// final String saveState() {
// return gson.toJson(state);
// }
//
// // LIFECYCLE
// final void createBase() {
// create();
// }
//
// final void resumeBase() {
// resume();
// }
//
// final void pauseBase() {
// unsubscribeAll(pauseSubscriptions);
// pause();
// }
//
// final void destroyBase() {
// unsubscribeAll(destroySubscriptions);
// destroy();
// }
//
// private void unsubscribeAll(List<Subscription> subscriptions) {
// for (Subscription subscription : subscriptions) {
// subscription.unsubscribe();
// }
// subscriptions.clear();
// }
//
// // PUBLIC API
// public void bindUntilPause(Subscription... subscriptions) {
// if (null != subscriptions) {
// Collections.addAll(pauseSubscriptions, subscriptions);
// }
// }
//
// public void bindUntilDestroy(Subscription... subscriptions) {
// if (null != subscriptions) {
// Collections.addAll(destroySubscriptions, subscriptions);
// }
// }
//
// // ABSTRACTS
// protected abstract U createNewState();
//
// public abstract void create();
//
// public abstract void resume();
//
// public abstract void pause();
//
// public abstract void destroy();
// }
| import com.pacoworks.dereference.dependencies.skeleton.ZimplBasePresenter;
import dagger.Module;
import dagger.Provides; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkickdetails;
@Module
public class SongkickDetailsModule {
@Provides | // Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimplBasePresenter.java
// public abstract class ZimplBasePresenter<T extends IUi, U extends ZimpleBaseState> {
// private final Class<U> stateClass;
//
// private final List<Subscription> pauseSubscriptions = new ArrayList<>();
//
// private final List<Subscription> destroySubscriptions = new ArrayList<>();
//
// @Inject
// @Getter(AccessLevel.PROTECTED)
// Gson gson;
//
// @Getter(AccessLevel.PROTECTED)
// private T ui;
//
// @Getter(AccessLevel.PROTECTED)
// private U state;
//
// public ZimplBasePresenter(Class<U> stateClass) {
// this.stateClass = stateClass;
// }
//
// // DEPENDENCY BINDING METHODS
// final void bindUi(T activity) {
// ui = activity;
// }
//
// final void unbindUi() {
// ui = null;
// }
//
// final void restoreState(String restoredState) {
// if (restoredState == null || restoredState.isEmpty()) {
// state = createNewState();
// } else {
// state = gson.fromJson(restoredState, stateClass);
// }
// }
//
// final String saveState() {
// return gson.toJson(state);
// }
//
// // LIFECYCLE
// final void createBase() {
// create();
// }
//
// final void resumeBase() {
// resume();
// }
//
// final void pauseBase() {
// unsubscribeAll(pauseSubscriptions);
// pause();
// }
//
// final void destroyBase() {
// unsubscribeAll(destroySubscriptions);
// destroy();
// }
//
// private void unsubscribeAll(List<Subscription> subscriptions) {
// for (Subscription subscription : subscriptions) {
// subscription.unsubscribe();
// }
// subscriptions.clear();
// }
//
// // PUBLIC API
// public void bindUntilPause(Subscription... subscriptions) {
// if (null != subscriptions) {
// Collections.addAll(pauseSubscriptions, subscriptions);
// }
// }
//
// public void bindUntilDestroy(Subscription... subscriptions) {
// if (null != subscriptions) {
// Collections.addAll(destroySubscriptions, subscriptions);
// }
// }
//
// // ABSTRACTS
// protected abstract U createNewState();
//
// public abstract void create();
//
// public abstract void resume();
//
// public abstract void pause();
//
// public abstract void destroy();
// }
// Path: app/src/main/java/com/pacoworks/dereference/screens/songkickdetails/SongkickDetailsModule.java
import com.pacoworks.dereference.dependencies.skeleton.ZimplBasePresenter;
import dagger.Module;
import dagger.Provides;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkickdetails;
@Module
public class SongkickDetailsModule {
@Provides | ZimplBasePresenter providePresenter() { |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/screens/songkickdetails/ISongkickDetailsUI.java | // Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/IUi.java
// public interface IUi {
// Action1<? super Boolean> showOfflineOverlay();
//
// Action1<Throwable> toastError();
//
// Action1<String> toastMessage();
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
| import java.util.List;
import rx.Observable;
import rx.functions.Action1;
import com.pacoworks.dereference.dependencies.skeleton.IUi;
import com.pacoworks.dereference.model.Artist; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkickdetails;
public interface ISongkickDetailsUI extends IUi {
<T> Action1<T> showLoading();
<T> Action1<T> hideLoading();
| // Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/IUi.java
// public interface IUi {
// Action1<? super Boolean> showOfflineOverlay();
//
// Action1<Throwable> toastError();
//
// Action1<String> toastMessage();
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/screens/songkickdetails/ISongkickDetailsUI.java
import java.util.List;
import rx.Observable;
import rx.functions.Action1;
import com.pacoworks.dereference.dependencies.skeleton.IUi;
import com.pacoworks.dereference.model.Artist;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkickdetails;
public interface ISongkickDetailsUI extends IUi {
<T> Action1<T> showLoading();
<T> Action1<T> hideLoading();
| Action1<List<Artist>> swapAdapter(); |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/screens/songkickdetails/SongkickDetailsInjectionComponent.java | // Path: app/src/whatever/java/com/pacoworks/dereference/ApplicationInjectionComponent.java
// @Singleton
// @Component(modules = {
// ApplicationModule.class, SerializationModule.class, NetworkModule.class
// })
// public interface ApplicationInjectionComponent extends DependencyDescription {
// final class Initializer {
// /* 10 MiB */
// private static final long CACHE_SIZE = 10 * 1024 * 1024;
//
// private Initializer() {
// /* No instances. */
// }
//
// static ApplicationInjectionComponent init(DereferenceApplication app) {
// return DaggerApplicationInjectionComponent
// .builder()
// .applicationModule(new ApplicationModule(app))
// .serializationModule(new SerializationModule())
// .networkModule(
// new NetworkModule(BuildConfig.ENDPOINT, app.getCacheDir(), CACHE_SIZE))
// .build();
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/ActivityInjectionComponent.java
// public interface ActivityInjectionComponent<T extends ZimplBasePresenter> {
// void inject(T presenter);
//
// void inject(ZimplBaseActivity activity);
//
// Activity activity();
//
// ZimplBasePresenter presenter();
//
// Picasso picasso();
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/modules/ActivityModule.java
// @Module
// public class ActivityModule {
// private final Activity activity;
//
// private final Downloader okHttpDownloader;
//
// public ActivityModule(Activity activity, Downloader okHttpDownloader) {
// this.activity = activity;
// this.okHttpDownloader = okHttpDownloader;
// }
//
// @Provides
// @ForActivity
// Activity provideActivity() {
// return activity;
// }
//
// @Provides
// @ForActivity
// Picasso providePicasso() {
// return new Picasso.Builder(activity).downloader(okHttpDownloader).build();
// }
//
// @Provides
// @ForActivity
// Observable<ConnectivityStatus> provideReactiveNetwork() {
// return new ReactiveNetwork().observeConnectivity(activity);
// }
// }
| import com.pacoworks.dereference.ApplicationInjectionComponent;
import com.pacoworks.dereference.dependencies.ActivityInjectionComponent;
import com.pacoworks.dereference.dependencies.ForActivity;
import com.pacoworks.dereference.dependencies.modules.ActivityModule;
import dagger.Component; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkickdetails;
@ForActivity
@Component(dependencies = ApplicationInjectionComponent.class, modules = { | // Path: app/src/whatever/java/com/pacoworks/dereference/ApplicationInjectionComponent.java
// @Singleton
// @Component(modules = {
// ApplicationModule.class, SerializationModule.class, NetworkModule.class
// })
// public interface ApplicationInjectionComponent extends DependencyDescription {
// final class Initializer {
// /* 10 MiB */
// private static final long CACHE_SIZE = 10 * 1024 * 1024;
//
// private Initializer() {
// /* No instances. */
// }
//
// static ApplicationInjectionComponent init(DereferenceApplication app) {
// return DaggerApplicationInjectionComponent
// .builder()
// .applicationModule(new ApplicationModule(app))
// .serializationModule(new SerializationModule())
// .networkModule(
// new NetworkModule(BuildConfig.ENDPOINT, app.getCacheDir(), CACHE_SIZE))
// .build();
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/ActivityInjectionComponent.java
// public interface ActivityInjectionComponent<T extends ZimplBasePresenter> {
// void inject(T presenter);
//
// void inject(ZimplBaseActivity activity);
//
// Activity activity();
//
// ZimplBasePresenter presenter();
//
// Picasso picasso();
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/modules/ActivityModule.java
// @Module
// public class ActivityModule {
// private final Activity activity;
//
// private final Downloader okHttpDownloader;
//
// public ActivityModule(Activity activity, Downloader okHttpDownloader) {
// this.activity = activity;
// this.okHttpDownloader = okHttpDownloader;
// }
//
// @Provides
// @ForActivity
// Activity provideActivity() {
// return activity;
// }
//
// @Provides
// @ForActivity
// Picasso providePicasso() {
// return new Picasso.Builder(activity).downloader(okHttpDownloader).build();
// }
//
// @Provides
// @ForActivity
// Observable<ConnectivityStatus> provideReactiveNetwork() {
// return new ReactiveNetwork().observeConnectivity(activity);
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/screens/songkickdetails/SongkickDetailsInjectionComponent.java
import com.pacoworks.dereference.ApplicationInjectionComponent;
import com.pacoworks.dereference.dependencies.ActivityInjectionComponent;
import com.pacoworks.dereference.dependencies.ForActivity;
import com.pacoworks.dereference.dependencies.modules.ActivityModule;
import dagger.Component;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkickdetails;
@ForActivity
@Component(dependencies = ApplicationInjectionComponent.class, modules = { | ActivityModule.class, SongkickDetailsModule.class |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/screens/songkickdetails/SongkickDetailsInjectionComponent.java | // Path: app/src/whatever/java/com/pacoworks/dereference/ApplicationInjectionComponent.java
// @Singleton
// @Component(modules = {
// ApplicationModule.class, SerializationModule.class, NetworkModule.class
// })
// public interface ApplicationInjectionComponent extends DependencyDescription {
// final class Initializer {
// /* 10 MiB */
// private static final long CACHE_SIZE = 10 * 1024 * 1024;
//
// private Initializer() {
// /* No instances. */
// }
//
// static ApplicationInjectionComponent init(DereferenceApplication app) {
// return DaggerApplicationInjectionComponent
// .builder()
// .applicationModule(new ApplicationModule(app))
// .serializationModule(new SerializationModule())
// .networkModule(
// new NetworkModule(BuildConfig.ENDPOINT, app.getCacheDir(), CACHE_SIZE))
// .build();
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/ActivityInjectionComponent.java
// public interface ActivityInjectionComponent<T extends ZimplBasePresenter> {
// void inject(T presenter);
//
// void inject(ZimplBaseActivity activity);
//
// Activity activity();
//
// ZimplBasePresenter presenter();
//
// Picasso picasso();
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/modules/ActivityModule.java
// @Module
// public class ActivityModule {
// private final Activity activity;
//
// private final Downloader okHttpDownloader;
//
// public ActivityModule(Activity activity, Downloader okHttpDownloader) {
// this.activity = activity;
// this.okHttpDownloader = okHttpDownloader;
// }
//
// @Provides
// @ForActivity
// Activity provideActivity() {
// return activity;
// }
//
// @Provides
// @ForActivity
// Picasso providePicasso() {
// return new Picasso.Builder(activity).downloader(okHttpDownloader).build();
// }
//
// @Provides
// @ForActivity
// Observable<ConnectivityStatus> provideReactiveNetwork() {
// return new ReactiveNetwork().observeConnectivity(activity);
// }
// }
| import com.pacoworks.dereference.ApplicationInjectionComponent;
import com.pacoworks.dereference.dependencies.ActivityInjectionComponent;
import com.pacoworks.dereference.dependencies.ForActivity;
import com.pacoworks.dereference.dependencies.modules.ActivityModule;
import dagger.Component; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkickdetails;
@ForActivity
@Component(dependencies = ApplicationInjectionComponent.class, modules = {
ActivityModule.class, SongkickDetailsModule.class
})
public interface SongkickDetailsInjectionComponent extends | // Path: app/src/whatever/java/com/pacoworks/dereference/ApplicationInjectionComponent.java
// @Singleton
// @Component(modules = {
// ApplicationModule.class, SerializationModule.class, NetworkModule.class
// })
// public interface ApplicationInjectionComponent extends DependencyDescription {
// final class Initializer {
// /* 10 MiB */
// private static final long CACHE_SIZE = 10 * 1024 * 1024;
//
// private Initializer() {
// /* No instances. */
// }
//
// static ApplicationInjectionComponent init(DereferenceApplication app) {
// return DaggerApplicationInjectionComponent
// .builder()
// .applicationModule(new ApplicationModule(app))
// .serializationModule(new SerializationModule())
// .networkModule(
// new NetworkModule(BuildConfig.ENDPOINT, app.getCacheDir(), CACHE_SIZE))
// .build();
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/ActivityInjectionComponent.java
// public interface ActivityInjectionComponent<T extends ZimplBasePresenter> {
// void inject(T presenter);
//
// void inject(ZimplBaseActivity activity);
//
// Activity activity();
//
// ZimplBasePresenter presenter();
//
// Picasso picasso();
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/modules/ActivityModule.java
// @Module
// public class ActivityModule {
// private final Activity activity;
//
// private final Downloader okHttpDownloader;
//
// public ActivityModule(Activity activity, Downloader okHttpDownloader) {
// this.activity = activity;
// this.okHttpDownloader = okHttpDownloader;
// }
//
// @Provides
// @ForActivity
// Activity provideActivity() {
// return activity;
// }
//
// @Provides
// @ForActivity
// Picasso providePicasso() {
// return new Picasso.Builder(activity).downloader(okHttpDownloader).build();
// }
//
// @Provides
// @ForActivity
// Observable<ConnectivityStatus> provideReactiveNetwork() {
// return new ReactiveNetwork().observeConnectivity(activity);
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/screens/songkickdetails/SongkickDetailsInjectionComponent.java
import com.pacoworks.dereference.ApplicationInjectionComponent;
import com.pacoworks.dereference.dependencies.ActivityInjectionComponent;
import com.pacoworks.dereference.dependencies.ForActivity;
import com.pacoworks.dereference.dependencies.modules.ActivityModule;
import dagger.Component;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.screens.songkickdetails;
@ForActivity
@Component(dependencies = ApplicationInjectionComponent.class, modules = {
ActivityModule.class, SongkickDetailsModule.class
})
public interface SongkickDetailsInjectionComponent extends | ActivityInjectionComponent<SongkickDetailsPresenter> { |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/ui/adapters/ArtistListAdapter.java | // Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/ui/delegates/ArtistDelegate.java
// public class ArtistDelegate implements AdapterDelegate<List<Artist>> {
// public static final int TYPE = 48984;
//
// SerializedSubject<Artist, Artist> artistClicks = new SerializedSubject<>(
// PublishSubject.<Artist> create());
//
// @Override
// public int getItemViewType() {
// return TYPE;
// }
//
// @Override
// public boolean isForViewType(@NonNull List<Artist> items, int position) {
// return (0 != position || items.size() != 0);
// }
//
// @NonNull
// @Override
// public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent) {
// return new ArtistViewHolder(LayoutInflater.from(parent.getContext()).inflate(
// R.layout.element_artist, parent, false));
// }
//
// @Override
// public void onBindViewHolder(@NonNull List<Artist> items, int position,
// @NonNull RecyclerView.ViewHolder holder) {
// ArtistViewHolder artistViewHolder = (ArtistViewHolder)holder;
// final Artist artist = items.get(position);
// artistViewHolder.name.setText(artist.getDisplayName());
// artistViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// artistClicks.onNext(artist);
// }
// });
// }
//
// public Observable<Artist> getArtistClicks() {
// return artistClicks.asObservable();
// }
//
// static class ArtistViewHolder extends RecyclerView.ViewHolder {
// @Bind(R.id.artist_name_txv)
// TextView name;
//
// public ArtistViewHolder(View itemView) {
// super(itemView);
// ButterKnife.bind(this, itemView);
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/ui/delegates/EmptyDelegate.java
// public class EmptyDelegate<T> implements AdapterDelegate<List<T>> {
// private static final int TYPE = 1916;
//
// @Override
// public int getItemViewType() {
// return TYPE;
// }
//
// @Override
// public boolean isForViewType(@NonNull List<T> items, int i) {
// return i == 0 && items.size() == 0;
// }
//
// @NonNull
// @Override
// public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup) {
// return new EmptyViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(
// R.layout.element_empty, viewGroup, false));
// }
//
// @Override
// public void onBindViewHolder(@NonNull List<T> recordAndReports, int i,
// @NonNull RecyclerView.ViewHolder viewHolder) {
// EmptyViewHolder holder = (EmptyViewHolder)viewHolder;
// }
//
// private class EmptyViewHolder extends RecyclerView.ViewHolder {
// public EmptyViewHolder(View view) {
// super(view);
// }
// }
// }
| import java.util.ArrayList;
import java.util.List;
import rx.Observable;
import rx.functions.Action1;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import com.hannesdorfmann.adapterdelegates.AdapterDelegatesManager;
import com.pacoworks.dereference.model.Artist;
import com.pacoworks.dereference.ui.delegates.ArtistDelegate;
import com.pacoworks.dereference.ui.delegates.EmptyDelegate; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.ui.adapters;
public class ArtistListAdapter extends RecyclerView.Adapter {
private final List<Artist> elementsMap = new ArrayList<>();
private final AdapterDelegatesManager<List<Artist>> delegatesManager = new AdapterDelegatesManager<>();
| // Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/ui/delegates/ArtistDelegate.java
// public class ArtistDelegate implements AdapterDelegate<List<Artist>> {
// public static final int TYPE = 48984;
//
// SerializedSubject<Artist, Artist> artistClicks = new SerializedSubject<>(
// PublishSubject.<Artist> create());
//
// @Override
// public int getItemViewType() {
// return TYPE;
// }
//
// @Override
// public boolean isForViewType(@NonNull List<Artist> items, int position) {
// return (0 != position || items.size() != 0);
// }
//
// @NonNull
// @Override
// public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent) {
// return new ArtistViewHolder(LayoutInflater.from(parent.getContext()).inflate(
// R.layout.element_artist, parent, false));
// }
//
// @Override
// public void onBindViewHolder(@NonNull List<Artist> items, int position,
// @NonNull RecyclerView.ViewHolder holder) {
// ArtistViewHolder artistViewHolder = (ArtistViewHolder)holder;
// final Artist artist = items.get(position);
// artistViewHolder.name.setText(artist.getDisplayName());
// artistViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// artistClicks.onNext(artist);
// }
// });
// }
//
// public Observable<Artist> getArtistClicks() {
// return artistClicks.asObservable();
// }
//
// static class ArtistViewHolder extends RecyclerView.ViewHolder {
// @Bind(R.id.artist_name_txv)
// TextView name;
//
// public ArtistViewHolder(View itemView) {
// super(itemView);
// ButterKnife.bind(this, itemView);
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/ui/delegates/EmptyDelegate.java
// public class EmptyDelegate<T> implements AdapterDelegate<List<T>> {
// private static final int TYPE = 1916;
//
// @Override
// public int getItemViewType() {
// return TYPE;
// }
//
// @Override
// public boolean isForViewType(@NonNull List<T> items, int i) {
// return i == 0 && items.size() == 0;
// }
//
// @NonNull
// @Override
// public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup) {
// return new EmptyViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(
// R.layout.element_empty, viewGroup, false));
// }
//
// @Override
// public void onBindViewHolder(@NonNull List<T> recordAndReports, int i,
// @NonNull RecyclerView.ViewHolder viewHolder) {
// EmptyViewHolder holder = (EmptyViewHolder)viewHolder;
// }
//
// private class EmptyViewHolder extends RecyclerView.ViewHolder {
// public EmptyViewHolder(View view) {
// super(view);
// }
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/ui/adapters/ArtistListAdapter.java
import java.util.ArrayList;
import java.util.List;
import rx.Observable;
import rx.functions.Action1;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import com.hannesdorfmann.adapterdelegates.AdapterDelegatesManager;
import com.pacoworks.dereference.model.Artist;
import com.pacoworks.dereference.ui.delegates.ArtistDelegate;
import com.pacoworks.dereference.ui.delegates.EmptyDelegate;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.ui.adapters;
public class ArtistListAdapter extends RecyclerView.Adapter {
private final List<Artist> elementsMap = new ArrayList<>();
private final AdapterDelegatesManager<List<Artist>> delegatesManager = new AdapterDelegatesManager<>();
| private final ArtistDelegate artistDelegate; |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/ui/adapters/ArtistListAdapter.java | // Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/ui/delegates/ArtistDelegate.java
// public class ArtistDelegate implements AdapterDelegate<List<Artist>> {
// public static final int TYPE = 48984;
//
// SerializedSubject<Artist, Artist> artistClicks = new SerializedSubject<>(
// PublishSubject.<Artist> create());
//
// @Override
// public int getItemViewType() {
// return TYPE;
// }
//
// @Override
// public boolean isForViewType(@NonNull List<Artist> items, int position) {
// return (0 != position || items.size() != 0);
// }
//
// @NonNull
// @Override
// public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent) {
// return new ArtistViewHolder(LayoutInflater.from(parent.getContext()).inflate(
// R.layout.element_artist, parent, false));
// }
//
// @Override
// public void onBindViewHolder(@NonNull List<Artist> items, int position,
// @NonNull RecyclerView.ViewHolder holder) {
// ArtistViewHolder artistViewHolder = (ArtistViewHolder)holder;
// final Artist artist = items.get(position);
// artistViewHolder.name.setText(artist.getDisplayName());
// artistViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// artistClicks.onNext(artist);
// }
// });
// }
//
// public Observable<Artist> getArtistClicks() {
// return artistClicks.asObservable();
// }
//
// static class ArtistViewHolder extends RecyclerView.ViewHolder {
// @Bind(R.id.artist_name_txv)
// TextView name;
//
// public ArtistViewHolder(View itemView) {
// super(itemView);
// ButterKnife.bind(this, itemView);
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/ui/delegates/EmptyDelegate.java
// public class EmptyDelegate<T> implements AdapterDelegate<List<T>> {
// private static final int TYPE = 1916;
//
// @Override
// public int getItemViewType() {
// return TYPE;
// }
//
// @Override
// public boolean isForViewType(@NonNull List<T> items, int i) {
// return i == 0 && items.size() == 0;
// }
//
// @NonNull
// @Override
// public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup) {
// return new EmptyViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(
// R.layout.element_empty, viewGroup, false));
// }
//
// @Override
// public void onBindViewHolder(@NonNull List<T> recordAndReports, int i,
// @NonNull RecyclerView.ViewHolder viewHolder) {
// EmptyViewHolder holder = (EmptyViewHolder)viewHolder;
// }
//
// private class EmptyViewHolder extends RecyclerView.ViewHolder {
// public EmptyViewHolder(View view) {
// super(view);
// }
// }
// }
| import java.util.ArrayList;
import java.util.List;
import rx.Observable;
import rx.functions.Action1;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import com.hannesdorfmann.adapterdelegates.AdapterDelegatesManager;
import com.pacoworks.dereference.model.Artist;
import com.pacoworks.dereference.ui.delegates.ArtistDelegate;
import com.pacoworks.dereference.ui.delegates.EmptyDelegate; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.ui.adapters;
public class ArtistListAdapter extends RecyclerView.Adapter {
private final List<Artist> elementsMap = new ArrayList<>();
private final AdapterDelegatesManager<List<Artist>> delegatesManager = new AdapterDelegatesManager<>();
private final ArtistDelegate artistDelegate;
public ArtistListAdapter() {
artistDelegate = new ArtistDelegate();
delegatesManager.addDelegate(artistDelegate); | // Path: app/src/main/java/com/pacoworks/dereference/model/Artist.java
// @ToString
// public class Artist implements Serializable {
// static final long serialVersionUID = 4653212L;
//
// @SerializedName("displayName")
// private final String displayName;
//
// @SerializedName("id")
// private final String id;
//
// @SerializedName("identifier")
// private final List<Identifier> identifier;
//
// @SerializedName("onTourUntil")
// private final String onTourUntil;
//
// @SerializedName("uri")
// private final String uri;
//
// public Artist(String displayName, String id, List<Identifier> identifier, String onTourUntil,
// String uri) {
// this.displayName = displayName;
// this.id = id;
// this.identifier = identifier;
// this.onTourUntil = onTourUntil;
// this.uri = uri;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getId() {
// return id;
// }
//
// public List<Identifier> getIdentifier() {
// return identifier;
// }
//
// public String getOnTourUntil() {
// return onTourUntil;
// }
//
// public String getUri() {
// return uri;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/ui/delegates/ArtistDelegate.java
// public class ArtistDelegate implements AdapterDelegate<List<Artist>> {
// public static final int TYPE = 48984;
//
// SerializedSubject<Artist, Artist> artistClicks = new SerializedSubject<>(
// PublishSubject.<Artist> create());
//
// @Override
// public int getItemViewType() {
// return TYPE;
// }
//
// @Override
// public boolean isForViewType(@NonNull List<Artist> items, int position) {
// return (0 != position || items.size() != 0);
// }
//
// @NonNull
// @Override
// public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent) {
// return new ArtistViewHolder(LayoutInflater.from(parent.getContext()).inflate(
// R.layout.element_artist, parent, false));
// }
//
// @Override
// public void onBindViewHolder(@NonNull List<Artist> items, int position,
// @NonNull RecyclerView.ViewHolder holder) {
// ArtistViewHolder artistViewHolder = (ArtistViewHolder)holder;
// final Artist artist = items.get(position);
// artistViewHolder.name.setText(artist.getDisplayName());
// artistViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// artistClicks.onNext(artist);
// }
// });
// }
//
// public Observable<Artist> getArtistClicks() {
// return artistClicks.asObservable();
// }
//
// static class ArtistViewHolder extends RecyclerView.ViewHolder {
// @Bind(R.id.artist_name_txv)
// TextView name;
//
// public ArtistViewHolder(View itemView) {
// super(itemView);
// ButterKnife.bind(this, itemView);
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/ui/delegates/EmptyDelegate.java
// public class EmptyDelegate<T> implements AdapterDelegate<List<T>> {
// private static final int TYPE = 1916;
//
// @Override
// public int getItemViewType() {
// return TYPE;
// }
//
// @Override
// public boolean isForViewType(@NonNull List<T> items, int i) {
// return i == 0 && items.size() == 0;
// }
//
// @NonNull
// @Override
// public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup) {
// return new EmptyViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(
// R.layout.element_empty, viewGroup, false));
// }
//
// @Override
// public void onBindViewHolder(@NonNull List<T> recordAndReports, int i,
// @NonNull RecyclerView.ViewHolder viewHolder) {
// EmptyViewHolder holder = (EmptyViewHolder)viewHolder;
// }
//
// private class EmptyViewHolder extends RecyclerView.ViewHolder {
// public EmptyViewHolder(View view) {
// super(view);
// }
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/ui/adapters/ArtistListAdapter.java
import java.util.ArrayList;
import java.util.List;
import rx.Observable;
import rx.functions.Action1;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import com.hannesdorfmann.adapterdelegates.AdapterDelegatesManager;
import com.pacoworks.dereference.model.Artist;
import com.pacoworks.dereference.ui.delegates.ArtistDelegate;
import com.pacoworks.dereference.ui.delegates.EmptyDelegate;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.ui.adapters;
public class ArtistListAdapter extends RecyclerView.Adapter {
private final List<Artist> elementsMap = new ArrayList<>();
private final AdapterDelegatesManager<List<Artist>> delegatesManager = new AdapterDelegatesManager<>();
private final ArtistDelegate artistDelegate;
public ArtistListAdapter() {
artistDelegate = new ArtistDelegate();
delegatesManager.addDelegate(artistDelegate); | delegatesManager.addDelegate(new EmptyDelegate<Artist>()); |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimplBaseActivity.java | // Path: app/src/whatever/java/com/pacoworks/dereference/ApplicationInjectionComponent.java
// @Singleton
// @Component(modules = {
// ApplicationModule.class, SerializationModule.class, NetworkModule.class
// })
// public interface ApplicationInjectionComponent extends DependencyDescription {
// final class Initializer {
// /* 10 MiB */
// private static final long CACHE_SIZE = 10 * 1024 * 1024;
//
// private Initializer() {
// /* No instances. */
// }
//
// static ApplicationInjectionComponent init(DereferenceApplication app) {
// return DaggerApplicationInjectionComponent
// .builder()
// .applicationModule(new ApplicationModule(app))
// .serializationModule(new SerializationModule())
// .networkModule(
// new NetworkModule(BuildConfig.ENDPOINT, app.getCacheDir(), CACHE_SIZE))
// .build();
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/ActivityInjectionComponent.java
// public interface ActivityInjectionComponent<T extends ZimplBasePresenter> {
// void inject(T presenter);
//
// void inject(ZimplBaseActivity activity);
//
// Activity activity();
//
// ZimplBasePresenter presenter();
//
// Picasso picasso();
// }
| import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Getter;
import rx.functions.Action1;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.widget.Toast;
import butterknife.ButterKnife;
import com.pacoworks.dereference.ApplicationInjectionComponent;
import com.pacoworks.dereference.BuildConfig;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.dependencies.ActivityInjectionComponent;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.picasso.Picasso;
import io.palaima.debugdrawer.DebugDrawer;
import io.palaima.debugdrawer.log.LogModule;
import io.palaima.debugdrawer.module.BuildModule;
import io.palaima.debugdrawer.module.DeviceModule;
import io.palaima.debugdrawer.module.NetworkModule;
import io.palaima.debugdrawer.module.SettingsModule;
import io.palaima.debugdrawer.okhttp.OkHttpModule;
import io.palaima.debugdrawer.picasso.PicassoModule;
import io.palaima.debugdrawer.scalpel.ScalpelModule; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies.skeleton;
public abstract class ZimplBaseActivity extends Activity implements IUi {
private static final String PRESENTER_STATE = "presenter_state";
@Inject
Picasso picasso;
@Inject
OkHttpClient okHttpClient;
@Getter(AccessLevel.PROTECTED) | // Path: app/src/whatever/java/com/pacoworks/dereference/ApplicationInjectionComponent.java
// @Singleton
// @Component(modules = {
// ApplicationModule.class, SerializationModule.class, NetworkModule.class
// })
// public interface ApplicationInjectionComponent extends DependencyDescription {
// final class Initializer {
// /* 10 MiB */
// private static final long CACHE_SIZE = 10 * 1024 * 1024;
//
// private Initializer() {
// /* No instances. */
// }
//
// static ApplicationInjectionComponent init(DereferenceApplication app) {
// return DaggerApplicationInjectionComponent
// .builder()
// .applicationModule(new ApplicationModule(app))
// .serializationModule(new SerializationModule())
// .networkModule(
// new NetworkModule(BuildConfig.ENDPOINT, app.getCacheDir(), CACHE_SIZE))
// .build();
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/ActivityInjectionComponent.java
// public interface ActivityInjectionComponent<T extends ZimplBasePresenter> {
// void inject(T presenter);
//
// void inject(ZimplBaseActivity activity);
//
// Activity activity();
//
// ZimplBasePresenter presenter();
//
// Picasso picasso();
// }
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimplBaseActivity.java
import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Getter;
import rx.functions.Action1;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.widget.Toast;
import butterknife.ButterKnife;
import com.pacoworks.dereference.ApplicationInjectionComponent;
import com.pacoworks.dereference.BuildConfig;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.dependencies.ActivityInjectionComponent;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.picasso.Picasso;
import io.palaima.debugdrawer.DebugDrawer;
import io.palaima.debugdrawer.log.LogModule;
import io.palaima.debugdrawer.module.BuildModule;
import io.palaima.debugdrawer.module.DeviceModule;
import io.palaima.debugdrawer.module.NetworkModule;
import io.palaima.debugdrawer.module.SettingsModule;
import io.palaima.debugdrawer.okhttp.OkHttpModule;
import io.palaima.debugdrawer.picasso.PicassoModule;
import io.palaima.debugdrawer.scalpel.ScalpelModule;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies.skeleton;
public abstract class ZimplBaseActivity extends Activity implements IUi {
private static final String PRESENTER_STATE = "presenter_state";
@Inject
Picasso picasso;
@Inject
OkHttpClient okHttpClient;
@Getter(AccessLevel.PROTECTED) | private ActivityInjectionComponent injector; |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimplBaseActivity.java | // Path: app/src/whatever/java/com/pacoworks/dereference/ApplicationInjectionComponent.java
// @Singleton
// @Component(modules = {
// ApplicationModule.class, SerializationModule.class, NetworkModule.class
// })
// public interface ApplicationInjectionComponent extends DependencyDescription {
// final class Initializer {
// /* 10 MiB */
// private static final long CACHE_SIZE = 10 * 1024 * 1024;
//
// private Initializer() {
// /* No instances. */
// }
//
// static ApplicationInjectionComponent init(DereferenceApplication app) {
// return DaggerApplicationInjectionComponent
// .builder()
// .applicationModule(new ApplicationModule(app))
// .serializationModule(new SerializationModule())
// .networkModule(
// new NetworkModule(BuildConfig.ENDPOINT, app.getCacheDir(), CACHE_SIZE))
// .build();
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/ActivityInjectionComponent.java
// public interface ActivityInjectionComponent<T extends ZimplBasePresenter> {
// void inject(T presenter);
//
// void inject(ZimplBaseActivity activity);
//
// Activity activity();
//
// ZimplBasePresenter presenter();
//
// Picasso picasso();
// }
| import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Getter;
import rx.functions.Action1;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.widget.Toast;
import butterknife.ButterKnife;
import com.pacoworks.dereference.ApplicationInjectionComponent;
import com.pacoworks.dereference.BuildConfig;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.dependencies.ActivityInjectionComponent;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.picasso.Picasso;
import io.palaima.debugdrawer.DebugDrawer;
import io.palaima.debugdrawer.log.LogModule;
import io.palaima.debugdrawer.module.BuildModule;
import io.palaima.debugdrawer.module.DeviceModule;
import io.palaima.debugdrawer.module.NetworkModule;
import io.palaima.debugdrawer.module.SettingsModule;
import io.palaima.debugdrawer.okhttp.OkHttpModule;
import io.palaima.debugdrawer.picasso.PicassoModule;
import io.palaima.debugdrawer.scalpel.ScalpelModule; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies.skeleton;
public abstract class ZimplBaseActivity extends Activity implements IUi {
private static final String PRESENTER_STATE = "presenter_state";
@Inject
Picasso picasso;
@Inject
OkHttpClient okHttpClient;
@Getter(AccessLevel.PROTECTED)
private ActivityInjectionComponent injector;
private ZimplBasePresenter presenter;
private DebugDrawer mDebugDrawer;
@Override
@SuppressWarnings("unchecked")
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
injector = startInjector();
startUi();
restorePresenter(savedInstanceState, injector);
}
@NonNull
private ActivityInjectionComponent startInjector() { | // Path: app/src/whatever/java/com/pacoworks/dereference/ApplicationInjectionComponent.java
// @Singleton
// @Component(modules = {
// ApplicationModule.class, SerializationModule.class, NetworkModule.class
// })
// public interface ApplicationInjectionComponent extends DependencyDescription {
// final class Initializer {
// /* 10 MiB */
// private static final long CACHE_SIZE = 10 * 1024 * 1024;
//
// private Initializer() {
// /* No instances. */
// }
//
// static ApplicationInjectionComponent init(DereferenceApplication app) {
// return DaggerApplicationInjectionComponent
// .builder()
// .applicationModule(new ApplicationModule(app))
// .serializationModule(new SerializationModule())
// .networkModule(
// new NetworkModule(BuildConfig.ENDPOINT, app.getCacheDir(), CACHE_SIZE))
// .build();
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/ActivityInjectionComponent.java
// public interface ActivityInjectionComponent<T extends ZimplBasePresenter> {
// void inject(T presenter);
//
// void inject(ZimplBaseActivity activity);
//
// Activity activity();
//
// ZimplBasePresenter presenter();
//
// Picasso picasso();
// }
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimplBaseActivity.java
import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Getter;
import rx.functions.Action1;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.widget.Toast;
import butterknife.ButterKnife;
import com.pacoworks.dereference.ApplicationInjectionComponent;
import com.pacoworks.dereference.BuildConfig;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.dependencies.ActivityInjectionComponent;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.picasso.Picasso;
import io.palaima.debugdrawer.DebugDrawer;
import io.palaima.debugdrawer.log.LogModule;
import io.palaima.debugdrawer.module.BuildModule;
import io.palaima.debugdrawer.module.DeviceModule;
import io.palaima.debugdrawer.module.NetworkModule;
import io.palaima.debugdrawer.module.SettingsModule;
import io.palaima.debugdrawer.okhttp.OkHttpModule;
import io.palaima.debugdrawer.picasso.PicassoModule;
import io.palaima.debugdrawer.scalpel.ScalpelModule;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies.skeleton;
public abstract class ZimplBaseActivity extends Activity implements IUi {
private static final String PRESENTER_STATE = "presenter_state";
@Inject
Picasso picasso;
@Inject
OkHttpClient okHttpClient;
@Getter(AccessLevel.PROTECTED)
private ActivityInjectionComponent injector;
private ZimplBasePresenter presenter;
private DebugDrawer mDebugDrawer;
@Override
@SuppressWarnings("unchecked")
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
injector = startInjector();
startUi();
restorePresenter(savedInstanceState, injector);
}
@NonNull
private ActivityInjectionComponent startInjector() { | final ApplicationInjectionComponent applicationInjectionComponent = DereferenceApplication |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimplBaseActivity.java | // Path: app/src/whatever/java/com/pacoworks/dereference/ApplicationInjectionComponent.java
// @Singleton
// @Component(modules = {
// ApplicationModule.class, SerializationModule.class, NetworkModule.class
// })
// public interface ApplicationInjectionComponent extends DependencyDescription {
// final class Initializer {
// /* 10 MiB */
// private static final long CACHE_SIZE = 10 * 1024 * 1024;
//
// private Initializer() {
// /* No instances. */
// }
//
// static ApplicationInjectionComponent init(DereferenceApplication app) {
// return DaggerApplicationInjectionComponent
// .builder()
// .applicationModule(new ApplicationModule(app))
// .serializationModule(new SerializationModule())
// .networkModule(
// new NetworkModule(BuildConfig.ENDPOINT, app.getCacheDir(), CACHE_SIZE))
// .build();
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/ActivityInjectionComponent.java
// public interface ActivityInjectionComponent<T extends ZimplBasePresenter> {
// void inject(T presenter);
//
// void inject(ZimplBaseActivity activity);
//
// Activity activity();
//
// ZimplBasePresenter presenter();
//
// Picasso picasso();
// }
| import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Getter;
import rx.functions.Action1;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.widget.Toast;
import butterknife.ButterKnife;
import com.pacoworks.dereference.ApplicationInjectionComponent;
import com.pacoworks.dereference.BuildConfig;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.dependencies.ActivityInjectionComponent;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.picasso.Picasso;
import io.palaima.debugdrawer.DebugDrawer;
import io.palaima.debugdrawer.log.LogModule;
import io.palaima.debugdrawer.module.BuildModule;
import io.palaima.debugdrawer.module.DeviceModule;
import io.palaima.debugdrawer.module.NetworkModule;
import io.palaima.debugdrawer.module.SettingsModule;
import io.palaima.debugdrawer.okhttp.OkHttpModule;
import io.palaima.debugdrawer.picasso.PicassoModule;
import io.palaima.debugdrawer.scalpel.ScalpelModule; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies.skeleton;
public abstract class ZimplBaseActivity extends Activity implements IUi {
private static final String PRESENTER_STATE = "presenter_state";
@Inject
Picasso picasso;
@Inject
OkHttpClient okHttpClient;
@Getter(AccessLevel.PROTECTED)
private ActivityInjectionComponent injector;
private ZimplBasePresenter presenter;
private DebugDrawer mDebugDrawer;
@Override
@SuppressWarnings("unchecked")
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
injector = startInjector();
startUi();
restorePresenter(savedInstanceState, injector);
}
@NonNull
private ActivityInjectionComponent startInjector() { | // Path: app/src/whatever/java/com/pacoworks/dereference/ApplicationInjectionComponent.java
// @Singleton
// @Component(modules = {
// ApplicationModule.class, SerializationModule.class, NetworkModule.class
// })
// public interface ApplicationInjectionComponent extends DependencyDescription {
// final class Initializer {
// /* 10 MiB */
// private static final long CACHE_SIZE = 10 * 1024 * 1024;
//
// private Initializer() {
// /* No instances. */
// }
//
// static ApplicationInjectionComponent init(DereferenceApplication app) {
// return DaggerApplicationInjectionComponent
// .builder()
// .applicationModule(new ApplicationModule(app))
// .serializationModule(new SerializationModule())
// .networkModule(
// new NetworkModule(BuildConfig.ENDPOINT, app.getCacheDir(), CACHE_SIZE))
// .build();
// }
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/DereferenceApplication.java
// public class DereferenceApplication extends Application {
// @Inject
// MainInitialiser mainInitialiser;
//
// @Inject
// FlavourInitialiser flavourInitialiser;
// private ApplicationInjectionComponent component;
//
// public static DereferenceApplication get(Context context) {
// return (DereferenceApplication)context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// buildComponentAndInject();
// }
//
// private void buildComponentAndInject() {
// component = ApplicationInjectionComponent.Initializer.init(this);
// /* Force initialisers to be created */
// component.inject(this);
// }
//
// public ApplicationInjectionComponent component() {
// return component;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/ActivityInjectionComponent.java
// public interface ActivityInjectionComponent<T extends ZimplBasePresenter> {
// void inject(T presenter);
//
// void inject(ZimplBaseActivity activity);
//
// Activity activity();
//
// ZimplBasePresenter presenter();
//
// Picasso picasso();
// }
// Path: app/src/main/java/com/pacoworks/dereference/dependencies/skeleton/ZimplBaseActivity.java
import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Getter;
import rx.functions.Action1;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.widget.Toast;
import butterknife.ButterKnife;
import com.pacoworks.dereference.ApplicationInjectionComponent;
import com.pacoworks.dereference.BuildConfig;
import com.pacoworks.dereference.DereferenceApplication;
import com.pacoworks.dereference.dependencies.ActivityInjectionComponent;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.picasso.Picasso;
import io.palaima.debugdrawer.DebugDrawer;
import io.palaima.debugdrawer.log.LogModule;
import io.palaima.debugdrawer.module.BuildModule;
import io.palaima.debugdrawer.module.DeviceModule;
import io.palaima.debugdrawer.module.NetworkModule;
import io.palaima.debugdrawer.module.SettingsModule;
import io.palaima.debugdrawer.okhttp.OkHttpModule;
import io.palaima.debugdrawer.picasso.PicassoModule;
import io.palaima.debugdrawer.scalpel.ScalpelModule;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.dependencies.skeleton;
public abstract class ZimplBaseActivity extends Activity implements IUi {
private static final String PRESENTER_STATE = "presenter_state";
@Inject
Picasso picasso;
@Inject
OkHttpClient okHttpClient;
@Getter(AccessLevel.PROTECTED)
private ActivityInjectionComponent injector;
private ZimplBasePresenter presenter;
private DebugDrawer mDebugDrawer;
@Override
@SuppressWarnings("unchecked")
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
injector = startInjector();
startUi();
restorePresenter(savedInstanceState, injector);
}
@NonNull
private ActivityInjectionComponent startInjector() { | final ApplicationInjectionComponent applicationInjectionComponent = DereferenceApplication |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/reactive/RxTuples.java | // Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Quadriple.java
// @EqualsAndHashCode
// @ToString
// public class Quadriple<T, U, V, X> implements Serializable {
// public final T first;
//
// public final U second;
//
// public final V third;
//
// public final X fourth;
//
// public Quadriple(T first, U second, V third, X fourth) {
// this.first = first;
// this.second = second;
// this.third = third;
// this.fourth = fourth;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Triple.java
// @EqualsAndHashCode
// @ToString
// public class Triple<T, U, V> implements Serializable {
// public final T first;
//
// public final U second;
//
// public final V third;
//
// public Triple(T first, U second, V third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Tuple.java
// @EqualsAndHashCode
// @ToString
// public class Tuple<T, U> implements Serializable {
// public final T first;
//
// public final U second;
//
// public Tuple(T first, U second) {
// this.first = first;
// this.second = second;
// }
// }
| import lombok.experimental.UtilityClass;
import rx.functions.Func2;
import com.pacoworks.dereference.reactive.tuples.Quadriple;
import com.pacoworks.dereference.reactive.tuples.Triple;
import com.pacoworks.dereference.reactive.tuples.Tuple; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.reactive;
@UtilityClass
public class RxTuples { | // Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Quadriple.java
// @EqualsAndHashCode
// @ToString
// public class Quadriple<T, U, V, X> implements Serializable {
// public final T first;
//
// public final U second;
//
// public final V third;
//
// public final X fourth;
//
// public Quadriple(T first, U second, V third, X fourth) {
// this.first = first;
// this.second = second;
// this.third = third;
// this.fourth = fourth;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Triple.java
// @EqualsAndHashCode
// @ToString
// public class Triple<T, U, V> implements Serializable {
// public final T first;
//
// public final U second;
//
// public final V third;
//
// public Triple(T first, U second, V third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Tuple.java
// @EqualsAndHashCode
// @ToString
// public class Tuple<T, U> implements Serializable {
// public final T first;
//
// public final U second;
//
// public Tuple(T first, U second) {
// this.first = first;
// this.second = second;
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/reactive/RxTuples.java
import lombok.experimental.UtilityClass;
import rx.functions.Func2;
import com.pacoworks.dereference.reactive.tuples.Quadriple;
import com.pacoworks.dereference.reactive.tuples.Triple;
import com.pacoworks.dereference.reactive.tuples.Tuple;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.reactive;
@UtilityClass
public class RxTuples { | public static <T, U> Func2<T, U, Tuple<T, U>> singleToTuple() { |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/reactive/RxTuples.java | // Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Quadriple.java
// @EqualsAndHashCode
// @ToString
// public class Quadriple<T, U, V, X> implements Serializable {
// public final T first;
//
// public final U second;
//
// public final V third;
//
// public final X fourth;
//
// public Quadriple(T first, U second, V third, X fourth) {
// this.first = first;
// this.second = second;
// this.third = third;
// this.fourth = fourth;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Triple.java
// @EqualsAndHashCode
// @ToString
// public class Triple<T, U, V> implements Serializable {
// public final T first;
//
// public final U second;
//
// public final V third;
//
// public Triple(T first, U second, V third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Tuple.java
// @EqualsAndHashCode
// @ToString
// public class Tuple<T, U> implements Serializable {
// public final T first;
//
// public final U second;
//
// public Tuple(T first, U second) {
// this.first = first;
// this.second = second;
// }
// }
| import lombok.experimental.UtilityClass;
import rx.functions.Func2;
import com.pacoworks.dereference.reactive.tuples.Quadriple;
import com.pacoworks.dereference.reactive.tuples.Triple;
import com.pacoworks.dereference.reactive.tuples.Tuple; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.reactive;
@UtilityClass
public class RxTuples {
public static <T, U> Func2<T, U, Tuple<T, U>> singleToTuple() {
return new Func2<T, U, Tuple<T, U>>() {
@Override
public Tuple<T, U> call(T first, U second) {
return new Tuple<>(first, second);
}
};
}
public static <T, U> Func2<T, U, Tuple<U, T>> singleToTupleInverse() {
return new Func2<T, U, Tuple<U, T>>() {
@Override
public Tuple<U, T> call(T first, U second) {
return new Tuple<>(second, first);
}
};
}
| // Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Quadriple.java
// @EqualsAndHashCode
// @ToString
// public class Quadriple<T, U, V, X> implements Serializable {
// public final T first;
//
// public final U second;
//
// public final V third;
//
// public final X fourth;
//
// public Quadriple(T first, U second, V third, X fourth) {
// this.first = first;
// this.second = second;
// this.third = third;
// this.fourth = fourth;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Triple.java
// @EqualsAndHashCode
// @ToString
// public class Triple<T, U, V> implements Serializable {
// public final T first;
//
// public final U second;
//
// public final V third;
//
// public Triple(T first, U second, V third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Tuple.java
// @EqualsAndHashCode
// @ToString
// public class Tuple<T, U> implements Serializable {
// public final T first;
//
// public final U second;
//
// public Tuple(T first, U second) {
// this.first = first;
// this.second = second;
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/reactive/RxTuples.java
import lombok.experimental.UtilityClass;
import rx.functions.Func2;
import com.pacoworks.dereference.reactive.tuples.Quadriple;
import com.pacoworks.dereference.reactive.tuples.Triple;
import com.pacoworks.dereference.reactive.tuples.Tuple;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.reactive;
@UtilityClass
public class RxTuples {
public static <T, U> Func2<T, U, Tuple<T, U>> singleToTuple() {
return new Func2<T, U, Tuple<T, U>>() {
@Override
public Tuple<T, U> call(T first, U second) {
return new Tuple<>(first, second);
}
};
}
public static <T, U> Func2<T, U, Tuple<U, T>> singleToTupleInverse() {
return new Func2<T, U, Tuple<U, T>>() {
@Override
public Tuple<U, T> call(T first, U second) {
return new Tuple<>(second, first);
}
};
}
| public static <T, U, V> Func2<T, Tuple<U, V>, Triple<T, U, V>> singleToTriple() { |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/reactive/RxTuples.java | // Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Quadriple.java
// @EqualsAndHashCode
// @ToString
// public class Quadriple<T, U, V, X> implements Serializable {
// public final T first;
//
// public final U second;
//
// public final V third;
//
// public final X fourth;
//
// public Quadriple(T first, U second, V third, X fourth) {
// this.first = first;
// this.second = second;
// this.third = third;
// this.fourth = fourth;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Triple.java
// @EqualsAndHashCode
// @ToString
// public class Triple<T, U, V> implements Serializable {
// public final T first;
//
// public final U second;
//
// public final V third;
//
// public Triple(T first, U second, V third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Tuple.java
// @EqualsAndHashCode
// @ToString
// public class Tuple<T, U> implements Serializable {
// public final T first;
//
// public final U second;
//
// public Tuple(T first, U second) {
// this.first = first;
// this.second = second;
// }
// }
| import lombok.experimental.UtilityClass;
import rx.functions.Func2;
import com.pacoworks.dereference.reactive.tuples.Quadriple;
import com.pacoworks.dereference.reactive.tuples.Triple;
import com.pacoworks.dereference.reactive.tuples.Tuple; | };
}
public static <T, U> Func2<T, U, Tuple<U, T>> singleToTupleInverse() {
return new Func2<T, U, Tuple<U, T>>() {
@Override
public Tuple<U, T> call(T first, U second) {
return new Tuple<>(second, first);
}
};
}
public static <T, U, V> Func2<T, Tuple<U, V>, Triple<T, U, V>> singleToTriple() {
return new Func2<T, Tuple<U, V>, Triple<T, U, V>>() {
@Override
public Triple<T, U, V> call(T first, Tuple<U, V> second) {
return new Triple<>(first, second.first, second.second);
}
};
}
public static <T, U, V> Func2<Tuple<T, U>, V, Triple<T, U, V>> tupleToTriple() {
return new Func2<Tuple<T, U>, V, Triple<T, U, V>>() {
@Override
public Triple<T, U, V> call(Tuple<T, U> first, V second) {
return new Triple<>(first.first, first.second, second);
}
};
}
| // Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Quadriple.java
// @EqualsAndHashCode
// @ToString
// public class Quadriple<T, U, V, X> implements Serializable {
// public final T first;
//
// public final U second;
//
// public final V third;
//
// public final X fourth;
//
// public Quadriple(T first, U second, V third, X fourth) {
// this.first = first;
// this.second = second;
// this.third = third;
// this.fourth = fourth;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Triple.java
// @EqualsAndHashCode
// @ToString
// public class Triple<T, U, V> implements Serializable {
// public final T first;
//
// public final U second;
//
// public final V third;
//
// public Triple(T first, U second, V third) {
// this.first = first;
// this.second = second;
// this.third = third;
// }
// }
//
// Path: app/src/main/java/com/pacoworks/dereference/reactive/tuples/Tuple.java
// @EqualsAndHashCode
// @ToString
// public class Tuple<T, U> implements Serializable {
// public final T first;
//
// public final U second;
//
// public Tuple(T first, U second) {
// this.first = first;
// this.second = second;
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/reactive/RxTuples.java
import lombok.experimental.UtilityClass;
import rx.functions.Func2;
import com.pacoworks.dereference.reactive.tuples.Quadriple;
import com.pacoworks.dereference.reactive.tuples.Triple;
import com.pacoworks.dereference.reactive.tuples.Tuple;
};
}
public static <T, U> Func2<T, U, Tuple<U, T>> singleToTupleInverse() {
return new Func2<T, U, Tuple<U, T>>() {
@Override
public Tuple<U, T> call(T first, U second) {
return new Tuple<>(second, first);
}
};
}
public static <T, U, V> Func2<T, Tuple<U, V>, Triple<T, U, V>> singleToTriple() {
return new Func2<T, Tuple<U, V>, Triple<T, U, V>>() {
@Override
public Triple<T, U, V> call(T first, Tuple<U, V> second) {
return new Triple<>(first, second.first, second.second);
}
};
}
public static <T, U, V> Func2<Tuple<T, U>, V, Triple<T, U, V>> tupleToTriple() {
return new Func2<Tuple<T, U>, V, Triple<T, U, V>>() {
@Override
public Triple<T, U, V> call(Tuple<T, U> first, V second) {
return new Triple<>(first.first, first.second, second);
}
};
}
| public static <T, U, V, X> Func2<T, Triple<U, V, X>, Quadriple<T, U, V, X>> singleToQuadruple() { |
pakoito/SongkickInterview | app/src/main/java/com/pacoworks/dereference/network/SongkickApi.java | // Path: app/src/main/java/com/pacoworks/dereference/model/SearchResult.java
// @ToString
// public class SearchResult {
// @SerializedName("resultsPage")
// private final ResultsPage resultsPage;
//
// public SearchResult(ResultsPage resultsPage) {
// this.resultsPage = resultsPage;
// }
//
// public ResultsPage getResultsPage() {
// return resultsPage;
// }
// }
| import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query;
import rx.Observable;
import com.pacoworks.dereference.model.SearchResult; | /*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.network;
public interface SongkickApi {
@GET("search/artists.json") | // Path: app/src/main/java/com/pacoworks/dereference/model/SearchResult.java
// @ToString
// public class SearchResult {
// @SerializedName("resultsPage")
// private final ResultsPage resultsPage;
//
// public SearchResult(ResultsPage resultsPage) {
// this.resultsPage = resultsPage;
// }
//
// public ResultsPage getResultsPage() {
// return resultsPage;
// }
// }
// Path: app/src/main/java/com/pacoworks/dereference/network/SongkickApi.java
import retrofit.http.GET;
import retrofit.http.Path;
import retrofit.http.Query;
import rx.Observable;
import com.pacoworks.dereference.model.SearchResult;
/*
* Copyright (c) pakoito 2015
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pacoworks.dereference.network;
public interface SongkickApi {
@GET("search/artists.json") | Observable<SearchResult> getSearchResult(@Query("apikey") String apikey, |
bhatti/RxJava8 | src/main/java/com/plexobject/rx/util/CancelableSpliterator.java | // Path: src/main/java/com/plexobject/rx/Cancelable.java
// public interface Cancelable {
// /**
// * Cancel this operation
// */
// void cancel();
//
// /**
// * Is operation canceled
// *
// * @return
// */
// boolean isCanceled();
// }
//
// Path: src/main/java/com/plexobject/rx/OnCompletion.java
// @FunctionalInterface
// public interface OnCompletion {
// /**
// * This method is called to notify user that all data is processed and there
// * is no more data.
// */
// void onCompleted();
// }
//
// Path: src/main/java/com/plexobject/rx/Streamable.java
// public interface Streamable<T> {
// Stream<T> getStream();
// }
//
// Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
| import java.util.Spliterator;
import java.util.concurrent.CountedCompleter;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import com.plexobject.rx.Cancelable;
import com.plexobject.rx.OnCompletion;
import com.plexobject.rx.Streamable;
import com.plexobject.rx.scheduler.Scheduler; | return false;
}
return delegate.tryAdvance(action);
}
@Override
public Spliterator<T> trySplit() {
return delegate.trySplit();
}
@Override
public long estimateSize() {
return delegate.estimateSize();
}
@Override
public int characteristics() {
return delegate.characteristics();
}
@Override
public void cancel() {
canceled.set(true);
}
@Override
public boolean isCanceled() {
return canceled.get();
}
| // Path: src/main/java/com/plexobject/rx/Cancelable.java
// public interface Cancelable {
// /**
// * Cancel this operation
// */
// void cancel();
//
// /**
// * Is operation canceled
// *
// * @return
// */
// boolean isCanceled();
// }
//
// Path: src/main/java/com/plexobject/rx/OnCompletion.java
// @FunctionalInterface
// public interface OnCompletion {
// /**
// * This method is called to notify user that all data is processed and there
// * is no more data.
// */
// void onCompleted();
// }
//
// Path: src/main/java/com/plexobject/rx/Streamable.java
// public interface Streamable<T> {
// Stream<T> getStream();
// }
//
// Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
// Path: src/main/java/com/plexobject/rx/util/CancelableSpliterator.java
import java.util.Spliterator;
import java.util.concurrent.CountedCompleter;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import com.plexobject.rx.Cancelable;
import com.plexobject.rx.OnCompletion;
import com.plexobject.rx.Streamable;
import com.plexobject.rx.scheduler.Scheduler;
return false;
}
return delegate.tryAdvance(action);
}
@Override
public Spliterator<T> trySplit() {
return delegate.trySplit();
}
@Override
public long estimateSize() {
return delegate.estimateSize();
}
@Override
public int characteristics() {
return delegate.characteristics();
}
@Override
public void cancel() {
canceled.set(true);
}
@Override
public boolean isCanceled() {
return canceled.get();
}
| public void parEach(Consumer<T> onNext, OnCompletion onCompletion) { |
bhatti/RxJava8 | src/main/java/com/plexobject/rx/util/CancelableSpliterator.java | // Path: src/main/java/com/plexobject/rx/Cancelable.java
// public interface Cancelable {
// /**
// * Cancel this operation
// */
// void cancel();
//
// /**
// * Is operation canceled
// *
// * @return
// */
// boolean isCanceled();
// }
//
// Path: src/main/java/com/plexobject/rx/OnCompletion.java
// @FunctionalInterface
// public interface OnCompletion {
// /**
// * This method is called to notify user that all data is processed and there
// * is no more data.
// */
// void onCompleted();
// }
//
// Path: src/main/java/com/plexobject/rx/Streamable.java
// public interface Streamable<T> {
// Stream<T> getStream();
// }
//
// Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
| import java.util.Spliterator;
import java.util.concurrent.CountedCompleter;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import com.plexobject.rx.Cancelable;
import com.plexobject.rx.OnCompletion;
import com.plexobject.rx.Streamable;
import com.plexobject.rx.scheduler.Scheduler; | }
@Override
public Spliterator<T> trySplit() {
return delegate.trySplit();
}
@Override
public long estimateSize() {
return delegate.estimateSize();
}
@Override
public int characteristics() {
return delegate.characteristics();
}
@Override
public void cancel() {
canceled.set(true);
}
@Override
public boolean isCanceled() {
return canceled.get();
}
public void parEach(Consumer<T> onNext, OnCompletion onCompletion) {
long targetBatchSize = (estimateSize() / (ForkJoinPool
.getCommonPoolParallelism() * 8)); | // Path: src/main/java/com/plexobject/rx/Cancelable.java
// public interface Cancelable {
// /**
// * Cancel this operation
// */
// void cancel();
//
// /**
// * Is operation canceled
// *
// * @return
// */
// boolean isCanceled();
// }
//
// Path: src/main/java/com/plexobject/rx/OnCompletion.java
// @FunctionalInterface
// public interface OnCompletion {
// /**
// * This method is called to notify user that all data is processed and there
// * is no more data.
// */
// void onCompleted();
// }
//
// Path: src/main/java/com/plexobject/rx/Streamable.java
// public interface Streamable<T> {
// Stream<T> getStream();
// }
//
// Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
// Path: src/main/java/com/plexobject/rx/util/CancelableSpliterator.java
import java.util.Spliterator;
import java.util.concurrent.CountedCompleter;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import com.plexobject.rx.Cancelable;
import com.plexobject.rx.OnCompletion;
import com.plexobject.rx.Streamable;
import com.plexobject.rx.scheduler.Scheduler;
}
@Override
public Spliterator<T> trySplit() {
return delegate.trySplit();
}
@Override
public long estimateSize() {
return delegate.estimateSize();
}
@Override
public int characteristics() {
return delegate.characteristics();
}
@Override
public void cancel() {
canceled.set(true);
}
@Override
public boolean isCanceled() {
return canceled.get();
}
public void parEach(Consumer<T> onNext, OnCompletion onCompletion) {
long targetBatchSize = (estimateSize() / (ForkJoinPool
.getCommonPoolParallelism() * 8)); | Scheduler.newNewThreadScheduler().scheduleBackgroundTask(it -> { |
bhatti/RxJava8 | src/test/java/com/plexobject/rx/ObservableCreateTest.java | // Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
| import java.util.function.Consumer;
import mockit.Mocked;
import mockit.Verifications;
import mockit.integration.junit4.JMockit;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.plexobject.rx.scheduler.Scheduler; | @Mocked
private Consumer<Throwable> onError;
@Mocked
private OnCompletion onCompleted;
@Test
public void testSubscribeCreate() throws Exception {
Observable<Integer> observable = Observable.create(observer -> {
observer.onNext(1);
observer.onNext(2);
observer.onNext(3);
observer.onCompleted();
});
observable.subscribe(onNext, onError, onCompleted);
new Verifications() {
{
onNext.accept(1);
onNext.accept(2);
onNext.accept(3);
onCompleted.onCompleted();
onError.accept((Throwable) any);
times = 0;
}
};
}
@Test
public void testSubscribeCreateAsync() throws Exception {
Observable<Integer> observable = Observable.create(observer -> { | // Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
// Path: src/test/java/com/plexobject/rx/ObservableCreateTest.java
import java.util.function.Consumer;
import mockit.Mocked;
import mockit.Verifications;
import mockit.integration.junit4.JMockit;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.plexobject.rx.scheduler.Scheduler;
@Mocked
private Consumer<Throwable> onError;
@Mocked
private OnCompletion onCompleted;
@Test
public void testSubscribeCreate() throws Exception {
Observable<Integer> observable = Observable.create(observer -> {
observer.onNext(1);
observer.onNext(2);
observer.onNext(3);
observer.onCompleted();
});
observable.subscribe(onNext, onError, onCompleted);
new Verifications() {
{
onNext.accept(1);
onNext.accept(2);
onNext.accept(3);
onCompleted.onCompleted();
onError.accept((Throwable) any);
times = 0;
}
};
}
@Test
public void testSubscribeCreateAsync() throws Exception {
Observable<Integer> observable = Observable.create(observer -> { | Scheduler.newNewThreadScheduler().scheduleBackgroundTask((o) -> { |
bhatti/RxJava8 | src/test/java/com/plexobject/rx/ObservableMergeZipTest.java | // Path: src/main/java/com/plexobject/rx/util/Tuple.java
// public class Tuple implements Serializable, Iterable<Object>,
// IntFunction<Object> {
// private static final long serialVersionUID = 1L;
// private final List<Object> objects = new ArrayList<>();
//
// @SuppressWarnings("unchecked")
// public Tuple(Object... objs) {
// Objects.requireNonNull(objs);
// for (Object o : objs) {
// if (o instanceof Collection) {
// Collection<Object> collection = (Collection<Object>) o;
// this.objects.addAll(collection);
// } else if (o.getClass().isArray()) {
// Object[] arr = (Object[]) o;
// this.objects.addAll(Arrays.asList(arr));
// } else if (o instanceof Tuple) {
// Tuple tuple = (Tuple) o;
// this.objects.addAll(tuple.objects);
// } else {
// this.objects.add(o);
// }
// }
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((objects == null) ? 0 : objects.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Tuple other = (Tuple) obj;
// if (objects == null) {
// if (other.objects != null)
// return false;
// } else if (!objects.equals(other.objects))
// return false;
// return true;
// }
//
// public <T> T getFirst() {
// return get(0);
// }
//
// public <T> T getSecond() {
// return get(1);
// }
//
// public <T> T getThird() {
// return get(1);
// }
//
// public <T> T getLast() {
// return get(objects.size() - 1);
// }
//
// @SuppressWarnings("unchecked")
// public <T> T get(int index) {
// return (T) objects.get(index);
// }
//
// @Override
// public Iterator<Object> iterator() {
// return objects.iterator();
// }
//
// @Override
// public Object apply(int index) {
// return get(index);
// }
//
// @Override
// public String toString() {
// return objects.toString();
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import com.plexobject.rx.util.Tuple; | assertNull(onError.get());
assertEquals(1, onCompleted.get());
}
@Test
public void testMergeToList() {
List<Integer> list = Observable.from(1, 2).merge(Observable.from(3, 4))
.toList();
assertEquals(new Integer(1), list.get(0));
assertEquals(new Integer(2), list.get(1));
assertEquals(new Integer(3), list.get(2));
assertEquals(new Integer(4), list.get(3));
}
@Test
public void testMergeToSet() {
Set<Integer> set = Observable.from(1, 2).merge(Observable.from(3, 4))
.merge(Observable.just(3)).toSet();
assertEquals(4, set.size());
assertTrue(set.contains(1));
assertTrue(set.contains(2));
assertTrue(set.contains(3));
assertTrue(set.contains(4));
}
@Test
public void testSubscribeZip() throws Exception {
Observable<String> observable1 = Observable.from("One", "Two", "Three");
Observable<Integer> observable2 = Observable.from(1, 2, 3); | // Path: src/main/java/com/plexobject/rx/util/Tuple.java
// public class Tuple implements Serializable, Iterable<Object>,
// IntFunction<Object> {
// private static final long serialVersionUID = 1L;
// private final List<Object> objects = new ArrayList<>();
//
// @SuppressWarnings("unchecked")
// public Tuple(Object... objs) {
// Objects.requireNonNull(objs);
// for (Object o : objs) {
// if (o instanceof Collection) {
// Collection<Object> collection = (Collection<Object>) o;
// this.objects.addAll(collection);
// } else if (o.getClass().isArray()) {
// Object[] arr = (Object[]) o;
// this.objects.addAll(Arrays.asList(arr));
// } else if (o instanceof Tuple) {
// Tuple tuple = (Tuple) o;
// this.objects.addAll(tuple.objects);
// } else {
// this.objects.add(o);
// }
// }
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((objects == null) ? 0 : objects.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Tuple other = (Tuple) obj;
// if (objects == null) {
// if (other.objects != null)
// return false;
// } else if (!objects.equals(other.objects))
// return false;
// return true;
// }
//
// public <T> T getFirst() {
// return get(0);
// }
//
// public <T> T getSecond() {
// return get(1);
// }
//
// public <T> T getThird() {
// return get(1);
// }
//
// public <T> T getLast() {
// return get(objects.size() - 1);
// }
//
// @SuppressWarnings("unchecked")
// public <T> T get(int index) {
// return (T) objects.get(index);
// }
//
// @Override
// public Iterator<Object> iterator() {
// return objects.iterator();
// }
//
// @Override
// public Object apply(int index) {
// return get(index);
// }
//
// @Override
// public String toString() {
// return objects.toString();
// }
//
// }
// Path: src/test/java/com/plexobject/rx/ObservableMergeZipTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import com.plexobject.rx.util.Tuple;
assertNull(onError.get());
assertEquals(1, onCompleted.get());
}
@Test
public void testMergeToList() {
List<Integer> list = Observable.from(1, 2).merge(Observable.from(3, 4))
.toList();
assertEquals(new Integer(1), list.get(0));
assertEquals(new Integer(2), list.get(1));
assertEquals(new Integer(3), list.get(2));
assertEquals(new Integer(4), list.get(3));
}
@Test
public void testMergeToSet() {
Set<Integer> set = Observable.from(1, 2).merge(Observable.from(3, 4))
.merge(Observable.just(3)).toSet();
assertEquals(4, set.size());
assertTrue(set.contains(1));
assertTrue(set.contains(2));
assertTrue(set.contains(3));
assertTrue(set.contains(4));
}
@Test
public void testSubscribeZip() throws Exception {
Observable<String> observable1 = Observable.from("One", "Two", "Three");
Observable<Integer> observable2 = Observable.from(1, 2, 3); | List<Tuple> expectedTuples = Arrays.asList(new Tuple("One", 1), |
bhatti/RxJava8 | src/test/java/com/plexobject/rx/ObservableSchedulerTest.java | // Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import com.plexobject.rx.scheduler.Scheduler; | package com.plexobject.rx;
public class ObservableSchedulerTest extends BaseObservableTest {
private static final int MAX_NUMBERS = 10;
@Test
public void testSubscribeFromWithTimer() throws Exception {
List<Long> times = new ArrayList<>();
Observable<Integer> observable = Observable.integers(1).limit(
MAX_NUMBERS);
initLatch(MAX_NUMBERS + 1); // N*onNext + onCompleted
| // Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
// Path: src/test/java/com/plexobject/rx/ObservableSchedulerTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import com.plexobject.rx.scheduler.Scheduler;
package com.plexobject.rx;
public class ObservableSchedulerTest extends BaseObservableTest {
private static final int MAX_NUMBERS = 10;
@Test
public void testSubscribeFromWithTimer() throws Exception {
List<Long> times = new ArrayList<>();
Observable<Integer> observable = Observable.integers(1).limit(
MAX_NUMBERS);
initLatch(MAX_NUMBERS + 1); // N*onNext + onCompleted
| observable.subscribeOn(Scheduler |
bhatti/RxJava8 | src/test/java/com/plexobject/rx/ObservableCountTest.java | // Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
| import java.util.function.Consumer;
import mockit.Mocked;
import mockit.Verifications;
import mockit.integration.junit4.JMockit;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.plexobject.rx.scheduler.Scheduler; | package com.plexobject.rx;
@RunWith(JMockit.class)
public class ObservableCountTest {
@Mocked
private Consumer<Long> onNext;
@Mocked
private Consumer<Throwable> onError;
@Mocked
private OnCompletion onCompleted;
@Test
public void testSubscribeCount() throws Exception {
Observable<Long> observable = Observable.from(1, 2, 3, 4, 5) | // Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
// Path: src/test/java/com/plexobject/rx/ObservableCountTest.java
import java.util.function.Consumer;
import mockit.Mocked;
import mockit.Verifications;
import mockit.integration.junit4.JMockit;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.plexobject.rx.scheduler.Scheduler;
package com.plexobject.rx;
@RunWith(JMockit.class)
public class ObservableCountTest {
@Mocked
private Consumer<Long> onNext;
@Mocked
private Consumer<Throwable> onError;
@Mocked
private OnCompletion onCompleted;
@Test
public void testSubscribeCount() throws Exception {
Observable<Long> observable = Observable.from(1, 2, 3, 4, 5) | .subscribeOn(Scheduler.newImmediateScheduler()).count(); |
bhatti/RxJava8 | src/main/java/com/plexobject/rx/impl/SubscriptionImpl.java | // Path: src/main/java/com/plexobject/rx/Cancelable.java
// public interface Cancelable {
// /**
// * Cancel this operation
// */
// void cancel();
//
// /**
// * Is operation canceled
// *
// * @return
// */
// boolean isCanceled();
// }
//
// Path: src/main/java/com/plexobject/rx/OnCompletion.java
// @FunctionalInterface
// public interface OnCompletion {
// /**
// * This method is called to notify user that all data is processed and there
// * is no more data.
// */
// void onCompleted();
// }
| import java.util.function.Consumer;
import com.plexobject.rx.Cancelable;
import com.plexobject.rx.OnCompletion; | package com.plexobject.rx.impl;
/**
* This class keeps track of user subscription including callback functions.
* This also allows user to unsubcribe from receiving data.
*
* @author Shahzad Bhatti
*
* @param <T>
* type of subscription data
*/
public class SubscriptionImpl<T> implements SubscriptionObserver<T> {
private final Consumer<T> onNext;
private final Consumer<Throwable> onError; | // Path: src/main/java/com/plexobject/rx/Cancelable.java
// public interface Cancelable {
// /**
// * Cancel this operation
// */
// void cancel();
//
// /**
// * Is operation canceled
// *
// * @return
// */
// boolean isCanceled();
// }
//
// Path: src/main/java/com/plexobject/rx/OnCompletion.java
// @FunctionalInterface
// public interface OnCompletion {
// /**
// * This method is called to notify user that all data is processed and there
// * is no more data.
// */
// void onCompleted();
// }
// Path: src/main/java/com/plexobject/rx/impl/SubscriptionImpl.java
import java.util.function.Consumer;
import com.plexobject.rx.Cancelable;
import com.plexobject.rx.OnCompletion;
package com.plexobject.rx.impl;
/**
* This class keeps track of user subscription including callback functions.
* This also allows user to unsubcribe from receiving data.
*
* @author Shahzad Bhatti
*
* @param <T>
* type of subscription data
*/
public class SubscriptionImpl<T> implements SubscriptionObserver<T> {
private final Consumer<T> onNext;
private final Consumer<Throwable> onError; | private final OnCompletion onCompletion; |
bhatti/RxJava8 | src/main/java/com/plexobject/rx/impl/SubscriptionImpl.java | // Path: src/main/java/com/plexobject/rx/Cancelable.java
// public interface Cancelable {
// /**
// * Cancel this operation
// */
// void cancel();
//
// /**
// * Is operation canceled
// *
// * @return
// */
// boolean isCanceled();
// }
//
// Path: src/main/java/com/plexobject/rx/OnCompletion.java
// @FunctionalInterface
// public interface OnCompletion {
// /**
// * This method is called to notify user that all data is processed and there
// * is no more data.
// */
// void onCompleted();
// }
| import java.util.function.Consumer;
import com.plexobject.rx.Cancelable;
import com.plexobject.rx.OnCompletion; | package com.plexobject.rx.impl;
/**
* This class keeps track of user subscription including callback functions.
* This also allows user to unsubcribe from receiving data.
*
* @author Shahzad Bhatti
*
* @param <T>
* type of subscription data
*/
public class SubscriptionImpl<T> implements SubscriptionObserver<T> {
private final Consumer<T> onNext;
private final Consumer<Throwable> onError;
private final OnCompletion onCompletion; | // Path: src/main/java/com/plexobject/rx/Cancelable.java
// public interface Cancelable {
// /**
// * Cancel this operation
// */
// void cancel();
//
// /**
// * Is operation canceled
// *
// * @return
// */
// boolean isCanceled();
// }
//
// Path: src/main/java/com/plexobject/rx/OnCompletion.java
// @FunctionalInterface
// public interface OnCompletion {
// /**
// * This method is called to notify user that all data is processed and there
// * is no more data.
// */
// void onCompleted();
// }
// Path: src/main/java/com/plexobject/rx/impl/SubscriptionImpl.java
import java.util.function.Consumer;
import com.plexobject.rx.Cancelable;
import com.plexobject.rx.OnCompletion;
package com.plexobject.rx.impl;
/**
* This class keeps track of user subscription including callback functions.
* This also allows user to unsubcribe from receiving data.
*
* @author Shahzad Bhatti
*
* @param <T>
* type of subscription data
*/
public class SubscriptionImpl<T> implements SubscriptionObserver<T> {
private final Consumer<T> onNext;
private final Consumer<Throwable> onError;
private final OnCompletion onCompletion; | private final Cancelable cancelable; |
bhatti/RxJava8 | src/test/java/com/plexobject/rx/ObservableTest.java | // Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
//
// Path: src/main/java/com/plexobject/rx/util/NatsSpliterator.java
// public class NatsSpliterator implements Spliterator<Integer>, Streamable<Integer> {
// private int number;
//
// public NatsSpliterator(int from) {
// this.number = from;
// }
//
// @Override
// public boolean tryAdvance(Consumer<? super Integer> action) {
// action.accept(number++);
// return true;
// }
//
// @Override
// public Spliterator<Integer> trySplit() {
// return null;
// }
//
// @Override
// public long estimateSize() {
// return Integer.MAX_VALUE;
// }
//
// @Override
// public int characteristics() {
// return Spliterator.IMMUTABLE;
// }
//
// public Stream<Integer> getStream() {
// return StreamSupport.stream(this, false);
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import org.junit.Test;
import com.plexobject.rx.scheduler.Scheduler;
import com.plexobject.rx.util.NatsSpliterator; | initLatch(names.size() + 1); // N*onNext + onCompleted
Observable<String> observable = Observable.from(names);
setupCallback(observable, null, true);
latch.await(100, TimeUnit.MILLISECONDS);
//
assertEquals(names.size(), onNext.get());
assertNull(onError.get());
assertEquals(1, onCompleted.get());
}
@Test
public void testSubscribeFromArray() throws Exception {
Observable<String> observable = Observable.from("one", "two", "three",
"four", "five");
initLatch(5 + 1); // N*onNext + onCompleted
setupCallback(observable, null, true);
latch.await(100, TimeUnit.MILLISECONDS);
//
assertEquals(5, onNext.get());
assertNull(onError.get());
assertEquals(1, onCompleted.get());
}
@Test
public void testSubscribeParallel() throws Exception {
Observable<Integer> observable = Observable.range(1, 101) | // Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
//
// Path: src/main/java/com/plexobject/rx/util/NatsSpliterator.java
// public class NatsSpliterator implements Spliterator<Integer>, Streamable<Integer> {
// private int number;
//
// public NatsSpliterator(int from) {
// this.number = from;
// }
//
// @Override
// public boolean tryAdvance(Consumer<? super Integer> action) {
// action.accept(number++);
// return true;
// }
//
// @Override
// public Spliterator<Integer> trySplit() {
// return null;
// }
//
// @Override
// public long estimateSize() {
// return Integer.MAX_VALUE;
// }
//
// @Override
// public int characteristics() {
// return Spliterator.IMMUTABLE;
// }
//
// public Stream<Integer> getStream() {
// return StreamSupport.stream(this, false);
// }
// }
// Path: src/test/java/com/plexobject/rx/ObservableTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import org.junit.Test;
import com.plexobject.rx.scheduler.Scheduler;
import com.plexobject.rx.util.NatsSpliterator;
initLatch(names.size() + 1); // N*onNext + onCompleted
Observable<String> observable = Observable.from(names);
setupCallback(observable, null, true);
latch.await(100, TimeUnit.MILLISECONDS);
//
assertEquals(names.size(), onNext.get());
assertNull(onError.get());
assertEquals(1, onCompleted.get());
}
@Test
public void testSubscribeFromArray() throws Exception {
Observable<String> observable = Observable.from("one", "two", "three",
"four", "five");
initLatch(5 + 1); // N*onNext + onCompleted
setupCallback(observable, null, true);
latch.await(100, TimeUnit.MILLISECONDS);
//
assertEquals(5, onNext.get());
assertNull(onError.get());
assertEquals(1, onCompleted.get());
}
@Test
public void testSubscribeParallel() throws Exception {
Observable<Integer> observable = Observable.range(1, 101) | .subscribeOn(Scheduler.newNewThreadScheduler()).parallel(); |
bhatti/RxJava8 | src/test/java/com/plexobject/rx/ObservableTest.java | // Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
//
// Path: src/main/java/com/plexobject/rx/util/NatsSpliterator.java
// public class NatsSpliterator implements Spliterator<Integer>, Streamable<Integer> {
// private int number;
//
// public NatsSpliterator(int from) {
// this.number = from;
// }
//
// @Override
// public boolean tryAdvance(Consumer<? super Integer> action) {
// action.accept(number++);
// return true;
// }
//
// @Override
// public Spliterator<Integer> trySplit() {
// return null;
// }
//
// @Override
// public long estimateSize() {
// return Integer.MAX_VALUE;
// }
//
// @Override
// public int characteristics() {
// return Spliterator.IMMUTABLE;
// }
//
// public Stream<Integer> getStream() {
// return StreamSupport.stream(this, false);
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import org.junit.Test;
import com.plexobject.rx.scheduler.Scheduler;
import com.plexobject.rx.util.NatsSpliterator; | initLatch(names.size() + 1); // N*onNext + onCompleted
Observable<String> observable = Observable.from(names.stream());
setupCallback(observable, null, true);
latch.await(100, TimeUnit.MILLISECONDS);
//
assertEquals(names.size(), onNext.get());
//
assertNull(onError.get());
assertEquals(1, onCompleted.get());
}
@Test
public void testSubscribeFromIterator() throws Exception {
initLatch(names.size() + 1); // N*onNext + onCompleted
Observable<String> observable = Observable.from(names.iterator());
setupCallback(observable, null, true);
latch.await(100, TimeUnit.MILLISECONDS);
//
assertEquals(names.size(), onNext.get());
//
assertNull(onError.get());
assertEquals(1, onCompleted.get());
}
@Test
public void testSubscribeFromInfiniteNats() throws Exception {
Observable<Integer> observable = Observable | // Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
//
// Path: src/main/java/com/plexobject/rx/util/NatsSpliterator.java
// public class NatsSpliterator implements Spliterator<Integer>, Streamable<Integer> {
// private int number;
//
// public NatsSpliterator(int from) {
// this.number = from;
// }
//
// @Override
// public boolean tryAdvance(Consumer<? super Integer> action) {
// action.accept(number++);
// return true;
// }
//
// @Override
// public Spliterator<Integer> trySplit() {
// return null;
// }
//
// @Override
// public long estimateSize() {
// return Integer.MAX_VALUE;
// }
//
// @Override
// public int characteristics() {
// return Spliterator.IMMUTABLE;
// }
//
// public Stream<Integer> getStream() {
// return StreamSupport.stream(this, false);
// }
// }
// Path: src/test/java/com/plexobject/rx/ObservableTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import org.junit.Test;
import com.plexobject.rx.scheduler.Scheduler;
import com.plexobject.rx.util.NatsSpliterator;
initLatch(names.size() + 1); // N*onNext + onCompleted
Observable<String> observable = Observable.from(names.stream());
setupCallback(observable, null, true);
latch.await(100, TimeUnit.MILLISECONDS);
//
assertEquals(names.size(), onNext.get());
//
assertNull(onError.get());
assertEquals(1, onCompleted.get());
}
@Test
public void testSubscribeFromIterator() throws Exception {
initLatch(names.size() + 1); // N*onNext + onCompleted
Observable<String> observable = Observable.from(names.iterator());
setupCallback(observable, null, true);
latch.await(100, TimeUnit.MILLISECONDS);
//
assertEquals(names.size(), onNext.get());
//
assertNull(onError.get());
assertEquals(1, onCompleted.get());
}
@Test
public void testSubscribeFromInfiniteNats() throws Exception {
Observable<Integer> observable = Observable | .from(new NatsSpliterator(0)); |
bhatti/RxJava8 | src/test/java/com/plexobject/rx/BaseObservableTest.java | // Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
| import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.plexobject.rx.scheduler.Scheduler; | package com.plexobject.rx;
public class BaseObservableTest {
protected final List<String> names = Arrays.asList("Erica", "Matt", "John",
"Mike", "Scott", "Alex", "Jeff", "Brad");
protected CountDownLatch latch;
protected AtomicReference<Throwable> onError;
protected AtomicInteger onNext;
protected AtomicInteger onCompleted; | // Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
// Path: src/test/java/com/plexobject/rx/BaseObservableTest.java
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.plexobject.rx.scheduler.Scheduler;
package com.plexobject.rx;
public class BaseObservableTest {
protected final List<String> names = Arrays.asList("Erica", "Matt", "John",
"Mike", "Scott", "Alex", "Jeff", "Brad");
protected CountDownLatch latch;
protected AtomicReference<Throwable> onError;
protected AtomicInteger onNext;
protected AtomicInteger onCompleted; | protected Scheduler[] allSchedulers = { Scheduler.newImmediateScheduler(), |
bhatti/RxJava8 | src/test/java/com/plexobject/rx/ObservableParallelTest.java | // Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import com.plexobject.rx.scheduler.Scheduler; | package com.plexobject.rx;
public class ObservableParallelTest extends BaseObservableTest {
@Test
public void testSubscribeParallelWithCancelation() throws Exception {
Observable<Integer> observable = Observable.range(1, 101) | // Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
// Path: src/test/java/com/plexobject/rx/ObservableParallelTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import com.plexobject.rx.scheduler.Scheduler;
package com.plexobject.rx;
public class ObservableParallelTest extends BaseObservableTest {
@Test
public void testSubscribeParallelWithCancelation() throws Exception {
Observable<Integer> observable = Observable.range(1, 101) | .subscribeOn(Scheduler.newNewThreadScheduler()).parallel(); |
bhatti/RxJava8 | src/test/java/com/plexobject/rx/ObservableErrorsTest.java | // Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import com.plexobject.rx.scheduler.Scheduler; | package com.plexobject.rx;
public class ObservableErrorsTest extends BaseObservableTest {
@Test
public void testSubscribeThrowing() throws Exception { | // Path: src/main/java/com/plexobject/rx/scheduler/Scheduler.java
// public interface Scheduler extends Disposable {
// /**
// * This method registers user-defined function that is invoked by scheduler
// *
// * @param consumer
// * - callback function to notify tick
// * @param handle
// * to pass in with consumer
// */
// <T> void scheduleBackgroundTask(Consumer<T> consumer, T handle);
//
// public static Scheduler newThreadPoolScheduler(int poolSize) {
// return new ThreadPoolScheduler(poolSize);
// }
//
// public static Scheduler newImmediateScheduler() {
// return new ImmediateScheduler();
// }
//
// public static Scheduler newNewThreadScheduler() {
// return new NewThreadScheduler();
// }
//
// public static Scheduler newTimerSchedulerWithMilliInterval(long interval) {
// return new TimerScheduler(interval);
// }
// }
// Path: src/test/java/com/plexobject/rx/ObservableErrorsTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import com.plexobject.rx.scheduler.Scheduler;
package com.plexobject.rx;
public class ObservableErrorsTest extends BaseObservableTest {
@Test
public void testSubscribeThrowing() throws Exception { | for (Scheduler scheduler : allSchedulers) { |
kittylyst/ocelotvm | src/main/java/ocelot/rt/OtField.java | // Path: src/main/java/ocelot/JVMType.java
// public enum JVMType {
// Z, B, S, C, I, J, F, D, A
// }
| import ocelot.JVMType; | package ocelot.rt;
public class OtField {
private final String name; | // Path: src/main/java/ocelot/JVMType.java
// public enum JVMType {
// Z, B, S, C, I, J, F, D, A
// }
// Path: src/main/java/ocelot/rt/OtField.java
import ocelot.JVMType;
package ocelot.rt;
public class OtField {
private final String name; | private final JVMType type; |
kittylyst/ocelotvm | src/main/java/ocelot/JVMStorage.java | // Path: src/main/java/ocelot/rt/OtObj.java
// public final class OtObj {
// private final OtMeta mark = new OtMeta();
// private final OtKlass klass;
// private final long id;
// private final JVMValue[] fields;
//
// static OtObj of(OtKlass klass, long id) {
// final OtObj out = new OtObj(klass, id);
// return out;
// }
//
// private OtObj(OtKlass klass, long id_) {
// this.klass = klass;
// id = id_;
// fields = new JVMValue[klass.numFields()];
// }
//
// @Override
// public String toString() {
// return "OtObj{" + "mark=" + mark + ", meta=" + klass + ", id=" + id + '}';
// }
//
// public long getId() {
// return id;
// }
//
// public OtMeta getMark() {
// return mark;
// }
//
// public OtKlass getKlass() {
// return klass;
// }
//
// public JVMValue getField(OtField f) {
// return fields[klass.getFieldOffset(f)];
// }
//
// public void putField(OtField f, JVMValue val) {
// fields[klass.getFieldOffset(f)] = val;
// }
// }
//
// Path: src/main/java/ocelot/rt/OtKlass.java
// public final class OtKlass {
// private final String name;
// private final String superClass;
//
// private final Map<Short, String> klassNamesByIndex = new HashMap<>();
//
// private final Map<String, OtMethod> methodsByName = new HashMap<>();
// private final Map<Short, String> methodNamesByIndex = new HashMap<>();
//
// // The ordered fields, needed for object layout
// private final List<OtField> orderedFields = new ArrayList<>();
// private final Map<String, OtField> fieldsByName = new HashMap<>();
// private final Map<Short, String> fieldNamesByIndex = new HashMap<>();
//
// // The actual values of the static fields
// private final Map<String, JVMValue> staticFieldsByName = new HashMap<>();
//
// public OtKlass(String className, String superClassName) {
// name = className;
// superClass = superClassName;
// }
//
// public String getParent() {
// return superClass;
// }
//
// public void addDefinedMethod(OtMethod m) {
// methodsByName.put(m.getNameAndType(), m);
// }
//
// public void addCPMethodRef(short index, String methodName) {
// methodNamesByIndex.put(index, methodName);
// }
//
// public void addCPKlassRef(short index, String methodName) {
// klassNamesByIndex.put(index, methodName);
// }
//
// public OtMethod getMethodByName(String nameAndType) {
// return methodsByName.get(nameAndType);
// }
//
// public Collection<OtMethod> getMethods() {
// return methodsByName.values();
// }
//
// public Collection<OtField> getFields() {
// return fieldsByName.values();
// }
//
// public String getName() {
// return name;
// }
//
// public String getMethodNameByCPIndex(short cpIndex) {
// return methodNamesByIndex.get(cpIndex);
// }
//
// public String getKlassNameByCPIndex(short cpIndex) {
// return klassNamesByIndex.get(cpIndex);
// }
//
// public void callClInit(InterpMain interpreter) {
// final OtMethod meth = methodsByName.get("<clinit>:()V");
//
// if (meth != null) {
// interpreter.execMethod(meth);
// }
// }
//
// public void setStaticField(String name, JVMValue val) {
// staticFieldsByName.put(name, val);
// }
//
// public JVMValue getStaticField(OtField f) {
// return staticFieldsByName.get(f.getName());
// }
//
// public void addField(OtField field) {
// fieldsByName.put(field.getName(), field);
// if ((field.getFlags() & ACC_STATIC) > 0) {
// addCPStaticField(field.getName());
// } else {
// orderedFields.add(field);
// }
// }
//
// void addCPStaticField(String name) {
// staticFieldsByName.put(name, null);
// }
//
// public void addCPFieldRef(short index, String name) {
// fieldNamesByIndex.put(index, name);
// }
//
// public String getFieldByCPIndex(short cpIndex) {
// return fieldNamesByIndex.get(cpIndex);
// }
//
// public OtField getFieldByName(String fieldName) {
// return fieldsByName.get(fieldName);
// }
//
// public void addDefinedField(OtField ocf) {
// fieldsByName.put(ocf.getName(), ocf);
// }
//
// public int numFields() {
// return orderedFields.size();
// }
//
// public int getFieldOffset(OtField f) {
// // FIXME
// return 0;
// }
// }
| import ocelot.rt.OtObj;
import ocelot.rt.OtKlass; | package ocelot;
/**
*
* @author ben
*/
public interface JVMStorage {
public long allocateObj(OtKlass klass);
| // Path: src/main/java/ocelot/rt/OtObj.java
// public final class OtObj {
// private final OtMeta mark = new OtMeta();
// private final OtKlass klass;
// private final long id;
// private final JVMValue[] fields;
//
// static OtObj of(OtKlass klass, long id) {
// final OtObj out = new OtObj(klass, id);
// return out;
// }
//
// private OtObj(OtKlass klass, long id_) {
// this.klass = klass;
// id = id_;
// fields = new JVMValue[klass.numFields()];
// }
//
// @Override
// public String toString() {
// return "OtObj{" + "mark=" + mark + ", meta=" + klass + ", id=" + id + '}';
// }
//
// public long getId() {
// return id;
// }
//
// public OtMeta getMark() {
// return mark;
// }
//
// public OtKlass getKlass() {
// return klass;
// }
//
// public JVMValue getField(OtField f) {
// return fields[klass.getFieldOffset(f)];
// }
//
// public void putField(OtField f, JVMValue val) {
// fields[klass.getFieldOffset(f)] = val;
// }
// }
//
// Path: src/main/java/ocelot/rt/OtKlass.java
// public final class OtKlass {
// private final String name;
// private final String superClass;
//
// private final Map<Short, String> klassNamesByIndex = new HashMap<>();
//
// private final Map<String, OtMethod> methodsByName = new HashMap<>();
// private final Map<Short, String> methodNamesByIndex = new HashMap<>();
//
// // The ordered fields, needed for object layout
// private final List<OtField> orderedFields = new ArrayList<>();
// private final Map<String, OtField> fieldsByName = new HashMap<>();
// private final Map<Short, String> fieldNamesByIndex = new HashMap<>();
//
// // The actual values of the static fields
// private final Map<String, JVMValue> staticFieldsByName = new HashMap<>();
//
// public OtKlass(String className, String superClassName) {
// name = className;
// superClass = superClassName;
// }
//
// public String getParent() {
// return superClass;
// }
//
// public void addDefinedMethod(OtMethod m) {
// methodsByName.put(m.getNameAndType(), m);
// }
//
// public void addCPMethodRef(short index, String methodName) {
// methodNamesByIndex.put(index, methodName);
// }
//
// public void addCPKlassRef(short index, String methodName) {
// klassNamesByIndex.put(index, methodName);
// }
//
// public OtMethod getMethodByName(String nameAndType) {
// return methodsByName.get(nameAndType);
// }
//
// public Collection<OtMethod> getMethods() {
// return methodsByName.values();
// }
//
// public Collection<OtField> getFields() {
// return fieldsByName.values();
// }
//
// public String getName() {
// return name;
// }
//
// public String getMethodNameByCPIndex(short cpIndex) {
// return methodNamesByIndex.get(cpIndex);
// }
//
// public String getKlassNameByCPIndex(short cpIndex) {
// return klassNamesByIndex.get(cpIndex);
// }
//
// public void callClInit(InterpMain interpreter) {
// final OtMethod meth = methodsByName.get("<clinit>:()V");
//
// if (meth != null) {
// interpreter.execMethod(meth);
// }
// }
//
// public void setStaticField(String name, JVMValue val) {
// staticFieldsByName.put(name, val);
// }
//
// public JVMValue getStaticField(OtField f) {
// return staticFieldsByName.get(f.getName());
// }
//
// public void addField(OtField field) {
// fieldsByName.put(field.getName(), field);
// if ((field.getFlags() & ACC_STATIC) > 0) {
// addCPStaticField(field.getName());
// } else {
// orderedFields.add(field);
// }
// }
//
// void addCPStaticField(String name) {
// staticFieldsByName.put(name, null);
// }
//
// public void addCPFieldRef(short index, String name) {
// fieldNamesByIndex.put(index, name);
// }
//
// public String getFieldByCPIndex(short cpIndex) {
// return fieldNamesByIndex.get(cpIndex);
// }
//
// public OtField getFieldByName(String fieldName) {
// return fieldsByName.get(fieldName);
// }
//
// public void addDefinedField(OtField ocf) {
// fieldsByName.put(ocf.getName(), ocf);
// }
//
// public int numFields() {
// return orderedFields.size();
// }
//
// public int getFieldOffset(OtField f) {
// // FIXME
// return 0;
// }
// }
// Path: src/main/java/ocelot/JVMStorage.java
import ocelot.rt.OtObj;
import ocelot.rt.OtKlass;
package ocelot;
/**
*
* @author ben
*/
public interface JVMStorage {
public long allocateObj(OtKlass klass);
| public OtObj findObject(long id); |
kittylyst/ocelotvm | src/main/java/ocelot/InterpLocalVars.java | // Path: src/main/java/ocelot/JVMType.java
// public enum JVMType {
// Z, B, S, C, I, J, F, D, A
// }
//
// Path: src/main/java/ocelot/JVMValue.java
// public static JVMValue entry(double d) {
// return new JVMValue(JVMType.D, Double.doubleToLongBits(d));
// }
| import static ocelot.JVMType.*;
import static ocelot.JVMValue.entry; | package ocelot;
/**
*
* @author ben
*/
public final class InterpLocalVars {
private final JVMValue[] vars = new JVMValue[256];
public InterpLocalVars() {
}
void iinc(byte offset, byte amount) {
JVMValue localVar = vars[offset & 0xff];
// Type check...
if (localVar.type != I)
throw new IllegalStateException("Wrong type " + localVar.type + " encountered at local var: " + (offset & 0xff) + " should be I");
// FIXME Overflow...? | // Path: src/main/java/ocelot/JVMType.java
// public enum JVMType {
// Z, B, S, C, I, J, F, D, A
// }
//
// Path: src/main/java/ocelot/JVMValue.java
// public static JVMValue entry(double d) {
// return new JVMValue(JVMType.D, Double.doubleToLongBits(d));
// }
// Path: src/main/java/ocelot/InterpLocalVars.java
import static ocelot.JVMType.*;
import static ocelot.JVMValue.entry;
package ocelot;
/**
*
* @author ben
*/
public final class InterpLocalVars {
private final JVMValue[] vars = new JVMValue[256];
public InterpLocalVars() {
}
void iinc(byte offset, byte amount) {
JVMValue localVar = vars[offset & 0xff];
// Type check...
if (localVar.type != I)
throw new IllegalStateException("Wrong type " + localVar.type + " encountered at local var: " + (offset & 0xff) + " should be I");
// FIXME Overflow...? | vars[offset & 0xff] = entry(amount + (int)localVar.value); |
kittylyst/ocelotvm | src/main/java/ocelot/rt/OtMethod.java | // Path: src/main/java/ocelot/Opcode.java
// public enum Opcode {
// ACONST_NULL(0x01),
// ALOAD(0x19, 1),
// ALOAD_0(0x2a),
// ALOAD_1(0x2b),
// ARETURN(0xb0),
// ASTORE(0x53, 1),
// ASTORE_0(0x4b),
// ASTORE_1(0x4c),
// BIPUSH(0x10, 1),
// BREAKPOINT(0xca),
// DADD(0x63),
// DCONST_0(0x0e),
// DCONST_1(0x0f),
// DLOAD(0x18, 1),
// DLOAD_0(0x26),
// DLOAD_1(0x27),
// DLOAD_2(0x28),
// DLOAD_3(0x29),
// DRETURN(0xaf),
// DSTORE(0x39, 1),
// DSTORE_0(0x47),
// DSTORE_1(0x48),
// DSTORE_2(0x49),
// DSTORE_3(0x4a),
// DSUB(0x67),
// DUP(0x59),
// DUP_X1(0x5a),
// GETFIELD(0xb4, 2),
// GETSTATIC(0xb2, 2),
// GOTO(0xa7, 2),
// I2D(0x87),
// IADD(0x60),
// IAND(0x7e),
// ICONST_M1(0x02),
// ICONST_0(0x03),
// ICONST_1(0x04),
// ICONST_2(0x05),
// ICONST_3(0x06),
// ICONST_4(0x07),
// ICONST_5(0x08),
// IDIV(0x6c),
// IF_ICMPEQ(0x9f, 2),
// IFEQ(0x99, 2),
// IFGE(0x9c, 2),
// IFGT(0x9d, 2),
// IFLE(0x9e, 2),
// IFLT(0x9b, 2),
// IFNE(0x9a, 2),
// IFNONNULL(0xc7, 2),
// IFNULL(0xc6, 2),
// IINC(0x84, 2),
// ILOAD(0x15, 1),
// ILOAD_0(0x1a),
// ILOAD_1(0x1b),
// ILOAD_2(0x1c),
// ILOAD_3(0x1d),
// IMPDEP1(0xfe),
// IMPDEP2(0xff),
// IMUL(0x68),
// INEG(0x74),
// INVOKESPECIAL(0xb7, 2),
// INVOKESTATIC(0xb8, 2),
// INVOKEVIRTUAL(0xb6, 2),
// IOR(0x80),
// IREM(0x70),
// IRETURN(0xac),
// ISTORE(0x36, 1),
// ISTORE_0(0x3b),
// ISTORE_1(0x3c),
// ISTORE_2(0x3d),
// ISTORE_3(0x3e),
// ISUB(0x64),
// MONITORENTER(0xc2),
// MONITOREXIT(0xc3),
// NEW(0xbb, 2),
// JSR(0xa8, 2),
// JSR_W(0xc9, 2),
// LDC(0x12, 1),
// NOP(0x00),
// POP(0x57),
// POP2(0x58),
// PUTFIELD(0xb5, 2),
// PUTSTATIC(0xb3, 2),
// RET(0xa9, 1),
// RETURN(0xb1),
// SIPUSH(0x11, 2),
// SWAP(0x5f);
//
// public byte numParams() {
// return numParams;
// }
// private final int opcode;
// private final byte numParams;
//
// public int getOpcode() {
// return opcode;
// }
//
// public byte B() {
// return (byte) opcode;
// }
//
// private Opcode(final int b) {
// this(b, 0);
// }
//
// private Opcode(final int b, final int p) {
// opcode = b;
// numParams = (byte) p;
// }
// }
//
// Path: src/main/java/ocelot/classfile/OtKlassParser.java
// public static final int ACC_PUBLIC = 0x0001; // Declared public; may be accessed from outside its package.
//
// Path: src/main/java/ocelot/classfile/OtKlassParser.java
// public static final int ACC_STATIC = 0x0008; // Declared static
| import static ocelot.Opcode.*;
import static ocelot.classfile.OtKlassParser.ACC_PUBLIC;
import static ocelot.classfile.OtKlassParser.ACC_STATIC; | package ocelot.rt;
/**
* @author ben
*/
public class OtMethod {
private final String className;
private final String nameAndType;
private final byte[] bytecode;
private final String signature;
private final int flags;
private int numParams = -1;
private static final byte[] JUST_RETURN = {RETURN.B()};
| // Path: src/main/java/ocelot/Opcode.java
// public enum Opcode {
// ACONST_NULL(0x01),
// ALOAD(0x19, 1),
// ALOAD_0(0x2a),
// ALOAD_1(0x2b),
// ARETURN(0xb0),
// ASTORE(0x53, 1),
// ASTORE_0(0x4b),
// ASTORE_1(0x4c),
// BIPUSH(0x10, 1),
// BREAKPOINT(0xca),
// DADD(0x63),
// DCONST_0(0x0e),
// DCONST_1(0x0f),
// DLOAD(0x18, 1),
// DLOAD_0(0x26),
// DLOAD_1(0x27),
// DLOAD_2(0x28),
// DLOAD_3(0x29),
// DRETURN(0xaf),
// DSTORE(0x39, 1),
// DSTORE_0(0x47),
// DSTORE_1(0x48),
// DSTORE_2(0x49),
// DSTORE_3(0x4a),
// DSUB(0x67),
// DUP(0x59),
// DUP_X1(0x5a),
// GETFIELD(0xb4, 2),
// GETSTATIC(0xb2, 2),
// GOTO(0xa7, 2),
// I2D(0x87),
// IADD(0x60),
// IAND(0x7e),
// ICONST_M1(0x02),
// ICONST_0(0x03),
// ICONST_1(0x04),
// ICONST_2(0x05),
// ICONST_3(0x06),
// ICONST_4(0x07),
// ICONST_5(0x08),
// IDIV(0x6c),
// IF_ICMPEQ(0x9f, 2),
// IFEQ(0x99, 2),
// IFGE(0x9c, 2),
// IFGT(0x9d, 2),
// IFLE(0x9e, 2),
// IFLT(0x9b, 2),
// IFNE(0x9a, 2),
// IFNONNULL(0xc7, 2),
// IFNULL(0xc6, 2),
// IINC(0x84, 2),
// ILOAD(0x15, 1),
// ILOAD_0(0x1a),
// ILOAD_1(0x1b),
// ILOAD_2(0x1c),
// ILOAD_3(0x1d),
// IMPDEP1(0xfe),
// IMPDEP2(0xff),
// IMUL(0x68),
// INEG(0x74),
// INVOKESPECIAL(0xb7, 2),
// INVOKESTATIC(0xb8, 2),
// INVOKEVIRTUAL(0xb6, 2),
// IOR(0x80),
// IREM(0x70),
// IRETURN(0xac),
// ISTORE(0x36, 1),
// ISTORE_0(0x3b),
// ISTORE_1(0x3c),
// ISTORE_2(0x3d),
// ISTORE_3(0x3e),
// ISUB(0x64),
// MONITORENTER(0xc2),
// MONITOREXIT(0xc3),
// NEW(0xbb, 2),
// JSR(0xa8, 2),
// JSR_W(0xc9, 2),
// LDC(0x12, 1),
// NOP(0x00),
// POP(0x57),
// POP2(0x58),
// PUTFIELD(0xb5, 2),
// PUTSTATIC(0xb3, 2),
// RET(0xa9, 1),
// RETURN(0xb1),
// SIPUSH(0x11, 2),
// SWAP(0x5f);
//
// public byte numParams() {
// return numParams;
// }
// private final int opcode;
// private final byte numParams;
//
// public int getOpcode() {
// return opcode;
// }
//
// public byte B() {
// return (byte) opcode;
// }
//
// private Opcode(final int b) {
// this(b, 0);
// }
//
// private Opcode(final int b, final int p) {
// opcode = b;
// numParams = (byte) p;
// }
// }
//
// Path: src/main/java/ocelot/classfile/OtKlassParser.java
// public static final int ACC_PUBLIC = 0x0001; // Declared public; may be accessed from outside its package.
//
// Path: src/main/java/ocelot/classfile/OtKlassParser.java
// public static final int ACC_STATIC = 0x0008; // Declared static
// Path: src/main/java/ocelot/rt/OtMethod.java
import static ocelot.Opcode.*;
import static ocelot.classfile.OtKlassParser.ACC_PUBLIC;
import static ocelot.classfile.OtKlassParser.ACC_STATIC;
package ocelot.rt;
/**
* @author ben
*/
public class OtMethod {
private final String className;
private final String nameAndType;
private final byte[] bytecode;
private final String signature;
private final int flags;
private int numParams = -1;
private static final byte[] JUST_RETURN = {RETURN.B()};
| public static final OtMethod OBJ_INIT = new OtMethod("java/lang/Object", "()V", "<init>:()V", ACC_PUBLIC, JUST_RETURN); |
kittylyst/ocelotvm | src/main/java/ocelot/rt/OtMethod.java | // Path: src/main/java/ocelot/Opcode.java
// public enum Opcode {
// ACONST_NULL(0x01),
// ALOAD(0x19, 1),
// ALOAD_0(0x2a),
// ALOAD_1(0x2b),
// ARETURN(0xb0),
// ASTORE(0x53, 1),
// ASTORE_0(0x4b),
// ASTORE_1(0x4c),
// BIPUSH(0x10, 1),
// BREAKPOINT(0xca),
// DADD(0x63),
// DCONST_0(0x0e),
// DCONST_1(0x0f),
// DLOAD(0x18, 1),
// DLOAD_0(0x26),
// DLOAD_1(0x27),
// DLOAD_2(0x28),
// DLOAD_3(0x29),
// DRETURN(0xaf),
// DSTORE(0x39, 1),
// DSTORE_0(0x47),
// DSTORE_1(0x48),
// DSTORE_2(0x49),
// DSTORE_3(0x4a),
// DSUB(0x67),
// DUP(0x59),
// DUP_X1(0x5a),
// GETFIELD(0xb4, 2),
// GETSTATIC(0xb2, 2),
// GOTO(0xa7, 2),
// I2D(0x87),
// IADD(0x60),
// IAND(0x7e),
// ICONST_M1(0x02),
// ICONST_0(0x03),
// ICONST_1(0x04),
// ICONST_2(0x05),
// ICONST_3(0x06),
// ICONST_4(0x07),
// ICONST_5(0x08),
// IDIV(0x6c),
// IF_ICMPEQ(0x9f, 2),
// IFEQ(0x99, 2),
// IFGE(0x9c, 2),
// IFGT(0x9d, 2),
// IFLE(0x9e, 2),
// IFLT(0x9b, 2),
// IFNE(0x9a, 2),
// IFNONNULL(0xc7, 2),
// IFNULL(0xc6, 2),
// IINC(0x84, 2),
// ILOAD(0x15, 1),
// ILOAD_0(0x1a),
// ILOAD_1(0x1b),
// ILOAD_2(0x1c),
// ILOAD_3(0x1d),
// IMPDEP1(0xfe),
// IMPDEP2(0xff),
// IMUL(0x68),
// INEG(0x74),
// INVOKESPECIAL(0xb7, 2),
// INVOKESTATIC(0xb8, 2),
// INVOKEVIRTUAL(0xb6, 2),
// IOR(0x80),
// IREM(0x70),
// IRETURN(0xac),
// ISTORE(0x36, 1),
// ISTORE_0(0x3b),
// ISTORE_1(0x3c),
// ISTORE_2(0x3d),
// ISTORE_3(0x3e),
// ISUB(0x64),
// MONITORENTER(0xc2),
// MONITOREXIT(0xc3),
// NEW(0xbb, 2),
// JSR(0xa8, 2),
// JSR_W(0xc9, 2),
// LDC(0x12, 1),
// NOP(0x00),
// POP(0x57),
// POP2(0x58),
// PUTFIELD(0xb5, 2),
// PUTSTATIC(0xb3, 2),
// RET(0xa9, 1),
// RETURN(0xb1),
// SIPUSH(0x11, 2),
// SWAP(0x5f);
//
// public byte numParams() {
// return numParams;
// }
// private final int opcode;
// private final byte numParams;
//
// public int getOpcode() {
// return opcode;
// }
//
// public byte B() {
// return (byte) opcode;
// }
//
// private Opcode(final int b) {
// this(b, 0);
// }
//
// private Opcode(final int b, final int p) {
// opcode = b;
// numParams = (byte) p;
// }
// }
//
// Path: src/main/java/ocelot/classfile/OtKlassParser.java
// public static final int ACC_PUBLIC = 0x0001; // Declared public; may be accessed from outside its package.
//
// Path: src/main/java/ocelot/classfile/OtKlassParser.java
// public static final int ACC_STATIC = 0x0008; // Declared static
| import static ocelot.Opcode.*;
import static ocelot.classfile.OtKlassParser.ACC_PUBLIC;
import static ocelot.classfile.OtKlassParser.ACC_STATIC; | package ocelot.rt;
/**
* @author ben
*/
public class OtMethod {
private final String className;
private final String nameAndType;
private final byte[] bytecode;
private final String signature;
private final int flags;
private int numParams = -1;
private static final byte[] JUST_RETURN = {RETURN.B()};
public static final OtMethod OBJ_INIT = new OtMethod("java/lang/Object", "()V", "<init>:()V", ACC_PUBLIC, JUST_RETURN);
public OtMethod(final String klassName, final String sig, final String nameType, final int fls, final byte[] buf) {
signature = sig;
nameAndType = nameType;
bytecode = buf;
flags = fls;
className = klassName;
}
public String getClassName() {
return className;
}
public String getNameAndType() {
return nameAndType;
}
public String getSignature() {
return signature;
}
public int getFlags() {
return flags;
}
public boolean isStatic() { | // Path: src/main/java/ocelot/Opcode.java
// public enum Opcode {
// ACONST_NULL(0x01),
// ALOAD(0x19, 1),
// ALOAD_0(0x2a),
// ALOAD_1(0x2b),
// ARETURN(0xb0),
// ASTORE(0x53, 1),
// ASTORE_0(0x4b),
// ASTORE_1(0x4c),
// BIPUSH(0x10, 1),
// BREAKPOINT(0xca),
// DADD(0x63),
// DCONST_0(0x0e),
// DCONST_1(0x0f),
// DLOAD(0x18, 1),
// DLOAD_0(0x26),
// DLOAD_1(0x27),
// DLOAD_2(0x28),
// DLOAD_3(0x29),
// DRETURN(0xaf),
// DSTORE(0x39, 1),
// DSTORE_0(0x47),
// DSTORE_1(0x48),
// DSTORE_2(0x49),
// DSTORE_3(0x4a),
// DSUB(0x67),
// DUP(0x59),
// DUP_X1(0x5a),
// GETFIELD(0xb4, 2),
// GETSTATIC(0xb2, 2),
// GOTO(0xa7, 2),
// I2D(0x87),
// IADD(0x60),
// IAND(0x7e),
// ICONST_M1(0x02),
// ICONST_0(0x03),
// ICONST_1(0x04),
// ICONST_2(0x05),
// ICONST_3(0x06),
// ICONST_4(0x07),
// ICONST_5(0x08),
// IDIV(0x6c),
// IF_ICMPEQ(0x9f, 2),
// IFEQ(0x99, 2),
// IFGE(0x9c, 2),
// IFGT(0x9d, 2),
// IFLE(0x9e, 2),
// IFLT(0x9b, 2),
// IFNE(0x9a, 2),
// IFNONNULL(0xc7, 2),
// IFNULL(0xc6, 2),
// IINC(0x84, 2),
// ILOAD(0x15, 1),
// ILOAD_0(0x1a),
// ILOAD_1(0x1b),
// ILOAD_2(0x1c),
// ILOAD_3(0x1d),
// IMPDEP1(0xfe),
// IMPDEP2(0xff),
// IMUL(0x68),
// INEG(0x74),
// INVOKESPECIAL(0xb7, 2),
// INVOKESTATIC(0xb8, 2),
// INVOKEVIRTUAL(0xb6, 2),
// IOR(0x80),
// IREM(0x70),
// IRETURN(0xac),
// ISTORE(0x36, 1),
// ISTORE_0(0x3b),
// ISTORE_1(0x3c),
// ISTORE_2(0x3d),
// ISTORE_3(0x3e),
// ISUB(0x64),
// MONITORENTER(0xc2),
// MONITOREXIT(0xc3),
// NEW(0xbb, 2),
// JSR(0xa8, 2),
// JSR_W(0xc9, 2),
// LDC(0x12, 1),
// NOP(0x00),
// POP(0x57),
// POP2(0x58),
// PUTFIELD(0xb5, 2),
// PUTSTATIC(0xb3, 2),
// RET(0xa9, 1),
// RETURN(0xb1),
// SIPUSH(0x11, 2),
// SWAP(0x5f);
//
// public byte numParams() {
// return numParams;
// }
// private final int opcode;
// private final byte numParams;
//
// public int getOpcode() {
// return opcode;
// }
//
// public byte B() {
// return (byte) opcode;
// }
//
// private Opcode(final int b) {
// this(b, 0);
// }
//
// private Opcode(final int b, final int p) {
// opcode = b;
// numParams = (byte) p;
// }
// }
//
// Path: src/main/java/ocelot/classfile/OtKlassParser.java
// public static final int ACC_PUBLIC = 0x0001; // Declared public; may be accessed from outside its package.
//
// Path: src/main/java/ocelot/classfile/OtKlassParser.java
// public static final int ACC_STATIC = 0x0008; // Declared static
// Path: src/main/java/ocelot/rt/OtMethod.java
import static ocelot.Opcode.*;
import static ocelot.classfile.OtKlassParser.ACC_PUBLIC;
import static ocelot.classfile.OtKlassParser.ACC_STATIC;
package ocelot.rt;
/**
* @author ben
*/
public class OtMethod {
private final String className;
private final String nameAndType;
private final byte[] bytecode;
private final String signature;
private final int flags;
private int numParams = -1;
private static final byte[] JUST_RETURN = {RETURN.B()};
public static final OtMethod OBJ_INIT = new OtMethod("java/lang/Object", "()V", "<init>:()V", ACC_PUBLIC, JUST_RETURN);
public OtMethod(final String klassName, final String sig, final String nameType, final int fls, final byte[] buf) {
signature = sig;
nameAndType = nameType;
bytecode = buf;
flags = fls;
className = klassName;
}
public String getClassName() {
return className;
}
public String getNameAndType() {
return nameAndType;
}
public String getSignature() {
return signature;
}
public int getFlags() {
return flags;
}
public boolean isStatic() { | return (flags & ACC_STATIC) > 0; |
kittylyst/ocelotvm | src/main/java/ocelot/rt/OtObj.java | // Path: src/main/java/ocelot/JVMValue.java
// public class JVMValue {
//
// public final JVMType type;
// public final long value;
//
// public JVMValue(JVMType t, long bits) {
// this.type = t;
// this.value = bits;
// }
//
// JVMValue copy() {
// return new JVMValue(type, value);
// }
//
// public static JVMValue entry(double d) {
// return new JVMValue(JVMType.D, Double.doubleToLongBits(d));
// }
//
// public static JVMValue entry(int i) {
// return new JVMValue(JVMType.I, i);
// }
//
// public static JVMValue entryRef(long id) {
// return new JVMValue(JVMType.A, id);
// }
//
// }
| import ocelot.JVMValue; | package ocelot.rt;
/**
* The class that implements a heap-allocated JVM object
*
* @author ben
*/
public final class OtObj {
private final OtMeta mark = new OtMeta();
private final OtKlass klass;
private final long id; | // Path: src/main/java/ocelot/JVMValue.java
// public class JVMValue {
//
// public final JVMType type;
// public final long value;
//
// public JVMValue(JVMType t, long bits) {
// this.type = t;
// this.value = bits;
// }
//
// JVMValue copy() {
// return new JVMValue(type, value);
// }
//
// public static JVMValue entry(double d) {
// return new JVMValue(JVMType.D, Double.doubleToLongBits(d));
// }
//
// public static JVMValue entry(int i) {
// return new JVMValue(JVMType.I, i);
// }
//
// public static JVMValue entryRef(long id) {
// return new JVMValue(JVMType.A, id);
// }
//
// }
// Path: src/main/java/ocelot/rt/OtObj.java
import ocelot.JVMValue;
package ocelot.rt;
/**
* The class that implements a heap-allocated JVM object
*
* @author ben
*/
public final class OtObj {
private final OtMeta mark = new OtMeta();
private final OtKlass klass;
private final long id; | private final JVMValue[] fields; |
kittylyst/ocelotvm | src/main/java/ocelot/InterpEvalStack.java | // Path: src/main/java/ocelot/JVMValue.java
// public static JVMValue entry(double d) {
// return new JVMValue(JVMType.D, Double.doubleToLongBits(d));
// }
//
// Path: src/main/java/ocelot/JVMValue.java
// public static JVMValue entryRef(long id) {
// return new JVMValue(JVMType.A, id);
// }
| import java.util.Stack;
import static ocelot.JVMValue.entry;
import static ocelot.JVMValue.entryRef; | package ocelot;
/**
*
* @author ben
*/
public class InterpEvalStack extends Stack<JVMValue> {
void iconst(int i) { | // Path: src/main/java/ocelot/JVMValue.java
// public static JVMValue entry(double d) {
// return new JVMValue(JVMType.D, Double.doubleToLongBits(d));
// }
//
// Path: src/main/java/ocelot/JVMValue.java
// public static JVMValue entryRef(long id) {
// return new JVMValue(JVMType.A, id);
// }
// Path: src/main/java/ocelot/InterpEvalStack.java
import java.util.Stack;
import static ocelot.JVMValue.entry;
import static ocelot.JVMValue.entryRef;
package ocelot;
/**
*
* @author ben
*/
public class InterpEvalStack extends Stack<JVMValue> {
void iconst(int i) { | push(entry(i)); |
kittylyst/ocelotvm | src/main/java/ocelot/InterpEvalStack.java | // Path: src/main/java/ocelot/JVMValue.java
// public static JVMValue entry(double d) {
// return new JVMValue(JVMType.D, Double.doubleToLongBits(d));
// }
//
// Path: src/main/java/ocelot/JVMValue.java
// public static JVMValue entryRef(long id) {
// return new JVMValue(JVMType.A, id);
// }
| import java.util.Stack;
import static ocelot.JVMValue.entry;
import static ocelot.JVMValue.entryRef; | push(entry(sub));
}
void dup() {
JVMValue ev = peek().copy();
push(ev);
}
void ineg() {
JVMValue ev = pop();
push(entry(-ev.value));
}
void iand() {
JVMValue ev1 = pop();
JVMValue ev2 = pop();
// For a runtime checking interpreter - type checks would go here...
int and = (int) ev1.value & (int) ev2.value;
push(entry(and));
}
void ior() {
JVMValue ev1 = pop();
JVMValue ev2 = pop();
// For a runtime checking interpreter - type checks would go here...
int or = (int) ev1.value | (int) ev2.value;
push(entry(or));
}
void aconst_null() { | // Path: src/main/java/ocelot/JVMValue.java
// public static JVMValue entry(double d) {
// return new JVMValue(JVMType.D, Double.doubleToLongBits(d));
// }
//
// Path: src/main/java/ocelot/JVMValue.java
// public static JVMValue entryRef(long id) {
// return new JVMValue(JVMType.A, id);
// }
// Path: src/main/java/ocelot/InterpEvalStack.java
import java.util.Stack;
import static ocelot.JVMValue.entry;
import static ocelot.JVMValue.entryRef;
push(entry(sub));
}
void dup() {
JVMValue ev = peek().copy();
push(ev);
}
void ineg() {
JVMValue ev = pop();
push(entry(-ev.value));
}
void iand() {
JVMValue ev1 = pop();
JVMValue ev2 = pop();
// For a runtime checking interpreter - type checks would go here...
int and = (int) ev1.value & (int) ev2.value;
push(entry(and));
}
void ior() {
JVMValue ev1 = pop();
JVMValue ev2 = pop();
// For a runtime checking interpreter - type checks would go here...
int or = (int) ev1.value | (int) ev2.value;
push(entry(or));
}
void aconst_null() { | push(entryRef(0L)); |
edvin/tornadofx-controls | src/test/java/tornadofx/control/test/DatePickerCellDemo.java | // Path: src/main/java/tornadofx/control/DatePickerTableCell.java
// public class DatePickerTableCell<S> extends TableCell<S, LocalDate> {
// private ObjectProperty<StringConverter<LocalDate>> converter = new SimpleObjectProperty<>(this, "converter");
// private DatePicker datePicker;
//
// public DatePickerTableCell(StringConverter<LocalDate> converter) {
// setConverter(converter);
// this.getStyleClass().add("datepicker-table-cell");
// }
//
// public static <S> Callback<TableColumn<S, LocalDate>, TableCell<S, LocalDate>> forTableColumn() {
// return column -> new DatePickerTableCell<>(new DefaultLocalDateConverter());
// }
//
// public static <S> Callback<TableColumn<S, LocalDate>, TableCell<S, LocalDate>> forTableColumn(StringConverter<LocalDate> converter) {
// return column -> new DatePickerTableCell<>(converter);
// }
//
// public void startEdit() {
// if (!isEditable() || !getTableView().isEditable() || !getTableColumn().isEditable())
// return;
//
// super.startEdit();
//
// if (isEditing()) {
// if (datePicker == null)
// createDatePicker();
//
// setText(null);
// setGraphic(datePicker);
// datePicker.requestFocus();
// }
// }
//
// public void cancelEdit() {
// super.cancelEdit();
// setText(getItemText());
// setGraphic(null);
// }
//
// private String getItemText() {
// return getConverter().toString(getItem());
// }
//
// private void createDatePicker() {
// datePicker = new DatePicker(getItem());
// datePicker.converterProperty().bind(converterProperty());
//
// datePicker.setOnAction(event -> {
// commitEdit(datePicker.getValue());
// event.consume();
// });
//
// datePicker.setOnKeyReleased(t -> {
// if (t.getCode() == KeyCode.ESCAPE) {
// cancelEdit();
// t.consume();
// }
// });
// }
//
// protected void updateItem(LocalDate item, boolean empty) {
// super.updateItem(item, empty);
//
// if (isEmpty()) {
// setText(null);
// setGraphic(null);
// } else {
// if (isEditing()) {
// datePicker.setValue(getItem());
// setText(null);
// setGraphic(datePicker);
// } else {
// setText(getItemText());
// setGraphic(null);
// }
// }
// }
//
// public StringConverter<LocalDate> getConverter() {
// return converter.get();
// }
//
// public ObjectProperty<StringConverter<LocalDate>> converterProperty() {
// return converter;
// }
//
// public void setConverter(StringConverter<LocalDate> converter) {
// this.converter.set(converter);
// }
//
// public DatePicker getDatePicker() {
// return datePicker;
// }
//
// public void setDatePicker(DatePicker datePicker) {
// this.datePicker = datePicker;
// }
//
// public static class DefaultLocalDateConverter extends StringConverter<LocalDate> {
// public String toString(LocalDate date) {
// return date != null ? date.toString() : "";
// }
//
// public LocalDate fromString(String string) {
// return string == null || string.isEmpty() ? null : LocalDate.parse(string);
// }
// }
// }
| import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.stage.Stage;
import tornadofx.control.DatePickerTableCell;
import java.time.LocalDate; | package tornadofx.control.test;
public class DatePickerCellDemo extends Application {
public void start(Stage stage) throws Exception {
TableView<Customer> tableView = new TableView<>(FXCollections.observableArrayList(Customer.createSample(555)));
tableView.setEditable(true);
TableColumn<Customer, String> username = new TableColumn<>("Username");
username.setCellValueFactory(param -> param.getValue().usernameProperty());
TableColumn<Customer, LocalDate> registered = new TableColumn<>("Registered");
registered.setCellValueFactory(param -> param.getValue().registeredProperty()); | // Path: src/main/java/tornadofx/control/DatePickerTableCell.java
// public class DatePickerTableCell<S> extends TableCell<S, LocalDate> {
// private ObjectProperty<StringConverter<LocalDate>> converter = new SimpleObjectProperty<>(this, "converter");
// private DatePicker datePicker;
//
// public DatePickerTableCell(StringConverter<LocalDate> converter) {
// setConverter(converter);
// this.getStyleClass().add("datepicker-table-cell");
// }
//
// public static <S> Callback<TableColumn<S, LocalDate>, TableCell<S, LocalDate>> forTableColumn() {
// return column -> new DatePickerTableCell<>(new DefaultLocalDateConverter());
// }
//
// public static <S> Callback<TableColumn<S, LocalDate>, TableCell<S, LocalDate>> forTableColumn(StringConverter<LocalDate> converter) {
// return column -> new DatePickerTableCell<>(converter);
// }
//
// public void startEdit() {
// if (!isEditable() || !getTableView().isEditable() || !getTableColumn().isEditable())
// return;
//
// super.startEdit();
//
// if (isEditing()) {
// if (datePicker == null)
// createDatePicker();
//
// setText(null);
// setGraphic(datePicker);
// datePicker.requestFocus();
// }
// }
//
// public void cancelEdit() {
// super.cancelEdit();
// setText(getItemText());
// setGraphic(null);
// }
//
// private String getItemText() {
// return getConverter().toString(getItem());
// }
//
// private void createDatePicker() {
// datePicker = new DatePicker(getItem());
// datePicker.converterProperty().bind(converterProperty());
//
// datePicker.setOnAction(event -> {
// commitEdit(datePicker.getValue());
// event.consume();
// });
//
// datePicker.setOnKeyReleased(t -> {
// if (t.getCode() == KeyCode.ESCAPE) {
// cancelEdit();
// t.consume();
// }
// });
// }
//
// protected void updateItem(LocalDate item, boolean empty) {
// super.updateItem(item, empty);
//
// if (isEmpty()) {
// setText(null);
// setGraphic(null);
// } else {
// if (isEditing()) {
// datePicker.setValue(getItem());
// setText(null);
// setGraphic(datePicker);
// } else {
// setText(getItemText());
// setGraphic(null);
// }
// }
// }
//
// public StringConverter<LocalDate> getConverter() {
// return converter.get();
// }
//
// public ObjectProperty<StringConverter<LocalDate>> converterProperty() {
// return converter;
// }
//
// public void setConverter(StringConverter<LocalDate> converter) {
// this.converter.set(converter);
// }
//
// public DatePicker getDatePicker() {
// return datePicker;
// }
//
// public void setDatePicker(DatePicker datePicker) {
// this.datePicker = datePicker;
// }
//
// public static class DefaultLocalDateConverter extends StringConverter<LocalDate> {
// public String toString(LocalDate date) {
// return date != null ? date.toString() : "";
// }
//
// public LocalDate fromString(String string) {
// return string == null || string.isEmpty() ? null : LocalDate.parse(string);
// }
// }
// }
// Path: src/test/java/tornadofx/control/test/DatePickerCellDemo.java
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.stage.Stage;
import tornadofx.control.DatePickerTableCell;
import java.time.LocalDate;
package tornadofx.control.test;
public class DatePickerCellDemo extends Application {
public void start(Stage stage) throws Exception {
TableView<Customer> tableView = new TableView<>(FXCollections.observableArrayList(Customer.createSample(555)));
tableView.setEditable(true);
TableColumn<Customer, String> username = new TableColumn<>("Username");
username.setCellValueFactory(param -> param.getValue().usernameProperty());
TableColumn<Customer, LocalDate> registered = new TableColumn<>("Registered");
registered.setCellValueFactory(param -> param.getValue().registeredProperty()); | registered.setCellFactory(DatePickerTableCell.forTableColumn()); |
edvin/tornadofx-controls | src/main/java/tornadofx/control/Field.java | // Path: src/main/java/tornadofx/util/NodeHelper.java
// public class NodeHelper {
//
// public static <T> T findParentOfType( Node node, Class<T> type ){
// if( node == null ) return null;
// Parent parent = node.getParent();
// if( parent == null ) return null;
// if( type.isAssignableFrom(parent.getClass()) ) return (T)parent;
// return findParentOfType( parent, type );
// }
//
// public static <T> List<T> findChildrenOfType(Pane parent, Class<T> type) {
// List<T> elements = new ArrayList<>();
// for (Node node : parent.getChildren()) {
// if (type.isAssignableFrom(node.getClass())) {
// elements.add((T) node);
// } else if (node instanceof Pane) {
// elements.addAll(findChildrenOfType((Pane) node, type));
// }
// }
// return Collections.unmodifiableList(elements);
// }
//
// public static void addPseudoClass( Node node, String className ){
// PseudoClass pseudoClass = PseudoClass.getPseudoClass( className );
// node.pseudoClassStateChanged( pseudoClass, true );
// }
// }
| import javafx.beans.DefaultProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.geometry.Orientation;
import javafx.scene.Node;
import javafx.scene.layout.*;
import tornadofx.util.NodeHelper; | package tornadofx.control;
@DefaultProperty("inputs")
public class Field extends AbstractField {
private Pane inputContainer = null;
private Orientation orientation;
public Field() {
this(null);
}
public Field( String text ){
this( text, Orientation.HORIZONTAL );
}
public Field( String text, Orientation orientation ){
this( text, orientation, false,null );
}
public Field( String text, Orientation orientation, Node... inputs ){
this( text, orientation, false,inputs );
}
public Field(String text, Node... inputs){
this( text, Orientation.HORIZONTAL, false, inputs );
}
public Field(String text, Orientation orientation, boolean forceLabelIndent, Node... inputs) {
super(text, forceLabelIndent);
this.orientation = orientation;
getStyleClass().add("field");
parentProperty().addListener( (obs, oldParent, newParent) -> {
if( !(oldParent instanceof Fieldset) ) {
Fieldset oldFieldSet = | // Path: src/main/java/tornadofx/util/NodeHelper.java
// public class NodeHelper {
//
// public static <T> T findParentOfType( Node node, Class<T> type ){
// if( node == null ) return null;
// Parent parent = node.getParent();
// if( parent == null ) return null;
// if( type.isAssignableFrom(parent.getClass()) ) return (T)parent;
// return findParentOfType( parent, type );
// }
//
// public static <T> List<T> findChildrenOfType(Pane parent, Class<T> type) {
// List<T> elements = new ArrayList<>();
// for (Node node : parent.getChildren()) {
// if (type.isAssignableFrom(node.getClass())) {
// elements.add((T) node);
// } else if (node instanceof Pane) {
// elements.addAll(findChildrenOfType((Pane) node, type));
// }
// }
// return Collections.unmodifiableList(elements);
// }
//
// public static void addPseudoClass( Node node, String className ){
// PseudoClass pseudoClass = PseudoClass.getPseudoClass( className );
// node.pseudoClassStateChanged( pseudoClass, true );
// }
// }
// Path: src/main/java/tornadofx/control/Field.java
import javafx.beans.DefaultProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.geometry.Orientation;
import javafx.scene.Node;
import javafx.scene.layout.*;
import tornadofx.util.NodeHelper;
package tornadofx.control;
@DefaultProperty("inputs")
public class Field extends AbstractField {
private Pane inputContainer = null;
private Orientation orientation;
public Field() {
this(null);
}
public Field( String text ){
this( text, Orientation.HORIZONTAL );
}
public Field( String text, Orientation orientation ){
this( text, orientation, false,null );
}
public Field( String text, Orientation orientation, Node... inputs ){
this( text, orientation, false,inputs );
}
public Field(String text, Node... inputs){
this( text, Orientation.HORIZONTAL, false, inputs );
}
public Field(String text, Orientation orientation, boolean forceLabelIndent, Node... inputs) {
super(text, forceLabelIndent);
this.orientation = orientation;
getStyleClass().add("field");
parentProperty().addListener( (obs, oldParent, newParent) -> {
if( !(oldParent instanceof Fieldset) ) {
Fieldset oldFieldSet = | NodeHelper.findParentOfType(oldParent, Fieldset.class); |
edvin/tornadofx-controls | src/main/java/tornadofx/control/Fieldset.java | // Path: src/main/java/tornadofx/util/NodeHelper.java
// public class NodeHelper {
//
// public static <T> T findParentOfType( Node node, Class<T> type ){
// if( node == null ) return null;
// Parent parent = node.getParent();
// if( parent == null ) return null;
// if( type.isAssignableFrom(parent.getClass()) ) return (T)parent;
// return findParentOfType( parent, type );
// }
//
// public static <T> List<T> findChildrenOfType(Pane parent, Class<T> type) {
// List<T> elements = new ArrayList<>();
// for (Node node : parent.getChildren()) {
// if (type.isAssignableFrom(node.getClass())) {
// elements.add((T) node);
// } else if (node instanceof Pane) {
// elements.addAll(findChildrenOfType((Pane) node, type));
// }
// }
// return Collections.unmodifiableList(elements);
// }
//
// public static void addPseudoClass( Node node, String className ){
// PseudoClass pseudoClass = PseudoClass.getPseudoClass( className );
// node.pseudoClassStateChanged( pseudoClass, true );
// }
// }
| import javafx.beans.DefaultProperty;
import javafx.beans.binding.ObjectBinding;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.ListChangeListener;
import javafx.css.PseudoClass;
import javafx.geometry.Orientation;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import tornadofx.util.NodeHelper;
import java.util.List;
import static javafx.beans.binding.Bindings.createObjectBinding;
import static javafx.geometry.Orientation.HORIZONTAL;
import static javafx.geometry.Orientation.VERTICAL;
import static javafx.scene.layout.Priority.SOMETIMES; | }
public Field field(Node... inputs) {
Field field = new Field(null, inputs);
getChildren().add(field);
return field;
}
public Fieldset() {
getStyleClass().add("fieldset");
syncOrientationState();
// Add legend label when text is populated
textProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null && !newValue.isEmpty() ) addLegend();
});
// Add legend when icon is populated
iconProperty().addListener(((observable1, oldValue1, newValue) -> {
if (newValue != null) addLegend();
}));
// Make sure input children get the configured HBox.hgrow property
syncHgrow();
// Register/deregister with parent Form
parentProperty().addListener( (observable, oldParent, newParent) -> {
if( !(oldParent instanceof Form) ) { | // Path: src/main/java/tornadofx/util/NodeHelper.java
// public class NodeHelper {
//
// public static <T> T findParentOfType( Node node, Class<T> type ){
// if( node == null ) return null;
// Parent parent = node.getParent();
// if( parent == null ) return null;
// if( type.isAssignableFrom(parent.getClass()) ) return (T)parent;
// return findParentOfType( parent, type );
// }
//
// public static <T> List<T> findChildrenOfType(Pane parent, Class<T> type) {
// List<T> elements = new ArrayList<>();
// for (Node node : parent.getChildren()) {
// if (type.isAssignableFrom(node.getClass())) {
// elements.add((T) node);
// } else if (node instanceof Pane) {
// elements.addAll(findChildrenOfType((Pane) node, type));
// }
// }
// return Collections.unmodifiableList(elements);
// }
//
// public static void addPseudoClass( Node node, String className ){
// PseudoClass pseudoClass = PseudoClass.getPseudoClass( className );
// node.pseudoClassStateChanged( pseudoClass, true );
// }
// }
// Path: src/main/java/tornadofx/control/Fieldset.java
import javafx.beans.DefaultProperty;
import javafx.beans.binding.ObjectBinding;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.ListChangeListener;
import javafx.css.PseudoClass;
import javafx.geometry.Orientation;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import tornadofx.util.NodeHelper;
import java.util.List;
import static javafx.beans.binding.Bindings.createObjectBinding;
import static javafx.geometry.Orientation.HORIZONTAL;
import static javafx.geometry.Orientation.VERTICAL;
import static javafx.scene.layout.Priority.SOMETIMES;
}
public Field field(Node... inputs) {
Field field = new Field(null, inputs);
getChildren().add(field);
return field;
}
public Fieldset() {
getStyleClass().add("fieldset");
syncOrientationState();
// Add legend label when text is populated
textProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null && !newValue.isEmpty() ) addLegend();
});
// Add legend when icon is populated
iconProperty().addListener(((observable1, oldValue1, newValue) -> {
if (newValue != null) addLegend();
}));
// Make sure input children get the configured HBox.hgrow property
syncHgrow();
// Register/deregister with parent Form
parentProperty().addListener( (observable, oldParent, newParent) -> {
if( !(oldParent instanceof Form) ) { | Form oldParentForm = NodeHelper.findParentOfType(oldParent, Form.class); |
edvin/tornadofx-controls | src/main/java/tornadofx/control/ListMenu.java | // Path: src/main/java/tornadofx/control/skin/ListMenuSkin.java
// public class ListMenuSkin extends SkinBase<ListMenu> {
// public ListMenuSkin(ListMenu control) {
// super(control);
// }
//
// private double acc(Function<Node, Double> fn) {
// double val = 0;
//
// for (Node node : getChildren())
// val += fn.apply(node);
//
// return val;
// }
//
// private double biggest(Function<Node, Double> fn) {
// double val = 0d;
//
// for (Node node : getChildren()) {
// double nval = fn.apply(node);
// if (nval > val)
// val = nval;
// }
//
// return val;
// }
//
// protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
// if (getSkinnable().getOrientation() == Orientation.VERTICAL)
// return biggest(n -> n.minWidth(height));
// else
// return acc(n -> n.minWidth(height));
// }
//
// protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
// if (getSkinnable().getOrientation() == Orientation.VERTICAL)
// return acc(n -> n.minHeight(width));
// else
// return biggest(n -> n.minHeight(width));
// }
//
// protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
// double prefWidth;
//
// if (getSkinnable().getOrientation() == Orientation.VERTICAL)
// prefWidth = biggest(n -> n.prefWidth(height)) + leftInset + rightInset;
// else
// prefWidth = acc(n -> n.prefWidth(height)) + leftInset + rightInset;
//
// return Math.max(prefWidth, getSkinnable().getPrefWidth());
// }
//
// protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
// double prefHeight;
//
// if (getSkinnable().getOrientation() == Orientation.VERTICAL)
// prefHeight = acc(n -> n.prefHeight(width)) + topInset + bottomInset;
// else
// prefHeight = biggest(n -> n.prefHeight(width)) + topInset + bottomInset;
//
// return Math.max(prefHeight, getSkinnable().getPrefHeight());
// }
//
// protected double computeMaxWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
// return computePrefWidth(height, topInset, rightInset, bottomInset, leftInset);
// }
//
// protected double computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
// return computePrefHeight(width, topInset, rightInset, bottomInset, leftInset);
// }
//
// protected void layoutChildren(double x, double y, double w, double h) {
// for (Node node : getChildren()) {
// if (getSkinnable().getOrientation() == Orientation.VERTICAL) {
// double prefHeight = node.prefHeight(-1);
// node.resizeRelocate(x, y, w, prefHeight);
// y += prefHeight;
// } else {
// double prefWidth = node.prefWidth(-1);
// node.resizeRelocate(x, y, prefWidth, h);
// x += prefWidth;
// }
// }
// }
//
// }
| import javafx.beans.DefaultProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.ObservableList;
import javafx.css.*;
import javafx.geometry.Orientation;
import javafx.geometry.Side;
import javafx.scene.Node;
import javafx.scene.control.Control;
import javafx.scene.control.Skin;
import javafx.scene.layout.Region;
import tornadofx.control.skin.ListMenuSkin;
import java.util.List; | };
public Side getIconPosition() {
return iconPosition.get();
}
public ObjectProperty<Side> iconPositionProperty() {
return iconPosition;
}
public void setIconPosition(Side iconPosition) {
this.iconPosition.set(iconPosition);
}
public ListMenu() {
getStyleClass().add("list-menu");
setFocusTraversable(true);
}
public ListMenu(ListItem... items) {
this();
if (items != null)
getChildren().addAll(items);
}
protected List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData() {
return FACTORY.getCssMetaData();
}
protected Skin<?> createDefaultSkin() { | // Path: src/main/java/tornadofx/control/skin/ListMenuSkin.java
// public class ListMenuSkin extends SkinBase<ListMenu> {
// public ListMenuSkin(ListMenu control) {
// super(control);
// }
//
// private double acc(Function<Node, Double> fn) {
// double val = 0;
//
// for (Node node : getChildren())
// val += fn.apply(node);
//
// return val;
// }
//
// private double biggest(Function<Node, Double> fn) {
// double val = 0d;
//
// for (Node node : getChildren()) {
// double nval = fn.apply(node);
// if (nval > val)
// val = nval;
// }
//
// return val;
// }
//
// protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
// if (getSkinnable().getOrientation() == Orientation.VERTICAL)
// return biggest(n -> n.minWidth(height));
// else
// return acc(n -> n.minWidth(height));
// }
//
// protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
// if (getSkinnable().getOrientation() == Orientation.VERTICAL)
// return acc(n -> n.minHeight(width));
// else
// return biggest(n -> n.minHeight(width));
// }
//
// protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
// double prefWidth;
//
// if (getSkinnable().getOrientation() == Orientation.VERTICAL)
// prefWidth = biggest(n -> n.prefWidth(height)) + leftInset + rightInset;
// else
// prefWidth = acc(n -> n.prefWidth(height)) + leftInset + rightInset;
//
// return Math.max(prefWidth, getSkinnable().getPrefWidth());
// }
//
// protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
// double prefHeight;
//
// if (getSkinnable().getOrientation() == Orientation.VERTICAL)
// prefHeight = acc(n -> n.prefHeight(width)) + topInset + bottomInset;
// else
// prefHeight = biggest(n -> n.prefHeight(width)) + topInset + bottomInset;
//
// return Math.max(prefHeight, getSkinnable().getPrefHeight());
// }
//
// protected double computeMaxWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
// return computePrefWidth(height, topInset, rightInset, bottomInset, leftInset);
// }
//
// protected double computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
// return computePrefHeight(width, topInset, rightInset, bottomInset, leftInset);
// }
//
// protected void layoutChildren(double x, double y, double w, double h) {
// for (Node node : getChildren()) {
// if (getSkinnable().getOrientation() == Orientation.VERTICAL) {
// double prefHeight = node.prefHeight(-1);
// node.resizeRelocate(x, y, w, prefHeight);
// y += prefHeight;
// } else {
// double prefWidth = node.prefWidth(-1);
// node.resizeRelocate(x, y, prefWidth, h);
// x += prefWidth;
// }
// }
// }
//
// }
// Path: src/main/java/tornadofx/control/ListMenu.java
import javafx.beans.DefaultProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.ObservableList;
import javafx.css.*;
import javafx.geometry.Orientation;
import javafx.geometry.Side;
import javafx.scene.Node;
import javafx.scene.control.Control;
import javafx.scene.control.Skin;
import javafx.scene.layout.Region;
import tornadofx.control.skin.ListMenuSkin;
import java.util.List;
};
public Side getIconPosition() {
return iconPosition.get();
}
public ObjectProperty<Side> iconPositionProperty() {
return iconPosition;
}
public void setIconPosition(Side iconPosition) {
this.iconPosition.set(iconPosition);
}
public ListMenu() {
getStyleClass().add("list-menu");
setFocusTraversable(true);
}
public ListMenu(ListItem... items) {
this();
if (items != null)
getChildren().addAll(items);
}
protected List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData() {
return FACTORY.getCssMetaData();
}
protected Skin<?> createDefaultSkin() { | return new ListMenuSkin(this); |
edvin/tornadofx-controls | src/main/java/tornadofx/control/AbstractField.java | // Path: src/main/java/tornadofx/util/NodeHelper.java
// public class NodeHelper {
//
// public static <T> T findParentOfType( Node node, Class<T> type ){
// if( node == null ) return null;
// Parent parent = node.getParent();
// if( parent == null ) return null;
// if( type.isAssignableFrom(parent.getClass()) ) return (T)parent;
// return findParentOfType( parent, type );
// }
//
// public static <T> List<T> findChildrenOfType(Pane parent, Class<T> type) {
// List<T> elements = new ArrayList<>();
// for (Node node : parent.getChildren()) {
// if (type.isAssignableFrom(node.getClass())) {
// elements.add((T) node);
// } else if (node instanceof Pane) {
// elements.addAll(findChildrenOfType((Pane) node, type));
// }
// }
// return Collections.unmodifiableList(elements);
// }
//
// public static void addPseudoClass( Node node, String className ){
// PseudoClass pseudoClass = PseudoClass.getPseudoClass( className );
// node.pseudoClassStateChanged( pseudoClass, true );
// }
// }
| import javafx.beans.property.SimpleStringProperty;
import javafx.collections.ObservableList;
import javafx.geometry.Orientation;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Region;
import tornadofx.util.NodeHelper; | package tornadofx.control;
public abstract class AbstractField extends Pane {
SimpleStringProperty textProperty = new SimpleStringProperty();
private boolean forceLabelIndent = false;
private Label label = new Label();
private LabelContainer labelContainer = new LabelContainer(label);
public AbstractField( String text, boolean forceLabelIndent ){
setText(text);
this.forceLabelIndent = forceLabelIndent;
setFocusTraversable(false);
getStyleClass().add("field");
label.textProperty().bind(textProperty);
getChildren().add( labelContainer );
}
public String getText(){
return textProperty.get();
}
public void setText(String text ){
textProperty.set(text);
}
public void setForceLabelIndent(boolean forceLabelIndent ){
this.forceLabelIndent = forceLabelIndent;
}
public boolean getForceLabelIndent(){
return this.forceLabelIndent;
}
public Fieldset getFieldSet(){ | // Path: src/main/java/tornadofx/util/NodeHelper.java
// public class NodeHelper {
//
// public static <T> T findParentOfType( Node node, Class<T> type ){
// if( node == null ) return null;
// Parent parent = node.getParent();
// if( parent == null ) return null;
// if( type.isAssignableFrom(parent.getClass()) ) return (T)parent;
// return findParentOfType( parent, type );
// }
//
// public static <T> List<T> findChildrenOfType(Pane parent, Class<T> type) {
// List<T> elements = new ArrayList<>();
// for (Node node : parent.getChildren()) {
// if (type.isAssignableFrom(node.getClass())) {
// elements.add((T) node);
// } else if (node instanceof Pane) {
// elements.addAll(findChildrenOfType((Pane) node, type));
// }
// }
// return Collections.unmodifiableList(elements);
// }
//
// public static void addPseudoClass( Node node, String className ){
// PseudoClass pseudoClass = PseudoClass.getPseudoClass( className );
// node.pseudoClassStateChanged( pseudoClass, true );
// }
// }
// Path: src/main/java/tornadofx/control/AbstractField.java
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.ObservableList;
import javafx.geometry.Orientation;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Region;
import tornadofx.util.NodeHelper;
package tornadofx.control;
public abstract class AbstractField extends Pane {
SimpleStringProperty textProperty = new SimpleStringProperty();
private boolean forceLabelIndent = false;
private Label label = new Label();
private LabelContainer labelContainer = new LabelContainer(label);
public AbstractField( String text, boolean forceLabelIndent ){
setText(text);
this.forceLabelIndent = forceLabelIndent;
setFocusTraversable(false);
getStyleClass().add("field");
label.textProperty().bind(textProperty);
getChildren().add( labelContainer );
}
public String getText(){
return textProperty.get();
}
public void setText(String text ){
textProperty.set(text);
}
public void setForceLabelIndent(boolean forceLabelIndent ){
this.forceLabelIndent = forceLabelIndent;
}
public boolean getForceLabelIndent(){
return this.forceLabelIndent;
}
public Fieldset getFieldSet(){ | return NodeHelper.findParentOfType(this,Fieldset.class); |
edvin/tornadofx-controls | src/main/java/tornadofx/control/TableRowExpanderColumn.java | // Path: src/main/java/tornadofx/control/skin/ExpandableTableRowSkin.java
// public class ExpandableTableRowSkin<S> extends TableRowSkin<S> {
// private final TableRow<S> tableRow;
// private TableRowExpanderColumn<S> expander;
// private Double tableRowPrefHeight = -1D;
//
// /**
// * Create the ExpandableTableRowSkin and listen to changes for the item this table row represents. When the
// * item is changed, the old expanded node, if any, is removed from the children list of the TableRow.
// *
// * @param tableRow The table row to apply this skin for
// * @param expander The expander column, used to retrieve the expanded node when this row is expanded
// */
// public ExpandableTableRowSkin(TableRow<S> tableRow, TableRowExpanderColumn<S> expander) {
// super(tableRow);
// this.tableRow = tableRow;
// this.expander = expander;
// tableRow.itemProperty().addListener((observable, oldValue, newValue) -> {
// if (oldValue != null) {
// Node expandedNode = this.expander.getExpandedNode(oldValue);
// if (expandedNode != null) getChildren().remove(expandedNode);
// }
// });
// }
//
// /**
// * Create the expanded content node that should represent the current table row.
// *
// * If the expanded content node is not currently in the children list of the TableRow it is automatically added.
// *
// * @return The expanded content Node
// */
// private Node getContent() {
// Node node = expander.getOrCreateExpandedNode(tableRow);
// if (!getChildren().contains(node)) getChildren().add(node);
// return node;
// }
//
// /**
// * Check if the current node is expanded. This is done by checking that there is an item for the current row,
// * and that the expanded property for the row is true.
// *
// * @return A boolean indicating the expanded state of this row
// */
// private Boolean isExpanded() {
// return getSkinnable().getItem() != null && expander.getCellData(getSkinnable().getIndex());
// }
//
// /**
// * Add the preferred height of the expanded Node whenever the expanded flag is true.
// *
// * @return The preferred height of the TableRow, appended with the preferred height of the expanded node
// * if this row is currently expanded.
// */
// @Override
// protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
// tableRowPrefHeight = super.computePrefHeight(width, topInset, rightInset, bottomInset, leftInset);
// return isExpanded() ? tableRowPrefHeight + getContent().prefHeight(width) : tableRowPrefHeight;
// }
//
// /**
// * Lay out the columns of the TableRow, then add the expanded content node below if this row is currently expanded.
// */
// @Override
// protected void layoutChildren(double x, double y, double w, double h) {
// super.layoutChildren(x, y, w, h);
// if (isExpanded()) getContent().resizeRelocate(0.0, tableRowPrefHeight, w, h - tableRowPrefHeight);
// }
// }
| import javafx.beans.property.SimpleBooleanProperty;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.util.Callback;
import tornadofx.control.skin.ExpandableTableRowSkin;
import java.util.HashMap;
import java.util.Map; | * The expandedNodeCallback is expected to return a Node representing the editor that should appear below the
* table row when the toggle button within the expander column is clicked.
*
* Once this column is assigned to a TableView, it will automatically install a custom row factory for the TableView
* so that it can configure a TableRow with the {@link ExpandableTableRowSkin}. It is within the skin that the actual
* rendering of the expanded node occurs.
*
* @see TableRowExpanderColumn
* @see TableRowDataFeatures
*
* @param expandedNodeCallback
*/
public TableRowExpanderColumn(Callback<TableRowDataFeatures<S>, Node> expandedNodeCallback) {
this.expandedNodeCallback = expandedNodeCallback;
getStyleClass().add(STYLE_CLASS);
setCellValueFactory(param -> getExpandedProperty(param.getValue()));
setCellFactory(param -> new ToggleCell());
installRowFactoryOnTableViewAssignment();
}
/**
* Install the row factory on the TableView when this column is assigned to a TableView.
*/
private void installRowFactoryOnTableViewAssignment() {
tableViewProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
getTableView().setRowFactory(param -> new TableRow<S>() {
@Override
protected Skin<?> createDefaultSkin() { | // Path: src/main/java/tornadofx/control/skin/ExpandableTableRowSkin.java
// public class ExpandableTableRowSkin<S> extends TableRowSkin<S> {
// private final TableRow<S> tableRow;
// private TableRowExpanderColumn<S> expander;
// private Double tableRowPrefHeight = -1D;
//
// /**
// * Create the ExpandableTableRowSkin and listen to changes for the item this table row represents. When the
// * item is changed, the old expanded node, if any, is removed from the children list of the TableRow.
// *
// * @param tableRow The table row to apply this skin for
// * @param expander The expander column, used to retrieve the expanded node when this row is expanded
// */
// public ExpandableTableRowSkin(TableRow<S> tableRow, TableRowExpanderColumn<S> expander) {
// super(tableRow);
// this.tableRow = tableRow;
// this.expander = expander;
// tableRow.itemProperty().addListener((observable, oldValue, newValue) -> {
// if (oldValue != null) {
// Node expandedNode = this.expander.getExpandedNode(oldValue);
// if (expandedNode != null) getChildren().remove(expandedNode);
// }
// });
// }
//
// /**
// * Create the expanded content node that should represent the current table row.
// *
// * If the expanded content node is not currently in the children list of the TableRow it is automatically added.
// *
// * @return The expanded content Node
// */
// private Node getContent() {
// Node node = expander.getOrCreateExpandedNode(tableRow);
// if (!getChildren().contains(node)) getChildren().add(node);
// return node;
// }
//
// /**
// * Check if the current node is expanded. This is done by checking that there is an item for the current row,
// * and that the expanded property for the row is true.
// *
// * @return A boolean indicating the expanded state of this row
// */
// private Boolean isExpanded() {
// return getSkinnable().getItem() != null && expander.getCellData(getSkinnable().getIndex());
// }
//
// /**
// * Add the preferred height of the expanded Node whenever the expanded flag is true.
// *
// * @return The preferred height of the TableRow, appended with the preferred height of the expanded node
// * if this row is currently expanded.
// */
// @Override
// protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
// tableRowPrefHeight = super.computePrefHeight(width, topInset, rightInset, bottomInset, leftInset);
// return isExpanded() ? tableRowPrefHeight + getContent().prefHeight(width) : tableRowPrefHeight;
// }
//
// /**
// * Lay out the columns of the TableRow, then add the expanded content node below if this row is currently expanded.
// */
// @Override
// protected void layoutChildren(double x, double y, double w, double h) {
// super.layoutChildren(x, y, w, h);
// if (isExpanded()) getContent().resizeRelocate(0.0, tableRowPrefHeight, w, h - tableRowPrefHeight);
// }
// }
// Path: src/main/java/tornadofx/control/TableRowExpanderColumn.java
import javafx.beans.property.SimpleBooleanProperty;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.util.Callback;
import tornadofx.control.skin.ExpandableTableRowSkin;
import java.util.HashMap;
import java.util.Map;
* The expandedNodeCallback is expected to return a Node representing the editor that should appear below the
* table row when the toggle button within the expander column is clicked.
*
* Once this column is assigned to a TableView, it will automatically install a custom row factory for the TableView
* so that it can configure a TableRow with the {@link ExpandableTableRowSkin}. It is within the skin that the actual
* rendering of the expanded node occurs.
*
* @see TableRowExpanderColumn
* @see TableRowDataFeatures
*
* @param expandedNodeCallback
*/
public TableRowExpanderColumn(Callback<TableRowDataFeatures<S>, Node> expandedNodeCallback) {
this.expandedNodeCallback = expandedNodeCallback;
getStyleClass().add(STYLE_CLASS);
setCellValueFactory(param -> getExpandedProperty(param.getValue()));
setCellFactory(param -> new ToggleCell());
installRowFactoryOnTableViewAssignment();
}
/**
* Install the row factory on the TableView when this column is assigned to a TableView.
*/
private void installRowFactoryOnTableViewAssignment() {
tableViewProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
getTableView().setRowFactory(param -> new TableRow<S>() {
@Override
protected Skin<?> createDefaultSkin() { | return new ExpandableTableRowSkin<>(this, TableRowExpanderColumn.this); |
edvin/tornadofx-controls | src/test/java/tornadofx/control/test/NaviSelectDemo.java | // Path: src/main/java/tornadofx/control/NaviSelect.java
// public class NaviSelect<T> extends HBox {
// private ComboBox<String> editButton = new ComboBox<>();
// private Button gotoButton = new Button();
// private Function<T, String> defaultVisualConverter = t -> { String value = t == null ? null : t.toString(); return value == null ? "" : value; };
// private ObjectProperty<Function<T, String>> visualConverter = new SimpleObjectProperty<Function<T, String>>(defaultVisualConverter) {
// public void set(Function<T, String> newValue) {
// super.set(newValue);
// visualBinding.invalidate();
// }
// };
// private ObjectProperty<T> value = new SimpleObjectProperty<>();
// private StringBinding visualBinding = createStringBinding(() -> getVisualConverter().apply(getValue()), valueProperty());
//
// public NaviSelect() {
// getStyleClass().add("navi-select");
// editButton.getStyleClass().add("edit-button");
//
// editButton.valueProperty().bind(visualBinding);
// HBox.setHgrow(editButton, Priority.ALWAYS);
//
// editButton.setTooltip(new Tooltip("Edit"));
//
// Pane gotoButtonGraphic = new Pane();
// gotoButtonGraphic.getStyleClass().add("icon");
// gotoButton.setGraphic(gotoButtonGraphic);
// gotoButton.setTooltip(new Tooltip("Goto"));
//
// gotoButton.getStyleClass().add("goto-button");
//
// getChildren().addAll(editButton, gotoButton);
// }
//
// public void setOnEdit(EventHandler<MouseEvent> editHandler) {
// editButton.setOnMouseClicked(editHandler);
// }
//
// public void setOnGoto(EventHandler<ActionEvent> gotoHandler) {
// gotoButton.setOnAction(gotoHandler);
// }
//
// public ObjectProperty<T> valueProperty() { return value; }
// public T getValue() { return value.get(); }
// public void setValue(T value) { this.value.set(value); }
//
// public ComboBox<String> getEditButton() {
// return editButton;
// }
//
// public void setEditButton(ComboBox<String> editButton) {
// this.editButton = editButton;
// }
//
// public Button getGotoButton() {
// return gotoButton;
// }
//
// public void setGotoButton(Button gotoButton) {
// this.gotoButton = gotoButton;
// }
//
// public String getUserAgentStylesheet() {
// return ListMenu.class.getResource("naviselect.css").toExternalForm();
// }
//
// public Function<T, String> getVisualConverter() {
// return visualConverter.get();
// }
//
// public ObjectProperty<Function<T, String>> visualConverterProperty() {
// return visualConverter;
// }
//
// public void setVisualConverter(Function<T, String> visualConverter) {
// this.visualConverter.set(visualConverter);
// }
//
// }
| import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import tornadofx.control.NaviSelect;
import static javafx.scene.control.Alert.AlertType.INFORMATION; | package tornadofx.control.test;
public class NaviSelectDemo extends Application {
public void start(Stage stage) throws Exception {
stage.setTitle("NaviSelect Demo");
HBox root = new HBox(10);
root.setAlignment(Pos.CENTER_LEFT);
root.setPadding(new Insets(50));
Label label = new Label("Choose customer:");
label.setStyle("-fx-font-weight: bold");
| // Path: src/main/java/tornadofx/control/NaviSelect.java
// public class NaviSelect<T> extends HBox {
// private ComboBox<String> editButton = new ComboBox<>();
// private Button gotoButton = new Button();
// private Function<T, String> defaultVisualConverter = t -> { String value = t == null ? null : t.toString(); return value == null ? "" : value; };
// private ObjectProperty<Function<T, String>> visualConverter = new SimpleObjectProperty<Function<T, String>>(defaultVisualConverter) {
// public void set(Function<T, String> newValue) {
// super.set(newValue);
// visualBinding.invalidate();
// }
// };
// private ObjectProperty<T> value = new SimpleObjectProperty<>();
// private StringBinding visualBinding = createStringBinding(() -> getVisualConverter().apply(getValue()), valueProperty());
//
// public NaviSelect() {
// getStyleClass().add("navi-select");
// editButton.getStyleClass().add("edit-button");
//
// editButton.valueProperty().bind(visualBinding);
// HBox.setHgrow(editButton, Priority.ALWAYS);
//
// editButton.setTooltip(new Tooltip("Edit"));
//
// Pane gotoButtonGraphic = new Pane();
// gotoButtonGraphic.getStyleClass().add("icon");
// gotoButton.setGraphic(gotoButtonGraphic);
// gotoButton.setTooltip(new Tooltip("Goto"));
//
// gotoButton.getStyleClass().add("goto-button");
//
// getChildren().addAll(editButton, gotoButton);
// }
//
// public void setOnEdit(EventHandler<MouseEvent> editHandler) {
// editButton.setOnMouseClicked(editHandler);
// }
//
// public void setOnGoto(EventHandler<ActionEvent> gotoHandler) {
// gotoButton.setOnAction(gotoHandler);
// }
//
// public ObjectProperty<T> valueProperty() { return value; }
// public T getValue() { return value.get(); }
// public void setValue(T value) { this.value.set(value); }
//
// public ComboBox<String> getEditButton() {
// return editButton;
// }
//
// public void setEditButton(ComboBox<String> editButton) {
// this.editButton = editButton;
// }
//
// public Button getGotoButton() {
// return gotoButton;
// }
//
// public void setGotoButton(Button gotoButton) {
// this.gotoButton = gotoButton;
// }
//
// public String getUserAgentStylesheet() {
// return ListMenu.class.getResource("naviselect.css").toExternalForm();
// }
//
// public Function<T, String> getVisualConverter() {
// return visualConverter.get();
// }
//
// public ObjectProperty<Function<T, String>> visualConverterProperty() {
// return visualConverter;
// }
//
// public void setVisualConverter(Function<T, String> visualConverter) {
// this.visualConverter.set(visualConverter);
// }
//
// }
// Path: src/test/java/tornadofx/control/test/NaviSelectDemo.java
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import tornadofx.control.NaviSelect;
import static javafx.scene.control.Alert.AlertType.INFORMATION;
package tornadofx.control.test;
public class NaviSelectDemo extends Application {
public void start(Stage stage) throws Exception {
stage.setTitle("NaviSelect Demo");
HBox root = new HBox(10);
root.setAlignment(Pos.CENTER_LEFT);
root.setPadding(new Insets(50));
Label label = new Label("Choose customer:");
label.setStyle("-fx-font-weight: bold");
| NaviSelect<Email> navi = new NaviSelect<>(); |
edvin/tornadofx-controls | src/main/java/tornadofx/control/MultiSelect.java | // Path: src/main/java/tornadofx/control/skin/MultiSelectSkin.java
// public class MultiSelectSkin<E> extends SkinBase<MultiSelect<E>> {
//
// public MultiSelectSkin(MultiSelect<E> control) {
// super(control);
// }
//
// private double getPrefRowHeight() {
// double editorHeight = getSkinnable().getEditor().prefHeight(-1);
// if (getChildren().isEmpty())
// return editorHeight;
// else
// return Math.max(editorHeight, getChildren().get(0).prefHeight(-1));
// }
//
// /**
// * Compute pref width by placing equal amount of childen on each line, with a line height equal to the editors preferred
// * height plus the vgap. This will not be correct in every case, depending on the difference in the other childrens
// * preferred width, but it seems to be adequate.
// */
// protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
// MultiSelect<E> control = getSkinnable();
//
// double hgap = control.getHgap().doubleValue();
// double vgap = control.getVgap().doubleValue();
// double prefRowHeight = getPrefRowHeight();
//
// int childCount = getChildren().size();
// int rows = height <= 0 ? 1 : (int) Math.max(1, Math.floor((prefRowHeight + vgap) / height));
// int perRow = (int) Math.ceil(childCount / rows);
//
// double widestRow = 0;
// int childPos = 0;
// for (int rowCount = 0; rowCount < rows; rowCount++) {
// double rowWidth = 0;
// double childPosInRow = 0;
//
// while (childPosInRow < perRow && childPos < childCount) {
// Node child = getChildren().get(childPos);
// rowWidth += child.prefWidth(prefRowHeight) + hgap;
// childPos++;
// childPosInRow++;
// }
//
// if (rowWidth > widestRow)
// widestRow = rowWidth;
// }
//
// return widestRow + leftInset + rightInset - hgap;
// }
//
// protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
// return computePrefHeight(width, topInset, rightInset, bottomInset, leftInset);
// }
//
// protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
// MultiSelect<E> control = getSkinnable();
//
// double usedLineWidth = 0;
// double hgap = control.getHgap().doubleValue();
// double vgap = control.getVgap().doubleValue();
// double prefHeight = getPrefRowHeight();
//
// double y = prefHeight;
// if (width == -1 && control.getWidth() > 0)
// width = control.getWidth();
//
// for (Node node : getChildren()) {
// double prefWidth = node.prefWidth(prefHeight);
// if (width > 0 && usedLineWidth + prefWidth > width && usedLineWidth > 0) {
// usedLineWidth = 0;
// y += prefHeight + vgap;
// }
// usedLineWidth += prefWidth + hgap;
// }
//
// return y;
// }
//
// protected void layoutChildren(double contentX, double contentY, double contentWidth, double contentHeight) {
// double usedLineWidth = 0;
// double hgap = getSkinnable().getHgap().doubleValue();
// double vgap = getSkinnable().getVgap().doubleValue();
// double prefHeight = getPrefRowHeight();
//
// for (Node node : getChildren()) {
// double prefWidth = node.prefWidth(prefHeight);
// if (usedLineWidth + prefWidth > contentWidth && usedLineWidth > 0) {
// usedLineWidth = 0;
// contentY += prefHeight + vgap;
// }
// double x = usedLineWidth + contentX;
// node.resizeRelocate(x, contentY, prefWidth, prefHeight);
// usedLineWidth += prefWidth + hgap;
// }
// }
//
// }
| import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.css.CssMetaData;
import javafx.css.Styleable;
import javafx.css.StyleableProperty;
import javafx.css.StyleablePropertyFactory;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.Region;
import javafx.util.StringConverter;
import tornadofx.control.skin.MultiSelectSkin;
import java.util.List;
import java.util.function.BiFunction; | getChildren().remove(c.getFrom(), c.getTo() + 1);
if (c.wasAdded()) {
for (int i = 0; i < c.getAddedSize(); i++) {
E item = c.getAddedSubList().get(i);
Node cell = getCellFactory().apply(this, item);
getChildren().add(i + c.getFrom(), cell);
}
}
}
});
}
/**
* Convert the given string to an Item by using the configured converter.
*
* @param text The string that the converter knows how to convert to an item
*/
public void addItem(String text) {
StringConverter<E> c = getConverter();
if (c == null)
throw new IllegalArgumentException("You must define a converter before you can add items as Strings");
E item = c.fromString(text);
if (item != null)
getItems().add(item);
}
protected Skin<?> createDefaultSkin() { | // Path: src/main/java/tornadofx/control/skin/MultiSelectSkin.java
// public class MultiSelectSkin<E> extends SkinBase<MultiSelect<E>> {
//
// public MultiSelectSkin(MultiSelect<E> control) {
// super(control);
// }
//
// private double getPrefRowHeight() {
// double editorHeight = getSkinnable().getEditor().prefHeight(-1);
// if (getChildren().isEmpty())
// return editorHeight;
// else
// return Math.max(editorHeight, getChildren().get(0).prefHeight(-1));
// }
//
// /**
// * Compute pref width by placing equal amount of childen on each line, with a line height equal to the editors preferred
// * height plus the vgap. This will not be correct in every case, depending on the difference in the other childrens
// * preferred width, but it seems to be adequate.
// */
// protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
// MultiSelect<E> control = getSkinnable();
//
// double hgap = control.getHgap().doubleValue();
// double vgap = control.getVgap().doubleValue();
// double prefRowHeight = getPrefRowHeight();
//
// int childCount = getChildren().size();
// int rows = height <= 0 ? 1 : (int) Math.max(1, Math.floor((prefRowHeight + vgap) / height));
// int perRow = (int) Math.ceil(childCount / rows);
//
// double widestRow = 0;
// int childPos = 0;
// for (int rowCount = 0; rowCount < rows; rowCount++) {
// double rowWidth = 0;
// double childPosInRow = 0;
//
// while (childPosInRow < perRow && childPos < childCount) {
// Node child = getChildren().get(childPos);
// rowWidth += child.prefWidth(prefRowHeight) + hgap;
// childPos++;
// childPosInRow++;
// }
//
// if (rowWidth > widestRow)
// widestRow = rowWidth;
// }
//
// return widestRow + leftInset + rightInset - hgap;
// }
//
// protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
// return computePrefHeight(width, topInset, rightInset, bottomInset, leftInset);
// }
//
// protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
// MultiSelect<E> control = getSkinnable();
//
// double usedLineWidth = 0;
// double hgap = control.getHgap().doubleValue();
// double vgap = control.getVgap().doubleValue();
// double prefHeight = getPrefRowHeight();
//
// double y = prefHeight;
// if (width == -1 && control.getWidth() > 0)
// width = control.getWidth();
//
// for (Node node : getChildren()) {
// double prefWidth = node.prefWidth(prefHeight);
// if (width > 0 && usedLineWidth + prefWidth > width && usedLineWidth > 0) {
// usedLineWidth = 0;
// y += prefHeight + vgap;
// }
// usedLineWidth += prefWidth + hgap;
// }
//
// return y;
// }
//
// protected void layoutChildren(double contentX, double contentY, double contentWidth, double contentHeight) {
// double usedLineWidth = 0;
// double hgap = getSkinnable().getHgap().doubleValue();
// double vgap = getSkinnable().getVgap().doubleValue();
// double prefHeight = getPrefRowHeight();
//
// for (Node node : getChildren()) {
// double prefWidth = node.prefWidth(prefHeight);
// if (usedLineWidth + prefWidth > contentWidth && usedLineWidth > 0) {
// usedLineWidth = 0;
// contentY += prefHeight + vgap;
// }
// double x = usedLineWidth + contentX;
// node.resizeRelocate(x, contentY, prefWidth, prefHeight);
// usedLineWidth += prefWidth + hgap;
// }
// }
//
// }
// Path: src/main/java/tornadofx/control/MultiSelect.java
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.css.CssMetaData;
import javafx.css.Styleable;
import javafx.css.StyleableProperty;
import javafx.css.StyleablePropertyFactory;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.Region;
import javafx.util.StringConverter;
import tornadofx.control.skin.MultiSelectSkin;
import java.util.List;
import java.util.function.BiFunction;
getChildren().remove(c.getFrom(), c.getTo() + 1);
if (c.wasAdded()) {
for (int i = 0; i < c.getAddedSize(); i++) {
E item = c.getAddedSubList().get(i);
Node cell = getCellFactory().apply(this, item);
getChildren().add(i + c.getFrom(), cell);
}
}
}
});
}
/**
* Convert the given string to an Item by using the configured converter.
*
* @param text The string that the converter knows how to convert to an item
*/
public void addItem(String text) {
StringConverter<E> c = getConverter();
if (c == null)
throw new IllegalArgumentException("You must define a converter before you can add items as Strings");
E item = c.fromString(text);
if (item != null)
getItems().add(item);
}
protected Skin<?> createDefaultSkin() { | return new MultiSelectSkin<>(this); |
taycaldwell/riot-api-java | src/main/java/net/rithms/riot/api/endpoints/tournament/methods/CreateTournamentCodes.java | // Path: src/main/java/net/rithms/riot/api/endpoints/tournament/constant/PickType.java
// public enum PickType {
// ALL_RANDOM,
// BLIND_PICK,
// DRAFT_MODE,
// TOURNAMENT_DRAFT
// }
//
// Path: src/main/java/net/rithms/riot/api/endpoints/tournament/constant/SpectatorType.java
// public enum SpectatorType {
// ALL,
// LOBBYONLY,
// NONE
// }
//
// Path: src/main/java/net/rithms/riot/api/endpoints/tournament/constant/TournamentMap.java
// public enum TournamentMap {
// HOWLING_ABYSS,
// SUMMONERS_RIFT,
// TWISTED_TREELINE
// }
| import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.gson.reflect.TypeToken;
import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.UrlParameter;
import net.rithms.riot.api.endpoints.tournament.TournamentApiMethod;
import net.rithms.riot.api.endpoints.tournament.constant.PickType;
import net.rithms.riot.api.endpoints.tournament.constant.SpectatorType;
import net.rithms.riot.api.endpoints.tournament.constant.TournamentMap;
import net.rithms.riot.api.request.RequestMethod;
| /*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.endpoints.tournament.methods;
public class CreateTournamentCodes extends TournamentApiMethod {
public CreateTournamentCodes(ApiConfig config, int tournamentId, int count, int teamSize, TournamentMap mapType, PickType pickType,
| // Path: src/main/java/net/rithms/riot/api/endpoints/tournament/constant/PickType.java
// public enum PickType {
// ALL_RANDOM,
// BLIND_PICK,
// DRAFT_MODE,
// TOURNAMENT_DRAFT
// }
//
// Path: src/main/java/net/rithms/riot/api/endpoints/tournament/constant/SpectatorType.java
// public enum SpectatorType {
// ALL,
// LOBBYONLY,
// NONE
// }
//
// Path: src/main/java/net/rithms/riot/api/endpoints/tournament/constant/TournamentMap.java
// public enum TournamentMap {
// HOWLING_ABYSS,
// SUMMONERS_RIFT,
// TWISTED_TREELINE
// }
// Path: src/main/java/net/rithms/riot/api/endpoints/tournament/methods/CreateTournamentCodes.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.gson.reflect.TypeToken;
import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.UrlParameter;
import net.rithms.riot.api.endpoints.tournament.TournamentApiMethod;
import net.rithms.riot.api.endpoints.tournament.constant.PickType;
import net.rithms.riot.api.endpoints.tournament.constant.SpectatorType;
import net.rithms.riot.api.endpoints.tournament.constant.TournamentMap;
import net.rithms.riot.api.request.RequestMethod;
/*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.endpoints.tournament.methods;
public class CreateTournamentCodes extends TournamentApiMethod {
public CreateTournamentCodes(ApiConfig config, int tournamentId, int count, int teamSize, TournamentMap mapType, PickType pickType,
| SpectatorType spectatorType, String metaData, String... allowedSummonerIds) {
|
taycaldwell/riot-api-java | src/main/java/net/rithms/riot/api/endpoints/summoner/methods/GetSummonerByName.java | // Path: src/main/java/net/rithms/riot/api/endpoints/summoner/dto/Summoner.java
// public class Summoner extends Dto implements Serializable {
//
// private static final long serialVersionUID = -8213488199644701555L;
//
// private String accountId;
// private String id;
// private String puuid;
// private String name;
// private int profileIconId;
// private long revisionDate;
// private int summonerLevel;
//
// public String getAccountId() {
// return accountId;
// }
//
// public String getId() {
// return id;
// }
//
// public String getPuuid() {
// return puuid;
// }
//
// public String getName() {
// return name;
// }
//
// public int getProfileIconId() {
// return profileIconId;
// }
//
// public long getRevisionDate() {
// return revisionDate;
// }
//
// public int getSummonerLevel() {
// return summonerLevel;
// }
//
// @Override
// public String toString() {
// return getId() + ": " + getName();
// }
// }
| import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.logging.Level;
import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.RiotApi;
import net.rithms.riot.api.endpoints.summoner.SummonerApiMethod;
import net.rithms.riot.api.endpoints.summoner.dto.Summoner;
import net.rithms.riot.constant.Platform;
import net.rithms.util.RiotApiUtil;
| /*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.endpoints.summoner.methods;
public class GetSummonerByName extends SummonerApiMethod {
public GetSummonerByName(ApiConfig config, Platform platform, String summonerName) {
super(config);
setPlatform(platform);
summonerName = RiotApiUtil.normalizeSummonerName(summonerName);
| // Path: src/main/java/net/rithms/riot/api/endpoints/summoner/dto/Summoner.java
// public class Summoner extends Dto implements Serializable {
//
// private static final long serialVersionUID = -8213488199644701555L;
//
// private String accountId;
// private String id;
// private String puuid;
// private String name;
// private int profileIconId;
// private long revisionDate;
// private int summonerLevel;
//
// public String getAccountId() {
// return accountId;
// }
//
// public String getId() {
// return id;
// }
//
// public String getPuuid() {
// return puuid;
// }
//
// public String getName() {
// return name;
// }
//
// public int getProfileIconId() {
// return profileIconId;
// }
//
// public long getRevisionDate() {
// return revisionDate;
// }
//
// public int getSummonerLevel() {
// return summonerLevel;
// }
//
// @Override
// public String toString() {
// return getId() + ": " + getName();
// }
// }
// Path: src/main/java/net/rithms/riot/api/endpoints/summoner/methods/GetSummonerByName.java
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.logging.Level;
import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.RiotApi;
import net.rithms.riot.api.endpoints.summoner.SummonerApiMethod;
import net.rithms.riot.api.endpoints.summoner.dto.Summoner;
import net.rithms.riot.constant.Platform;
import net.rithms.util.RiotApiUtil;
/*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.endpoints.summoner.methods;
public class GetSummonerByName extends SummonerApiMethod {
public GetSummonerByName(ApiConfig config, Platform platform, String summonerName) {
super(config);
setPlatform(platform);
summonerName = RiotApiUtil.normalizeSummonerName(summonerName);
| setReturnType(Summoner.class);
|
taycaldwell/riot-api-java | src/main/java/net/rithms/riot/api/endpoints/lol_status/methods/GetShardData.java | // Path: src/main/java/net/rithms/riot/api/endpoints/lol_status/dto/ShardStatus.java
// public class ShardStatus extends Dto implements Serializable {
//
// private static final long serialVersionUID = -530404100006610537L;
//
// private String hostname;
// private List<String> locales;
// private String name;
// @SerializedName(value = "region_tag")
// private String regionTag;
// private List<Service> services;
// private String slug;
//
// public String getHostname() {
// return hostname;
// }
//
// public List<String> getLocales() {
// return locales;
// }
//
// public String getName() {
// return name;
// }
//
// public String getRegionTag() {
// return regionTag;
// }
//
// public List<Service> getServices() {
// return services;
// }
//
// public String getSlug() {
// return slug;
// }
//
// @Override
// public String toString() {
// return getName();
// }
// }
| import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.endpoints.lol_status.LolStatusApiMethod;
import net.rithms.riot.api.endpoints.lol_status.dto.ShardStatus;
import net.rithms.riot.constant.Platform;
| /*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.endpoints.lol_status.methods;
public class GetShardData extends LolStatusApiMethod {
public GetShardData(ApiConfig config, Platform platform) {
super(config);
setPlatform(platform);
| // Path: src/main/java/net/rithms/riot/api/endpoints/lol_status/dto/ShardStatus.java
// public class ShardStatus extends Dto implements Serializable {
//
// private static final long serialVersionUID = -530404100006610537L;
//
// private String hostname;
// private List<String> locales;
// private String name;
// @SerializedName(value = "region_tag")
// private String regionTag;
// private List<Service> services;
// private String slug;
//
// public String getHostname() {
// return hostname;
// }
//
// public List<String> getLocales() {
// return locales;
// }
//
// public String getName() {
// return name;
// }
//
// public String getRegionTag() {
// return regionTag;
// }
//
// public List<Service> getServices() {
// return services;
// }
//
// public String getSlug() {
// return slug;
// }
//
// @Override
// public String toString() {
// return getName();
// }
// }
// Path: src/main/java/net/rithms/riot/api/endpoints/lol_status/methods/GetShardData.java
import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.endpoints.lol_status.LolStatusApiMethod;
import net.rithms.riot.api.endpoints.lol_status.dto.ShardStatus;
import net.rithms.riot.constant.Platform;
/*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.endpoints.lol_status.methods;
public class GetShardData extends LolStatusApiMethod {
public GetShardData(ApiConfig config, Platform platform) {
super(config);
setPlatform(platform);
| setReturnType(ShardStatus.class);
|
taycaldwell/riot-api-java | src/main/java/net/rithms/riot/api/endpoints/static_data/methods/GetDataMaps.java | // Path: src/main/java/net/rithms/riot/api/endpoints/static_data/StaticDataApiMethod.java
// abstract public class StaticDataApiMethod extends ApiMethod {
//
// protected StaticDataApiMethod(ApiConfig config) {
// super(config, "staticdata");
// requireApiKey();
// }
// }
//
// Path: src/main/java/net/rithms/riot/api/endpoints/static_data/dto/MapData.java
// public class MapData extends Dto implements Serializable {
//
// private static final long serialVersionUID = 1718454202345877041L;
//
// private Map<String, MapDetails> data;
// private String type;
// private String version;
//
// public Map<String, MapDetails> getData() {
// return data;
// }
//
// public String getType() {
// return type;
// }
//
// public String getVersion() {
// return version;
// }
//
// @Override
// public String toString() {
// return getType();
// }
// }
| import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.UrlParameter;
import net.rithms.riot.api.endpoints.static_data.StaticDataApiMethod;
import net.rithms.riot.api.endpoints.static_data.constant.Locale;
import net.rithms.riot.api.endpoints.static_data.dto.MapData;
import net.rithms.riot.constant.Platform;
| /*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.endpoints.static_data.methods;
public class GetDataMaps extends StaticDataApiMethod {
public GetDataMaps(ApiConfig config, Platform platform, Locale locale, String version) {
super(config);
setPlatform(platform);
| // Path: src/main/java/net/rithms/riot/api/endpoints/static_data/StaticDataApiMethod.java
// abstract public class StaticDataApiMethod extends ApiMethod {
//
// protected StaticDataApiMethod(ApiConfig config) {
// super(config, "staticdata");
// requireApiKey();
// }
// }
//
// Path: src/main/java/net/rithms/riot/api/endpoints/static_data/dto/MapData.java
// public class MapData extends Dto implements Serializable {
//
// private static final long serialVersionUID = 1718454202345877041L;
//
// private Map<String, MapDetails> data;
// private String type;
// private String version;
//
// public Map<String, MapDetails> getData() {
// return data;
// }
//
// public String getType() {
// return type;
// }
//
// public String getVersion() {
// return version;
// }
//
// @Override
// public String toString() {
// return getType();
// }
// }
// Path: src/main/java/net/rithms/riot/api/endpoints/static_data/methods/GetDataMaps.java
import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.UrlParameter;
import net.rithms.riot.api.endpoints.static_data.StaticDataApiMethod;
import net.rithms.riot.api.endpoints.static_data.constant.Locale;
import net.rithms.riot.api.endpoints.static_data.dto.MapData;
import net.rithms.riot.constant.Platform;
/*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.endpoints.static_data.methods;
public class GetDataMaps extends StaticDataApiMethod {
public GetDataMaps(ApiConfig config, Platform platform, Locale locale, String version) {
super(config);
setPlatform(platform);
| setReturnType(MapData.class);
|
taycaldwell/riot-api-java | src/test/java/net/rithms/test/sync/SummonerTest.java | // Path: src/main/java/net/rithms/riot/api/endpoints/summoner/dto/Summoner.java
// public class Summoner extends Dto implements Serializable {
//
// private static final long serialVersionUID = -8213488199644701555L;
//
// private String accountId;
// private String id;
// private String puuid;
// private String name;
// private int profileIconId;
// private long revisionDate;
// private int summonerLevel;
//
// public String getAccountId() {
// return accountId;
// }
//
// public String getId() {
// return id;
// }
//
// public String getPuuid() {
// return puuid;
// }
//
// public String getName() {
// return name;
// }
//
// public int getProfileIconId() {
// return profileIconId;
// }
//
// public long getRevisionDate() {
// return revisionDate;
// }
//
// public int getSummonerLevel() {
// return summonerLevel;
// }
//
// @Override
// public String toString() {
// return getId() + ": " + getName();
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.BeforeClass;
import org.junit.Test;
import net.rithms.riot.api.RiotApi;
import net.rithms.riot.api.RiotApiException;
import net.rithms.riot.api.endpoints.summoner.dto.Summoner;
import net.rithms.riot.constant.Platform;
import net.rithms.test.RiotApiTest;
| /*
* Copyright 2016-2017 Taylor Caldwell
*
* 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.rithms.test.sync;
/**
* Tests synchronous calls to the summoner endpoint
*/
public class SummonerTest {
private static RiotApi api = null;
@BeforeClass
public static void prepareApi() {
api = RiotApiTest.getRiotApi();
}
@Test
public void testGetSummoner() throws RiotApiException {
// TODO This test is currently expected to fail, due to summonerIds being encrypted differently for each app.
| // Path: src/main/java/net/rithms/riot/api/endpoints/summoner/dto/Summoner.java
// public class Summoner extends Dto implements Serializable {
//
// private static final long serialVersionUID = -8213488199644701555L;
//
// private String accountId;
// private String id;
// private String puuid;
// private String name;
// private int profileIconId;
// private long revisionDate;
// private int summonerLevel;
//
// public String getAccountId() {
// return accountId;
// }
//
// public String getId() {
// return id;
// }
//
// public String getPuuid() {
// return puuid;
// }
//
// public String getName() {
// return name;
// }
//
// public int getProfileIconId() {
// return profileIconId;
// }
//
// public long getRevisionDate() {
// return revisionDate;
// }
//
// public int getSummonerLevel() {
// return summonerLevel;
// }
//
// @Override
// public String toString() {
// return getId() + ": " + getName();
// }
// }
// Path: src/test/java/net/rithms/test/sync/SummonerTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.BeforeClass;
import org.junit.Test;
import net.rithms.riot.api.RiotApi;
import net.rithms.riot.api.RiotApiException;
import net.rithms.riot.api.endpoints.summoner.dto.Summoner;
import net.rithms.riot.constant.Platform;
import net.rithms.test.RiotApiTest;
/*
* Copyright 2016-2017 Taylor Caldwell
*
* 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.rithms.test.sync;
/**
* Tests synchronous calls to the summoner endpoint
*/
public class SummonerTest {
private static RiotApi api = null;
@BeforeClass
public static void prepareApi() {
api = RiotApiTest.getRiotApi();
}
@Test
public void testGetSummoner() throws RiotApiException {
// TODO This test is currently expected to fail, due to summonerIds being encrypted differently for each app.
| Summoner summoner = api.getSummoner(Platform.NA, "81439110");
|
taycaldwell/riot-api-java | src/main/java/net/rithms/riot/api/endpoints/league/methods/GetLeagueEntries.java | // Path: src/main/java/net/rithms/riot/api/endpoints/league/LeagueApiMethod.java
// abstract public class LeagueApiMethod extends ApiMethod {
//
// protected LeagueApiMethod(ApiConfig config) {
// super(config, "league");
// requireApiKey();
// }
// }
//
// Path: src/main/java/net/rithms/riot/api/endpoints/league/dto/LeagueEntry.java
// public class LeagueEntry extends Dto implements Serializable {
//
// private static final long serialVersionUID = 7672279635939129200L;
//
// private boolean freshBlood;
// private boolean hotStreak;
// private boolean inactive;
// private String leagueId;
// private int leaguePoints;
// private int losses;
// private MiniSeries miniSeries;
// private String queueType;
// private String rank;
// private String summonerId;
// private String summonerName;
// private String tier;
// private boolean veteran;
// private int wins;
//
// public String getLeagueId() {
// return leagueId;
// }
//
// public int getLeaguePoints() {
// return leaguePoints;
// }
//
// public int getLosses() {
// return losses;
// }
//
// public MiniSeries getMiniSeries() {
// return miniSeries;
// }
//
// public String getQueueType() {
// return queueType;
// }
//
// public String getRank() {
// return rank;
// }
//
// public String getSummonerId() {
// return summonerId;
// }
//
// public String getSummonerName() {
// return summonerName;
// }
//
// public String getTier() {
// return tier;
// }
//
// public int getWins() {
// return wins;
// }
//
// public boolean isFreshBlood() {
// return freshBlood;
// }
//
// public boolean isHotStreak() {
// return hotStreak;
// }
//
// public boolean isInactive() {
// return inactive;
// }
//
// public boolean isVeteran() {
// return veteran;
// }
//
// @Override
// public String toString() {
// return getQueueType();
// }
// }
| import java.util.Set;
import com.google.gson.reflect.TypeToken;
import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.endpoints.league.LeagueApiMethod;
import net.rithms.riot.api.endpoints.league.dto.LeagueEntry;
import net.rithms.riot.constant.Platform;
| /*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.endpoints.league.methods;
public class GetLeagueEntries extends LeagueApiMethod {
public GetLeagueEntries(ApiConfig config, Platform platform, String queue, String tier, String division) {
super(config);
setPlatform(platform);
| // Path: src/main/java/net/rithms/riot/api/endpoints/league/LeagueApiMethod.java
// abstract public class LeagueApiMethod extends ApiMethod {
//
// protected LeagueApiMethod(ApiConfig config) {
// super(config, "league");
// requireApiKey();
// }
// }
//
// Path: src/main/java/net/rithms/riot/api/endpoints/league/dto/LeagueEntry.java
// public class LeagueEntry extends Dto implements Serializable {
//
// private static final long serialVersionUID = 7672279635939129200L;
//
// private boolean freshBlood;
// private boolean hotStreak;
// private boolean inactive;
// private String leagueId;
// private int leaguePoints;
// private int losses;
// private MiniSeries miniSeries;
// private String queueType;
// private String rank;
// private String summonerId;
// private String summonerName;
// private String tier;
// private boolean veteran;
// private int wins;
//
// public String getLeagueId() {
// return leagueId;
// }
//
// public int getLeaguePoints() {
// return leaguePoints;
// }
//
// public int getLosses() {
// return losses;
// }
//
// public MiniSeries getMiniSeries() {
// return miniSeries;
// }
//
// public String getQueueType() {
// return queueType;
// }
//
// public String getRank() {
// return rank;
// }
//
// public String getSummonerId() {
// return summonerId;
// }
//
// public String getSummonerName() {
// return summonerName;
// }
//
// public String getTier() {
// return tier;
// }
//
// public int getWins() {
// return wins;
// }
//
// public boolean isFreshBlood() {
// return freshBlood;
// }
//
// public boolean isHotStreak() {
// return hotStreak;
// }
//
// public boolean isInactive() {
// return inactive;
// }
//
// public boolean isVeteran() {
// return veteran;
// }
//
// @Override
// public String toString() {
// return getQueueType();
// }
// }
// Path: src/main/java/net/rithms/riot/api/endpoints/league/methods/GetLeagueEntries.java
import java.util.Set;
import com.google.gson.reflect.TypeToken;
import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.endpoints.league.LeagueApiMethod;
import net.rithms.riot.api.endpoints.league.dto.LeagueEntry;
import net.rithms.riot.constant.Platform;
/*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.endpoints.league.methods;
public class GetLeagueEntries extends LeagueApiMethod {
public GetLeagueEntries(ApiConfig config, Platform platform, String queue, String tier, String division) {
super(config);
setPlatform(platform);
| setReturnType(new TypeToken<Set<LeagueEntry>>() {
|
taycaldwell/riot-api-java | src/main/java/net/rithms/riot/api/request/AsyncRequest.java | // Path: src/main/java/net/rithms/riot/api/ApiMethod.java
// abstract public class ApiMethod {
//
// private final ApiConfig config;
// private final String service;
// private Platform platform = null;
// private String urlBase;
// private final List<UrlParameter> urlParameters = new ArrayList<UrlParameter>();
// private final List<HttpHeadParameter> httpHeadParameters = new ArrayList<HttpHeadParameter>();
// private RequestMethod httpMethod = RequestMethod.GET;
// private String body = null;
// private Type returnType = null;
//
// private boolean requireApiKey = false;
//
// protected ApiMethod(ApiConfig config, String service) {
// this.config = config;
// this.service = service;
// }
//
// protected void add(HttpHeadParameter p) {
// httpHeadParameters.add(p);
// }
//
// protected void add(UrlParameter p) {
// urlParameters.add(p);
// }
//
// protected void addApiKeyParameter() {
// add(new HttpHeadParameter("X-Riot-Token", getConfig().getKey()));
// }
//
// public void buildJsonBody(Map<String, Object> map) {
// body = new Gson().toJson(map);
// }
//
// public void checkRequirements() throws RiotApiException {
// if (doesRequireApiKey() && getConfig().getKey() == null) {
// throw new RiotApiException(RiotApiException.MISSING_API_KEY);
// }
// }
//
// public boolean doesRequireApiKey() {
// return requireApiKey;
// }
//
// public String getBody() {
// return body;
// }
//
// protected ApiConfig getConfig() {
// return config;
// }
//
// public List<HttpHeadParameter> getHttpHeadParameters() {
// return httpHeadParameters;
// }
//
// public RequestMethod getHttpMethod() {
// return httpMethod;
// }
//
// public Platform getPlatform() {
// return platform;
// }
//
// public Type getReturnType() {
// return returnType;
// }
//
// public String getService() {
// return service;
// }
//
// public String getUrl() {
// StringBuilder url = new StringBuilder(urlBase);
// char connector = '?';
// for (UrlParameter p : urlParameters) {
// url.append(connector).append(p.toString());
// connector = '&';
// }
// return url.toString();
// }
//
// protected void requireApiKey() {
// requireApiKey = true;
// }
//
// protected void setPlatform(Platform platform) {
// this.platform = platform;
// }
//
// protected void setReturnType(Type returnType) {
// this.returnType = returnType;
// }
//
// protected void setHttpMethod(RequestMethod httpMethod) {
// this.httpMethod = httpMethod;
// }
//
// protected void setUrlBase(String urlBase) {
// this.urlBase = urlBase;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName();
// }
// }
| import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.ApiMethod;
import net.rithms.riot.api.RiotApi;
import net.rithms.riot.api.RiotApiAsync;
import net.rithms.riot.api.RiotApiException;
| /*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.request;
/**
* This class is used to fire asynchronous call at the Riot Api. You should not construct these requests manually. To fire asynchronous
* requests, use a {@link RiotApiAsync} object.
*
* @author Daniel 'Linnun' Figge
* @see RiotApiAsync
*/
public class AsyncRequest extends Request implements Runnable {
protected final Object signal = new Object();
private Collection<RequestListener> listeners = new CopyOnWriteArrayList<RequestListener>();
private Thread executionThread = null;
private boolean sent = false;
/**
* Constructs an asynchronous request
*
* @param config
* Configuration to use
* @param method
* Api method to call
* @see ApiConfig
* @see ApiMethod
*/
| // Path: src/main/java/net/rithms/riot/api/ApiMethod.java
// abstract public class ApiMethod {
//
// private final ApiConfig config;
// private final String service;
// private Platform platform = null;
// private String urlBase;
// private final List<UrlParameter> urlParameters = new ArrayList<UrlParameter>();
// private final List<HttpHeadParameter> httpHeadParameters = new ArrayList<HttpHeadParameter>();
// private RequestMethod httpMethod = RequestMethod.GET;
// private String body = null;
// private Type returnType = null;
//
// private boolean requireApiKey = false;
//
// protected ApiMethod(ApiConfig config, String service) {
// this.config = config;
// this.service = service;
// }
//
// protected void add(HttpHeadParameter p) {
// httpHeadParameters.add(p);
// }
//
// protected void add(UrlParameter p) {
// urlParameters.add(p);
// }
//
// protected void addApiKeyParameter() {
// add(new HttpHeadParameter("X-Riot-Token", getConfig().getKey()));
// }
//
// public void buildJsonBody(Map<String, Object> map) {
// body = new Gson().toJson(map);
// }
//
// public void checkRequirements() throws RiotApiException {
// if (doesRequireApiKey() && getConfig().getKey() == null) {
// throw new RiotApiException(RiotApiException.MISSING_API_KEY);
// }
// }
//
// public boolean doesRequireApiKey() {
// return requireApiKey;
// }
//
// public String getBody() {
// return body;
// }
//
// protected ApiConfig getConfig() {
// return config;
// }
//
// public List<HttpHeadParameter> getHttpHeadParameters() {
// return httpHeadParameters;
// }
//
// public RequestMethod getHttpMethod() {
// return httpMethod;
// }
//
// public Platform getPlatform() {
// return platform;
// }
//
// public Type getReturnType() {
// return returnType;
// }
//
// public String getService() {
// return service;
// }
//
// public String getUrl() {
// StringBuilder url = new StringBuilder(urlBase);
// char connector = '?';
// for (UrlParameter p : urlParameters) {
// url.append(connector).append(p.toString());
// connector = '&';
// }
// return url.toString();
// }
//
// protected void requireApiKey() {
// requireApiKey = true;
// }
//
// protected void setPlatform(Platform platform) {
// this.platform = platform;
// }
//
// protected void setReturnType(Type returnType) {
// this.returnType = returnType;
// }
//
// protected void setHttpMethod(RequestMethod httpMethod) {
// this.httpMethod = httpMethod;
// }
//
// protected void setUrlBase(String urlBase) {
// this.urlBase = urlBase;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName();
// }
// }
// Path: src/main/java/net/rithms/riot/api/request/AsyncRequest.java
import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.ApiMethod;
import net.rithms.riot.api.RiotApi;
import net.rithms.riot.api.RiotApiAsync;
import net.rithms.riot.api.RiotApiException;
/*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.request;
/**
* This class is used to fire asynchronous call at the Riot Api. You should not construct these requests manually. To fire asynchronous
* requests, use a {@link RiotApiAsync} object.
*
* @author Daniel 'Linnun' Figge
* @see RiotApiAsync
*/
public class AsyncRequest extends Request implements Runnable {
protected final Object signal = new Object();
private Collection<RequestListener> listeners = new CopyOnWriteArrayList<RequestListener>();
private Thread executionThread = null;
private boolean sent = false;
/**
* Constructs an asynchronous request
*
* @param config
* Configuration to use
* @param method
* Api method to call
* @see ApiConfig
* @see ApiMethod
*/
| public AsyncRequest(ApiConfig config, ApiMethod object) {
|
taycaldwell/riot-api-java | src/main/java/net/rithms/riot/api/endpoints/static_data/methods/GetDataChampion.java | // Path: src/main/java/net/rithms/riot/api/endpoints/static_data/StaticDataApiMethod.java
// abstract public class StaticDataApiMethod extends ApiMethod {
//
// protected StaticDataApiMethod(ApiConfig config) {
// super(config, "staticdata");
// requireApiKey();
// }
// }
//
// Path: src/main/java/net/rithms/riot/api/endpoints/static_data/dto/Champion.java
// public class Champion extends Dto implements Serializable {
//
// private static final long serialVersionUID = 8120597968700936522L;
//
// private List<String> allytips;
// private String blurb;
// private List<String> enemytips;
// private int id;
// private Image image;
// private Info info;
// private String key;
// private String lore;
// private String name;
// private String partype;
// private Passive passive;
// private List<Recommended> recommended;
// private List<Skin> skins;
// private List<ChampionSpell> spells;
// private Stats stats;
// private List<String> tags;
// private String title;
//
// public List<String> getAllytips() {
// return allytips;
// }
//
// public String getBlurb() {
// return blurb;
// }
//
// public List<String> getEnemytips() {
// return enemytips;
// }
//
// public int getId() {
// return id;
// }
//
// public Image getImage() {
// return image;
// }
//
// public Info getInfo() {
// return info;
// }
//
// public String getKey() {
// return key;
// }
//
// public String getLore() {
// return lore;
// }
//
// public String getName() {
// return name;
// }
//
// public String getPartype() {
// return partype;
// }
//
// public Passive getPassive() {
// return passive;
// }
//
// public List<Recommended> getRecommended() {
// return recommended;
// }
//
// public List<Skin> getSkins() {
// return skins;
// }
//
// public List<ChampionSpell> getSpells() {
// return spells;
// }
//
// public Stats getStats() {
// return stats;
// }
//
// public List<String> getTags() {
// return tags;
// }
//
// public String getTitle() {
// return title;
// }
//
// @Override
// public String toString() {
// return getId() + ": " + getName();
// }
// }
| import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.UrlParameter;
import net.rithms.riot.api.endpoints.static_data.StaticDataApiMethod;
import net.rithms.riot.api.endpoints.static_data.constant.ChampionTags;
import net.rithms.riot.api.endpoints.static_data.constant.Locale;
import net.rithms.riot.api.endpoints.static_data.dto.Champion;
import net.rithms.riot.constant.Platform;
| /*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.endpoints.static_data.methods;
public class GetDataChampion extends StaticDataApiMethod {
public GetDataChampion(ApiConfig config, Platform platform, int id, Locale locale, String version, ChampionTags... tags) {
super(config);
setPlatform(platform);
| // Path: src/main/java/net/rithms/riot/api/endpoints/static_data/StaticDataApiMethod.java
// abstract public class StaticDataApiMethod extends ApiMethod {
//
// protected StaticDataApiMethod(ApiConfig config) {
// super(config, "staticdata");
// requireApiKey();
// }
// }
//
// Path: src/main/java/net/rithms/riot/api/endpoints/static_data/dto/Champion.java
// public class Champion extends Dto implements Serializable {
//
// private static final long serialVersionUID = 8120597968700936522L;
//
// private List<String> allytips;
// private String blurb;
// private List<String> enemytips;
// private int id;
// private Image image;
// private Info info;
// private String key;
// private String lore;
// private String name;
// private String partype;
// private Passive passive;
// private List<Recommended> recommended;
// private List<Skin> skins;
// private List<ChampionSpell> spells;
// private Stats stats;
// private List<String> tags;
// private String title;
//
// public List<String> getAllytips() {
// return allytips;
// }
//
// public String getBlurb() {
// return blurb;
// }
//
// public List<String> getEnemytips() {
// return enemytips;
// }
//
// public int getId() {
// return id;
// }
//
// public Image getImage() {
// return image;
// }
//
// public Info getInfo() {
// return info;
// }
//
// public String getKey() {
// return key;
// }
//
// public String getLore() {
// return lore;
// }
//
// public String getName() {
// return name;
// }
//
// public String getPartype() {
// return partype;
// }
//
// public Passive getPassive() {
// return passive;
// }
//
// public List<Recommended> getRecommended() {
// return recommended;
// }
//
// public List<Skin> getSkins() {
// return skins;
// }
//
// public List<ChampionSpell> getSpells() {
// return spells;
// }
//
// public Stats getStats() {
// return stats;
// }
//
// public List<String> getTags() {
// return tags;
// }
//
// public String getTitle() {
// return title;
// }
//
// @Override
// public String toString() {
// return getId() + ": " + getName();
// }
// }
// Path: src/main/java/net/rithms/riot/api/endpoints/static_data/methods/GetDataChampion.java
import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.UrlParameter;
import net.rithms.riot.api.endpoints.static_data.StaticDataApiMethod;
import net.rithms.riot.api.endpoints.static_data.constant.ChampionTags;
import net.rithms.riot.api.endpoints.static_data.constant.Locale;
import net.rithms.riot.api.endpoints.static_data.dto.Champion;
import net.rithms.riot.constant.Platform;
/*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.endpoints.static_data.methods;
public class GetDataChampion extends StaticDataApiMethod {
public GetDataChampion(ApiConfig config, Platform platform, int id, Locale locale, String version, ChampionTags... tags) {
super(config);
setPlatform(platform);
| setReturnType(Champion.class);
|
taycaldwell/riot-api-java | src/main/java/net/rithms/riot/api/endpoints/summoner/methods/GetSummoner.java | // Path: src/main/java/net/rithms/riot/api/endpoints/summoner/dto/Summoner.java
// public class Summoner extends Dto implements Serializable {
//
// private static final long serialVersionUID = -8213488199644701555L;
//
// private String accountId;
// private String id;
// private String puuid;
// private String name;
// private int profileIconId;
// private long revisionDate;
// private int summonerLevel;
//
// public String getAccountId() {
// return accountId;
// }
//
// public String getId() {
// return id;
// }
//
// public String getPuuid() {
// return puuid;
// }
//
// public String getName() {
// return name;
// }
//
// public int getProfileIconId() {
// return profileIconId;
// }
//
// public long getRevisionDate() {
// return revisionDate;
// }
//
// public int getSummonerLevel() {
// return summonerLevel;
// }
//
// @Override
// public String toString() {
// return getId() + ": " + getName();
// }
// }
| import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.endpoints.summoner.SummonerApiMethod;
import net.rithms.riot.api.endpoints.summoner.dto.Summoner;
import net.rithms.riot.constant.Platform;
| /*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.endpoints.summoner.methods;
public class GetSummoner extends SummonerApiMethod {
public GetSummoner(ApiConfig config, Platform platform, String summonerId) {
super(config);
setPlatform(platform);
| // Path: src/main/java/net/rithms/riot/api/endpoints/summoner/dto/Summoner.java
// public class Summoner extends Dto implements Serializable {
//
// private static final long serialVersionUID = -8213488199644701555L;
//
// private String accountId;
// private String id;
// private String puuid;
// private String name;
// private int profileIconId;
// private long revisionDate;
// private int summonerLevel;
//
// public String getAccountId() {
// return accountId;
// }
//
// public String getId() {
// return id;
// }
//
// public String getPuuid() {
// return puuid;
// }
//
// public String getName() {
// return name;
// }
//
// public int getProfileIconId() {
// return profileIconId;
// }
//
// public long getRevisionDate() {
// return revisionDate;
// }
//
// public int getSummonerLevel() {
// return summonerLevel;
// }
//
// @Override
// public String toString() {
// return getId() + ": " + getName();
// }
// }
// Path: src/main/java/net/rithms/riot/api/endpoints/summoner/methods/GetSummoner.java
import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.endpoints.summoner.SummonerApiMethod;
import net.rithms.riot.api.endpoints.summoner.dto.Summoner;
import net.rithms.riot.constant.Platform;
/*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.endpoints.summoner.methods;
public class GetSummoner extends SummonerApiMethod {
public GetSummoner(ApiConfig config, Platform platform, String summonerId) {
super(config);
setPlatform(platform);
| setReturnType(Summoner.class);
|
taycaldwell/riot-api-java | src/main/java/net/rithms/riot/api/endpoints/match/methods/GetTimelineByMatchId.java | // Path: src/main/java/net/rithms/riot/api/endpoints/match/dto/MatchTimeline.java
// public class MatchTimeline extends Dto implements Serializable {
//
// private static final long serialVersionUID = 3888184958883394435L;
//
// private long frameInterval;
// private List<MatchFrame> frames;
//
// public long getFrameInterval() {
// return frameInterval;
// }
//
// public List<MatchFrame> getFrames() {
// return frames;
// }
//
// @Override
// public String toString() {
// return String.valueOf(getFrameInterval());
// }
// }
| import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.endpoints.match.MatchApiMethod;
import net.rithms.riot.api.endpoints.match.dto.MatchTimeline;
import net.rithms.riot.constant.Platform;
| /*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.endpoints.match.methods;
public class GetTimelineByMatchId extends MatchApiMethod {
public GetTimelineByMatchId(ApiConfig config, Platform platform, long matchId) {
super(config);
setPlatform(platform);
| // Path: src/main/java/net/rithms/riot/api/endpoints/match/dto/MatchTimeline.java
// public class MatchTimeline extends Dto implements Serializable {
//
// private static final long serialVersionUID = 3888184958883394435L;
//
// private long frameInterval;
// private List<MatchFrame> frames;
//
// public long getFrameInterval() {
// return frameInterval;
// }
//
// public List<MatchFrame> getFrames() {
// return frames;
// }
//
// @Override
// public String toString() {
// return String.valueOf(getFrameInterval());
// }
// }
// Path: src/main/java/net/rithms/riot/api/endpoints/match/methods/GetTimelineByMatchId.java
import net.rithms.riot.api.ApiConfig;
import net.rithms.riot.api.endpoints.match.MatchApiMethod;
import net.rithms.riot.api.endpoints.match.dto.MatchTimeline;
import net.rithms.riot.constant.Platform;
/*
* Copyright 2016 Taylor Caldwell
*
* 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.rithms.riot.api.endpoints.match.methods;
public class GetTimelineByMatchId extends MatchApiMethod {
public GetTimelineByMatchId(ApiConfig config, Platform platform, long matchId) {
super(config);
setPlatform(platform);
| setReturnType(MatchTimeline.class);
|
martinschaef/jar2bpl | src/main/java/org/joogie/Main.java | // Path: src/main/java/org/joogie/util/Log.java
// public class Log {
//
// /**
// * log4j's Logger object
// */
// private static Logger logger = null;
//
// /**
// * Singleton method
// *
// * @return Logger object
// */
// public static Logger v() {
// if (null == logger) {
// // create logger
// logger = Logger.getRootLogger();
// }
//
// return logger;
// }
//
// /**
// * Log a message object with the DEBUG Level.
// *
// * @param o
// * the message object to log
// */
// public static void debug(Object o) {
// v().debug(o);
// }
//
// /**
// * Log a message object with the INFO Level.
// *
// * @param o
// * the message object to log
// */
// public static void info(Object o) {
// v().info(o);
// }
//
// /**
// * Log a message object with the ERROR Level.
// *
// * @param o
// * the message object to log
// */
// public static void error(Object o) {
// v().error(o);
// }
//
// /**
// * C-tor
// */
// private Log() {
// // do nothing
// }
// }
| import org.joogie.util.Log;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
| /*
* jimple2boogie - Translates Jimple (or Java) Programs to Boogie
* Copyright (C) 2013 Martin Schaef and Stephan Arlt
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.joogie;
/**
* Main-Class
*
* @author schaef
*/
public class Main {
/**
* Main method
*
* @param args
* Command-line arguments
*/
public static void main(String[] args) {
Options options = Options.v();
CmdLineParser parser = new CmdLineParser(options);
//soot.jimple.toolkits.ide.icfg.JimpleBasedInterproceduralCFG cfg = new soot.jimple.toolkits.ide.icfg.JimpleBasedInterproceduralCFG();
try {
// parse command-line arguments
parser.parseArgument(args);
runConsoleMode();
} catch (CmdLineException e) {
| // Path: src/main/java/org/joogie/util/Log.java
// public class Log {
//
// /**
// * log4j's Logger object
// */
// private static Logger logger = null;
//
// /**
// * Singleton method
// *
// * @return Logger object
// */
// public static Logger v() {
// if (null == logger) {
// // create logger
// logger = Logger.getRootLogger();
// }
//
// return logger;
// }
//
// /**
// * Log a message object with the DEBUG Level.
// *
// * @param o
// * the message object to log
// */
// public static void debug(Object o) {
// v().debug(o);
// }
//
// /**
// * Log a message object with the INFO Level.
// *
// * @param o
// * the message object to log
// */
// public static void info(Object o) {
// v().info(o);
// }
//
// /**
// * Log a message object with the ERROR Level.
// *
// * @param o
// * the message object to log
// */
// public static void error(Object o) {
// v().error(o);
// }
//
// /**
// * C-tor
// */
// private Log() {
// // do nothing
// }
// }
// Path: src/main/java/org/joogie/Main.java
import org.joogie.util.Log;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
/*
* jimple2boogie - Translates Jimple (or Java) Programs to Boogie
* Copyright (C) 2013 Martin Schaef and Stephan Arlt
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.joogie;
/**
* Main-Class
*
* @author schaef
*/
public class Main {
/**
* Main method
*
* @param args
* Command-line arguments
*/
public static void main(String[] args) {
Options options = Options.v();
CmdLineParser parser = new CmdLineParser(options);
//soot.jimple.toolkits.ide.icfg.JimpleBasedInterproceduralCFG cfg = new soot.jimple.toolkits.ide.icfg.JimpleBasedInterproceduralCFG();
try {
// parse command-line arguments
parser.parseArgument(args);
runConsoleMode();
} catch (CmdLineException e) {
| Log.error(e.toString());
|
jparsercombinator/jparsercombinator | src/test/java/org/jparsercombinator/ParserCombinatorTest.java | // Path: src/main/java/org/jparsercombinator/ParserCombinators.java
// public static ParserCombinator<String> regex(String regex) {
// return regexMatchResult(regex).map(MatchResult::group);
// }
//
// Path: src/main/java/org/jparsercombinator/ParserCombinators.java
// public static ParserCombinator<String> string(String str) {
// return regex(Pattern.quote(str));
// }
| import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static org.jparsercombinator.ParserCombinators.regex;
import static org.jparsercombinator.ParserCombinators.string;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.junit.Test; | package org.jparsercombinator;
public class ParserCombinatorTest {
private ParserCombinator<String> foo = string("foo");
private ParserCombinator<String> bar = string("bar");
private Parser<String> fooParser = foo.end();
private Parser<Optional<String>> fooOptionalParser = foo.optional().end();
private Parser<String> fooOrBarParser = foo.or(bar).end();
private Parser<List<String>> fooRepeatingParser = foo.many().end();
private Parser<List<String>> fooRepeatingCommaSeparatedParser = foo.many(string(",")).end();
private Parser<Pair<String, String>> fooNextBarParser = foo.next(bar).end(); | // Path: src/main/java/org/jparsercombinator/ParserCombinators.java
// public static ParserCombinator<String> regex(String regex) {
// return regexMatchResult(regex).map(MatchResult::group);
// }
//
// Path: src/main/java/org/jparsercombinator/ParserCombinators.java
// public static ParserCombinator<String> string(String str) {
// return regex(Pattern.quote(str));
// }
// Path: src/test/java/org/jparsercombinator/ParserCombinatorTest.java
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static org.jparsercombinator.ParserCombinators.regex;
import static org.jparsercombinator.ParserCombinators.string;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
package org.jparsercombinator;
public class ParserCombinatorTest {
private ParserCombinator<String> foo = string("foo");
private ParserCombinator<String> bar = string("bar");
private Parser<String> fooParser = foo.end();
private Parser<Optional<String>> fooOptionalParser = foo.optional().end();
private Parser<String> fooOrBarParser = foo.or(bar).end();
private Parser<List<String>> fooRepeatingParser = foo.many().end();
private Parser<List<String>> fooRepeatingCommaSeparatedParser = foo.many(string(",")).end();
private Parser<Pair<String, String>> fooNextBarParser = foo.next(bar).end(); | private Parser<Integer> integerParser = regex("[0-9]+").map(Integer::parseInt).end(); |
jparsercombinator/jparsercombinator | src/test/java/org/jparsercombinator/examples/expression/ExpressionParserTest.java | // Path: src/main/java/org/jparsercombinator/ParseException.java
// public class ParseException extends RuntimeException {
//
// ParseException(String message) {
// super(message);
// }
//
// }
//
// Path: src/main/java/org/jparsercombinator/Parser.java
// public interface Parser<T> {
//
// /**
// * Parses input and returns a result of type {@code T}. May throw {@code ParseException} depending
// * on the implementation.
// *
// * @param input to be parsed
// * @return parse result, e.g. an AST
// */
// T apply(String input);
//
// }
| import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.jparsercombinator.ParseException;
import org.jparsercombinator.Parser; | package org.jparsercombinator.examples.expression;
public class ExpressionParserTest {
private Parser<Integer> expressionParser = new ExpressionParser();
| // Path: src/main/java/org/jparsercombinator/ParseException.java
// public class ParseException extends RuntimeException {
//
// ParseException(String message) {
// super(message);
// }
//
// }
//
// Path: src/main/java/org/jparsercombinator/Parser.java
// public interface Parser<T> {
//
// /**
// * Parses input and returns a result of type {@code T}. May throw {@code ParseException} depending
// * on the implementation.
// *
// * @param input to be parsed
// * @return parse result, e.g. an AST
// */
// T apply(String input);
//
// }
// Path: src/test/java/org/jparsercombinator/examples/expression/ExpressionParserTest.java
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.jparsercombinator.ParseException;
import org.jparsercombinator.Parser;
package org.jparsercombinator.examples.expression;
public class ExpressionParserTest {
private Parser<Integer> expressionParser = new ExpressionParser();
| @Test(expected = ParseException.class) |
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/disambiguate/TestDisambiguationCases.java | // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/A.java
// @ImplementedBy(AImpl.class)
// public interface A {
//
// public String a();
// }
| import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.A;
| package com.insightfullogic.multiinherit.disambiguate;
public class TestDisambiguationCases {
@Test
public void checkAtPrefer() {
| // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/A.java
// @ImplementedBy(AImpl.class)
// public interface A {
//
// public String a();
// }
// Path: src/test/java/com/insightfullogic/multiinherit/disambiguate/TestDisambiguationCases.java
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.A;
package com.insightfullogic.multiinherit.disambiguate;
public class TestDisambiguationCases {
@Test
public void checkAtPrefer() {
| Util.withBools(new Do<Boolean>() {
|
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/disambiguate/TestDisambiguationCases.java | // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/A.java
// @ImplementedBy(AImpl.class)
// public interface A {
//
// public String a();
// }
| import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.A;
| package com.insightfullogic.multiinherit.disambiguate;
public class TestDisambiguationCases {
@Test
public void checkAtPrefer() {
| // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/A.java
// @ImplementedBy(AImpl.class)
// public interface A {
//
// public String a();
// }
// Path: src/test/java/com/insightfullogic/multiinherit/disambiguate/TestDisambiguationCases.java
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.A;
package com.insightfullogic.multiinherit.disambiguate;
public class TestDisambiguationCases {
@Test
public void checkAtPrefer() {
| Util.withBools(new Do<Boolean>() {
|
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/disambiguate/TestDisambiguationCases.java | // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/A.java
// @ImplementedBy(AImpl.class)
// public interface A {
//
// public String a();
// }
| import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.A;
| package com.insightfullogic.multiinherit.disambiguate;
public class TestDisambiguationCases {
@Test
public void checkAtPrefer() {
Util.withBools(new Do<Boolean>() {
@Override
public void apply(final Boolean b) {
| // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/A.java
// @ImplementedBy(AImpl.class)
// public interface A {
//
// public String a();
// }
// Path: src/test/java/com/insightfullogic/multiinherit/disambiguate/TestDisambiguationCases.java
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.A;
package com.insightfullogic.multiinherit.disambiguate;
public class TestDisambiguationCases {
@Test
public void checkAtPrefer() {
Util.withBools(new Do<Boolean>() {
@Override
public void apply(final Boolean b) {
| final Injector injector = Guice.createInjector(new MultiModule(b, CombinedPreferC.class));
|
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/disambiguate/TestDisambiguationCases.java | // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/A.java
// @ImplementedBy(AImpl.class)
// public interface A {
//
// public String a();
// }
| import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.A;
| package com.insightfullogic.multiinherit.disambiguate;
public class TestDisambiguationCases {
@Test
public void checkAtPrefer() {
Util.withBools(new Do<Boolean>() {
@Override
public void apply(final Boolean b) {
final Injector injector = Guice.createInjector(new MultiModule(b, CombinedPreferC.class));
| // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/A.java
// @ImplementedBy(AImpl.class)
// public interface A {
//
// public String a();
// }
// Path: src/test/java/com/insightfullogic/multiinherit/disambiguate/TestDisambiguationCases.java
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.A;
package com.insightfullogic.multiinherit.disambiguate;
public class TestDisambiguationCases {
@Test
public void checkAtPrefer() {
Util.withBools(new Do<Boolean>() {
@Override
public void apply(final Boolean b) {
final Injector injector = Guice.createInjector(new MultiModule(b, CombinedPreferC.class));
| final A aImpl = injector.getInstance(A.class);
|
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/simple/TestSimpleCases.java | // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
| import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
| package com.insightfullogic.multiinherit.simple;
public class TestSimpleCases {
@Test
public void egs() {
| // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
// Path: src/test/java/com/insightfullogic/multiinherit/simple/TestSimpleCases.java
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
package com.insightfullogic.multiinherit.simple;
public class TestSimpleCases {
@Test
public void egs() {
| Util.withBools(new Do<Boolean>() {
|
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/simple/TestSimpleCases.java | // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
| import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
| package com.insightfullogic.multiinherit.simple;
public class TestSimpleCases {
@Test
public void egs() {
| // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
// Path: src/test/java/com/insightfullogic/multiinherit/simple/TestSimpleCases.java
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
package com.insightfullogic.multiinherit.simple;
public class TestSimpleCases {
@Test
public void egs() {
| Util.withBools(new Do<Boolean>() {
|
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/simple/TestSimpleCases.java | // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
| import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
| package com.insightfullogic.multiinherit.simple;
public class TestSimpleCases {
@Test
public void egs() {
Util.withBools(new Do<Boolean>() {
@Override
public void apply(final Boolean b) {
| // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
// Path: src/test/java/com/insightfullogic/multiinherit/simple/TestSimpleCases.java
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
package com.insightfullogic.multiinherit.simple;
public class TestSimpleCases {
@Test
public void egs() {
Util.withBools(new Do<Boolean>() {
@Override
public void apply(final Boolean b) {
| final Injector injector = Guice.createInjector(new MultiModule(b, Combined.class));
|
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/traits/TestTraitCases.java | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
| import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.ProvisionException;
import com.insightfullogic.multiinherit.api.MultiModule; | package com.insightfullogic.multiinherit.traits;
public class TestTraitCases {
@Test
public void testSingleTrait() { | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
// Path: src/test/java/com/insightfullogic/multiinherit/traits/TestTraitCases.java
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.ProvisionException;
import com.insightfullogic.multiinherit.api.MultiModule;
package com.insightfullogic.multiinherit.traits;
public class TestTraitCases {
@Test
public void testSingleTrait() { | final Injector injector = Guice.createInjector(new MultiModule(true, Number.class)); |
insightfullogic/java-multi-inherit | src/main/java/com/insightfullogic/multiinherit/reflection/ReflectionMultiInjector.java | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiInjector.java
// public interface MultiInjector {
//
// public <T> T getInstance(Class<T> combined);
//
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/common/ResolutionInfo.java
// public final class ResolutionInfo {
//
// private final String name;
// private final Class<?>[] parameterTypes;
//
// public ResolutionInfo(final Method method) {
// super();
// name = method.getName();
// parameterTypes = method.getParameterTypes();
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// result = prime * result + Arrays.hashCode(parameterTypes);
// return result;
// }
//
// @Override
// public boolean equals(final Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// final ResolutionInfo other = (ResolutionInfo) obj;
// if (name == null) {
// if (other.name != null)
// return false;
// } else if (!name.equals(other.name))
// return false;
// if (!Arrays.equals(parameterTypes, other.parameterTypes))
// return false;
// return true;
// }
// }
| import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Singleton;
import com.insightfullogic.multiinherit.api.MultiInjector;
import com.insightfullogic.multiinherit.api.Prefer;
import com.insightfullogic.multiinherit.common.ResolutionInfo; | package com.insightfullogic.multiinherit.reflection;
@Singleton
public class ReflectionMultiInjector implements MultiInjector {
@Inject
private Injector injector;
@SuppressWarnings("unchecked")
@Override
public <T> T getInstance(final Class<T> combined) {
final Class<?>[] parents = combined.getInterfaces();
Class<?>[] interfaces = null;
if (combined.isInterface()) {
interfaces = Arrays.copyOf(parents, parents.length + 1);
interfaces[parents.length] = combined;
} else {
interfaces = parents;
throw new UnsupportedOperationException(
"It is impossible to do multiple class inheritance with the Reflection backend, try using the Generation backend");
} | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiInjector.java
// public interface MultiInjector {
//
// public <T> T getInstance(Class<T> combined);
//
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/common/ResolutionInfo.java
// public final class ResolutionInfo {
//
// private final String name;
// private final Class<?>[] parameterTypes;
//
// public ResolutionInfo(final Method method) {
// super();
// name = method.getName();
// parameterTypes = method.getParameterTypes();
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// result = prime * result + Arrays.hashCode(parameterTypes);
// return result;
// }
//
// @Override
// public boolean equals(final Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// final ResolutionInfo other = (ResolutionInfo) obj;
// if (name == null) {
// if (other.name != null)
// return false;
// } else if (!name.equals(other.name))
// return false;
// if (!Arrays.equals(parameterTypes, other.parameterTypes))
// return false;
// return true;
// }
// }
// Path: src/main/java/com/insightfullogic/multiinherit/reflection/ReflectionMultiInjector.java
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Singleton;
import com.insightfullogic.multiinherit.api.MultiInjector;
import com.insightfullogic.multiinherit.api.Prefer;
import com.insightfullogic.multiinherit.common.ResolutionInfo;
package com.insightfullogic.multiinherit.reflection;
@Singleton
public class ReflectionMultiInjector implements MultiInjector {
@Inject
private Injector injector;
@SuppressWarnings("unchecked")
@Override
public <T> T getInstance(final Class<T> combined) {
final Class<?>[] parents = combined.getInterfaces();
Class<?>[] interfaces = null;
if (combined.isInterface()) {
interfaces = Arrays.copyOf(parents, parents.length + 1);
interfaces[parents.length] = combined;
} else {
interfaces = parents;
throw new UnsupportedOperationException(
"It is impossible to do multiple class inheritance with the Reflection backend, try using the Generation backend");
} | final Map<ResolutionInfo, Method> preferences1 = new HashMap<ResolutionInfo, Method>(); |
insightfullogic/java-multi-inherit | src/main/java/com/insightfullogic/multiinherit/reflection/MultiInvocationHandler.java | // Path: src/main/java/com/insightfullogic/multiinherit/common/ResolutionInfo.java
// public final class ResolutionInfo {
//
// private final String name;
// private final Class<?>[] parameterTypes;
//
// public ResolutionInfo(final Method method) {
// super();
// name = method.getName();
// parameterTypes = method.getParameterTypes();
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// result = prime * result + Arrays.hashCode(parameterTypes);
// return result;
// }
//
// @Override
// public boolean equals(final Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// final ResolutionInfo other = (ResolutionInfo) obj;
// if (name == null) {
// if (other.name != null)
// return false;
// } else if (!name.equals(other.name))
// return false;
// if (!Arrays.equals(parameterTypes, other.parameterTypes))
// return false;
// return true;
// }
// }
| import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Map;
import com.insightfullogic.multiinherit.common.ResolutionInfo;
| package com.insightfullogic.multiinherit.reflection;
class MultiInvocationHandler implements InvocationHandler {
private final Map<Class<?>, Object> cache;
| // Path: src/main/java/com/insightfullogic/multiinherit/common/ResolutionInfo.java
// public final class ResolutionInfo {
//
// private final String name;
// private final Class<?>[] parameterTypes;
//
// public ResolutionInfo(final Method method) {
// super();
// name = method.getName();
// parameterTypes = method.getParameterTypes();
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// result = prime * result + Arrays.hashCode(parameterTypes);
// return result;
// }
//
// @Override
// public boolean equals(final Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// final ResolutionInfo other = (ResolutionInfo) obj;
// if (name == null) {
// if (other.name != null)
// return false;
// } else if (!name.equals(other.name))
// return false;
// if (!Arrays.equals(parameterTypes, other.parameterTypes))
// return false;
// return true;
// }
// }
// Path: src/main/java/com/insightfullogic/multiinherit/reflection/MultiInvocationHandler.java
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Map;
import com.insightfullogic.multiinherit.common.ResolutionInfo;
package com.insightfullogic.multiinherit.reflection;
class MultiInvocationHandler implements InvocationHandler {
private final Map<Class<?>, Object> cache;
| private final Map<ResolutionInfo, Method> preferences;
|
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/overriding/TestOverridingCases.java | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/A.java
// @ImplementedBy(AImpl.class)
// public interface A {
//
// public String a();
// }
| import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.ProvisionException;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.A; | package com.insightfullogic.multiinherit.overriding;
public class TestOverridingCases {
@Test
public void customImplementation() { | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/A.java
// @ImplementedBy(AImpl.class)
// public interface A {
//
// public String a();
// }
// Path: src/test/java/com/insightfullogic/multiinherit/overriding/TestOverridingCases.java
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.ProvisionException;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.A;
package com.insightfullogic.multiinherit.overriding;
public class TestOverridingCases {
@Test
public void customImplementation() { | final Injector injector = Guice.createInjector(new MultiModule(true, CustomAB.class)); |
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/overriding/TestOverridingCases.java | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/A.java
// @ImplementedBy(AImpl.class)
// public interface A {
//
// public String a();
// }
| import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.ProvisionException;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.A; | package com.insightfullogic.multiinherit.overriding;
public class TestOverridingCases {
@Test
public void customImplementation() {
final Injector injector = Guice.createInjector(new MultiModule(true, CustomAB.class)); | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/A.java
// @ImplementedBy(AImpl.class)
// public interface A {
//
// public String a();
// }
// Path: src/test/java/com/insightfullogic/multiinherit/overriding/TestOverridingCases.java
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.ProvisionException;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.A;
package com.insightfullogic.multiinherit.overriding;
public class TestOverridingCases {
@Test
public void customImplementation() {
final Injector injector = Guice.createInjector(new MultiModule(true, CustomAB.class)); | final A aImpl = injector.getInstance(A.class); |
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/TestCommon.java | // Path: src/main/java/com/insightfullogic/multiinherit/common/ResolutionInfo.java
// public final class ResolutionInfo {
//
// private final String name;
// private final Class<?>[] parameterTypes;
//
// public ResolutionInfo(final Method method) {
// super();
// name = method.getName();
// parameterTypes = method.getParameterTypes();
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// result = prime * result + Arrays.hashCode(parameterTypes);
// return result;
// }
//
// @Override
// public boolean equals(final Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// final ResolutionInfo other = (ResolutionInfo) obj;
// if (name == null) {
// if (other.name != null)
// return false;
// } else if (!name.equals(other.name))
// return false;
// if (!Arrays.equals(parameterTypes, other.parameterTypes))
// return false;
// return true;
// }
// }
| import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import com.insightfullogic.multiinherit.common.ResolutionInfo; | package com.insightfullogic.multiinherit;
public class TestCommon {
@Test
public void resolutionInfoContracts() { | // Path: src/main/java/com/insightfullogic/multiinherit/common/ResolutionInfo.java
// public final class ResolutionInfo {
//
// private final String name;
// private final Class<?>[] parameterTypes;
//
// public ResolutionInfo(final Method method) {
// super();
// name = method.getName();
// parameterTypes = method.getParameterTypes();
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// result = prime * result + Arrays.hashCode(parameterTypes);
// return result;
// }
//
// @Override
// public boolean equals(final Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// final ResolutionInfo other = (ResolutionInfo) obj;
// if (name == null) {
// if (other.name != null)
// return false;
// } else if (!name.equals(other.name))
// return false;
// if (!Arrays.equals(parameterTypes, other.parameterTypes))
// return false;
// return true;
// }
// }
// Path: src/test/java/com/insightfullogic/multiinherit/TestCommon.java
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;
import com.insightfullogic.multiinherit.common.ResolutionInfo;
package com.insightfullogic.multiinherit;
public class TestCommon {
@Test
public void resolutionInfoContracts() { | EqualsVerifier.forClass(ResolutionInfo.class).verify(); |
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/primitives/TestPrimitiveCases.java | // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
| import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule; | package com.insightfullogic.multiinherit.primitives;
public class TestPrimitiveCases {
@Test
public void testPrim() { | // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
// Path: src/test/java/com/insightfullogic/multiinherit/primitives/TestPrimitiveCases.java
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
package com.insightfullogic.multiinherit.primitives;
public class TestPrimitiveCases {
@Test
public void testPrim() { | Util.withBools(new Do<Boolean>() { |
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/primitives/TestPrimitiveCases.java | // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
| import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule; | package com.insightfullogic.multiinherit.primitives;
public class TestPrimitiveCases {
@Test
public void testPrim() { | // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
// Path: src/test/java/com/insightfullogic/multiinherit/primitives/TestPrimitiveCases.java
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
package com.insightfullogic.multiinherit.primitives;
public class TestPrimitiveCases {
@Test
public void testPrim() { | Util.withBools(new Do<Boolean>() { |
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/primitives/TestPrimitiveCases.java | // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
| import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule; | package com.insightfullogic.multiinherit.primitives;
public class TestPrimitiveCases {
@Test
public void testPrim() {
Util.withBools(new Do<Boolean>() {
@Override
public void apply(final Boolean b) { | // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
// Path: src/test/java/com/insightfullogic/multiinherit/primitives/TestPrimitiveCases.java
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
package com.insightfullogic.multiinherit.primitives;
public class TestPrimitiveCases {
@Test
public void testPrim() {
Util.withBools(new Do<Boolean>() {
@Override
public void apply(final Boolean b) { | final Injector injector = Guice.createInjector(new MultiModule(b, PrimCombined.class)); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.