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 |
|---|---|---|---|---|---|---|
philipperemy/Leboncoin | src/mail/processing/CleanDeletingAdEmail.java | // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
| import javax.mail.Flags.Flag;
import javax.mail.Message;
import javax.mail.internet.InternetAddress;
import log.Logger;
| package mail.processing;
public class CleanDeletingAdEmail implements MessageProcess
{
@Override
public void treatMessage(Message message) throws Exception
{
String sender = InternetAddress.toString(message.getFrom());
String subject = message.getSubject();
if (sender.contains("leboncoin.fr") && subject.contains("Suppression de votre annonce"))
{
| // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
// Path: src/mail/processing/CleanDeletingAdEmail.java
import javax.mail.Flags.Flag;
import javax.mail.Message;
import javax.mail.internet.InternetAddress;
import log.Logger;
package mail.processing;
public class CleanDeletingAdEmail implements MessageProcess
{
@Override
public void treatMessage(Message message) throws Exception
{
String sender = InternetAddress.toString(message.getFrom());
String subject = message.getSubject();
if (sender.contains("leboncoin.fr") && subject.contains("Suppression de votre annonce"))
{
| Logger.traceINFO("Received : " + subject);
|
philipperemy/Leboncoin | src/utils/StringUtils.java | // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
| import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import log.Logger;
| {
Matcher matcher = Pattern.compile("-{0,1}\\d+\\.{0,1}\\d{0,}").matcher(str);
if (!matcher.find())
{
throw new NumberFormatException("For input string [" + str + "]");
}
String matchStr = matcher.group();
matchStr = matchStr.replaceAll("\\.", "");
return Integer.parseInt(matchStr);
}
public static String md5(String input)
{
String md5 = null;
if (input == null)
{
return null;
}
try
{
MessageDigest digest = MessageDigest.getInstance("MD5");
digest.update(input.getBytes(), 0, input.length());
md5 = new BigInteger(1, digest.digest()).toString(16);
}
catch (NoSuchAlgorithmException e)
{
| // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
// Path: src/utils/StringUtils.java
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import log.Logger;
{
Matcher matcher = Pattern.compile("-{0,1}\\d+\\.{0,1}\\d{0,}").matcher(str);
if (!matcher.find())
{
throw new NumberFormatException("For input string [" + str + "]");
}
String matchStr = matcher.group();
matchStr = matchStr.replaceAll("\\.", "");
return Integer.parseInt(matchStr);
}
public static String md5(String input)
{
String md5 = null;
if (input == null)
{
return null;
}
try
{
MessageDigest digest = MessageDigest.getInstance("MD5");
digest.update(input.getBytes(), 0, input.length());
md5 = new BigInteger(1, digest.digest()).toString(16);
}
catch (NoSuchAlgorithmException e)
{
| Logger.traceERROR(e);
|
philipperemy/Leboncoin | src/persistence/Persistence.java | // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
//
// Path: src/run/main/App.java
// public class App
// {
// public static void main(String[] args)
// {
// start();
// stop();
// }
//
// public static void start()
// {
// new DeleteAdMailCleaner().run();
// new AdRetrieveID().run();
// new AdPublisher().run();
// new AdRepublisher().run();
// new MonitoringTask().run();
// }
//
// public static void stop()
// {
// Logger.endLogging();
// }
//
// public static void restart()
// {
// Client.reset();
// start();
// }
//
// public static void kill()
// {
// kill(null);
// }
//
// public static void kill(Exception e)
// {
// Logger.traceERROR(e);
// Logger.traceERROR("Killing the app...");
// System.exit(-1);
// }
// }
//
// Path: src/utils/NameFactory.java
// public class NameFactory
// {
// public static final String REGION_TAG_NAME = "region";
// public static final String DEPARTMENT_TAG_NAME = "dpt_code";
// public static final String CODE_POSTAL_TAG_NAME = "zipcode";
// public static final String CATEGORY_TAG_NAME = "category";
// public static final String NAME_TAG_NAME = "name";
// public static final String EMAIL_TAG_NAME = "email";
// public static final String PHONE_TAG_NAME = "phone";
// public static final String SUBJECT_TAG_NAME = "subject";
// public static final String BODY_TAG_NAME = "body";
// public static final String PRICE_TAG_NAME = "price";
// public static final String IMAGE_0 = "image0";
// public static final String SUBMIT_BUTTON = "validate";
//
// public static final String WINE_CATEGORY_ID = "48";
//
// public static final int ORIG_YEAR = 2016;
//
// public static final String CONF_PATH_FILE = "conf/conf.csv";
// public static final String PERSISTENCE_CSV = "conf/persistence.csv";
// }
| import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import log.Logger;
import run.main.App;
import utils.NameFactory;
import au.com.bytecode.opencsv.CSVReader;
import au.com.bytecode.opencsv.CSVWriter;
| package persistence;
public final class Persistence
{
// 0 : hash
// 1 : web id
private static Persistence persistence = new Persistence();
public static Persistence getInstance()
{
return persistence;
}
private Persistence()
{
}
public List<PersistedObject> getPersistedObjects()
{
List<PersistedObject> persistedObjects = new ArrayList<>();
try
{
| // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
//
// Path: src/run/main/App.java
// public class App
// {
// public static void main(String[] args)
// {
// start();
// stop();
// }
//
// public static void start()
// {
// new DeleteAdMailCleaner().run();
// new AdRetrieveID().run();
// new AdPublisher().run();
// new AdRepublisher().run();
// new MonitoringTask().run();
// }
//
// public static void stop()
// {
// Logger.endLogging();
// }
//
// public static void restart()
// {
// Client.reset();
// start();
// }
//
// public static void kill()
// {
// kill(null);
// }
//
// public static void kill(Exception e)
// {
// Logger.traceERROR(e);
// Logger.traceERROR("Killing the app...");
// System.exit(-1);
// }
// }
//
// Path: src/utils/NameFactory.java
// public class NameFactory
// {
// public static final String REGION_TAG_NAME = "region";
// public static final String DEPARTMENT_TAG_NAME = "dpt_code";
// public static final String CODE_POSTAL_TAG_NAME = "zipcode";
// public static final String CATEGORY_TAG_NAME = "category";
// public static final String NAME_TAG_NAME = "name";
// public static final String EMAIL_TAG_NAME = "email";
// public static final String PHONE_TAG_NAME = "phone";
// public static final String SUBJECT_TAG_NAME = "subject";
// public static final String BODY_TAG_NAME = "body";
// public static final String PRICE_TAG_NAME = "price";
// public static final String IMAGE_0 = "image0";
// public static final String SUBMIT_BUTTON = "validate";
//
// public static final String WINE_CATEGORY_ID = "48";
//
// public static final int ORIG_YEAR = 2016;
//
// public static final String CONF_PATH_FILE = "conf/conf.csv";
// public static final String PERSISTENCE_CSV = "conf/persistence.csv";
// }
// Path: src/persistence/Persistence.java
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import log.Logger;
import run.main.App;
import utils.NameFactory;
import au.com.bytecode.opencsv.CSVReader;
import au.com.bytecode.opencsv.CSVWriter;
package persistence;
public final class Persistence
{
// 0 : hash
// 1 : web id
private static Persistence persistence = new Persistence();
public static Persistence getInstance()
{
return persistence;
}
private Persistence()
{
}
public List<PersistedObject> getPersistedObjects()
{
List<PersistedObject> persistedObjects = new ArrayList<>();
try
{
| CSVReader reader = new CSVReader(new FileReader(NameFactory.PERSISTENCE_CSV));
|
philipperemy/Leboncoin | src/utils/FormatConsoleTable.java | // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
| import java.util.ArrayList;
import java.util.List;
import log.Logger;
| package utils;
public class FormatConsoleTable
{
private List<Row> rows = new ArrayList<>();
private class Row
{
String adTitle;
String adPrice;
String status;
public Row(String adTitle, String adPrice, String status)
{
this.adTitle = adTitle;
this.adPrice = adPrice;
this.status = status;
}
}
public void print(String adTitle, String adPrice, String status)
{
rows.add(new Row(adTitle, adPrice, status));
}
public void flush()
{
String formatString = "| %55s | %9s | %18s |";
// Mind that all rows have the same sizes.
for (int i = 0; i < rows.size(); i++)
{
Row row = rows.get(i);
String strOut = String.format(formatString, row.adTitle, row.adPrice, row.status);
// First or last row
if (i == 0)
{
| // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
// Path: src/utils/FormatConsoleTable.java
import java.util.ArrayList;
import java.util.List;
import log.Logger;
package utils;
public class FormatConsoleTable
{
private List<Row> rows = new ArrayList<>();
private class Row
{
String adTitle;
String adPrice;
String status;
public Row(String adTitle, String adPrice, String status)
{
this.adTitle = adTitle;
this.adPrice = adPrice;
this.status = status;
}
}
public void print(String adTitle, String adPrice, String status)
{
rows.add(new Row(adTitle, adPrice, status));
}
public void flush()
{
String formatString = "| %55s | %9s | %18s |";
// Mind that all rows have the same sizes.
for (int i = 0; i < rows.size(); i++)
{
Row row = rows.get(i);
String strOut = String.format(formatString, row.adTitle, row.adPrice, row.status);
// First or last row
if (i == 0)
{
| Logger.traceINFO(org.apache.commons.lang3.StringUtils.repeat("_", strOut.length()));
|
philipperemy/Leboncoin | src/connectivity/Client.java | // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
| import java.io.FileNotFoundException;
import java.io.PrintStream;
import log.Logger;
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.WebClient; | package connectivity;
public class Client
{
private static volatile WebClient webClient;
public synchronized static WebClient get() throws FileNotFoundException
{
if (webClient == null)
{ | // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
// Path: src/connectivity/Client.java
import java.io.FileNotFoundException;
import java.io.PrintStream;
import log.Logger;
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.WebClient;
package connectivity;
public class Client
{
private static volatile WebClient webClient;
public synchronized static WebClient get() throws FileNotFoundException
{
if (webClient == null)
{ | Logger.traceINFO_NoNewLine("Initialization of the client..."); |
philipperemy/Leboncoin | src/persistence/PersistedObject.java | // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
//
// Path: src/run/main/App.java
// public class App
// {
// public static void main(String[] args)
// {
// start();
// stop();
// }
//
// public static void start()
// {
// new DeleteAdMailCleaner().run();
// new AdRetrieveID().run();
// new AdPublisher().run();
// new AdRepublisher().run();
// new MonitoringTask().run();
// }
//
// public static void stop()
// {
// Logger.endLogging();
// }
//
// public static void restart()
// {
// Client.reset();
// start();
// }
//
// public static void kill()
// {
// kill(null);
// }
//
// public static void kill(Exception e)
// {
// Logger.traceERROR(e);
// Logger.traceERROR("Killing the app...");
// System.exit(-1);
// }
// }
| import log.Logger;
import run.main.App;
| package persistence;
public class PersistedObject
{
@Override
public String toString()
{
return "PersistedObject [" + (id != null ? "id=" + id + ", " : "") + (hash != null ? "hash=" + hash : "") + "]";
}
public PersistedObject()
{
}
public PersistedObject(String id, String hash)
{
super();
this.id = id;
if (hash.length() != 32 && hash.length() != 31)
{
| // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
//
// Path: src/run/main/App.java
// public class App
// {
// public static void main(String[] args)
// {
// start();
// stop();
// }
//
// public static void start()
// {
// new DeleteAdMailCleaner().run();
// new AdRetrieveID().run();
// new AdPublisher().run();
// new AdRepublisher().run();
// new MonitoringTask().run();
// }
//
// public static void stop()
// {
// Logger.endLogging();
// }
//
// public static void restart()
// {
// Client.reset();
// start();
// }
//
// public static void kill()
// {
// kill(null);
// }
//
// public static void kill(Exception e)
// {
// Logger.traceERROR(e);
// Logger.traceERROR("Killing the app...");
// System.exit(-1);
// }
// }
// Path: src/persistence/PersistedObject.java
import log.Logger;
import run.main.App;
package persistence;
public class PersistedObject
{
@Override
public String toString()
{
return "PersistedObject [" + (id != null ? "id=" + id + ", " : "") + (hash != null ? "hash=" + hash : "") + "]";
}
public PersistedObject()
{
}
public PersistedObject(String id, String hash)
{
super();
this.id = id;
if (hash.length() != 32 && hash.length() != 31)
{
| Logger.traceERROR("This is not a correct hash : " + hash + ".");
|
philipperemy/Leboncoin | src/persistence/PersistedObject.java | // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
//
// Path: src/run/main/App.java
// public class App
// {
// public static void main(String[] args)
// {
// start();
// stop();
// }
//
// public static void start()
// {
// new DeleteAdMailCleaner().run();
// new AdRetrieveID().run();
// new AdPublisher().run();
// new AdRepublisher().run();
// new MonitoringTask().run();
// }
//
// public static void stop()
// {
// Logger.endLogging();
// }
//
// public static void restart()
// {
// Client.reset();
// start();
// }
//
// public static void kill()
// {
// kill(null);
// }
//
// public static void kill(Exception e)
// {
// Logger.traceERROR(e);
// Logger.traceERROR("Killing the app...");
// System.exit(-1);
// }
// }
| import log.Logger;
import run.main.App;
| package persistence;
public class PersistedObject
{
@Override
public String toString()
{
return "PersistedObject [" + (id != null ? "id=" + id + ", " : "") + (hash != null ? "hash=" + hash : "") + "]";
}
public PersistedObject()
{
}
public PersistedObject(String id, String hash)
{
super();
this.id = id;
if (hash.length() != 32 && hash.length() != 31)
{
Logger.traceERROR("This is not a correct hash : " + hash + ".");
| // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
//
// Path: src/run/main/App.java
// public class App
// {
// public static void main(String[] args)
// {
// start();
// stop();
// }
//
// public static void start()
// {
// new DeleteAdMailCleaner().run();
// new AdRetrieveID().run();
// new AdPublisher().run();
// new AdRepublisher().run();
// new MonitoringTask().run();
// }
//
// public static void stop()
// {
// Logger.endLogging();
// }
//
// public static void restart()
// {
// Client.reset();
// start();
// }
//
// public static void kill()
// {
// kill(null);
// }
//
// public static void kill(Exception e)
// {
// Logger.traceERROR(e);
// Logger.traceERROR("Killing the app...");
// System.exit(-1);
// }
// }
// Path: src/persistence/PersistedObject.java
import log.Logger;
import run.main.App;
package persistence;
public class PersistedObject
{
@Override
public String toString()
{
return "PersistedObject [" + (id != null ? "id=" + id + ", " : "") + (hash != null ? "hash=" + hash : "") + "]";
}
public PersistedObject()
{
}
public PersistedObject(String id, String hash)
{
super();
this.id = id;
if (hash.length() != 32 && hash.length() != 31)
{
Logger.traceERROR("This is not a correct hash : " + hash + ".");
| App.kill();
|
philipperemy/Leboncoin | src/mail/MailManager.java | // Path: src/conf/DefaultUserConf.java
// public class DefaultUserConf
// {
// public static final String NAME = "";
// public static final String EMAIL = "";
// public static final String PHONE_NUMBER = "";
// public static final String PASSWORD = "";
// }
//
// Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
//
// Path: src/mail/processing/MessageProcess.java
// public interface MessageProcess
// {
// void treatMessage(Message message) throws Exception;
// }
| import java.util.Properties;
import javax.mail.Flags;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.search.FlagTerm;
import conf.DefaultUserConf;
import log.Logger;
import mail.processing.MessageProcess;
| package mail;
public class MailManager {
public synchronized static boolean doAction(MessageProcess f) {
return doActionGmail(f, 0);
}
static int MAX_ATTEMPS = 10;
public synchronized static boolean doActionGmail(MessageProcess f,
int attempts) {
try {
Properties props = System.getProperties();
props.setProperty("mail.smtp.host", "smtp.gmail.com");
props.setProperty("mail.smtp.socketFactory.port", "465");
props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.setProperty("mail.smtp.auth", "true");
props.setProperty("mail.smtp.port", "465");
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
| // Path: src/conf/DefaultUserConf.java
// public class DefaultUserConf
// {
// public static final String NAME = "";
// public static final String EMAIL = "";
// public static final String PHONE_NUMBER = "";
// public static final String PASSWORD = "";
// }
//
// Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
//
// Path: src/mail/processing/MessageProcess.java
// public interface MessageProcess
// {
// void treatMessage(Message message) throws Exception;
// }
// Path: src/mail/MailManager.java
import java.util.Properties;
import javax.mail.Flags;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.search.FlagTerm;
import conf.DefaultUserConf;
import log.Logger;
import mail.processing.MessageProcess;
package mail;
public class MailManager {
public synchronized static boolean doAction(MessageProcess f) {
return doActionGmail(f, 0);
}
static int MAX_ATTEMPS = 10;
public synchronized static boolean doActionGmail(MessageProcess f,
int attempts) {
try {
Properties props = System.getProperties();
props.setProperty("mail.smtp.host", "smtp.gmail.com");
props.setProperty("mail.smtp.socketFactory.port", "465");
props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.setProperty("mail.smtp.auth", "true");
props.setProperty("mail.smtp.port", "465");
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
| store.connect("smtp.gmail.com", DefaultUserConf.EMAIL,
|
philipperemy/Leboncoin | src/mail/MailManager.java | // Path: src/conf/DefaultUserConf.java
// public class DefaultUserConf
// {
// public static final String NAME = "";
// public static final String EMAIL = "";
// public static final String PHONE_NUMBER = "";
// public static final String PASSWORD = "";
// }
//
// Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
//
// Path: src/mail/processing/MessageProcess.java
// public interface MessageProcess
// {
// void treatMessage(Message message) throws Exception;
// }
| import java.util.Properties;
import javax.mail.Flags;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.search.FlagTerm;
import conf.DefaultUserConf;
import log.Logger;
import mail.processing.MessageProcess;
| Properties props = System.getProperties();
props.setProperty("mail.smtp.host", "smtp.gmail.com");
props.setProperty("mail.smtp.socketFactory.port", "465");
props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.setProperty("mail.smtp.auth", "true");
props.setProperty("mail.smtp.port", "465");
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
store.connect("smtp.gmail.com", DefaultUserConf.EMAIL,
DefaultUserConf.PASSWORD);
Folder inbox = store.getFolder("Inbox");
inbox.open(Folder.READ_WRITE);
// Get directory
Flags seen = new Flags(Flags.Flag.SEEN);
FlagTerm unseenFlagTerm = new FlagTerm(seen, false);
Message messages[] = inbox.search(unseenFlagTerm);
for (int i = 0; i < messages.length; i++) {
f.treatMessage(messages[i]);
}
// Close connection
inbox.close(true);
store.close();
return true;
} catch (Exception e) {
| // Path: src/conf/DefaultUserConf.java
// public class DefaultUserConf
// {
// public static final String NAME = "";
// public static final String EMAIL = "";
// public static final String PHONE_NUMBER = "";
// public static final String PASSWORD = "";
// }
//
// Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
//
// Path: src/mail/processing/MessageProcess.java
// public interface MessageProcess
// {
// void treatMessage(Message message) throws Exception;
// }
// Path: src/mail/MailManager.java
import java.util.Properties;
import javax.mail.Flags;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.search.FlagTerm;
import conf.DefaultUserConf;
import log.Logger;
import mail.processing.MessageProcess;
Properties props = System.getProperties();
props.setProperty("mail.smtp.host", "smtp.gmail.com");
props.setProperty("mail.smtp.socketFactory.port", "465");
props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.setProperty("mail.smtp.auth", "true");
props.setProperty("mail.smtp.port", "465");
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
store.connect("smtp.gmail.com", DefaultUserConf.EMAIL,
DefaultUserConf.PASSWORD);
Folder inbox = store.getFolder("Inbox");
inbox.open(Folder.READ_WRITE);
// Get directory
Flags seen = new Flags(Flags.Flag.SEEN);
FlagTerm unseenFlagTerm = new FlagTerm(seen, false);
Message messages[] = inbox.search(unseenFlagTerm);
for (int i = 0; i < messages.length; i++) {
f.treatMessage(messages[i]);
}
// Close connection
inbox.close(true);
store.close();
return true;
} catch (Exception e) {
| Logger.traceERROR(e);
|
philipperemy/Leboncoin | src/recovery/Ad.java | // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
| import java.util.Date;
import log.Logger;
| package recovery;
public class Ad
{
@Override
public String toString()
{
| // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
// Path: src/recovery/Ad.java
import java.util.Date;
import log.Logger;
package recovery;
public class Ad
{
@Override
public String toString()
{
| return "Ad [" + (dateOfPost != null ? "dateOfPost=" + Logger.sdf.format(dateOfPost) + ", " : "") + (name != null ? "name=" + name : "") + "]";
|
philipperemy/Leboncoin | src/recovery/AdRetrievalCache.java | // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
| import java.util.HashMap;
import java.util.Map;
import log.Logger;
| package recovery;
public class AdRetrievalCache {
public Map<String, String> cacheById = new HashMap<>();
public String getById(String id)
{
String content = cacheById.get(id);
String status = (content == null) ? "MISS" : "HIT";
| // Path: src/log/Logger.java
// public class Logger
// {
// private static final String infoKey = "INFO";
// private static final String errorKey = "ERROR";
//
// private static final Printer out = new Printer();
//
// public static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//
// private static String getCallingClass()
// {
// final Throwable t = new Throwable();
// final StackTraceElement methodCaller = t.getStackTrace()[3];
// String filename = methodCaller.getFileName();
// return filename.substring(0, filename.lastIndexOf('.'));
// }
//
// private static String baseLogMessage(String key, String msg)
// {
// return sdf.format(new Date()) + " [" + key + "] [" + getCallingClass() + "] " + msg;
// }
//
// public static void traceINFO(String msg)
// {
// out.println(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoNewLine(String msg)
// {
// out.print(baseLogMessage(infoKey, msg));
// }
//
// public static void traceINFO_NoBaseLine(String msg)
// {
// out.println(msg);
// }
//
// public static void traceERROR(String msg)
// {
// out.println(baseLogMessage(errorKey, msg));
// }
//
// public static void traceINFO(int level, long[] array)
// {
// StringBuilder sBuilder = new StringBuilder();
// sBuilder.append(level + " : ");
// for (int i = 0; i < array.length; i++)
// {
// if (i == array.length - 1)
// {
//
// sBuilder.append(array[i]);
// }
// else
// {
// sBuilder.append(array[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceINFO(String... msgs)
// {
// StringBuilder sBuilder = new StringBuilder();
// for (int i = 0; i < msgs.length; i++)
// {
// if (i == msgs.length - 1)
// {
//
// sBuilder.append(msgs[i]);
// }
// else
// {
// sBuilder.append(msgs[i] + ", ");
// }
// }
// traceINFO(sBuilder.toString());
// }
//
// public static void traceERROR(Exception e)
// {
// if (e != null)
// {
// out.println(baseLogMessage(errorKey, e.getMessage()));
// e.printStackTrace(System.out);
// }
// }
//
// public static void endLogging()
// {
// out.close();
// }
// }
// Path: src/recovery/AdRetrievalCache.java
import java.util.HashMap;
import java.util.Map;
import log.Logger;
package recovery;
public class AdRetrievalCache {
public Map<String, String> cacheById = new HashMap<>();
public String getById(String id)
{
String content = cacheById.get(id);
String status = (content == null) ? "MISS" : "HIT";
| Logger.traceINFO("Query cache with id : " + id + ", status : " + status);
|
fluxroot/pulse | src/main/java/com/fluxchess/pulse/Perft.java | // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
| import static com.fluxchess.pulse.MoveList.MoveEntry;
import static com.fluxchess.pulse.model.Color.opposite;
import static java.lang.System.currentTimeMillis;
import static java.util.concurrent.TimeUnit.*; |
System.out.format("Testing %s at depth %d%n", Notation.fromPosition(position), depth);
long startTime = currentTimeMillis();
long result = miniMax(depth, position, 0);
long endTime = currentTimeMillis();
long duration = endTime - startTime;
System.out.format(
"Nodes: %d%nDuration: %02d:%02d:%02d.%03d%n",
result,
MILLISECONDS.toHours(duration),
MILLISECONDS.toMinutes(duration) - HOURS.toMinutes(MILLISECONDS.toHours(duration)),
MILLISECONDS.toSeconds(duration) - MINUTES.toSeconds(MILLISECONDS.toMinutes(duration)),
duration - SECONDS.toMillis(MILLISECONDS.toSeconds(duration))
);
System.out.format("n/ms: %d%n", result / duration);
}
private long miniMax(int depth, Position position, int ply) {
if (depth == 0) {
return 1;
}
int totalNodes = 0;
boolean isCheck = position.isCheck();
MoveGenerator moveGenerator = moveGenerators[ply]; | // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
// Path: src/main/java/com/fluxchess/pulse/Perft.java
import static com.fluxchess.pulse.MoveList.MoveEntry;
import static com.fluxchess.pulse.model.Color.opposite;
import static java.lang.System.currentTimeMillis;
import static java.util.concurrent.TimeUnit.*;
System.out.format("Testing %s at depth %d%n", Notation.fromPosition(position), depth);
long startTime = currentTimeMillis();
long result = miniMax(depth, position, 0);
long endTime = currentTimeMillis();
long duration = endTime - startTime;
System.out.format(
"Nodes: %d%nDuration: %02d:%02d:%02d.%03d%n",
result,
MILLISECONDS.toHours(duration),
MILLISECONDS.toMinutes(duration) - HOURS.toMinutes(MILLISECONDS.toHours(duration)),
MILLISECONDS.toSeconds(duration) - MINUTES.toSeconds(MILLISECONDS.toMinutes(duration)),
duration - SECONDS.toMillis(MILLISECONDS.toSeconds(duration))
);
System.out.format("n/ms: %d%n", result / duration);
}
private long miniMax(int depth, Position position, int ply) {
if (depth == 0) {
return 1;
}
int totalNodes = 0;
boolean isCheck = position.isCheck();
MoveGenerator moveGenerator = moveGenerators[ply]; | MoveList<MoveEntry> moves = moveGenerator.getMoves(position, depth, isCheck); |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/Perft.java | // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
| import static com.fluxchess.pulse.MoveList.MoveEntry;
import static com.fluxchess.pulse.model.Color.opposite;
import static java.lang.System.currentTimeMillis;
import static java.util.concurrent.TimeUnit.*; | long endTime = currentTimeMillis();
long duration = endTime - startTime;
System.out.format(
"Nodes: %d%nDuration: %02d:%02d:%02d.%03d%n",
result,
MILLISECONDS.toHours(duration),
MILLISECONDS.toMinutes(duration) - HOURS.toMinutes(MILLISECONDS.toHours(duration)),
MILLISECONDS.toSeconds(duration) - MINUTES.toSeconds(MILLISECONDS.toMinutes(duration)),
duration - SECONDS.toMillis(MILLISECONDS.toSeconds(duration))
);
System.out.format("n/ms: %d%n", result / duration);
}
private long miniMax(int depth, Position position, int ply) {
if (depth == 0) {
return 1;
}
int totalNodes = 0;
boolean isCheck = position.isCheck();
MoveGenerator moveGenerator = moveGenerators[ply];
MoveList<MoveEntry> moves = moveGenerator.getMoves(position, depth, isCheck);
for (int i = 0; i < moves.size; i++) {
int move = moves.entries[i].move;
position.makeMove(move); | // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
// Path: src/main/java/com/fluxchess/pulse/Perft.java
import static com.fluxchess.pulse.MoveList.MoveEntry;
import static com.fluxchess.pulse.model.Color.opposite;
import static java.lang.System.currentTimeMillis;
import static java.util.concurrent.TimeUnit.*;
long endTime = currentTimeMillis();
long duration = endTime - startTime;
System.out.format(
"Nodes: %d%nDuration: %02d:%02d:%02d.%03d%n",
result,
MILLISECONDS.toHours(duration),
MILLISECONDS.toMinutes(duration) - HOURS.toMinutes(MILLISECONDS.toHours(duration)),
MILLISECONDS.toSeconds(duration) - MINUTES.toSeconds(MILLISECONDS.toMinutes(duration)),
duration - SECONDS.toMillis(MILLISECONDS.toSeconds(duration))
);
System.out.format("n/ms: %d%n", result / duration);
}
private long miniMax(int depth, Position position, int ply) {
if (depth == 0) {
return 1;
}
int totalNodes = 0;
boolean isCheck = position.isCheck();
MoveGenerator moveGenerator = moveGenerators[ply];
MoveList<MoveEntry> moves = moveGenerator.getMoves(position, depth, isCheck);
for (int i = 0; i < moves.size; i++) {
int move = moves.entries[i].move;
position.makeMove(move); | if (!position.isCheck(opposite(position.activeColor))) { |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/Protocol.java | // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// static final class RootEntry extends MoveEntry {
//
// final MoveVariation pv = new MoveVariation();
// }
| import static com.fluxchess.pulse.MoveList.RootEntry; | /*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse;
interface Protocol {
void sendBestMove(int bestMove, int ponderMove);
void sendStatus(int currentDepth, int currentMaxDepth, long totalNodes, int currentMove, int currentMoveNumber);
void sendStatus(boolean force, int currentDepth, int currentMaxDepth, long totalNodes, int currentMove, int currentMoveNumber);
| // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// static final class RootEntry extends MoveEntry {
//
// final MoveVariation pv = new MoveVariation();
// }
// Path: src/main/java/com/fluxchess/pulse/Protocol.java
import static com.fluxchess.pulse.MoveList.RootEntry;
/*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse;
interface Protocol {
void sendBestMove(int bestMove, int ponderMove);
void sendStatus(int currentDepth, int currentMaxDepth, long totalNodes, int currentMove, int currentMoveNumber);
void sendStatus(boolean force, int currentDepth, int currentMaxDepth, long totalNodes, int currentMove, int currentMoveNumber);
| void sendMove(RootEntry entry, int currentDepth, int currentMaxDepth, long totalNodes); |
fluxroot/pulse | src/test/java/com/fluxchess/pulse/model/PieceTypeTest.java | // Path: src/main/java/com/fluxchess/pulse/model/PieceType.java
// public final class PieceType {
//
// public static final int MASK = 0x7;
//
// public static final int PAWN = 0;
// public static final int KNIGHT = 1;
// public static final int BISHOP = 2;
// public static final int ROOK = 3;
// public static final int QUEEN = 4;
// public static final int KING = 5;
//
// public static final int NOPIECETYPE = 6;
//
// public static final int[] values = {
// PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING
// };
//
// // Piece values as defined by Larry Kaufman
// public static final int PAWN_VALUE = 100;
// public static final int KNIGHT_VALUE = 325;
// public static final int BISHOP_VALUE = 325;
// public static final int ROOK_VALUE = 500;
// public static final int QUEEN_VALUE = 975;
// public static final int KING_VALUE = 20000;
//
// private PieceType() {
// }
//
// public static boolean isValidPromotion(int piecetype) {
// switch (piecetype) {
// case KNIGHT:
// case BISHOP:
// case ROOK:
// case QUEEN:
// return true;
// default:
// return false;
// }
// }
//
// public static boolean isSliding(int piecetype) {
// switch (piecetype) {
// case BISHOP:
// case ROOK:
// case QUEEN:
// return true;
// case PAWN:
// case KNIGHT:
// case KING:
// return false;
// default:
// throw new IllegalArgumentException();
// }
// }
//
// public static int getValue(int piecetype) {
// switch (piecetype) {
// case PAWN:
// return PAWN_VALUE;
// case KNIGHT:
// return KNIGHT_VALUE;
// case BISHOP:
// return BISHOP_VALUE;
// case ROOK:
// return ROOK_VALUE;
// case QUEEN:
// return QUEEN_VALUE;
// case KING:
// return KING_VALUE;
// default:
// throw new IllegalArgumentException();
// }
// }
// }
| import org.junit.jupiter.api.Test;
import static com.fluxchess.pulse.model.PieceType.*;
import static org.assertj.core.api.Assertions.assertThat; | /*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
class PieceTypeTest {
@Test
void testValues() { | // Path: src/main/java/com/fluxchess/pulse/model/PieceType.java
// public final class PieceType {
//
// public static final int MASK = 0x7;
//
// public static final int PAWN = 0;
// public static final int KNIGHT = 1;
// public static final int BISHOP = 2;
// public static final int ROOK = 3;
// public static final int QUEEN = 4;
// public static final int KING = 5;
//
// public static final int NOPIECETYPE = 6;
//
// public static final int[] values = {
// PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING
// };
//
// // Piece values as defined by Larry Kaufman
// public static final int PAWN_VALUE = 100;
// public static final int KNIGHT_VALUE = 325;
// public static final int BISHOP_VALUE = 325;
// public static final int ROOK_VALUE = 500;
// public static final int QUEEN_VALUE = 975;
// public static final int KING_VALUE = 20000;
//
// private PieceType() {
// }
//
// public static boolean isValidPromotion(int piecetype) {
// switch (piecetype) {
// case KNIGHT:
// case BISHOP:
// case ROOK:
// case QUEEN:
// return true;
// default:
// return false;
// }
// }
//
// public static boolean isSliding(int piecetype) {
// switch (piecetype) {
// case BISHOP:
// case ROOK:
// case QUEEN:
// return true;
// case PAWN:
// case KNIGHT:
// case KING:
// return false;
// default:
// throw new IllegalArgumentException();
// }
// }
//
// public static int getValue(int piecetype) {
// switch (piecetype) {
// case PAWN:
// return PAWN_VALUE;
// case KNIGHT:
// return KNIGHT_VALUE;
// case BISHOP:
// return BISHOP_VALUE;
// case ROOK:
// return ROOK_VALUE;
// case QUEEN:
// return QUEEN_VALUE;
// case KING:
// return KING_VALUE;
// default:
// throw new IllegalArgumentException();
// }
// }
// }
// Path: src/test/java/com/fluxchess/pulse/model/PieceTypeTest.java
import org.junit.jupiter.api.Test;
import static com.fluxchess.pulse.model.PieceType.*;
import static org.assertj.core.api.Assertions.assertThat;
/*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
class PieceTypeTest {
@Test
void testValues() { | for (int piecetype : PieceType.values) { |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/model/Piece.java | // Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int BLACK = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/PieceType.java
// public final class PieceType {
//
// public static final int MASK = 0x7;
//
// public static final int PAWN = 0;
// public static final int KNIGHT = 1;
// public static final int BISHOP = 2;
// public static final int ROOK = 3;
// public static final int QUEEN = 4;
// public static final int KING = 5;
//
// public static final int NOPIECETYPE = 6;
//
// public static final int[] values = {
// PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING
// };
//
// // Piece values as defined by Larry Kaufman
// public static final int PAWN_VALUE = 100;
// public static final int KNIGHT_VALUE = 325;
// public static final int BISHOP_VALUE = 325;
// public static final int ROOK_VALUE = 500;
// public static final int QUEEN_VALUE = 975;
// public static final int KING_VALUE = 20000;
//
// private PieceType() {
// }
//
// public static boolean isValidPromotion(int piecetype) {
// switch (piecetype) {
// case KNIGHT:
// case BISHOP:
// case ROOK:
// case QUEEN:
// return true;
// default:
// return false;
// }
// }
//
// public static boolean isSliding(int piecetype) {
// switch (piecetype) {
// case BISHOP:
// case ROOK:
// case QUEEN:
// return true;
// case PAWN:
// case KNIGHT:
// case KING:
// return false;
// default:
// throw new IllegalArgumentException();
// }
// }
//
// public static int getValue(int piecetype) {
// switch (piecetype) {
// case PAWN:
// return PAWN_VALUE;
// case KNIGHT:
// return KNIGHT_VALUE;
// case BISHOP:
// return BISHOP_VALUE;
// case ROOK:
// return ROOK_VALUE;
// case QUEEN:
// return QUEEN_VALUE;
// case KING:
// return KING_VALUE;
// default:
// throw new IllegalArgumentException();
// }
// }
// }
| import static com.fluxchess.pulse.model.Color.BLACK;
import static com.fluxchess.pulse.model.Color.WHITE;
import static com.fluxchess.pulse.model.PieceType.*; | public static final int[] values = {
WHITE_PAWN, WHITE_KNIGHT, WHITE_BISHOP, WHITE_ROOK, WHITE_QUEEN, WHITE_KING,
BLACK_PAWN, BLACK_KNIGHT, BLACK_BISHOP, BLACK_ROOK, BLACK_QUEEN, BLACK_KING
};
private Piece() {
}
public static boolean isValid(int piece) {
switch (piece) {
case WHITE_PAWN:
case WHITE_KNIGHT:
case WHITE_BISHOP:
case WHITE_ROOK:
case WHITE_QUEEN:
case WHITE_KING:
case BLACK_PAWN:
case BLACK_KNIGHT:
case BLACK_BISHOP:
case BLACK_ROOK:
case BLACK_QUEEN:
case BLACK_KING:
return true;
default:
return false;
}
}
public static int valueOf(int color, int piecetype) {
switch (color) { | // Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int BLACK = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/PieceType.java
// public final class PieceType {
//
// public static final int MASK = 0x7;
//
// public static final int PAWN = 0;
// public static final int KNIGHT = 1;
// public static final int BISHOP = 2;
// public static final int ROOK = 3;
// public static final int QUEEN = 4;
// public static final int KING = 5;
//
// public static final int NOPIECETYPE = 6;
//
// public static final int[] values = {
// PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING
// };
//
// // Piece values as defined by Larry Kaufman
// public static final int PAWN_VALUE = 100;
// public static final int KNIGHT_VALUE = 325;
// public static final int BISHOP_VALUE = 325;
// public static final int ROOK_VALUE = 500;
// public static final int QUEEN_VALUE = 975;
// public static final int KING_VALUE = 20000;
//
// private PieceType() {
// }
//
// public static boolean isValidPromotion(int piecetype) {
// switch (piecetype) {
// case KNIGHT:
// case BISHOP:
// case ROOK:
// case QUEEN:
// return true;
// default:
// return false;
// }
// }
//
// public static boolean isSliding(int piecetype) {
// switch (piecetype) {
// case BISHOP:
// case ROOK:
// case QUEEN:
// return true;
// case PAWN:
// case KNIGHT:
// case KING:
// return false;
// default:
// throw new IllegalArgumentException();
// }
// }
//
// public static int getValue(int piecetype) {
// switch (piecetype) {
// case PAWN:
// return PAWN_VALUE;
// case KNIGHT:
// return KNIGHT_VALUE;
// case BISHOP:
// return BISHOP_VALUE;
// case ROOK:
// return ROOK_VALUE;
// case QUEEN:
// return QUEEN_VALUE;
// case KING:
// return KING_VALUE;
// default:
// throw new IllegalArgumentException();
// }
// }
// }
// Path: src/main/java/com/fluxchess/pulse/model/Piece.java
import static com.fluxchess.pulse.model.Color.BLACK;
import static com.fluxchess.pulse.model.Color.WHITE;
import static com.fluxchess.pulse.model.PieceType.*;
public static final int[] values = {
WHITE_PAWN, WHITE_KNIGHT, WHITE_BISHOP, WHITE_ROOK, WHITE_QUEEN, WHITE_KING,
BLACK_PAWN, BLACK_KNIGHT, BLACK_BISHOP, BLACK_ROOK, BLACK_QUEEN, BLACK_KING
};
private Piece() {
}
public static boolean isValid(int piece) {
switch (piece) {
case WHITE_PAWN:
case WHITE_KNIGHT:
case WHITE_BISHOP:
case WHITE_ROOK:
case WHITE_QUEEN:
case WHITE_KING:
case BLACK_PAWN:
case BLACK_KNIGHT:
case BLACK_BISHOP:
case BLACK_ROOK:
case BLACK_QUEEN:
case BLACK_KING:
return true;
default:
return false;
}
}
public static int valueOf(int color, int piecetype) {
switch (color) { | case WHITE: |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/model/Piece.java | // Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int BLACK = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/PieceType.java
// public final class PieceType {
//
// public static final int MASK = 0x7;
//
// public static final int PAWN = 0;
// public static final int KNIGHT = 1;
// public static final int BISHOP = 2;
// public static final int ROOK = 3;
// public static final int QUEEN = 4;
// public static final int KING = 5;
//
// public static final int NOPIECETYPE = 6;
//
// public static final int[] values = {
// PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING
// };
//
// // Piece values as defined by Larry Kaufman
// public static final int PAWN_VALUE = 100;
// public static final int KNIGHT_VALUE = 325;
// public static final int BISHOP_VALUE = 325;
// public static final int ROOK_VALUE = 500;
// public static final int QUEEN_VALUE = 975;
// public static final int KING_VALUE = 20000;
//
// private PieceType() {
// }
//
// public static boolean isValidPromotion(int piecetype) {
// switch (piecetype) {
// case KNIGHT:
// case BISHOP:
// case ROOK:
// case QUEEN:
// return true;
// default:
// return false;
// }
// }
//
// public static boolean isSliding(int piecetype) {
// switch (piecetype) {
// case BISHOP:
// case ROOK:
// case QUEEN:
// return true;
// case PAWN:
// case KNIGHT:
// case KING:
// return false;
// default:
// throw new IllegalArgumentException();
// }
// }
//
// public static int getValue(int piecetype) {
// switch (piecetype) {
// case PAWN:
// return PAWN_VALUE;
// case KNIGHT:
// return KNIGHT_VALUE;
// case BISHOP:
// return BISHOP_VALUE;
// case ROOK:
// return ROOK_VALUE;
// case QUEEN:
// return QUEEN_VALUE;
// case KING:
// return KING_VALUE;
// default:
// throw new IllegalArgumentException();
// }
// }
// }
| import static com.fluxchess.pulse.model.Color.BLACK;
import static com.fluxchess.pulse.model.Color.WHITE;
import static com.fluxchess.pulse.model.PieceType.*; | case BLACK_KNIGHT:
case BLACK_BISHOP:
case BLACK_ROOK:
case BLACK_QUEEN:
case BLACK_KING:
return true;
default:
return false;
}
}
public static int valueOf(int color, int piecetype) {
switch (color) {
case WHITE:
switch (piecetype) {
case PAWN:
return WHITE_PAWN;
case KNIGHT:
return WHITE_KNIGHT;
case BISHOP:
return WHITE_BISHOP;
case ROOK:
return WHITE_ROOK;
case QUEEN:
return WHITE_QUEEN;
case KING:
return WHITE_KING;
default:
throw new IllegalArgumentException();
} | // Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int BLACK = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/PieceType.java
// public final class PieceType {
//
// public static final int MASK = 0x7;
//
// public static final int PAWN = 0;
// public static final int KNIGHT = 1;
// public static final int BISHOP = 2;
// public static final int ROOK = 3;
// public static final int QUEEN = 4;
// public static final int KING = 5;
//
// public static final int NOPIECETYPE = 6;
//
// public static final int[] values = {
// PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING
// };
//
// // Piece values as defined by Larry Kaufman
// public static final int PAWN_VALUE = 100;
// public static final int KNIGHT_VALUE = 325;
// public static final int BISHOP_VALUE = 325;
// public static final int ROOK_VALUE = 500;
// public static final int QUEEN_VALUE = 975;
// public static final int KING_VALUE = 20000;
//
// private PieceType() {
// }
//
// public static boolean isValidPromotion(int piecetype) {
// switch (piecetype) {
// case KNIGHT:
// case BISHOP:
// case ROOK:
// case QUEEN:
// return true;
// default:
// return false;
// }
// }
//
// public static boolean isSliding(int piecetype) {
// switch (piecetype) {
// case BISHOP:
// case ROOK:
// case QUEEN:
// return true;
// case PAWN:
// case KNIGHT:
// case KING:
// return false;
// default:
// throw new IllegalArgumentException();
// }
// }
//
// public static int getValue(int piecetype) {
// switch (piecetype) {
// case PAWN:
// return PAWN_VALUE;
// case KNIGHT:
// return KNIGHT_VALUE;
// case BISHOP:
// return BISHOP_VALUE;
// case ROOK:
// return ROOK_VALUE;
// case QUEEN:
// return QUEEN_VALUE;
// case KING:
// return KING_VALUE;
// default:
// throw new IllegalArgumentException();
// }
// }
// }
// Path: src/main/java/com/fluxchess/pulse/model/Piece.java
import static com.fluxchess.pulse.model.Color.BLACK;
import static com.fluxchess.pulse.model.Color.WHITE;
import static com.fluxchess.pulse.model.PieceType.*;
case BLACK_KNIGHT:
case BLACK_BISHOP:
case BLACK_ROOK:
case BLACK_QUEEN:
case BLACK_KING:
return true;
default:
return false;
}
}
public static int valueOf(int color, int piecetype) {
switch (color) {
case WHITE:
switch (piecetype) {
case PAWN:
return WHITE_PAWN;
case KNIGHT:
return WHITE_KNIGHT;
case BISHOP:
return WHITE_BISHOP;
case ROOK:
return WHITE_ROOK;
case QUEEN:
return WHITE_QUEEN;
case KING:
return WHITE_KING;
default:
throw new IllegalArgumentException();
} | case BLACK: |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/model/Value.java | // Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_PLY = 256;
| import static com.fluxchess.pulse.model.Depth.MAX_PLY;
import static java.lang.Math.abs; | /*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
public final class Value {
public static final int INFINITE = 200000;
public static final int CHECKMATE = 100000; | // Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_PLY = 256;
// Path: src/main/java/com/fluxchess/pulse/model/Value.java
import static com.fluxchess.pulse.model.Depth.MAX_PLY;
import static java.lang.Math.abs;
/*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
public final class Value {
public static final int INFINITE = 200000;
public static final int CHECKMATE = 100000; | public static final int CHECKMATE_THRESHOLD = CHECKMATE - MAX_PLY; |
fluxroot/pulse | src/test/java/com/fluxchess/pulse/BitboardTest.java | // Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public final class Square {
//
// public static final int MASK = 0x7F;
//
// public static final int a1 = 0, a2 = 16;
// public static final int b1 = 1, b2 = 17;
// public static final int c1 = 2, c2 = 18;
// public static final int d1 = 3, d2 = 19;
// public static final int e1 = 4, e2 = 20;
// public static final int f1 = 5, f2 = 21;
// public static final int g1 = 6, g2 = 22;
// public static final int h1 = 7, h2 = 23;
//
// public static final int a3 = 32, a4 = 48;
// public static final int b3 = 33, b4 = 49;
// public static final int c3 = 34, c4 = 50;
// public static final int d3 = 35, d4 = 51;
// public static final int e3 = 36, e4 = 52;
// public static final int f3 = 37, f4 = 53;
// public static final int g3 = 38, g4 = 54;
// public static final int h3 = 39, h4 = 55;
//
// public static final int a5 = 64, a6 = 80;
// public static final int b5 = 65, b6 = 81;
// public static final int c5 = 66, c6 = 82;
// public static final int d5 = 67, d6 = 83;
// public static final int e5 = 68, e6 = 84;
// public static final int f5 = 69, f6 = 85;
// public static final int g5 = 70, g6 = 86;
// public static final int h5 = 71, h6 = 87;
//
// public static final int a7 = 96, a8 = 112;
// public static final int b7 = 97, b8 = 113;
// public static final int c7 = 98, c8 = 114;
// public static final int d7 = 99, d8 = 115;
// public static final int e7 = 100, e8 = 116;
// public static final int f7 = 101, f8 = 117;
// public static final int g7 = 102, g8 = 118;
// public static final int h7 = 103, h8 = 119;
//
// public static final int NOSQUARE = 127;
//
// public static final int VALUES_LENGTH = 128;
// public static final int[] values = {
// a1, b1, c1, d1, e1, f1, g1, h1,
// a2, b2, c2, d2, e2, f2, g2, h2,
// a3, b3, c3, d3, e3, f3, g3, h3,
// a4, b4, c4, d4, e4, f4, g4, h4,
// a5, b5, c5, d5, e5, f5, g5, h5,
// a6, b6, c6, d6, e6, f6, g6, h6,
// a7, b7, c7, d7, e7, f7, g7, h7,
// a8, b8, c8, d8, e8, f8, g8, h8
// };
//
// // These are our move directions
// // N = north, E = east, S = south, W = west
// public static final int N = 16;
// public static final int E = 1;
// public static final int S = -16;
// public static final int W = -1;
// public static final int NE = N + E;
// public static final int SE = S + E;
// public static final int SW = S + W;
// public static final int NW = N + W;
//
// public static final int[][] pawnDirections = {
// {N, NE, NW}, // Color.WHITE
// {S, SE, SW} // Color.BLACK
// };
// public static final int[] knightDirections = {
// N + N + E,
// N + N + W,
// N + E + E,
// N + W + W,
// S + S + E,
// S + S + W,
// S + E + E,
// S + W + W
// };
// public static final int[] bishopDirections = {
// NE, NW, SE, SW
// };
// public static final int[] rookDirections = {
// N, E, S, W
// };
// public static final int[] queenDirections = {
// N, E, S, W,
// NE, NW, SE, SW
// };
// public static final int[] kingDirections = {
// N, E, S, W,
// NE, NW, SE, SW
// };
//
// private Square() {
// }
//
// public static boolean isValid(int square) {
// return (square & 0x88) == 0;
// }
//
// public static int valueOf(int file, int rank) {
// return (rank << 4) + file;
// }
//
// public static int getFile(int square) {
// return square & 0xF;
// }
//
// public static int getRank(int square) {
// return square >>> 4;
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/Bitboard.java
// static long add(int square, long bitboard) {
// return bitboard | 1L << toBitSquare(square);
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public static final int a5 = 64, a6 = 80;
| import com.fluxchess.pulse.model.Square;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.LinkedList;
import java.util.Random;
import static com.fluxchess.pulse.Bitboard.add;
import static com.fluxchess.pulse.model.Square.a6;
import static org.assertj.core.api.Assertions.assertThat; | /*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse;
class BitboardTest {
private LinkedList<Integer> pool = null;
@BeforeEach
void setUp() {
Random random = new Random();
pool = new LinkedList<>();
while (pool.size() < Long.SIZE) {
int value = random.nextInt(Long.SIZE); | // Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public final class Square {
//
// public static final int MASK = 0x7F;
//
// public static final int a1 = 0, a2 = 16;
// public static final int b1 = 1, b2 = 17;
// public static final int c1 = 2, c2 = 18;
// public static final int d1 = 3, d2 = 19;
// public static final int e1 = 4, e2 = 20;
// public static final int f1 = 5, f2 = 21;
// public static final int g1 = 6, g2 = 22;
// public static final int h1 = 7, h2 = 23;
//
// public static final int a3 = 32, a4 = 48;
// public static final int b3 = 33, b4 = 49;
// public static final int c3 = 34, c4 = 50;
// public static final int d3 = 35, d4 = 51;
// public static final int e3 = 36, e4 = 52;
// public static final int f3 = 37, f4 = 53;
// public static final int g3 = 38, g4 = 54;
// public static final int h3 = 39, h4 = 55;
//
// public static final int a5 = 64, a6 = 80;
// public static final int b5 = 65, b6 = 81;
// public static final int c5 = 66, c6 = 82;
// public static final int d5 = 67, d6 = 83;
// public static final int e5 = 68, e6 = 84;
// public static final int f5 = 69, f6 = 85;
// public static final int g5 = 70, g6 = 86;
// public static final int h5 = 71, h6 = 87;
//
// public static final int a7 = 96, a8 = 112;
// public static final int b7 = 97, b8 = 113;
// public static final int c7 = 98, c8 = 114;
// public static final int d7 = 99, d8 = 115;
// public static final int e7 = 100, e8 = 116;
// public static final int f7 = 101, f8 = 117;
// public static final int g7 = 102, g8 = 118;
// public static final int h7 = 103, h8 = 119;
//
// public static final int NOSQUARE = 127;
//
// public static final int VALUES_LENGTH = 128;
// public static final int[] values = {
// a1, b1, c1, d1, e1, f1, g1, h1,
// a2, b2, c2, d2, e2, f2, g2, h2,
// a3, b3, c3, d3, e3, f3, g3, h3,
// a4, b4, c4, d4, e4, f4, g4, h4,
// a5, b5, c5, d5, e5, f5, g5, h5,
// a6, b6, c6, d6, e6, f6, g6, h6,
// a7, b7, c7, d7, e7, f7, g7, h7,
// a8, b8, c8, d8, e8, f8, g8, h8
// };
//
// // These are our move directions
// // N = north, E = east, S = south, W = west
// public static final int N = 16;
// public static final int E = 1;
// public static final int S = -16;
// public static final int W = -1;
// public static final int NE = N + E;
// public static final int SE = S + E;
// public static final int SW = S + W;
// public static final int NW = N + W;
//
// public static final int[][] pawnDirections = {
// {N, NE, NW}, // Color.WHITE
// {S, SE, SW} // Color.BLACK
// };
// public static final int[] knightDirections = {
// N + N + E,
// N + N + W,
// N + E + E,
// N + W + W,
// S + S + E,
// S + S + W,
// S + E + E,
// S + W + W
// };
// public static final int[] bishopDirections = {
// NE, NW, SE, SW
// };
// public static final int[] rookDirections = {
// N, E, S, W
// };
// public static final int[] queenDirections = {
// N, E, S, W,
// NE, NW, SE, SW
// };
// public static final int[] kingDirections = {
// N, E, S, W,
// NE, NW, SE, SW
// };
//
// private Square() {
// }
//
// public static boolean isValid(int square) {
// return (square & 0x88) == 0;
// }
//
// public static int valueOf(int file, int rank) {
// return (rank << 4) + file;
// }
//
// public static int getFile(int square) {
// return square & 0xF;
// }
//
// public static int getRank(int square) {
// return square >>> 4;
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/Bitboard.java
// static long add(int square, long bitboard) {
// return bitboard | 1L << toBitSquare(square);
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public static final int a5 = 64, a6 = 80;
// Path: src/test/java/com/fluxchess/pulse/BitboardTest.java
import com.fluxchess.pulse.model.Square;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.LinkedList;
import java.util.Random;
import static com.fluxchess.pulse.Bitboard.add;
import static com.fluxchess.pulse.model.Square.a6;
import static org.assertj.core.api.Assertions.assertThat;
/*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse;
class BitboardTest {
private LinkedList<Integer> pool = null;
@BeforeEach
void setUp() {
Random random = new Random();
pool = new LinkedList<>();
while (pool.size() < Long.SIZE) {
int value = random.nextInt(Long.SIZE); | if (!pool.contains(Square.values[value])) { |
fluxroot/pulse | src/test/java/com/fluxchess/pulse/BitboardTest.java | // Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public final class Square {
//
// public static final int MASK = 0x7F;
//
// public static final int a1 = 0, a2 = 16;
// public static final int b1 = 1, b2 = 17;
// public static final int c1 = 2, c2 = 18;
// public static final int d1 = 3, d2 = 19;
// public static final int e1 = 4, e2 = 20;
// public static final int f1 = 5, f2 = 21;
// public static final int g1 = 6, g2 = 22;
// public static final int h1 = 7, h2 = 23;
//
// public static final int a3 = 32, a4 = 48;
// public static final int b3 = 33, b4 = 49;
// public static final int c3 = 34, c4 = 50;
// public static final int d3 = 35, d4 = 51;
// public static final int e3 = 36, e4 = 52;
// public static final int f3 = 37, f4 = 53;
// public static final int g3 = 38, g4 = 54;
// public static final int h3 = 39, h4 = 55;
//
// public static final int a5 = 64, a6 = 80;
// public static final int b5 = 65, b6 = 81;
// public static final int c5 = 66, c6 = 82;
// public static final int d5 = 67, d6 = 83;
// public static final int e5 = 68, e6 = 84;
// public static final int f5 = 69, f6 = 85;
// public static final int g5 = 70, g6 = 86;
// public static final int h5 = 71, h6 = 87;
//
// public static final int a7 = 96, a8 = 112;
// public static final int b7 = 97, b8 = 113;
// public static final int c7 = 98, c8 = 114;
// public static final int d7 = 99, d8 = 115;
// public static final int e7 = 100, e8 = 116;
// public static final int f7 = 101, f8 = 117;
// public static final int g7 = 102, g8 = 118;
// public static final int h7 = 103, h8 = 119;
//
// public static final int NOSQUARE = 127;
//
// public static final int VALUES_LENGTH = 128;
// public static final int[] values = {
// a1, b1, c1, d1, e1, f1, g1, h1,
// a2, b2, c2, d2, e2, f2, g2, h2,
// a3, b3, c3, d3, e3, f3, g3, h3,
// a4, b4, c4, d4, e4, f4, g4, h4,
// a5, b5, c5, d5, e5, f5, g5, h5,
// a6, b6, c6, d6, e6, f6, g6, h6,
// a7, b7, c7, d7, e7, f7, g7, h7,
// a8, b8, c8, d8, e8, f8, g8, h8
// };
//
// // These are our move directions
// // N = north, E = east, S = south, W = west
// public static final int N = 16;
// public static final int E = 1;
// public static final int S = -16;
// public static final int W = -1;
// public static final int NE = N + E;
// public static final int SE = S + E;
// public static final int SW = S + W;
// public static final int NW = N + W;
//
// public static final int[][] pawnDirections = {
// {N, NE, NW}, // Color.WHITE
// {S, SE, SW} // Color.BLACK
// };
// public static final int[] knightDirections = {
// N + N + E,
// N + N + W,
// N + E + E,
// N + W + W,
// S + S + E,
// S + S + W,
// S + E + E,
// S + W + W
// };
// public static final int[] bishopDirections = {
// NE, NW, SE, SW
// };
// public static final int[] rookDirections = {
// N, E, S, W
// };
// public static final int[] queenDirections = {
// N, E, S, W,
// NE, NW, SE, SW
// };
// public static final int[] kingDirections = {
// N, E, S, W,
// NE, NW, SE, SW
// };
//
// private Square() {
// }
//
// public static boolean isValid(int square) {
// return (square & 0x88) == 0;
// }
//
// public static int valueOf(int file, int rank) {
// return (rank << 4) + file;
// }
//
// public static int getFile(int square) {
// return square & 0xF;
// }
//
// public static int getRank(int square) {
// return square >>> 4;
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/Bitboard.java
// static long add(int square, long bitboard) {
// return bitboard | 1L << toBitSquare(square);
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public static final int a5 = 64, a6 = 80;
| import com.fluxchess.pulse.model.Square;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.LinkedList;
import java.util.Random;
import static com.fluxchess.pulse.Bitboard.add;
import static com.fluxchess.pulse.model.Square.a6;
import static org.assertj.core.api.Assertions.assertThat; | /*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse;
class BitboardTest {
private LinkedList<Integer> pool = null;
@BeforeEach
void setUp() {
Random random = new Random();
pool = new LinkedList<>();
while (pool.size() < Long.SIZE) {
int value = random.nextInt(Long.SIZE);
if (!pool.contains(Square.values[value])) { | // Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public final class Square {
//
// public static final int MASK = 0x7F;
//
// public static final int a1 = 0, a2 = 16;
// public static final int b1 = 1, b2 = 17;
// public static final int c1 = 2, c2 = 18;
// public static final int d1 = 3, d2 = 19;
// public static final int e1 = 4, e2 = 20;
// public static final int f1 = 5, f2 = 21;
// public static final int g1 = 6, g2 = 22;
// public static final int h1 = 7, h2 = 23;
//
// public static final int a3 = 32, a4 = 48;
// public static final int b3 = 33, b4 = 49;
// public static final int c3 = 34, c4 = 50;
// public static final int d3 = 35, d4 = 51;
// public static final int e3 = 36, e4 = 52;
// public static final int f3 = 37, f4 = 53;
// public static final int g3 = 38, g4 = 54;
// public static final int h3 = 39, h4 = 55;
//
// public static final int a5 = 64, a6 = 80;
// public static final int b5 = 65, b6 = 81;
// public static final int c5 = 66, c6 = 82;
// public static final int d5 = 67, d6 = 83;
// public static final int e5 = 68, e6 = 84;
// public static final int f5 = 69, f6 = 85;
// public static final int g5 = 70, g6 = 86;
// public static final int h5 = 71, h6 = 87;
//
// public static final int a7 = 96, a8 = 112;
// public static final int b7 = 97, b8 = 113;
// public static final int c7 = 98, c8 = 114;
// public static final int d7 = 99, d8 = 115;
// public static final int e7 = 100, e8 = 116;
// public static final int f7 = 101, f8 = 117;
// public static final int g7 = 102, g8 = 118;
// public static final int h7 = 103, h8 = 119;
//
// public static final int NOSQUARE = 127;
//
// public static final int VALUES_LENGTH = 128;
// public static final int[] values = {
// a1, b1, c1, d1, e1, f1, g1, h1,
// a2, b2, c2, d2, e2, f2, g2, h2,
// a3, b3, c3, d3, e3, f3, g3, h3,
// a4, b4, c4, d4, e4, f4, g4, h4,
// a5, b5, c5, d5, e5, f5, g5, h5,
// a6, b6, c6, d6, e6, f6, g6, h6,
// a7, b7, c7, d7, e7, f7, g7, h7,
// a8, b8, c8, d8, e8, f8, g8, h8
// };
//
// // These are our move directions
// // N = north, E = east, S = south, W = west
// public static final int N = 16;
// public static final int E = 1;
// public static final int S = -16;
// public static final int W = -1;
// public static final int NE = N + E;
// public static final int SE = S + E;
// public static final int SW = S + W;
// public static final int NW = N + W;
//
// public static final int[][] pawnDirections = {
// {N, NE, NW}, // Color.WHITE
// {S, SE, SW} // Color.BLACK
// };
// public static final int[] knightDirections = {
// N + N + E,
// N + N + W,
// N + E + E,
// N + W + W,
// S + S + E,
// S + S + W,
// S + E + E,
// S + W + W
// };
// public static final int[] bishopDirections = {
// NE, NW, SE, SW
// };
// public static final int[] rookDirections = {
// N, E, S, W
// };
// public static final int[] queenDirections = {
// N, E, S, W,
// NE, NW, SE, SW
// };
// public static final int[] kingDirections = {
// N, E, S, W,
// NE, NW, SE, SW
// };
//
// private Square() {
// }
//
// public static boolean isValid(int square) {
// return (square & 0x88) == 0;
// }
//
// public static int valueOf(int file, int rank) {
// return (rank << 4) + file;
// }
//
// public static int getFile(int square) {
// return square & 0xF;
// }
//
// public static int getRank(int square) {
// return square >>> 4;
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/Bitboard.java
// static long add(int square, long bitboard) {
// return bitboard | 1L << toBitSquare(square);
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public static final int a5 = 64, a6 = 80;
// Path: src/test/java/com/fluxchess/pulse/BitboardTest.java
import com.fluxchess.pulse.model.Square;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.LinkedList;
import java.util.Random;
import static com.fluxchess.pulse.Bitboard.add;
import static com.fluxchess.pulse.model.Square.a6;
import static org.assertj.core.api.Assertions.assertThat;
/*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse;
class BitboardTest {
private LinkedList<Integer> pool = null;
@BeforeEach
void setUp() {
Random random = new Random();
pool = new LinkedList<>();
while (pool.size() < Long.SIZE) {
int value = random.nextInt(Long.SIZE);
if (!pool.contains(Square.values[value])) { | pool.add(Square.values[value]); |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/Search.java | // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// final class MoveList<T extends MoveList.MoveEntry> {
//
// private static final int MAX_MOVES = 256;
//
// final T[] entries;
// int size = 0;
//
// static final class MoveVariation {
//
// final int[] moves = new int[MAX_PLY];
// int size = 0;
// }
//
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
//
// static final class RootEntry extends MoveEntry {
//
// final MoveVariation pv = new MoveVariation();
// }
//
// MoveList(Class<T> clazz) {
// @SuppressWarnings("unchecked") final T[] entries = (T[]) Array.newInstance(clazz, MAX_MOVES);
// this.entries = entries;
// try {
// for (int i = 0; i < entries.length; i++) {
// entries[i] = clazz.getDeclaredConstructor().newInstance();
// }
// } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
// throw new IllegalStateException(e);
// }
// }
//
// /**
// * Sorts the move list using a stable insertion sort.
// */
// void sort() {
// for (int i = 1; i < size; i++) {
// T entry = entries[i];
//
// int j = i;
// while ((j > 0) && (entries[j - 1].value < entry.value)) {
// entries[j] = entries[j - 1];
// j--;
// }
//
// entries[j] = entry;
// }
// }
//
// /**
// * Rates the moves in the list according to "Most Valuable Victim - Least Valuable Aggressor".
// */
// void rateFromMVVLVA() {
// for (int i = 0; i < size; i++) {
// int move = entries[i].move;
// int value = 0;
//
// int piecetypeValue = PieceType.getValue(Piece.getType(Move.getOriginPiece(move)));
// value += KING_VALUE / piecetypeValue;
//
// int target = Move.getTargetPiece(move);
// if (Piece.isValid(target)) {
// value += 10 * PieceType.getValue(Piece.getType(target));
// }
//
// entries[i].value = value;
// }
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_DEPTH = 64;
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_PLY = 256;
//
// Path: src/main/java/com/fluxchess/pulse/model/Move.java
// public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT)
// | (NOSQUARE << ORIGIN_SQUARE_SHIFT)
// | (NOSQUARE << TARGET_SQUARE_SHIFT)
// | (NOPIECE << ORIGIN_PIECE_SHIFT)
// | (NOPIECE << TARGET_PIECE_SHIFT)
// | (NOPIECETYPE << PROMOTION_SHIFT);
//
// Path: src/main/java/com/fluxchess/pulse/model/Value.java
// public final class Value {
//
// public static final int INFINITE = 200000;
// public static final int CHECKMATE = 100000;
// public static final int CHECKMATE_THRESHOLD = CHECKMATE - MAX_PLY;
// public static final int DRAW = 0;
//
// public static final int NOVALUE = 300000;
//
// private Value() {
// }
//
// public static boolean isCheckmate(int value) {
// int absvalue = abs(value);
// return absvalue >= CHECKMATE_THRESHOLD && absvalue <= CHECKMATE;
// }
// }
| import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import static com.fluxchess.pulse.MoveList.*;
import static com.fluxchess.pulse.model.Color.WHITE;
import static com.fluxchess.pulse.model.Color.opposite;
import static com.fluxchess.pulse.model.Depth.MAX_DEPTH;
import static com.fluxchess.pulse.model.Depth.MAX_PLY;
import static com.fluxchess.pulse.model.Move.NOMOVE;
import static com.fluxchess.pulse.model.Value.*;
import static java.lang.Math.abs;
import static java.lang.Runtime.getRuntime;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS; | /*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse;
final class Search {
private final ExecutorService threadPool = newFixedThreadPool(getRuntime().availableProcessors());
private Optional<Future<?>> future = Optional.empty();
private volatile boolean abort;
private final Protocol protocol;
private Position position;
private final Evaluation evaluation = new Evaluation();
// We will store a MoveGenerator for each ply so we don't have to create them
// in search. (which is expensive) | // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// final class MoveList<T extends MoveList.MoveEntry> {
//
// private static final int MAX_MOVES = 256;
//
// final T[] entries;
// int size = 0;
//
// static final class MoveVariation {
//
// final int[] moves = new int[MAX_PLY];
// int size = 0;
// }
//
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
//
// static final class RootEntry extends MoveEntry {
//
// final MoveVariation pv = new MoveVariation();
// }
//
// MoveList(Class<T> clazz) {
// @SuppressWarnings("unchecked") final T[] entries = (T[]) Array.newInstance(clazz, MAX_MOVES);
// this.entries = entries;
// try {
// for (int i = 0; i < entries.length; i++) {
// entries[i] = clazz.getDeclaredConstructor().newInstance();
// }
// } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
// throw new IllegalStateException(e);
// }
// }
//
// /**
// * Sorts the move list using a stable insertion sort.
// */
// void sort() {
// for (int i = 1; i < size; i++) {
// T entry = entries[i];
//
// int j = i;
// while ((j > 0) && (entries[j - 1].value < entry.value)) {
// entries[j] = entries[j - 1];
// j--;
// }
//
// entries[j] = entry;
// }
// }
//
// /**
// * Rates the moves in the list according to "Most Valuable Victim - Least Valuable Aggressor".
// */
// void rateFromMVVLVA() {
// for (int i = 0; i < size; i++) {
// int move = entries[i].move;
// int value = 0;
//
// int piecetypeValue = PieceType.getValue(Piece.getType(Move.getOriginPiece(move)));
// value += KING_VALUE / piecetypeValue;
//
// int target = Move.getTargetPiece(move);
// if (Piece.isValid(target)) {
// value += 10 * PieceType.getValue(Piece.getType(target));
// }
//
// entries[i].value = value;
// }
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_DEPTH = 64;
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_PLY = 256;
//
// Path: src/main/java/com/fluxchess/pulse/model/Move.java
// public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT)
// | (NOSQUARE << ORIGIN_SQUARE_SHIFT)
// | (NOSQUARE << TARGET_SQUARE_SHIFT)
// | (NOPIECE << ORIGIN_PIECE_SHIFT)
// | (NOPIECE << TARGET_PIECE_SHIFT)
// | (NOPIECETYPE << PROMOTION_SHIFT);
//
// Path: src/main/java/com/fluxchess/pulse/model/Value.java
// public final class Value {
//
// public static final int INFINITE = 200000;
// public static final int CHECKMATE = 100000;
// public static final int CHECKMATE_THRESHOLD = CHECKMATE - MAX_PLY;
// public static final int DRAW = 0;
//
// public static final int NOVALUE = 300000;
//
// private Value() {
// }
//
// public static boolean isCheckmate(int value) {
// int absvalue = abs(value);
// return absvalue >= CHECKMATE_THRESHOLD && absvalue <= CHECKMATE;
// }
// }
// Path: src/main/java/com/fluxchess/pulse/Search.java
import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import static com.fluxchess.pulse.MoveList.*;
import static com.fluxchess.pulse.model.Color.WHITE;
import static com.fluxchess.pulse.model.Color.opposite;
import static com.fluxchess.pulse.model.Depth.MAX_DEPTH;
import static com.fluxchess.pulse.model.Depth.MAX_PLY;
import static com.fluxchess.pulse.model.Move.NOMOVE;
import static com.fluxchess.pulse.model.Value.*;
import static java.lang.Math.abs;
import static java.lang.Runtime.getRuntime;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS;
/*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse;
final class Search {
private final ExecutorService threadPool = newFixedThreadPool(getRuntime().availableProcessors());
private Optional<Future<?>> future = Optional.empty();
private volatile boolean abort;
private final Protocol protocol;
private Position position;
private final Evaluation evaluation = new Evaluation();
// We will store a MoveGenerator for each ply so we don't have to create them
// in search. (which is expensive) | private final MoveGenerator[] moveGenerators = new MoveGenerator[MAX_PLY]; |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/Search.java | // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// final class MoveList<T extends MoveList.MoveEntry> {
//
// private static final int MAX_MOVES = 256;
//
// final T[] entries;
// int size = 0;
//
// static final class MoveVariation {
//
// final int[] moves = new int[MAX_PLY];
// int size = 0;
// }
//
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
//
// static final class RootEntry extends MoveEntry {
//
// final MoveVariation pv = new MoveVariation();
// }
//
// MoveList(Class<T> clazz) {
// @SuppressWarnings("unchecked") final T[] entries = (T[]) Array.newInstance(clazz, MAX_MOVES);
// this.entries = entries;
// try {
// for (int i = 0; i < entries.length; i++) {
// entries[i] = clazz.getDeclaredConstructor().newInstance();
// }
// } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
// throw new IllegalStateException(e);
// }
// }
//
// /**
// * Sorts the move list using a stable insertion sort.
// */
// void sort() {
// for (int i = 1; i < size; i++) {
// T entry = entries[i];
//
// int j = i;
// while ((j > 0) && (entries[j - 1].value < entry.value)) {
// entries[j] = entries[j - 1];
// j--;
// }
//
// entries[j] = entry;
// }
// }
//
// /**
// * Rates the moves in the list according to "Most Valuable Victim - Least Valuable Aggressor".
// */
// void rateFromMVVLVA() {
// for (int i = 0; i < size; i++) {
// int move = entries[i].move;
// int value = 0;
//
// int piecetypeValue = PieceType.getValue(Piece.getType(Move.getOriginPiece(move)));
// value += KING_VALUE / piecetypeValue;
//
// int target = Move.getTargetPiece(move);
// if (Piece.isValid(target)) {
// value += 10 * PieceType.getValue(Piece.getType(target));
// }
//
// entries[i].value = value;
// }
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_DEPTH = 64;
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_PLY = 256;
//
// Path: src/main/java/com/fluxchess/pulse/model/Move.java
// public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT)
// | (NOSQUARE << ORIGIN_SQUARE_SHIFT)
// | (NOSQUARE << TARGET_SQUARE_SHIFT)
// | (NOPIECE << ORIGIN_PIECE_SHIFT)
// | (NOPIECE << TARGET_PIECE_SHIFT)
// | (NOPIECETYPE << PROMOTION_SHIFT);
//
// Path: src/main/java/com/fluxchess/pulse/model/Value.java
// public final class Value {
//
// public static final int INFINITE = 200000;
// public static final int CHECKMATE = 100000;
// public static final int CHECKMATE_THRESHOLD = CHECKMATE - MAX_PLY;
// public static final int DRAW = 0;
//
// public static final int NOVALUE = 300000;
//
// private Value() {
// }
//
// public static boolean isCheckmate(int value) {
// int absvalue = abs(value);
// return absvalue >= CHECKMATE_THRESHOLD && absvalue <= CHECKMATE;
// }
// }
| import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import static com.fluxchess.pulse.MoveList.*;
import static com.fluxchess.pulse.model.Color.WHITE;
import static com.fluxchess.pulse.model.Color.opposite;
import static com.fluxchess.pulse.model.Depth.MAX_DEPTH;
import static com.fluxchess.pulse.model.Depth.MAX_PLY;
import static com.fluxchess.pulse.model.Move.NOMOVE;
import static com.fluxchess.pulse.model.Value.*;
import static java.lang.Math.abs;
import static java.lang.Runtime.getRuntime;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS; | /*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse;
final class Search {
private final ExecutorService threadPool = newFixedThreadPool(getRuntime().availableProcessors());
private Optional<Future<?>> future = Optional.empty();
private volatile boolean abort;
private final Protocol protocol;
private Position position;
private final Evaluation evaluation = new Evaluation();
// We will store a MoveGenerator for each ply so we don't have to create them
// in search. (which is expensive)
private final MoveGenerator[] moveGenerators = new MoveGenerator[MAX_PLY];
// Depth search
private int searchDepth;
// Nodes search
private long searchNodes;
// Time & Clock & Ponder search
private long searchTime;
private Timer timer;
private boolean timerStopped;
private boolean doTimeManagement;
// Search parameters | // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// final class MoveList<T extends MoveList.MoveEntry> {
//
// private static final int MAX_MOVES = 256;
//
// final T[] entries;
// int size = 0;
//
// static final class MoveVariation {
//
// final int[] moves = new int[MAX_PLY];
// int size = 0;
// }
//
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
//
// static final class RootEntry extends MoveEntry {
//
// final MoveVariation pv = new MoveVariation();
// }
//
// MoveList(Class<T> clazz) {
// @SuppressWarnings("unchecked") final T[] entries = (T[]) Array.newInstance(clazz, MAX_MOVES);
// this.entries = entries;
// try {
// for (int i = 0; i < entries.length; i++) {
// entries[i] = clazz.getDeclaredConstructor().newInstance();
// }
// } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
// throw new IllegalStateException(e);
// }
// }
//
// /**
// * Sorts the move list using a stable insertion sort.
// */
// void sort() {
// for (int i = 1; i < size; i++) {
// T entry = entries[i];
//
// int j = i;
// while ((j > 0) && (entries[j - 1].value < entry.value)) {
// entries[j] = entries[j - 1];
// j--;
// }
//
// entries[j] = entry;
// }
// }
//
// /**
// * Rates the moves in the list according to "Most Valuable Victim - Least Valuable Aggressor".
// */
// void rateFromMVVLVA() {
// for (int i = 0; i < size; i++) {
// int move = entries[i].move;
// int value = 0;
//
// int piecetypeValue = PieceType.getValue(Piece.getType(Move.getOriginPiece(move)));
// value += KING_VALUE / piecetypeValue;
//
// int target = Move.getTargetPiece(move);
// if (Piece.isValid(target)) {
// value += 10 * PieceType.getValue(Piece.getType(target));
// }
//
// entries[i].value = value;
// }
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_DEPTH = 64;
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_PLY = 256;
//
// Path: src/main/java/com/fluxchess/pulse/model/Move.java
// public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT)
// | (NOSQUARE << ORIGIN_SQUARE_SHIFT)
// | (NOSQUARE << TARGET_SQUARE_SHIFT)
// | (NOPIECE << ORIGIN_PIECE_SHIFT)
// | (NOPIECE << TARGET_PIECE_SHIFT)
// | (NOPIECETYPE << PROMOTION_SHIFT);
//
// Path: src/main/java/com/fluxchess/pulse/model/Value.java
// public final class Value {
//
// public static final int INFINITE = 200000;
// public static final int CHECKMATE = 100000;
// public static final int CHECKMATE_THRESHOLD = CHECKMATE - MAX_PLY;
// public static final int DRAW = 0;
//
// public static final int NOVALUE = 300000;
//
// private Value() {
// }
//
// public static boolean isCheckmate(int value) {
// int absvalue = abs(value);
// return absvalue >= CHECKMATE_THRESHOLD && absvalue <= CHECKMATE;
// }
// }
// Path: src/main/java/com/fluxchess/pulse/Search.java
import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import static com.fluxchess.pulse.MoveList.*;
import static com.fluxchess.pulse.model.Color.WHITE;
import static com.fluxchess.pulse.model.Color.opposite;
import static com.fluxchess.pulse.model.Depth.MAX_DEPTH;
import static com.fluxchess.pulse.model.Depth.MAX_PLY;
import static com.fluxchess.pulse.model.Move.NOMOVE;
import static com.fluxchess.pulse.model.Value.*;
import static java.lang.Math.abs;
import static java.lang.Runtime.getRuntime;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS;
/*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse;
final class Search {
private final ExecutorService threadPool = newFixedThreadPool(getRuntime().availableProcessors());
private Optional<Future<?>> future = Optional.empty();
private volatile boolean abort;
private final Protocol protocol;
private Position position;
private final Evaluation evaluation = new Evaluation();
// We will store a MoveGenerator for each ply so we don't have to create them
// in search. (which is expensive)
private final MoveGenerator[] moveGenerators = new MoveGenerator[MAX_PLY];
// Depth search
private int searchDepth;
// Nodes search
private long searchNodes;
// Time & Clock & Ponder search
private long searchTime;
private Timer timer;
private boolean timerStopped;
private boolean doTimeManagement;
// Search parameters | private final MoveList<RootEntry> rootMoves = new MoveList<>(RootEntry.class); |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/Search.java | // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// final class MoveList<T extends MoveList.MoveEntry> {
//
// private static final int MAX_MOVES = 256;
//
// final T[] entries;
// int size = 0;
//
// static final class MoveVariation {
//
// final int[] moves = new int[MAX_PLY];
// int size = 0;
// }
//
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
//
// static final class RootEntry extends MoveEntry {
//
// final MoveVariation pv = new MoveVariation();
// }
//
// MoveList(Class<T> clazz) {
// @SuppressWarnings("unchecked") final T[] entries = (T[]) Array.newInstance(clazz, MAX_MOVES);
// this.entries = entries;
// try {
// for (int i = 0; i < entries.length; i++) {
// entries[i] = clazz.getDeclaredConstructor().newInstance();
// }
// } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
// throw new IllegalStateException(e);
// }
// }
//
// /**
// * Sorts the move list using a stable insertion sort.
// */
// void sort() {
// for (int i = 1; i < size; i++) {
// T entry = entries[i];
//
// int j = i;
// while ((j > 0) && (entries[j - 1].value < entry.value)) {
// entries[j] = entries[j - 1];
// j--;
// }
//
// entries[j] = entry;
// }
// }
//
// /**
// * Rates the moves in the list according to "Most Valuable Victim - Least Valuable Aggressor".
// */
// void rateFromMVVLVA() {
// for (int i = 0; i < size; i++) {
// int move = entries[i].move;
// int value = 0;
//
// int piecetypeValue = PieceType.getValue(Piece.getType(Move.getOriginPiece(move)));
// value += KING_VALUE / piecetypeValue;
//
// int target = Move.getTargetPiece(move);
// if (Piece.isValid(target)) {
// value += 10 * PieceType.getValue(Piece.getType(target));
// }
//
// entries[i].value = value;
// }
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_DEPTH = 64;
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_PLY = 256;
//
// Path: src/main/java/com/fluxchess/pulse/model/Move.java
// public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT)
// | (NOSQUARE << ORIGIN_SQUARE_SHIFT)
// | (NOSQUARE << TARGET_SQUARE_SHIFT)
// | (NOPIECE << ORIGIN_PIECE_SHIFT)
// | (NOPIECE << TARGET_PIECE_SHIFT)
// | (NOPIECETYPE << PROMOTION_SHIFT);
//
// Path: src/main/java/com/fluxchess/pulse/model/Value.java
// public final class Value {
//
// public static final int INFINITE = 200000;
// public static final int CHECKMATE = 100000;
// public static final int CHECKMATE_THRESHOLD = CHECKMATE - MAX_PLY;
// public static final int DRAW = 0;
//
// public static final int NOVALUE = 300000;
//
// private Value() {
// }
//
// public static boolean isCheckmate(int value) {
// int absvalue = abs(value);
// return absvalue >= CHECKMATE_THRESHOLD && absvalue <= CHECKMATE;
// }
// }
| import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import static com.fluxchess.pulse.MoveList.*;
import static com.fluxchess.pulse.model.Color.WHITE;
import static com.fluxchess.pulse.model.Color.opposite;
import static com.fluxchess.pulse.model.Depth.MAX_DEPTH;
import static com.fluxchess.pulse.model.Depth.MAX_PLY;
import static com.fluxchess.pulse.model.Move.NOMOVE;
import static com.fluxchess.pulse.model.Value.*;
import static java.lang.Math.abs;
import static java.lang.Runtime.getRuntime;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS; | reset();
this.position = position;
this.searchTime = searchTime;
this.timer = new Timer(true);
}
void newInfiniteSearch(Position position) {
reset();
this.position = position;
}
void newClockSearch(Position position,
long whiteTimeLeft, long whiteTimeIncrement, long blackTimeLeft, long blackTimeIncrement, int movesToGo) {
newPonderSearch(position,
whiteTimeLeft, whiteTimeIncrement, blackTimeLeft, blackTimeIncrement, movesToGo
);
this.timer = new Timer(true);
}
void newPonderSearch(Position position,
long whiteTimeLeft, long whiteTimeIncrement, long blackTimeLeft, long blackTimeIncrement, int movesToGo) {
reset();
this.position = position;
long timeLeft;
long timeIncrement; | // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// final class MoveList<T extends MoveList.MoveEntry> {
//
// private static final int MAX_MOVES = 256;
//
// final T[] entries;
// int size = 0;
//
// static final class MoveVariation {
//
// final int[] moves = new int[MAX_PLY];
// int size = 0;
// }
//
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
//
// static final class RootEntry extends MoveEntry {
//
// final MoveVariation pv = new MoveVariation();
// }
//
// MoveList(Class<T> clazz) {
// @SuppressWarnings("unchecked") final T[] entries = (T[]) Array.newInstance(clazz, MAX_MOVES);
// this.entries = entries;
// try {
// for (int i = 0; i < entries.length; i++) {
// entries[i] = clazz.getDeclaredConstructor().newInstance();
// }
// } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
// throw new IllegalStateException(e);
// }
// }
//
// /**
// * Sorts the move list using a stable insertion sort.
// */
// void sort() {
// for (int i = 1; i < size; i++) {
// T entry = entries[i];
//
// int j = i;
// while ((j > 0) && (entries[j - 1].value < entry.value)) {
// entries[j] = entries[j - 1];
// j--;
// }
//
// entries[j] = entry;
// }
// }
//
// /**
// * Rates the moves in the list according to "Most Valuable Victim - Least Valuable Aggressor".
// */
// void rateFromMVVLVA() {
// for (int i = 0; i < size; i++) {
// int move = entries[i].move;
// int value = 0;
//
// int piecetypeValue = PieceType.getValue(Piece.getType(Move.getOriginPiece(move)));
// value += KING_VALUE / piecetypeValue;
//
// int target = Move.getTargetPiece(move);
// if (Piece.isValid(target)) {
// value += 10 * PieceType.getValue(Piece.getType(target));
// }
//
// entries[i].value = value;
// }
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_DEPTH = 64;
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_PLY = 256;
//
// Path: src/main/java/com/fluxchess/pulse/model/Move.java
// public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT)
// | (NOSQUARE << ORIGIN_SQUARE_SHIFT)
// | (NOSQUARE << TARGET_SQUARE_SHIFT)
// | (NOPIECE << ORIGIN_PIECE_SHIFT)
// | (NOPIECE << TARGET_PIECE_SHIFT)
// | (NOPIECETYPE << PROMOTION_SHIFT);
//
// Path: src/main/java/com/fluxchess/pulse/model/Value.java
// public final class Value {
//
// public static final int INFINITE = 200000;
// public static final int CHECKMATE = 100000;
// public static final int CHECKMATE_THRESHOLD = CHECKMATE - MAX_PLY;
// public static final int DRAW = 0;
//
// public static final int NOVALUE = 300000;
//
// private Value() {
// }
//
// public static boolean isCheckmate(int value) {
// int absvalue = abs(value);
// return absvalue >= CHECKMATE_THRESHOLD && absvalue <= CHECKMATE;
// }
// }
// Path: src/main/java/com/fluxchess/pulse/Search.java
import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import static com.fluxchess.pulse.MoveList.*;
import static com.fluxchess.pulse.model.Color.WHITE;
import static com.fluxchess.pulse.model.Color.opposite;
import static com.fluxchess.pulse.model.Depth.MAX_DEPTH;
import static com.fluxchess.pulse.model.Depth.MAX_PLY;
import static com.fluxchess.pulse.model.Move.NOMOVE;
import static com.fluxchess.pulse.model.Value.*;
import static java.lang.Math.abs;
import static java.lang.Runtime.getRuntime;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS;
reset();
this.position = position;
this.searchTime = searchTime;
this.timer = new Timer(true);
}
void newInfiniteSearch(Position position) {
reset();
this.position = position;
}
void newClockSearch(Position position,
long whiteTimeLeft, long whiteTimeIncrement, long blackTimeLeft, long blackTimeIncrement, int movesToGo) {
newPonderSearch(position,
whiteTimeLeft, whiteTimeIncrement, blackTimeLeft, blackTimeIncrement, movesToGo
);
this.timer = new Timer(true);
}
void newPonderSearch(Position position,
long whiteTimeLeft, long whiteTimeIncrement, long blackTimeLeft, long blackTimeIncrement, int movesToGo) {
reset();
this.position = position;
long timeLeft;
long timeIncrement; | if (position.activeColor == WHITE) { |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/Search.java | // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// final class MoveList<T extends MoveList.MoveEntry> {
//
// private static final int MAX_MOVES = 256;
//
// final T[] entries;
// int size = 0;
//
// static final class MoveVariation {
//
// final int[] moves = new int[MAX_PLY];
// int size = 0;
// }
//
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
//
// static final class RootEntry extends MoveEntry {
//
// final MoveVariation pv = new MoveVariation();
// }
//
// MoveList(Class<T> clazz) {
// @SuppressWarnings("unchecked") final T[] entries = (T[]) Array.newInstance(clazz, MAX_MOVES);
// this.entries = entries;
// try {
// for (int i = 0; i < entries.length; i++) {
// entries[i] = clazz.getDeclaredConstructor().newInstance();
// }
// } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
// throw new IllegalStateException(e);
// }
// }
//
// /**
// * Sorts the move list using a stable insertion sort.
// */
// void sort() {
// for (int i = 1; i < size; i++) {
// T entry = entries[i];
//
// int j = i;
// while ((j > 0) && (entries[j - 1].value < entry.value)) {
// entries[j] = entries[j - 1];
// j--;
// }
//
// entries[j] = entry;
// }
// }
//
// /**
// * Rates the moves in the list according to "Most Valuable Victim - Least Valuable Aggressor".
// */
// void rateFromMVVLVA() {
// for (int i = 0; i < size; i++) {
// int move = entries[i].move;
// int value = 0;
//
// int piecetypeValue = PieceType.getValue(Piece.getType(Move.getOriginPiece(move)));
// value += KING_VALUE / piecetypeValue;
//
// int target = Move.getTargetPiece(move);
// if (Piece.isValid(target)) {
// value += 10 * PieceType.getValue(Piece.getType(target));
// }
//
// entries[i].value = value;
// }
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_DEPTH = 64;
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_PLY = 256;
//
// Path: src/main/java/com/fluxchess/pulse/model/Move.java
// public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT)
// | (NOSQUARE << ORIGIN_SQUARE_SHIFT)
// | (NOSQUARE << TARGET_SQUARE_SHIFT)
// | (NOPIECE << ORIGIN_PIECE_SHIFT)
// | (NOPIECE << TARGET_PIECE_SHIFT)
// | (NOPIECETYPE << PROMOTION_SHIFT);
//
// Path: src/main/java/com/fluxchess/pulse/model/Value.java
// public final class Value {
//
// public static final int INFINITE = 200000;
// public static final int CHECKMATE = 100000;
// public static final int CHECKMATE_THRESHOLD = CHECKMATE - MAX_PLY;
// public static final int DRAW = 0;
//
// public static final int NOVALUE = 300000;
//
// private Value() {
// }
//
// public static boolean isCheckmate(int value) {
// int absvalue = abs(value);
// return absvalue >= CHECKMATE_THRESHOLD && absvalue <= CHECKMATE;
// }
// }
| import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import static com.fluxchess.pulse.MoveList.*;
import static com.fluxchess.pulse.model.Color.WHITE;
import static com.fluxchess.pulse.model.Color.opposite;
import static com.fluxchess.pulse.model.Depth.MAX_DEPTH;
import static com.fluxchess.pulse.model.Depth.MAX_PLY;
import static com.fluxchess.pulse.model.Move.NOMOVE;
import static com.fluxchess.pulse.model.Value.*;
import static java.lang.Math.abs;
import static java.lang.Runtime.getRuntime;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS; | // We don't have enough time left. Search only for 1 millisecond, meaning
// get a result as fast as we can.
maxSearchTime = 1;
}
// Assume that we still have to do movesToGo number of moves. For every next
// move (movesToGo - 1) we will receive a time increment.
this.searchTime = (maxSearchTime + (movesToGo - 1) * timeIncrement) / movesToGo;
if (this.searchTime > maxSearchTime) {
this.searchTime = maxSearchTime;
}
this.doTimeManagement = true;
}
Search(Protocol protocol) {
this.protocol = protocol;
for (int i = 0; i < MAX_PLY; i++) {
moveGenerators[i] = new MoveGenerator();
}
for (int i = 0; i < pv.length; i++) {
pv[i] = new MoveVariation();
}
reset();
}
private void reset() { | // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// final class MoveList<T extends MoveList.MoveEntry> {
//
// private static final int MAX_MOVES = 256;
//
// final T[] entries;
// int size = 0;
//
// static final class MoveVariation {
//
// final int[] moves = new int[MAX_PLY];
// int size = 0;
// }
//
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
//
// static final class RootEntry extends MoveEntry {
//
// final MoveVariation pv = new MoveVariation();
// }
//
// MoveList(Class<T> clazz) {
// @SuppressWarnings("unchecked") final T[] entries = (T[]) Array.newInstance(clazz, MAX_MOVES);
// this.entries = entries;
// try {
// for (int i = 0; i < entries.length; i++) {
// entries[i] = clazz.getDeclaredConstructor().newInstance();
// }
// } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
// throw new IllegalStateException(e);
// }
// }
//
// /**
// * Sorts the move list using a stable insertion sort.
// */
// void sort() {
// for (int i = 1; i < size; i++) {
// T entry = entries[i];
//
// int j = i;
// while ((j > 0) && (entries[j - 1].value < entry.value)) {
// entries[j] = entries[j - 1];
// j--;
// }
//
// entries[j] = entry;
// }
// }
//
// /**
// * Rates the moves in the list according to "Most Valuable Victim - Least Valuable Aggressor".
// */
// void rateFromMVVLVA() {
// for (int i = 0; i < size; i++) {
// int move = entries[i].move;
// int value = 0;
//
// int piecetypeValue = PieceType.getValue(Piece.getType(Move.getOriginPiece(move)));
// value += KING_VALUE / piecetypeValue;
//
// int target = Move.getTargetPiece(move);
// if (Piece.isValid(target)) {
// value += 10 * PieceType.getValue(Piece.getType(target));
// }
//
// entries[i].value = value;
// }
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_DEPTH = 64;
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_PLY = 256;
//
// Path: src/main/java/com/fluxchess/pulse/model/Move.java
// public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT)
// | (NOSQUARE << ORIGIN_SQUARE_SHIFT)
// | (NOSQUARE << TARGET_SQUARE_SHIFT)
// | (NOPIECE << ORIGIN_PIECE_SHIFT)
// | (NOPIECE << TARGET_PIECE_SHIFT)
// | (NOPIECETYPE << PROMOTION_SHIFT);
//
// Path: src/main/java/com/fluxchess/pulse/model/Value.java
// public final class Value {
//
// public static final int INFINITE = 200000;
// public static final int CHECKMATE = 100000;
// public static final int CHECKMATE_THRESHOLD = CHECKMATE - MAX_PLY;
// public static final int DRAW = 0;
//
// public static final int NOVALUE = 300000;
//
// private Value() {
// }
//
// public static boolean isCheckmate(int value) {
// int absvalue = abs(value);
// return absvalue >= CHECKMATE_THRESHOLD && absvalue <= CHECKMATE;
// }
// }
// Path: src/main/java/com/fluxchess/pulse/Search.java
import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import static com.fluxchess.pulse.MoveList.*;
import static com.fluxchess.pulse.model.Color.WHITE;
import static com.fluxchess.pulse.model.Color.opposite;
import static com.fluxchess.pulse.model.Depth.MAX_DEPTH;
import static com.fluxchess.pulse.model.Depth.MAX_PLY;
import static com.fluxchess.pulse.model.Move.NOMOVE;
import static com.fluxchess.pulse.model.Value.*;
import static java.lang.Math.abs;
import static java.lang.Runtime.getRuntime;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS;
// We don't have enough time left. Search only for 1 millisecond, meaning
// get a result as fast as we can.
maxSearchTime = 1;
}
// Assume that we still have to do movesToGo number of moves. For every next
// move (movesToGo - 1) we will receive a time increment.
this.searchTime = (maxSearchTime + (movesToGo - 1) * timeIncrement) / movesToGo;
if (this.searchTime > maxSearchTime) {
this.searchTime = maxSearchTime;
}
this.doTimeManagement = true;
}
Search(Protocol protocol) {
this.protocol = protocol;
for (int i = 0; i < MAX_PLY; i++) {
moveGenerators[i] = new MoveGenerator();
}
for (int i = 0; i < pv.length; i++) {
pv[i] = new MoveVariation();
}
reset();
}
private void reset() { | searchDepth = MAX_DEPTH; |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/Search.java | // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// final class MoveList<T extends MoveList.MoveEntry> {
//
// private static final int MAX_MOVES = 256;
//
// final T[] entries;
// int size = 0;
//
// static final class MoveVariation {
//
// final int[] moves = new int[MAX_PLY];
// int size = 0;
// }
//
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
//
// static final class RootEntry extends MoveEntry {
//
// final MoveVariation pv = new MoveVariation();
// }
//
// MoveList(Class<T> clazz) {
// @SuppressWarnings("unchecked") final T[] entries = (T[]) Array.newInstance(clazz, MAX_MOVES);
// this.entries = entries;
// try {
// for (int i = 0; i < entries.length; i++) {
// entries[i] = clazz.getDeclaredConstructor().newInstance();
// }
// } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
// throw new IllegalStateException(e);
// }
// }
//
// /**
// * Sorts the move list using a stable insertion sort.
// */
// void sort() {
// for (int i = 1; i < size; i++) {
// T entry = entries[i];
//
// int j = i;
// while ((j > 0) && (entries[j - 1].value < entry.value)) {
// entries[j] = entries[j - 1];
// j--;
// }
//
// entries[j] = entry;
// }
// }
//
// /**
// * Rates the moves in the list according to "Most Valuable Victim - Least Valuable Aggressor".
// */
// void rateFromMVVLVA() {
// for (int i = 0; i < size; i++) {
// int move = entries[i].move;
// int value = 0;
//
// int piecetypeValue = PieceType.getValue(Piece.getType(Move.getOriginPiece(move)));
// value += KING_VALUE / piecetypeValue;
//
// int target = Move.getTargetPiece(move);
// if (Piece.isValid(target)) {
// value += 10 * PieceType.getValue(Piece.getType(target));
// }
//
// entries[i].value = value;
// }
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_DEPTH = 64;
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_PLY = 256;
//
// Path: src/main/java/com/fluxchess/pulse/model/Move.java
// public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT)
// | (NOSQUARE << ORIGIN_SQUARE_SHIFT)
// | (NOSQUARE << TARGET_SQUARE_SHIFT)
// | (NOPIECE << ORIGIN_PIECE_SHIFT)
// | (NOPIECE << TARGET_PIECE_SHIFT)
// | (NOPIECETYPE << PROMOTION_SHIFT);
//
// Path: src/main/java/com/fluxchess/pulse/model/Value.java
// public final class Value {
//
// public static final int INFINITE = 200000;
// public static final int CHECKMATE = 100000;
// public static final int CHECKMATE_THRESHOLD = CHECKMATE - MAX_PLY;
// public static final int DRAW = 0;
//
// public static final int NOVALUE = 300000;
//
// private Value() {
// }
//
// public static boolean isCheckmate(int value) {
// int absvalue = abs(value);
// return absvalue >= CHECKMATE_THRESHOLD && absvalue <= CHECKMATE;
// }
// }
| import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import static com.fluxchess.pulse.MoveList.*;
import static com.fluxchess.pulse.model.Color.WHITE;
import static com.fluxchess.pulse.model.Color.opposite;
import static com.fluxchess.pulse.model.Depth.MAX_DEPTH;
import static com.fluxchess.pulse.model.Depth.MAX_PLY;
import static com.fluxchess.pulse.model.Move.NOMOVE;
import static com.fluxchess.pulse.model.Value.*;
import static java.lang.Math.abs;
import static java.lang.Runtime.getRuntime;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS; |
this.doTimeManagement = true;
}
Search(Protocol protocol) {
this.protocol = protocol;
for (int i = 0; i < MAX_PLY; i++) {
moveGenerators[i] = new MoveGenerator();
}
for (int i = 0; i < pv.length; i++) {
pv[i] = new MoveVariation();
}
reset();
}
private void reset() {
searchDepth = MAX_DEPTH;
searchNodes = Long.MAX_VALUE;
searchTime = 0;
timer = null;
timerStopped = false;
doTimeManagement = false;
rootMoves.size = 0;
abort = false;
totalNodes = 0;
currentDepth = initialDepth;
currentMaxDepth = 0; | // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// final class MoveList<T extends MoveList.MoveEntry> {
//
// private static final int MAX_MOVES = 256;
//
// final T[] entries;
// int size = 0;
//
// static final class MoveVariation {
//
// final int[] moves = new int[MAX_PLY];
// int size = 0;
// }
//
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
//
// static final class RootEntry extends MoveEntry {
//
// final MoveVariation pv = new MoveVariation();
// }
//
// MoveList(Class<T> clazz) {
// @SuppressWarnings("unchecked") final T[] entries = (T[]) Array.newInstance(clazz, MAX_MOVES);
// this.entries = entries;
// try {
// for (int i = 0; i < entries.length; i++) {
// entries[i] = clazz.getDeclaredConstructor().newInstance();
// }
// } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
// throw new IllegalStateException(e);
// }
// }
//
// /**
// * Sorts the move list using a stable insertion sort.
// */
// void sort() {
// for (int i = 1; i < size; i++) {
// T entry = entries[i];
//
// int j = i;
// while ((j > 0) && (entries[j - 1].value < entry.value)) {
// entries[j] = entries[j - 1];
// j--;
// }
//
// entries[j] = entry;
// }
// }
//
// /**
// * Rates the moves in the list according to "Most Valuable Victim - Least Valuable Aggressor".
// */
// void rateFromMVVLVA() {
// for (int i = 0; i < size; i++) {
// int move = entries[i].move;
// int value = 0;
//
// int piecetypeValue = PieceType.getValue(Piece.getType(Move.getOriginPiece(move)));
// value += KING_VALUE / piecetypeValue;
//
// int target = Move.getTargetPiece(move);
// if (Piece.isValid(target)) {
// value += 10 * PieceType.getValue(Piece.getType(target));
// }
//
// entries[i].value = value;
// }
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_DEPTH = 64;
//
// Path: src/main/java/com/fluxchess/pulse/model/Depth.java
// public static final int MAX_PLY = 256;
//
// Path: src/main/java/com/fluxchess/pulse/model/Move.java
// public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT)
// | (NOSQUARE << ORIGIN_SQUARE_SHIFT)
// | (NOSQUARE << TARGET_SQUARE_SHIFT)
// | (NOPIECE << ORIGIN_PIECE_SHIFT)
// | (NOPIECE << TARGET_PIECE_SHIFT)
// | (NOPIECETYPE << PROMOTION_SHIFT);
//
// Path: src/main/java/com/fluxchess/pulse/model/Value.java
// public final class Value {
//
// public static final int INFINITE = 200000;
// public static final int CHECKMATE = 100000;
// public static final int CHECKMATE_THRESHOLD = CHECKMATE - MAX_PLY;
// public static final int DRAW = 0;
//
// public static final int NOVALUE = 300000;
//
// private Value() {
// }
//
// public static boolean isCheckmate(int value) {
// int absvalue = abs(value);
// return absvalue >= CHECKMATE_THRESHOLD && absvalue <= CHECKMATE;
// }
// }
// Path: src/main/java/com/fluxchess/pulse/Search.java
import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import static com.fluxchess.pulse.MoveList.*;
import static com.fluxchess.pulse.model.Color.WHITE;
import static com.fluxchess.pulse.model.Color.opposite;
import static com.fluxchess.pulse.model.Depth.MAX_DEPTH;
import static com.fluxchess.pulse.model.Depth.MAX_PLY;
import static com.fluxchess.pulse.model.Move.NOMOVE;
import static com.fluxchess.pulse.model.Value.*;
import static java.lang.Math.abs;
import static java.lang.Runtime.getRuntime;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS;
this.doTimeManagement = true;
}
Search(Protocol protocol) {
this.protocol = protocol;
for (int i = 0; i < MAX_PLY; i++) {
moveGenerators[i] = new MoveGenerator();
}
for (int i = 0; i < pv.length; i++) {
pv[i] = new MoveVariation();
}
reset();
}
private void reset() {
searchDepth = MAX_DEPTH;
searchNodes = Long.MAX_VALUE;
searchTime = 0;
timer = null;
timerStopped = false;
doTimeManagement = false;
rootMoves.size = 0;
abort = false;
totalNodes = 0;
currentDepth = initialDepth;
currentMaxDepth = 0; | currentMove = NOMOVE; |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/model/Castling.java | // Path: src/main/java/com/fluxchess/pulse/model/CastlingType.java
// public static final int KINGSIDE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/CastlingType.java
// public static final int QUEENSIDE = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int BLACK = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
| import static com.fluxchess.pulse.model.CastlingType.KINGSIDE;
import static com.fluxchess.pulse.model.CastlingType.QUEENSIDE;
import static com.fluxchess.pulse.model.Color.BLACK;
import static com.fluxchess.pulse.model.Color.WHITE; | /*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
public final class Castling {
public static final int WHITE_KINGSIDE = 1; // 1 << 0
public static final int WHITE_QUEENSIDE = 1 << 1;
public static final int BLACK_KINGSIDE = 1 << 2;
public static final int BLACK_QUEENSIDE = 1 << 3;
public static final int NOCASTLING = 0;
public static final int VALUES_LENGTH = 16;
private Castling() {
}
public static int valueOf(int color, int castlingtype) {
switch (color) { | // Path: src/main/java/com/fluxchess/pulse/model/CastlingType.java
// public static final int KINGSIDE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/CastlingType.java
// public static final int QUEENSIDE = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int BLACK = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
// Path: src/main/java/com/fluxchess/pulse/model/Castling.java
import static com.fluxchess.pulse.model.CastlingType.KINGSIDE;
import static com.fluxchess.pulse.model.CastlingType.QUEENSIDE;
import static com.fluxchess.pulse.model.Color.BLACK;
import static com.fluxchess.pulse.model.Color.WHITE;
/*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
public final class Castling {
public static final int WHITE_KINGSIDE = 1; // 1 << 0
public static final int WHITE_QUEENSIDE = 1 << 1;
public static final int BLACK_KINGSIDE = 1 << 2;
public static final int BLACK_QUEENSIDE = 1 << 3;
public static final int NOCASTLING = 0;
public static final int VALUES_LENGTH = 16;
private Castling() {
}
public static int valueOf(int color, int castlingtype) {
switch (color) { | case WHITE: |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/model/Castling.java | // Path: src/main/java/com/fluxchess/pulse/model/CastlingType.java
// public static final int KINGSIDE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/CastlingType.java
// public static final int QUEENSIDE = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int BLACK = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
| import static com.fluxchess.pulse.model.CastlingType.KINGSIDE;
import static com.fluxchess.pulse.model.CastlingType.QUEENSIDE;
import static com.fluxchess.pulse.model.Color.BLACK;
import static com.fluxchess.pulse.model.Color.WHITE; | /*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
public final class Castling {
public static final int WHITE_KINGSIDE = 1; // 1 << 0
public static final int WHITE_QUEENSIDE = 1 << 1;
public static final int BLACK_KINGSIDE = 1 << 2;
public static final int BLACK_QUEENSIDE = 1 << 3;
public static final int NOCASTLING = 0;
public static final int VALUES_LENGTH = 16;
private Castling() {
}
public static int valueOf(int color, int castlingtype) {
switch (color) {
case WHITE:
switch (castlingtype) { | // Path: src/main/java/com/fluxchess/pulse/model/CastlingType.java
// public static final int KINGSIDE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/CastlingType.java
// public static final int QUEENSIDE = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int BLACK = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
// Path: src/main/java/com/fluxchess/pulse/model/Castling.java
import static com.fluxchess.pulse.model.CastlingType.KINGSIDE;
import static com.fluxchess.pulse.model.CastlingType.QUEENSIDE;
import static com.fluxchess.pulse.model.Color.BLACK;
import static com.fluxchess.pulse.model.Color.WHITE;
/*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
public final class Castling {
public static final int WHITE_KINGSIDE = 1; // 1 << 0
public static final int WHITE_QUEENSIDE = 1 << 1;
public static final int BLACK_KINGSIDE = 1 << 2;
public static final int BLACK_QUEENSIDE = 1 << 3;
public static final int NOCASTLING = 0;
public static final int VALUES_LENGTH = 16;
private Castling() {
}
public static int valueOf(int color, int castlingtype) {
switch (color) {
case WHITE:
switch (castlingtype) { | case KINGSIDE: |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/model/Castling.java | // Path: src/main/java/com/fluxchess/pulse/model/CastlingType.java
// public static final int KINGSIDE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/CastlingType.java
// public static final int QUEENSIDE = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int BLACK = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
| import static com.fluxchess.pulse.model.CastlingType.KINGSIDE;
import static com.fluxchess.pulse.model.CastlingType.QUEENSIDE;
import static com.fluxchess.pulse.model.Color.BLACK;
import static com.fluxchess.pulse.model.Color.WHITE; | /*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
public final class Castling {
public static final int WHITE_KINGSIDE = 1; // 1 << 0
public static final int WHITE_QUEENSIDE = 1 << 1;
public static final int BLACK_KINGSIDE = 1 << 2;
public static final int BLACK_QUEENSIDE = 1 << 3;
public static final int NOCASTLING = 0;
public static final int VALUES_LENGTH = 16;
private Castling() {
}
public static int valueOf(int color, int castlingtype) {
switch (color) {
case WHITE:
switch (castlingtype) {
case KINGSIDE:
return WHITE_KINGSIDE; | // Path: src/main/java/com/fluxchess/pulse/model/CastlingType.java
// public static final int KINGSIDE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/CastlingType.java
// public static final int QUEENSIDE = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int BLACK = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
// Path: src/main/java/com/fluxchess/pulse/model/Castling.java
import static com.fluxchess.pulse.model.CastlingType.KINGSIDE;
import static com.fluxchess.pulse.model.CastlingType.QUEENSIDE;
import static com.fluxchess.pulse.model.Color.BLACK;
import static com.fluxchess.pulse.model.Color.WHITE;
/*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
public final class Castling {
public static final int WHITE_KINGSIDE = 1; // 1 << 0
public static final int WHITE_QUEENSIDE = 1 << 1;
public static final int BLACK_KINGSIDE = 1 << 2;
public static final int BLACK_QUEENSIDE = 1 << 3;
public static final int NOCASTLING = 0;
public static final int VALUES_LENGTH = 16;
private Castling() {
}
public static int valueOf(int color, int castlingtype) {
switch (color) {
case WHITE:
switch (castlingtype) {
case KINGSIDE:
return WHITE_KINGSIDE; | case QUEENSIDE: |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/model/Castling.java | // Path: src/main/java/com/fluxchess/pulse/model/CastlingType.java
// public static final int KINGSIDE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/CastlingType.java
// public static final int QUEENSIDE = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int BLACK = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
| import static com.fluxchess.pulse.model.CastlingType.KINGSIDE;
import static com.fluxchess.pulse.model.CastlingType.QUEENSIDE;
import static com.fluxchess.pulse.model.Color.BLACK;
import static com.fluxchess.pulse.model.Color.WHITE; | /*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
public final class Castling {
public static final int WHITE_KINGSIDE = 1; // 1 << 0
public static final int WHITE_QUEENSIDE = 1 << 1;
public static final int BLACK_KINGSIDE = 1 << 2;
public static final int BLACK_QUEENSIDE = 1 << 3;
public static final int NOCASTLING = 0;
public static final int VALUES_LENGTH = 16;
private Castling() {
}
public static int valueOf(int color, int castlingtype) {
switch (color) {
case WHITE:
switch (castlingtype) {
case KINGSIDE:
return WHITE_KINGSIDE;
case QUEENSIDE:
return WHITE_QUEENSIDE;
default:
throw new IllegalArgumentException();
} | // Path: src/main/java/com/fluxchess/pulse/model/CastlingType.java
// public static final int KINGSIDE = 0;
//
// Path: src/main/java/com/fluxchess/pulse/model/CastlingType.java
// public static final int QUEENSIDE = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int BLACK = 1;
//
// Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public static final int WHITE = 0;
// Path: src/main/java/com/fluxchess/pulse/model/Castling.java
import static com.fluxchess.pulse.model.CastlingType.KINGSIDE;
import static com.fluxchess.pulse.model.CastlingType.QUEENSIDE;
import static com.fluxchess.pulse.model.Color.BLACK;
import static com.fluxchess.pulse.model.Color.WHITE;
/*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
public final class Castling {
public static final int WHITE_KINGSIDE = 1; // 1 << 0
public static final int WHITE_QUEENSIDE = 1 << 1;
public static final int BLACK_KINGSIDE = 1 << 2;
public static final int BLACK_QUEENSIDE = 1 << 3;
public static final int NOCASTLING = 0;
public static final int VALUES_LENGTH = 16;
private Castling() {
}
public static int valueOf(int color, int castlingtype) {
switch (color) {
case WHITE:
switch (castlingtype) {
case KINGSIDE:
return WHITE_KINGSIDE;
case QUEENSIDE:
return WHITE_QUEENSIDE;
default:
throw new IllegalArgumentException();
} | case BLACK: |
fluxroot/pulse | src/test/java/com/fluxchess/pulse/model/ColorTest.java | // Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public final class Color {
//
// public static final int WHITE = 0;
// public static final int BLACK = 1;
//
// public static final int NOCOLOR = 2;
//
// public static final int[] values = {
// WHITE, BLACK
// };
//
// private Color() {
// }
//
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
// }
| import org.junit.jupiter.api.Test;
import static com.fluxchess.pulse.model.Color.*;
import static org.assertj.core.api.Assertions.assertThat; | /*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
class ColorTest {
@Test
void testValues() { | // Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public final class Color {
//
// public static final int WHITE = 0;
// public static final int BLACK = 1;
//
// public static final int NOCOLOR = 2;
//
// public static final int[] values = {
// WHITE, BLACK
// };
//
// private Color() {
// }
//
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
// }
// Path: src/test/java/com/fluxchess/pulse/model/ColorTest.java
import org.junit.jupiter.api.Test;
import static com.fluxchess.pulse.model.Color.*;
import static org.assertj.core.api.Assertions.assertThat;
/*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
class ColorTest {
@Test
void testValues() { | for (int color : Color.values) { |
fluxroot/pulse | src/test/java/com/fluxchess/pulse/MoveListTest.java | // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
| import org.junit.jupiter.api.Test;
import static com.fluxchess.pulse.MoveList.MoveEntry;
import static org.assertj.core.api.Assertions.assertThat; | /*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse;
class MoveListTest {
@Test
void test() { | // Path: src/main/java/com/fluxchess/pulse/MoveList.java
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
// Path: src/test/java/com/fluxchess/pulse/MoveListTest.java
import org.junit.jupiter.api.Test;
import static com.fluxchess.pulse.MoveList.MoveEntry;
import static org.assertj.core.api.Assertions.assertThat;
/*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse;
class MoveListTest {
@Test
void test() { | MoveList<MoveEntry> moveList = new MoveList<>(MoveEntry.class); |
fluxroot/pulse | src/test/java/com/fluxchess/pulse/MoveGeneratorTest.java | // Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public final class Color {
//
// public static final int WHITE = 0;
// public static final int BLACK = 1;
//
// public static final int NOCOLOR = 2;
//
// public static final int[] values = {
// WHITE, BLACK
// };
//
// private Color() {
// }
//
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/MoveList.java
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
| import com.fluxchess.jcpi.models.GenericBoard;
import com.fluxchess.jcpi.models.GenericMove;
import com.fluxchess.pulse.model.Color;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import static com.fluxchess.pulse.MoveList.MoveEntry; |
E(int depth, long nodes) {
this.depth = depth;
this.nodes = nodes;
}
}
@BeforeAll
static void setUpClass() {
for (int i = 0; i < MAX_DEPTH; i++) {
moveGenerators[i] = new MoveGenerator();
}
}
private static P p(String fen, E... perftEntries) {
return new P(fen, perftEntries);
}
private static E e(int depth, long nodes) {
return new E(depth, nodes);
}
private long miniMax(int depth, Position position, int ply) {
if (depth <= 0) {
return 1;
}
long totalNodes = 0;
boolean isCheck = position.isCheck(); | // Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public final class Color {
//
// public static final int WHITE = 0;
// public static final int BLACK = 1;
//
// public static final int NOCOLOR = 2;
//
// public static final int[] values = {
// WHITE, BLACK
// };
//
// private Color() {
// }
//
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/MoveList.java
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
// Path: src/test/java/com/fluxchess/pulse/MoveGeneratorTest.java
import com.fluxchess.jcpi.models.GenericBoard;
import com.fluxchess.jcpi.models.GenericMove;
import com.fluxchess.pulse.model.Color;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import static com.fluxchess.pulse.MoveList.MoveEntry;
E(int depth, long nodes) {
this.depth = depth;
this.nodes = nodes;
}
}
@BeforeAll
static void setUpClass() {
for (int i = 0; i < MAX_DEPTH; i++) {
moveGenerators[i] = new MoveGenerator();
}
}
private static P p(String fen, E... perftEntries) {
return new P(fen, perftEntries);
}
private static E e(int depth, long nodes) {
return new E(depth, nodes);
}
private long miniMax(int depth, Position position, int ply) {
if (depth <= 0) {
return 1;
}
long totalNodes = 0;
boolean isCheck = position.isCheck(); | MoveList<MoveEntry> moves = moveGenerators[ply].getMoves(position, depth, isCheck); |
fluxroot/pulse | src/test/java/com/fluxchess/pulse/MoveGeneratorTest.java | // Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public final class Color {
//
// public static final int WHITE = 0;
// public static final int BLACK = 1;
//
// public static final int NOCOLOR = 2;
//
// public static final int[] values = {
// WHITE, BLACK
// };
//
// private Color() {
// }
//
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/MoveList.java
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
| import com.fluxchess.jcpi.models.GenericBoard;
import com.fluxchess.jcpi.models.GenericMove;
import com.fluxchess.pulse.model.Color;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import static com.fluxchess.pulse.MoveList.MoveEntry; |
@BeforeAll
static void setUpClass() {
for (int i = 0; i < MAX_DEPTH; i++) {
moveGenerators[i] = new MoveGenerator();
}
}
private static P p(String fen, E... perftEntries) {
return new P(fen, perftEntries);
}
private static E e(int depth, long nodes) {
return new E(depth, nodes);
}
private long miniMax(int depth, Position position, int ply) {
if (depth <= 0) {
return 1;
}
long totalNodes = 0;
boolean isCheck = position.isCheck();
MoveList<MoveEntry> moves = moveGenerators[ply].getMoves(position, depth, isCheck);
for (int i = 0; i < moves.size; i++) {
int move = moves.entries[i].move;
position.makeMove(move); | // Path: src/main/java/com/fluxchess/pulse/model/Color.java
// public final class Color {
//
// public static final int WHITE = 0;
// public static final int BLACK = 1;
//
// public static final int NOCOLOR = 2;
//
// public static final int[] values = {
// WHITE, BLACK
// };
//
// private Color() {
// }
//
// public static int opposite(int color) {
// switch (color) {
// case WHITE:
// return BLACK;
// case BLACK:
// return WHITE;
// default:
// throw new IllegalArgumentException();
// }
// }
// }
//
// Path: src/main/java/com/fluxchess/pulse/MoveList.java
// static class MoveEntry {
//
// int move = NOMOVE;
// int value = NOVALUE;
// }
// Path: src/test/java/com/fluxchess/pulse/MoveGeneratorTest.java
import com.fluxchess.jcpi.models.GenericBoard;
import com.fluxchess.jcpi.models.GenericMove;
import com.fluxchess.pulse.model.Color;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import static com.fluxchess.pulse.MoveList.MoveEntry;
@BeforeAll
static void setUpClass() {
for (int i = 0; i < MAX_DEPTH; i++) {
moveGenerators[i] = new MoveGenerator();
}
}
private static P p(String fen, E... perftEntries) {
return new P(fen, perftEntries);
}
private static E e(int depth, long nodes) {
return new E(depth, nodes);
}
private long miniMax(int depth, Position position, int ply) {
if (depth <= 0) {
return 1;
}
long totalNodes = 0;
boolean isCheck = position.isCheck();
MoveList<MoveEntry> moves = moveGenerators[ply].getMoves(position, depth, isCheck);
for (int i = 0; i < moves.size; i++) {
int move = moves.entries[i].move;
position.makeMove(move); | if (!position.isCheck(Color.opposite(position.activeColor))) { |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/model/Move.java | // Path: src/main/java/com/fluxchess/pulse/model/MoveType.java
// public static final int NOMOVETYPE = 5;
//
// Path: src/main/java/com/fluxchess/pulse/model/Piece.java
// public static final int NOPIECE = 12;
//
// Path: src/main/java/com/fluxchess/pulse/model/PieceType.java
// public static final int NOPIECETYPE = 6;
//
// Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public static final int NOSQUARE = 127;
| import static com.fluxchess.pulse.model.MoveType.NOMOVETYPE;
import static com.fluxchess.pulse.model.Piece.NOPIECE;
import static com.fluxchess.pulse.model.PieceType.NOPIECETYPE;
import static com.fluxchess.pulse.model.Square.NOSQUARE; | /*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
/**
* This class represents a move as a int value. The fields are represented by
* the following bits.
* <ul>
* <li><code> 0 - 2</code>: type (required)</li>
* <li><code> 3 - 9</code>: origin square (required)</li>
* <li><code>10 - 16</code>: target square (required)</li>
* <li><code>17 - 21</code>: origin piece (required)</li>
* <li><code>22 - 26</code>: target piece (optional)</li>
* <li><code>27 - 29</code>: promotion type (optional)</li>
* </ul>
*/
public final class Move {
// These are our bit masks
private static final int TYPE_SHIFT = 0;
private static final int TYPE_MASK = MoveType.MASK << TYPE_SHIFT;
private static final int ORIGIN_SQUARE_SHIFT = 3;
private static final int ORIGIN_SQUARE_MASK = Square.MASK << ORIGIN_SQUARE_SHIFT;
private static final int TARGET_SQUARE_SHIFT = 10;
private static final int TARGET_SQUARE_MASK = Square.MASK << TARGET_SQUARE_SHIFT;
private static final int ORIGIN_PIECE_SHIFT = 17;
private static final int ORIGIN_PIECE_MASK = Piece.MASK << ORIGIN_PIECE_SHIFT;
private static final int TARGET_PIECE_SHIFT = 22;
private static final int TARGET_PIECE_MASK = Piece.MASK << TARGET_PIECE_SHIFT;
private static final int PROMOTION_SHIFT = 27;
private static final int PROMOTION_MASK = PieceType.MASK << PROMOTION_SHIFT;
// We don't use 0 as a null value to protect against errors. | // Path: src/main/java/com/fluxchess/pulse/model/MoveType.java
// public static final int NOMOVETYPE = 5;
//
// Path: src/main/java/com/fluxchess/pulse/model/Piece.java
// public static final int NOPIECE = 12;
//
// Path: src/main/java/com/fluxchess/pulse/model/PieceType.java
// public static final int NOPIECETYPE = 6;
//
// Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public static final int NOSQUARE = 127;
// Path: src/main/java/com/fluxchess/pulse/model/Move.java
import static com.fluxchess.pulse.model.MoveType.NOMOVETYPE;
import static com.fluxchess.pulse.model.Piece.NOPIECE;
import static com.fluxchess.pulse.model.PieceType.NOPIECETYPE;
import static com.fluxchess.pulse.model.Square.NOSQUARE;
/*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
/**
* This class represents a move as a int value. The fields are represented by
* the following bits.
* <ul>
* <li><code> 0 - 2</code>: type (required)</li>
* <li><code> 3 - 9</code>: origin square (required)</li>
* <li><code>10 - 16</code>: target square (required)</li>
* <li><code>17 - 21</code>: origin piece (required)</li>
* <li><code>22 - 26</code>: target piece (optional)</li>
* <li><code>27 - 29</code>: promotion type (optional)</li>
* </ul>
*/
public final class Move {
// These are our bit masks
private static final int TYPE_SHIFT = 0;
private static final int TYPE_MASK = MoveType.MASK << TYPE_SHIFT;
private static final int ORIGIN_SQUARE_SHIFT = 3;
private static final int ORIGIN_SQUARE_MASK = Square.MASK << ORIGIN_SQUARE_SHIFT;
private static final int TARGET_SQUARE_SHIFT = 10;
private static final int TARGET_SQUARE_MASK = Square.MASK << TARGET_SQUARE_SHIFT;
private static final int ORIGIN_PIECE_SHIFT = 17;
private static final int ORIGIN_PIECE_MASK = Piece.MASK << ORIGIN_PIECE_SHIFT;
private static final int TARGET_PIECE_SHIFT = 22;
private static final int TARGET_PIECE_MASK = Piece.MASK << TARGET_PIECE_SHIFT;
private static final int PROMOTION_SHIFT = 27;
private static final int PROMOTION_MASK = PieceType.MASK << PROMOTION_SHIFT;
// We don't use 0 as a null value to protect against errors. | public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT) |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/model/Move.java | // Path: src/main/java/com/fluxchess/pulse/model/MoveType.java
// public static final int NOMOVETYPE = 5;
//
// Path: src/main/java/com/fluxchess/pulse/model/Piece.java
// public static final int NOPIECE = 12;
//
// Path: src/main/java/com/fluxchess/pulse/model/PieceType.java
// public static final int NOPIECETYPE = 6;
//
// Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public static final int NOSQUARE = 127;
| import static com.fluxchess.pulse.model.MoveType.NOMOVETYPE;
import static com.fluxchess.pulse.model.Piece.NOPIECE;
import static com.fluxchess.pulse.model.PieceType.NOPIECETYPE;
import static com.fluxchess.pulse.model.Square.NOSQUARE; | /*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
/**
* This class represents a move as a int value. The fields are represented by
* the following bits.
* <ul>
* <li><code> 0 - 2</code>: type (required)</li>
* <li><code> 3 - 9</code>: origin square (required)</li>
* <li><code>10 - 16</code>: target square (required)</li>
* <li><code>17 - 21</code>: origin piece (required)</li>
* <li><code>22 - 26</code>: target piece (optional)</li>
* <li><code>27 - 29</code>: promotion type (optional)</li>
* </ul>
*/
public final class Move {
// These are our bit masks
private static final int TYPE_SHIFT = 0;
private static final int TYPE_MASK = MoveType.MASK << TYPE_SHIFT;
private static final int ORIGIN_SQUARE_SHIFT = 3;
private static final int ORIGIN_SQUARE_MASK = Square.MASK << ORIGIN_SQUARE_SHIFT;
private static final int TARGET_SQUARE_SHIFT = 10;
private static final int TARGET_SQUARE_MASK = Square.MASK << TARGET_SQUARE_SHIFT;
private static final int ORIGIN_PIECE_SHIFT = 17;
private static final int ORIGIN_PIECE_MASK = Piece.MASK << ORIGIN_PIECE_SHIFT;
private static final int TARGET_PIECE_SHIFT = 22;
private static final int TARGET_PIECE_MASK = Piece.MASK << TARGET_PIECE_SHIFT;
private static final int PROMOTION_SHIFT = 27;
private static final int PROMOTION_MASK = PieceType.MASK << PROMOTION_SHIFT;
// We don't use 0 as a null value to protect against errors.
public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT) | // Path: src/main/java/com/fluxchess/pulse/model/MoveType.java
// public static final int NOMOVETYPE = 5;
//
// Path: src/main/java/com/fluxchess/pulse/model/Piece.java
// public static final int NOPIECE = 12;
//
// Path: src/main/java/com/fluxchess/pulse/model/PieceType.java
// public static final int NOPIECETYPE = 6;
//
// Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public static final int NOSQUARE = 127;
// Path: src/main/java/com/fluxchess/pulse/model/Move.java
import static com.fluxchess.pulse.model.MoveType.NOMOVETYPE;
import static com.fluxchess.pulse.model.Piece.NOPIECE;
import static com.fluxchess.pulse.model.PieceType.NOPIECETYPE;
import static com.fluxchess.pulse.model.Square.NOSQUARE;
/*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
/**
* This class represents a move as a int value. The fields are represented by
* the following bits.
* <ul>
* <li><code> 0 - 2</code>: type (required)</li>
* <li><code> 3 - 9</code>: origin square (required)</li>
* <li><code>10 - 16</code>: target square (required)</li>
* <li><code>17 - 21</code>: origin piece (required)</li>
* <li><code>22 - 26</code>: target piece (optional)</li>
* <li><code>27 - 29</code>: promotion type (optional)</li>
* </ul>
*/
public final class Move {
// These are our bit masks
private static final int TYPE_SHIFT = 0;
private static final int TYPE_MASK = MoveType.MASK << TYPE_SHIFT;
private static final int ORIGIN_SQUARE_SHIFT = 3;
private static final int ORIGIN_SQUARE_MASK = Square.MASK << ORIGIN_SQUARE_SHIFT;
private static final int TARGET_SQUARE_SHIFT = 10;
private static final int TARGET_SQUARE_MASK = Square.MASK << TARGET_SQUARE_SHIFT;
private static final int ORIGIN_PIECE_SHIFT = 17;
private static final int ORIGIN_PIECE_MASK = Piece.MASK << ORIGIN_PIECE_SHIFT;
private static final int TARGET_PIECE_SHIFT = 22;
private static final int TARGET_PIECE_MASK = Piece.MASK << TARGET_PIECE_SHIFT;
private static final int PROMOTION_SHIFT = 27;
private static final int PROMOTION_MASK = PieceType.MASK << PROMOTION_SHIFT;
// We don't use 0 as a null value to protect against errors.
public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT) | | (NOSQUARE << ORIGIN_SQUARE_SHIFT) |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/model/Move.java | // Path: src/main/java/com/fluxchess/pulse/model/MoveType.java
// public static final int NOMOVETYPE = 5;
//
// Path: src/main/java/com/fluxchess/pulse/model/Piece.java
// public static final int NOPIECE = 12;
//
// Path: src/main/java/com/fluxchess/pulse/model/PieceType.java
// public static final int NOPIECETYPE = 6;
//
// Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public static final int NOSQUARE = 127;
| import static com.fluxchess.pulse.model.MoveType.NOMOVETYPE;
import static com.fluxchess.pulse.model.Piece.NOPIECE;
import static com.fluxchess.pulse.model.PieceType.NOPIECETYPE;
import static com.fluxchess.pulse.model.Square.NOSQUARE; | /*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
/**
* This class represents a move as a int value. The fields are represented by
* the following bits.
* <ul>
* <li><code> 0 - 2</code>: type (required)</li>
* <li><code> 3 - 9</code>: origin square (required)</li>
* <li><code>10 - 16</code>: target square (required)</li>
* <li><code>17 - 21</code>: origin piece (required)</li>
* <li><code>22 - 26</code>: target piece (optional)</li>
* <li><code>27 - 29</code>: promotion type (optional)</li>
* </ul>
*/
public final class Move {
// These are our bit masks
private static final int TYPE_SHIFT = 0;
private static final int TYPE_MASK = MoveType.MASK << TYPE_SHIFT;
private static final int ORIGIN_SQUARE_SHIFT = 3;
private static final int ORIGIN_SQUARE_MASK = Square.MASK << ORIGIN_SQUARE_SHIFT;
private static final int TARGET_SQUARE_SHIFT = 10;
private static final int TARGET_SQUARE_MASK = Square.MASK << TARGET_SQUARE_SHIFT;
private static final int ORIGIN_PIECE_SHIFT = 17;
private static final int ORIGIN_PIECE_MASK = Piece.MASK << ORIGIN_PIECE_SHIFT;
private static final int TARGET_PIECE_SHIFT = 22;
private static final int TARGET_PIECE_MASK = Piece.MASK << TARGET_PIECE_SHIFT;
private static final int PROMOTION_SHIFT = 27;
private static final int PROMOTION_MASK = PieceType.MASK << PROMOTION_SHIFT;
// We don't use 0 as a null value to protect against errors.
public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT)
| (NOSQUARE << ORIGIN_SQUARE_SHIFT)
| (NOSQUARE << TARGET_SQUARE_SHIFT) | // Path: src/main/java/com/fluxchess/pulse/model/MoveType.java
// public static final int NOMOVETYPE = 5;
//
// Path: src/main/java/com/fluxchess/pulse/model/Piece.java
// public static final int NOPIECE = 12;
//
// Path: src/main/java/com/fluxchess/pulse/model/PieceType.java
// public static final int NOPIECETYPE = 6;
//
// Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public static final int NOSQUARE = 127;
// Path: src/main/java/com/fluxchess/pulse/model/Move.java
import static com.fluxchess.pulse.model.MoveType.NOMOVETYPE;
import static com.fluxchess.pulse.model.Piece.NOPIECE;
import static com.fluxchess.pulse.model.PieceType.NOPIECETYPE;
import static com.fluxchess.pulse.model.Square.NOSQUARE;
/*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
/**
* This class represents a move as a int value. The fields are represented by
* the following bits.
* <ul>
* <li><code> 0 - 2</code>: type (required)</li>
* <li><code> 3 - 9</code>: origin square (required)</li>
* <li><code>10 - 16</code>: target square (required)</li>
* <li><code>17 - 21</code>: origin piece (required)</li>
* <li><code>22 - 26</code>: target piece (optional)</li>
* <li><code>27 - 29</code>: promotion type (optional)</li>
* </ul>
*/
public final class Move {
// These are our bit masks
private static final int TYPE_SHIFT = 0;
private static final int TYPE_MASK = MoveType.MASK << TYPE_SHIFT;
private static final int ORIGIN_SQUARE_SHIFT = 3;
private static final int ORIGIN_SQUARE_MASK = Square.MASK << ORIGIN_SQUARE_SHIFT;
private static final int TARGET_SQUARE_SHIFT = 10;
private static final int TARGET_SQUARE_MASK = Square.MASK << TARGET_SQUARE_SHIFT;
private static final int ORIGIN_PIECE_SHIFT = 17;
private static final int ORIGIN_PIECE_MASK = Piece.MASK << ORIGIN_PIECE_SHIFT;
private static final int TARGET_PIECE_SHIFT = 22;
private static final int TARGET_PIECE_MASK = Piece.MASK << TARGET_PIECE_SHIFT;
private static final int PROMOTION_SHIFT = 27;
private static final int PROMOTION_MASK = PieceType.MASK << PROMOTION_SHIFT;
// We don't use 0 as a null value to protect against errors.
public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT)
| (NOSQUARE << ORIGIN_SQUARE_SHIFT)
| (NOSQUARE << TARGET_SQUARE_SHIFT) | | (NOPIECE << ORIGIN_PIECE_SHIFT) |
fluxroot/pulse | src/main/java/com/fluxchess/pulse/model/Move.java | // Path: src/main/java/com/fluxchess/pulse/model/MoveType.java
// public static final int NOMOVETYPE = 5;
//
// Path: src/main/java/com/fluxchess/pulse/model/Piece.java
// public static final int NOPIECE = 12;
//
// Path: src/main/java/com/fluxchess/pulse/model/PieceType.java
// public static final int NOPIECETYPE = 6;
//
// Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public static final int NOSQUARE = 127;
| import static com.fluxchess.pulse.model.MoveType.NOMOVETYPE;
import static com.fluxchess.pulse.model.Piece.NOPIECE;
import static com.fluxchess.pulse.model.PieceType.NOPIECETYPE;
import static com.fluxchess.pulse.model.Square.NOSQUARE; | /*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
/**
* This class represents a move as a int value. The fields are represented by
* the following bits.
* <ul>
* <li><code> 0 - 2</code>: type (required)</li>
* <li><code> 3 - 9</code>: origin square (required)</li>
* <li><code>10 - 16</code>: target square (required)</li>
* <li><code>17 - 21</code>: origin piece (required)</li>
* <li><code>22 - 26</code>: target piece (optional)</li>
* <li><code>27 - 29</code>: promotion type (optional)</li>
* </ul>
*/
public final class Move {
// These are our bit masks
private static final int TYPE_SHIFT = 0;
private static final int TYPE_MASK = MoveType.MASK << TYPE_SHIFT;
private static final int ORIGIN_SQUARE_SHIFT = 3;
private static final int ORIGIN_SQUARE_MASK = Square.MASK << ORIGIN_SQUARE_SHIFT;
private static final int TARGET_SQUARE_SHIFT = 10;
private static final int TARGET_SQUARE_MASK = Square.MASK << TARGET_SQUARE_SHIFT;
private static final int ORIGIN_PIECE_SHIFT = 17;
private static final int ORIGIN_PIECE_MASK = Piece.MASK << ORIGIN_PIECE_SHIFT;
private static final int TARGET_PIECE_SHIFT = 22;
private static final int TARGET_PIECE_MASK = Piece.MASK << TARGET_PIECE_SHIFT;
private static final int PROMOTION_SHIFT = 27;
private static final int PROMOTION_MASK = PieceType.MASK << PROMOTION_SHIFT;
// We don't use 0 as a null value to protect against errors.
public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT)
| (NOSQUARE << ORIGIN_SQUARE_SHIFT)
| (NOSQUARE << TARGET_SQUARE_SHIFT)
| (NOPIECE << ORIGIN_PIECE_SHIFT)
| (NOPIECE << TARGET_PIECE_SHIFT) | // Path: src/main/java/com/fluxchess/pulse/model/MoveType.java
// public static final int NOMOVETYPE = 5;
//
// Path: src/main/java/com/fluxchess/pulse/model/Piece.java
// public static final int NOPIECE = 12;
//
// Path: src/main/java/com/fluxchess/pulse/model/PieceType.java
// public static final int NOPIECETYPE = 6;
//
// Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public static final int NOSQUARE = 127;
// Path: src/main/java/com/fluxchess/pulse/model/Move.java
import static com.fluxchess.pulse.model.MoveType.NOMOVETYPE;
import static com.fluxchess.pulse.model.Piece.NOPIECE;
import static com.fluxchess.pulse.model.PieceType.NOPIECETYPE;
import static com.fluxchess.pulse.model.Square.NOSQUARE;
/*
* Copyright 2013-2021 Phokham Nonava
*
* Use of this source code is governed by the MIT license that can be
* found in the LICENSE file.
*/
package com.fluxchess.pulse.model;
/**
* This class represents a move as a int value. The fields are represented by
* the following bits.
* <ul>
* <li><code> 0 - 2</code>: type (required)</li>
* <li><code> 3 - 9</code>: origin square (required)</li>
* <li><code>10 - 16</code>: target square (required)</li>
* <li><code>17 - 21</code>: origin piece (required)</li>
* <li><code>22 - 26</code>: target piece (optional)</li>
* <li><code>27 - 29</code>: promotion type (optional)</li>
* </ul>
*/
public final class Move {
// These are our bit masks
private static final int TYPE_SHIFT = 0;
private static final int TYPE_MASK = MoveType.MASK << TYPE_SHIFT;
private static final int ORIGIN_SQUARE_SHIFT = 3;
private static final int ORIGIN_SQUARE_MASK = Square.MASK << ORIGIN_SQUARE_SHIFT;
private static final int TARGET_SQUARE_SHIFT = 10;
private static final int TARGET_SQUARE_MASK = Square.MASK << TARGET_SQUARE_SHIFT;
private static final int ORIGIN_PIECE_SHIFT = 17;
private static final int ORIGIN_PIECE_MASK = Piece.MASK << ORIGIN_PIECE_SHIFT;
private static final int TARGET_PIECE_SHIFT = 22;
private static final int TARGET_PIECE_MASK = Piece.MASK << TARGET_PIECE_SHIFT;
private static final int PROMOTION_SHIFT = 27;
private static final int PROMOTION_MASK = PieceType.MASK << PROMOTION_SHIFT;
// We don't use 0 as a null value to protect against errors.
public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT)
| (NOSQUARE << ORIGIN_SQUARE_SHIFT)
| (NOSQUARE << TARGET_SQUARE_SHIFT)
| (NOPIECE << ORIGIN_PIECE_SHIFT)
| (NOPIECE << TARGET_PIECE_SHIFT) | | (NOPIECETYPE << PROMOTION_SHIFT); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/AbstractEmoteMessage.java | // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
| import com.gikk.twirk.types.emote.Emote;
import java.util.List; | package com.gikk.twirk.types;
/**Interface for chat messages that might contain emotes
*
* @author Gikkman
*/
public interface AbstractEmoteMessage extends AbstractType{
/**Checks whether this message contains emotes or not
*
* @return {@code true} if the message contains emotes
*/
public boolean hasEmotes();
/**Fetches a list of all all emotes in this message. Each emote is encapsulated in a {@link Emote}.
* The list might be empty, if the message contained no emotes.
*
* @return List of emotes (might be empty)
*/ | // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
// Path: src/main/java/com/gikk/twirk/types/AbstractEmoteMessage.java
import com.gikk.twirk.types.emote.Emote;
import java.util.List;
package com.gikk.twirk.types;
/**Interface for chat messages that might contain emotes
*
* @author Gikkman
*/
public interface AbstractEmoteMessage extends AbstractType{
/**Checks whether this message contains emotes or not
*
* @return {@code true} if the message contains emotes
*/
public boolean hasEmotes();
/**Fetches a list of all all emotes in this message. Each emote is encapsulated in a {@link Emote}.
* The list might be empty, if the message contained no emotes.
*
* @return List of emotes (might be empty)
*/ | public List<Emote> getEmotes(); |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/roomstate/TestRoomstate.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.roomstate;
public class TestRoomstate {
private final static String JOIN = "@broadcaster-lang=;emote-only=0;r9k=0;slow=0;subs-only=0;followers-only=-1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String SUB_MODE_ON_MESSAGE = "@subs-only=1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String SUB_MODE_OFF_MESSAGE = "@subs-only=0 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String R9K_MODE_ON_MESSAGE = "@r9k=1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String R9K_MODE_OFF_MESSAGE = "@r9k=0 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String SLOW_MODE_120_MESSAGE = "@slow=120 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String SLOW_MODE_OFF_MESSAGE = "@slow=0 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String FOLLOWERS_MODE_ON_MESSAGE = "@followers-only=0 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String FOLLOWERS_MODE_OFF_MESSAGE = "@followers-only=-1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String EMOTE_ONLY_MODE_ON_MESSAGE = "@emote-only=1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String EMOTE_ONLY_MODE_OFF_MESSAGE = "@emote-only=0 :tmi.twitch.tv ROOMSTATE #gikkman";
| // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
// Path: src/test/java/com/gikk/twirk/types/roomstate/TestRoomstate.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.roomstate;
public class TestRoomstate {
private final static String JOIN = "@broadcaster-lang=;emote-only=0;r9k=0;slow=0;subs-only=0;followers-only=-1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String SUB_MODE_ON_MESSAGE = "@subs-only=1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String SUB_MODE_OFF_MESSAGE = "@subs-only=0 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String R9K_MODE_ON_MESSAGE = "@r9k=1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String R9K_MODE_OFF_MESSAGE = "@r9k=0 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String SLOW_MODE_120_MESSAGE = "@slow=120 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String SLOW_MODE_OFF_MESSAGE = "@slow=0 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String FOLLOWERS_MODE_ON_MESSAGE = "@followers-only=0 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String FOLLOWERS_MODE_OFF_MESSAGE = "@followers-only=-1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String EMOTE_ONLY_MODE_ON_MESSAGE = "@emote-only=1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String EMOTE_ONLY_MODE_OFF_MESSAGE = "@emote-only=0 :tmi.twitch.tv ROOMSTATE #gikkman";
| public static void test(Consumer<String> twirkIn, TestConsumer<Roomstate> roomstateTest) throws Exception { |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/roomstate/TestRoomstate.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.roomstate;
public class TestRoomstate {
private final static String JOIN = "@broadcaster-lang=;emote-only=0;r9k=0;slow=0;subs-only=0;followers-only=-1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String SUB_MODE_ON_MESSAGE = "@subs-only=1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String SUB_MODE_OFF_MESSAGE = "@subs-only=0 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String R9K_MODE_ON_MESSAGE = "@r9k=1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String R9K_MODE_OFF_MESSAGE = "@r9k=0 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String SLOW_MODE_120_MESSAGE = "@slow=120 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String SLOW_MODE_OFF_MESSAGE = "@slow=0 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String FOLLOWERS_MODE_ON_MESSAGE = "@followers-only=0 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String FOLLOWERS_MODE_OFF_MESSAGE = "@followers-only=-1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String EMOTE_ONLY_MODE_ON_MESSAGE = "@emote-only=1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String EMOTE_ONLY_MODE_OFF_MESSAGE = "@emote-only=0 :tmi.twitch.tv ROOMSTATE #gikkman";
public static void test(Consumer<String> twirkIn, TestConsumer<Roomstate> roomstateTest) throws Exception { | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
// Path: src/test/java/com/gikk/twirk/types/roomstate/TestRoomstate.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.roomstate;
public class TestRoomstate {
private final static String JOIN = "@broadcaster-lang=;emote-only=0;r9k=0;slow=0;subs-only=0;followers-only=-1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String SUB_MODE_ON_MESSAGE = "@subs-only=1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String SUB_MODE_OFF_MESSAGE = "@subs-only=0 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String R9K_MODE_ON_MESSAGE = "@r9k=1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String R9K_MODE_OFF_MESSAGE = "@r9k=0 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String SLOW_MODE_120_MESSAGE = "@slow=120 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String SLOW_MODE_OFF_MESSAGE = "@slow=0 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String FOLLOWERS_MODE_ON_MESSAGE = "@followers-only=0 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String FOLLOWERS_MODE_OFF_MESSAGE = "@followers-only=-1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String EMOTE_ONLY_MODE_ON_MESSAGE = "@emote-only=1 :tmi.twitch.tv ROOMSTATE #gikkman";
private final static String EMOTE_ONLY_MODE_OFF_MESSAGE = "@emote-only=0 :tmi.twitch.tv ROOMSTATE #gikkman";
public static void test(Consumer<String> twirkIn, TestConsumer<Roomstate> roomstateTest) throws Exception { | TestResult t1 = roomstateTest.assign(TestRoomstate::testJoin); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/emote/EmoteImpl.java | // Path: src/main/java/com/gikk/twirk/enums/EMOTE_SIZE.java
// public enum EMOTE_SIZE{
// SMALL("/1.0"),
// MEDIUM("/2.0"),
// LARGE("/3.0");
// public final String value;
// private EMOTE_SIZE(String val){ this.value = val; }
// }
| import com.gikk.twirk.enums.EMOTE_SIZE;
import java.util.LinkedList; | return this;
}
public EmoteImpl setPattern(String pattern){
this.pattern = pattern;
return this;
}
public EmoteImpl addIndices(int begin, int end){
this.indices.add( new EmoteIndices(begin, end) );
return this;
}
@Override
public String getEmoteIDString() {
return emoteIDString;
}
@Override
public String getPattern() {
return pattern;
}
@Override
public LinkedList<EmoteIndices> getIndices() {
return indices;
}
@Override | // Path: src/main/java/com/gikk/twirk/enums/EMOTE_SIZE.java
// public enum EMOTE_SIZE{
// SMALL("/1.0"),
// MEDIUM("/2.0"),
// LARGE("/3.0");
// public final String value;
// private EMOTE_SIZE(String val){ this.value = val; }
// }
// Path: src/main/java/com/gikk/twirk/types/emote/EmoteImpl.java
import com.gikk.twirk.enums.EMOTE_SIZE;
import java.util.LinkedList;
return this;
}
public EmoteImpl setPattern(String pattern){
this.pattern = pattern;
return this;
}
public EmoteImpl addIndices(int begin, int end){
this.indices.add( new EmoteIndices(begin, end) );
return this;
}
@Override
public String getEmoteIDString() {
return emoteIDString;
}
@Override
public String getPattern() {
return pattern;
}
@Override
public LinkedList<EmoteIndices> getIndices() {
return indices;
}
@Override | public String getEmoteImageUrl(EMOTE_SIZE imageSize){ |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/twitchMessage/TestMessage.java | // Path: src/test/java/com/gikk/twirk/TestBiConsumer.java
// public class TestBiConsumer<T, U> {
// private BiFunction<T,U, Boolean> test;
// private TestResult res;
//
// public TestResult assign(BiFunction<T, U, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T t, U u){
// if(test != null) {
// res.complete(test.apply(t, u));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/users/TwitchUser.java
// public interface TwitchUser {
//
// /**Retrieves this user's user name. This is the name the user logs in to
// * Twitch with
// *
// * @return The user's user name
// */
// public String getUserName();
//
// /**Retrieves this user's display name, as displayed in Twitch chat
// *
// * @return The user's display name
// */
// public String getDisplayName();
//
// /**Retrieves info whether this user is the owner of this channel or not
// *
// * @return {@code true} if the user is the owner, {@code false} if not
// */
// public boolean isOwner();
//
// /**Retrieves info whether this user is a mod in this channel or not
// *
// * @return {@code true} if the user is mod, {@code false} if not
// */
// public boolean isMod();
//
// /**Retrieves info whether this user has turbo or not
// *
// * @return {@code true} if the user has turbo, {@code false} if not
// */
// public boolean isTurbo();
//
// /**Retrieves info whether this user is a sub to this channel or not
// *
// * @return {@code true} if the user is a sub, {@code false} if not
// */
// public boolean isSub();
//
// /**Retrieves this users {@link USER_TYPE} <br>
// * There are seven USER_TYPEs: OWNER, MOD, GLOBAL_MOD, ADMIN, STAFF, SUBSCRIBER and DEFAULT.
// *
// * @return The user's USER_TYPE
// */
// public USER_TYPE getUserType();
//
// /**Retrieves this users display color, as seen in Twitch chat.<br>
// * The color is a hexadecimal number.
// *
// * @return The users display color, as a hex number
// */
// public int getColor();
//
// /**Retrieves the users set of badges in Twitch chat. A badge looks like this: <br>
// * {@code broadcaster/1} <br><br>
// *
// * There are several different badges, such as {@code broadcaster/1}, {@code turbo/1} and so on. I do
// * not know all of them explicitly, or what to do with them.
// *
// * TODO: Find out more about badges
// *
// * @return Arrays of strings, representing this users badges. Might be empty if user has none.
// */
// public String[] getBadges();
//
// /**Retrieves this user's unique user ID. This ID is decided by Twitch, and will
// * always be the same for the same user
// *
// * @return The users unique user ID
// */
// public long getUserID();
// }
| import com.gikk.twirk.TestBiConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.users.TwitchUser;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.twitchMessage;
public class TestMessage {
final static String USER_MESSAGE_NO_EMOTE = "@badges=;color=;display-name=Gikkman;emotes=;mod=0;room-id=31974228;subscriber=0;turbo=0;user-id=27658385;user-type= :gikkman!gikkman@gikkman.tmi.twitch.tv PRIVMSG #gikkman :userMessage 조선말";
final static String USER_MESSAGE_WITH_EMOTE = "@badges=;color=#FF69B4;display-name=Gikklol;emotes=86:10-19;mod=0;room-id=31974228;subscriber=0;turbo=0;user-id=27658385;user-type= :gikklol!gikklol@gikklol.tmi.twitch.tv PRIVMSG #gikkman :beefin it BibleThump";
| // Path: src/test/java/com/gikk/twirk/TestBiConsumer.java
// public class TestBiConsumer<T, U> {
// private BiFunction<T,U, Boolean> test;
// private TestResult res;
//
// public TestResult assign(BiFunction<T, U, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T t, U u){
// if(test != null) {
// res.complete(test.apply(t, u));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/users/TwitchUser.java
// public interface TwitchUser {
//
// /**Retrieves this user's user name. This is the name the user logs in to
// * Twitch with
// *
// * @return The user's user name
// */
// public String getUserName();
//
// /**Retrieves this user's display name, as displayed in Twitch chat
// *
// * @return The user's display name
// */
// public String getDisplayName();
//
// /**Retrieves info whether this user is the owner of this channel or not
// *
// * @return {@code true} if the user is the owner, {@code false} if not
// */
// public boolean isOwner();
//
// /**Retrieves info whether this user is a mod in this channel or not
// *
// * @return {@code true} if the user is mod, {@code false} if not
// */
// public boolean isMod();
//
// /**Retrieves info whether this user has turbo or not
// *
// * @return {@code true} if the user has turbo, {@code false} if not
// */
// public boolean isTurbo();
//
// /**Retrieves info whether this user is a sub to this channel or not
// *
// * @return {@code true} if the user is a sub, {@code false} if not
// */
// public boolean isSub();
//
// /**Retrieves this users {@link USER_TYPE} <br>
// * There are seven USER_TYPEs: OWNER, MOD, GLOBAL_MOD, ADMIN, STAFF, SUBSCRIBER and DEFAULT.
// *
// * @return The user's USER_TYPE
// */
// public USER_TYPE getUserType();
//
// /**Retrieves this users display color, as seen in Twitch chat.<br>
// * The color is a hexadecimal number.
// *
// * @return The users display color, as a hex number
// */
// public int getColor();
//
// /**Retrieves the users set of badges in Twitch chat. A badge looks like this: <br>
// * {@code broadcaster/1} <br><br>
// *
// * There are several different badges, such as {@code broadcaster/1}, {@code turbo/1} and so on. I do
// * not know all of them explicitly, or what to do with them.
// *
// * TODO: Find out more about badges
// *
// * @return Arrays of strings, representing this users badges. Might be empty if user has none.
// */
// public String[] getBadges();
//
// /**Retrieves this user's unique user ID. This ID is decided by Twitch, and will
// * always be the same for the same user
// *
// * @return The users unique user ID
// */
// public long getUserID();
// }
// Path: src/test/java/com/gikk/twirk/types/twitchMessage/TestMessage.java
import com.gikk.twirk.TestBiConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.users.TwitchUser;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.twitchMessage;
public class TestMessage {
final static String USER_MESSAGE_NO_EMOTE = "@badges=;color=;display-name=Gikkman;emotes=;mod=0;room-id=31974228;subscriber=0;turbo=0;user-id=27658385;user-type= :gikkman!gikkman@gikkman.tmi.twitch.tv PRIVMSG #gikkman :userMessage 조선말";
final static String USER_MESSAGE_WITH_EMOTE = "@badges=;color=#FF69B4;display-name=Gikklol;emotes=86:10-19;mod=0;room-id=31974228;subscriber=0;turbo=0;user-id=27658385;user-type= :gikklol!gikklol@gikklol.tmi.twitch.tv PRIVMSG #gikkman :beefin it BibleThump";
| public static void testPrivMsg(Consumer<String> twirkInput, TestBiConsumer<TwitchUser, TwitchMessage> test ) throws Exception{ |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/twitchMessage/TestMessage.java | // Path: src/test/java/com/gikk/twirk/TestBiConsumer.java
// public class TestBiConsumer<T, U> {
// private BiFunction<T,U, Boolean> test;
// private TestResult res;
//
// public TestResult assign(BiFunction<T, U, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T t, U u){
// if(test != null) {
// res.complete(test.apply(t, u));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/users/TwitchUser.java
// public interface TwitchUser {
//
// /**Retrieves this user's user name. This is the name the user logs in to
// * Twitch with
// *
// * @return The user's user name
// */
// public String getUserName();
//
// /**Retrieves this user's display name, as displayed in Twitch chat
// *
// * @return The user's display name
// */
// public String getDisplayName();
//
// /**Retrieves info whether this user is the owner of this channel or not
// *
// * @return {@code true} if the user is the owner, {@code false} if not
// */
// public boolean isOwner();
//
// /**Retrieves info whether this user is a mod in this channel or not
// *
// * @return {@code true} if the user is mod, {@code false} if not
// */
// public boolean isMod();
//
// /**Retrieves info whether this user has turbo or not
// *
// * @return {@code true} if the user has turbo, {@code false} if not
// */
// public boolean isTurbo();
//
// /**Retrieves info whether this user is a sub to this channel or not
// *
// * @return {@code true} if the user is a sub, {@code false} if not
// */
// public boolean isSub();
//
// /**Retrieves this users {@link USER_TYPE} <br>
// * There are seven USER_TYPEs: OWNER, MOD, GLOBAL_MOD, ADMIN, STAFF, SUBSCRIBER and DEFAULT.
// *
// * @return The user's USER_TYPE
// */
// public USER_TYPE getUserType();
//
// /**Retrieves this users display color, as seen in Twitch chat.<br>
// * The color is a hexadecimal number.
// *
// * @return The users display color, as a hex number
// */
// public int getColor();
//
// /**Retrieves the users set of badges in Twitch chat. A badge looks like this: <br>
// * {@code broadcaster/1} <br><br>
// *
// * There are several different badges, such as {@code broadcaster/1}, {@code turbo/1} and so on. I do
// * not know all of them explicitly, or what to do with them.
// *
// * TODO: Find out more about badges
// *
// * @return Arrays of strings, representing this users badges. Might be empty if user has none.
// */
// public String[] getBadges();
//
// /**Retrieves this user's unique user ID. This ID is decided by Twitch, and will
// * always be the same for the same user
// *
// * @return The users unique user ID
// */
// public long getUserID();
// }
| import com.gikk.twirk.TestBiConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.users.TwitchUser;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.twitchMessage;
public class TestMessage {
final static String USER_MESSAGE_NO_EMOTE = "@badges=;color=;display-name=Gikkman;emotes=;mod=0;room-id=31974228;subscriber=0;turbo=0;user-id=27658385;user-type= :gikkman!gikkman@gikkman.tmi.twitch.tv PRIVMSG #gikkman :userMessage 조선말";
final static String USER_MESSAGE_WITH_EMOTE = "@badges=;color=#FF69B4;display-name=Gikklol;emotes=86:10-19;mod=0;room-id=31974228;subscriber=0;turbo=0;user-id=27658385;user-type= :gikklol!gikklol@gikklol.tmi.twitch.tv PRIVMSG #gikkman :beefin it BibleThump";
| // Path: src/test/java/com/gikk/twirk/TestBiConsumer.java
// public class TestBiConsumer<T, U> {
// private BiFunction<T,U, Boolean> test;
// private TestResult res;
//
// public TestResult assign(BiFunction<T, U, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T t, U u){
// if(test != null) {
// res.complete(test.apply(t, u));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/users/TwitchUser.java
// public interface TwitchUser {
//
// /**Retrieves this user's user name. This is the name the user logs in to
// * Twitch with
// *
// * @return The user's user name
// */
// public String getUserName();
//
// /**Retrieves this user's display name, as displayed in Twitch chat
// *
// * @return The user's display name
// */
// public String getDisplayName();
//
// /**Retrieves info whether this user is the owner of this channel or not
// *
// * @return {@code true} if the user is the owner, {@code false} if not
// */
// public boolean isOwner();
//
// /**Retrieves info whether this user is a mod in this channel or not
// *
// * @return {@code true} if the user is mod, {@code false} if not
// */
// public boolean isMod();
//
// /**Retrieves info whether this user has turbo or not
// *
// * @return {@code true} if the user has turbo, {@code false} if not
// */
// public boolean isTurbo();
//
// /**Retrieves info whether this user is a sub to this channel or not
// *
// * @return {@code true} if the user is a sub, {@code false} if not
// */
// public boolean isSub();
//
// /**Retrieves this users {@link USER_TYPE} <br>
// * There are seven USER_TYPEs: OWNER, MOD, GLOBAL_MOD, ADMIN, STAFF, SUBSCRIBER and DEFAULT.
// *
// * @return The user's USER_TYPE
// */
// public USER_TYPE getUserType();
//
// /**Retrieves this users display color, as seen in Twitch chat.<br>
// * The color is a hexadecimal number.
// *
// * @return The users display color, as a hex number
// */
// public int getColor();
//
// /**Retrieves the users set of badges in Twitch chat. A badge looks like this: <br>
// * {@code broadcaster/1} <br><br>
// *
// * There are several different badges, such as {@code broadcaster/1}, {@code turbo/1} and so on. I do
// * not know all of them explicitly, or what to do with them.
// *
// * TODO: Find out more about badges
// *
// * @return Arrays of strings, representing this users badges. Might be empty if user has none.
// */
// public String[] getBadges();
//
// /**Retrieves this user's unique user ID. This ID is decided by Twitch, and will
// * always be the same for the same user
// *
// * @return The users unique user ID
// */
// public long getUserID();
// }
// Path: src/test/java/com/gikk/twirk/types/twitchMessage/TestMessage.java
import com.gikk.twirk.TestBiConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.users.TwitchUser;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.twitchMessage;
public class TestMessage {
final static String USER_MESSAGE_NO_EMOTE = "@badges=;color=;display-name=Gikkman;emotes=;mod=0;room-id=31974228;subscriber=0;turbo=0;user-id=27658385;user-type= :gikkman!gikkman@gikkman.tmi.twitch.tv PRIVMSG #gikkman :userMessage 조선말";
final static String USER_MESSAGE_WITH_EMOTE = "@badges=;color=#FF69B4;display-name=Gikklol;emotes=86:10-19;mod=0;room-id=31974228;subscriber=0;turbo=0;user-id=27658385;user-type= :gikklol!gikklol@gikklol.tmi.twitch.tv PRIVMSG #gikkman :beefin it BibleThump";
| public static void testPrivMsg(Consumer<String> twirkInput, TestBiConsumer<TwitchUser, TwitchMessage> test ) throws Exception{ |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/twitchMessage/TestMessage.java | // Path: src/test/java/com/gikk/twirk/TestBiConsumer.java
// public class TestBiConsumer<T, U> {
// private BiFunction<T,U, Boolean> test;
// private TestResult res;
//
// public TestResult assign(BiFunction<T, U, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T t, U u){
// if(test != null) {
// res.complete(test.apply(t, u));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/users/TwitchUser.java
// public interface TwitchUser {
//
// /**Retrieves this user's user name. This is the name the user logs in to
// * Twitch with
// *
// * @return The user's user name
// */
// public String getUserName();
//
// /**Retrieves this user's display name, as displayed in Twitch chat
// *
// * @return The user's display name
// */
// public String getDisplayName();
//
// /**Retrieves info whether this user is the owner of this channel or not
// *
// * @return {@code true} if the user is the owner, {@code false} if not
// */
// public boolean isOwner();
//
// /**Retrieves info whether this user is a mod in this channel or not
// *
// * @return {@code true} if the user is mod, {@code false} if not
// */
// public boolean isMod();
//
// /**Retrieves info whether this user has turbo or not
// *
// * @return {@code true} if the user has turbo, {@code false} if not
// */
// public boolean isTurbo();
//
// /**Retrieves info whether this user is a sub to this channel or not
// *
// * @return {@code true} if the user is a sub, {@code false} if not
// */
// public boolean isSub();
//
// /**Retrieves this users {@link USER_TYPE} <br>
// * There are seven USER_TYPEs: OWNER, MOD, GLOBAL_MOD, ADMIN, STAFF, SUBSCRIBER and DEFAULT.
// *
// * @return The user's USER_TYPE
// */
// public USER_TYPE getUserType();
//
// /**Retrieves this users display color, as seen in Twitch chat.<br>
// * The color is a hexadecimal number.
// *
// * @return The users display color, as a hex number
// */
// public int getColor();
//
// /**Retrieves the users set of badges in Twitch chat. A badge looks like this: <br>
// * {@code broadcaster/1} <br><br>
// *
// * There are several different badges, such as {@code broadcaster/1}, {@code turbo/1} and so on. I do
// * not know all of them explicitly, or what to do with them.
// *
// * TODO: Find out more about badges
// *
// * @return Arrays of strings, representing this users badges. Might be empty if user has none.
// */
// public String[] getBadges();
//
// /**Retrieves this user's unique user ID. This ID is decided by Twitch, and will
// * always be the same for the same user
// *
// * @return The users unique user ID
// */
// public long getUserID();
// }
| import com.gikk.twirk.TestBiConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.users.TwitchUser;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.twitchMessage;
public class TestMessage {
final static String USER_MESSAGE_NO_EMOTE = "@badges=;color=;display-name=Gikkman;emotes=;mod=0;room-id=31974228;subscriber=0;turbo=0;user-id=27658385;user-type= :gikkman!gikkman@gikkman.tmi.twitch.tv PRIVMSG #gikkman :userMessage 조선말";
final static String USER_MESSAGE_WITH_EMOTE = "@badges=;color=#FF69B4;display-name=Gikklol;emotes=86:10-19;mod=0;room-id=31974228;subscriber=0;turbo=0;user-id=27658385;user-type= :gikklol!gikklol@gikklol.tmi.twitch.tv PRIVMSG #gikkman :beefin it BibleThump";
public static void testPrivMsg(Consumer<String> twirkInput, TestBiConsumer<TwitchUser, TwitchMessage> test ) throws Exception{ | // Path: src/test/java/com/gikk/twirk/TestBiConsumer.java
// public class TestBiConsumer<T, U> {
// private BiFunction<T,U, Boolean> test;
// private TestResult res;
//
// public TestResult assign(BiFunction<T, U, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T t, U u){
// if(test != null) {
// res.complete(test.apply(t, u));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/users/TwitchUser.java
// public interface TwitchUser {
//
// /**Retrieves this user's user name. This is the name the user logs in to
// * Twitch with
// *
// * @return The user's user name
// */
// public String getUserName();
//
// /**Retrieves this user's display name, as displayed in Twitch chat
// *
// * @return The user's display name
// */
// public String getDisplayName();
//
// /**Retrieves info whether this user is the owner of this channel or not
// *
// * @return {@code true} if the user is the owner, {@code false} if not
// */
// public boolean isOwner();
//
// /**Retrieves info whether this user is a mod in this channel or not
// *
// * @return {@code true} if the user is mod, {@code false} if not
// */
// public boolean isMod();
//
// /**Retrieves info whether this user has turbo or not
// *
// * @return {@code true} if the user has turbo, {@code false} if not
// */
// public boolean isTurbo();
//
// /**Retrieves info whether this user is a sub to this channel or not
// *
// * @return {@code true} if the user is a sub, {@code false} if not
// */
// public boolean isSub();
//
// /**Retrieves this users {@link USER_TYPE} <br>
// * There are seven USER_TYPEs: OWNER, MOD, GLOBAL_MOD, ADMIN, STAFF, SUBSCRIBER and DEFAULT.
// *
// * @return The user's USER_TYPE
// */
// public USER_TYPE getUserType();
//
// /**Retrieves this users display color, as seen in Twitch chat.<br>
// * The color is a hexadecimal number.
// *
// * @return The users display color, as a hex number
// */
// public int getColor();
//
// /**Retrieves the users set of badges in Twitch chat. A badge looks like this: <br>
// * {@code broadcaster/1} <br><br>
// *
// * There are several different badges, such as {@code broadcaster/1}, {@code turbo/1} and so on. I do
// * not know all of them explicitly, or what to do with them.
// *
// * TODO: Find out more about badges
// *
// * @return Arrays of strings, representing this users badges. Might be empty if user has none.
// */
// public String[] getBadges();
//
// /**Retrieves this user's unique user ID. This ID is decided by Twitch, and will
// * always be the same for the same user
// *
// * @return The users unique user ID
// */
// public long getUserID();
// }
// Path: src/test/java/com/gikk/twirk/types/twitchMessage/TestMessage.java
import com.gikk.twirk.TestBiConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.users.TwitchUser;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.twitchMessage;
public class TestMessage {
final static String USER_MESSAGE_NO_EMOTE = "@badges=;color=;display-name=Gikkman;emotes=;mod=0;room-id=31974228;subscriber=0;turbo=0;user-id=27658385;user-type= :gikkman!gikkman@gikkman.tmi.twitch.tv PRIVMSG #gikkman :userMessage 조선말";
final static String USER_MESSAGE_WITH_EMOTE = "@badges=;color=#FF69B4;display-name=Gikklol;emotes=86:10-19;mod=0;room-id=31974228;subscriber=0;turbo=0;user-id=27658385;user-type= :gikklol!gikklol@gikklol.tmi.twitch.tv PRIVMSG #gikkman :beefin it BibleThump";
public static void testPrivMsg(Consumer<String> twirkInput, TestBiConsumer<TwitchUser, TwitchMessage> test ) throws Exception{ | TestResult t1 = test.assign(TestMessage::testUserMessageNoEmote); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/roomstate/RoomstateBuilder.java | // Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
| import com.gikk.twirk.types.twitchMessage.TwitchMessage; | package com.gikk.twirk.types.roomstate;
/**Constructs a {@link Roomstate} object. To create a {@link Roomstate} object, call the {@link #build(TwitchMessage)} method
*
* @author Gikkman
*
*/
public interface RoomstateBuilder {
public static RoomstateBuilder getDefault() {
return new DefaultRoomstateBuilder();
}
/**Constructs a new {@link Roomstate} object from a {@link TwitchMessage}, received from Twitch. The user
* is responsible for making sure that this message can actually be made into a {@link Roomstate} object.
* Make sure that the COMMAND of the message equals "ROOMSTATE"
*
* @param message The message we received from Twitch
* @return A {@link Roomstate}, or <code>null</code> if a {@link Roomstate} could not be created
*/ | // Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
// Path: src/main/java/com/gikk/twirk/types/roomstate/RoomstateBuilder.java
import com.gikk.twirk.types.twitchMessage.TwitchMessage;
package com.gikk.twirk.types.roomstate;
/**Constructs a {@link Roomstate} object. To create a {@link Roomstate} object, call the {@link #build(TwitchMessage)} method
*
* @author Gikkman
*
*/
public interface RoomstateBuilder {
public static RoomstateBuilder getDefault() {
return new DefaultRoomstateBuilder();
}
/**Constructs a new {@link Roomstate} object from a {@link TwitchMessage}, received from Twitch. The user
* is responsible for making sure that this message can actually be made into a {@link Roomstate} object.
* Make sure that the COMMAND of the message equals "ROOMSTATE"
*
* @param message The message we received from Twitch
* @return A {@link Roomstate}, or <code>null</code> if a {@link Roomstate} could not be created
*/ | public Roomstate build(TwitchMessage message); |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/hostTarget/TestHostTarget.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/enums/HOSTTARGET_MODE.java
// public enum HOSTTARGET_MODE {
// /**Indicates that we started hosting a channel*/
// START,
// /**Indicates that we stopped hosting a channel*/
// STOP }
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.enums.HOSTTARGET_MODE;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.hostTarget;
public class TestHostTarget {
private final static String START_HOST = ":tmi.twitch.tv HOSTTARGET #gikkman :gikkbot 1"; //Gikkman host Gikkbot for 1 viewer
private final static String STOP_HOST_NO_VIEWERS = ":tmi.twitch.tv HOSTTARGET #gikkman :-"; //Gikkbot stopped hosting for 0 viewers
private final static String STOP_HOST_VIEWERS = ":tmi.twitch.tv HOSTTARGET #gikkman :- 5"; //Gikkbot stopped hosting for 0 viewers
| // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/enums/HOSTTARGET_MODE.java
// public enum HOSTTARGET_MODE {
// /**Indicates that we started hosting a channel*/
// START,
// /**Indicates that we stopped hosting a channel*/
// STOP }
// Path: src/test/java/com/gikk/twirk/types/hostTarget/TestHostTarget.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.enums.HOSTTARGET_MODE;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.hostTarget;
public class TestHostTarget {
private final static String START_HOST = ":tmi.twitch.tv HOSTTARGET #gikkman :gikkbot 1"; //Gikkman host Gikkbot for 1 viewer
private final static String STOP_HOST_NO_VIEWERS = ":tmi.twitch.tv HOSTTARGET #gikkman :-"; //Gikkbot stopped hosting for 0 viewers
private final static String STOP_HOST_VIEWERS = ":tmi.twitch.tv HOSTTARGET #gikkman :- 5"; //Gikkbot stopped hosting for 0 viewers
| public static void test(Consumer<String> twirkInput, TestConsumer<HostTarget> test ) throws Exception{ |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/hostTarget/TestHostTarget.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/enums/HOSTTARGET_MODE.java
// public enum HOSTTARGET_MODE {
// /**Indicates that we started hosting a channel*/
// START,
// /**Indicates that we stopped hosting a channel*/
// STOP }
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.enums.HOSTTARGET_MODE;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.hostTarget;
public class TestHostTarget {
private final static String START_HOST = ":tmi.twitch.tv HOSTTARGET #gikkman :gikkbot 1"; //Gikkman host Gikkbot for 1 viewer
private final static String STOP_HOST_NO_VIEWERS = ":tmi.twitch.tv HOSTTARGET #gikkman :-"; //Gikkbot stopped hosting for 0 viewers
private final static String STOP_HOST_VIEWERS = ":tmi.twitch.tv HOSTTARGET #gikkman :- 5"; //Gikkbot stopped hosting for 0 viewers
public static void test(Consumer<String> twirkInput, TestConsumer<HostTarget> test ) throws Exception{ | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/enums/HOSTTARGET_MODE.java
// public enum HOSTTARGET_MODE {
// /**Indicates that we started hosting a channel*/
// START,
// /**Indicates that we stopped hosting a channel*/
// STOP }
// Path: src/test/java/com/gikk/twirk/types/hostTarget/TestHostTarget.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.enums.HOSTTARGET_MODE;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.hostTarget;
public class TestHostTarget {
private final static String START_HOST = ":tmi.twitch.tv HOSTTARGET #gikkman :gikkbot 1"; //Gikkman host Gikkbot for 1 viewer
private final static String STOP_HOST_NO_VIEWERS = ":tmi.twitch.tv HOSTTARGET #gikkman :-"; //Gikkbot stopped hosting for 0 viewers
private final static String STOP_HOST_VIEWERS = ":tmi.twitch.tv HOSTTARGET #gikkman :- 5"; //Gikkbot stopped hosting for 0 viewers
public static void test(Consumer<String> twirkInput, TestConsumer<HostTarget> test ) throws Exception{ | TestResult resStart = test.assign(TestHostTarget::testStart); |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/hostTarget/TestHostTarget.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/enums/HOSTTARGET_MODE.java
// public enum HOSTTARGET_MODE {
// /**Indicates that we started hosting a channel*/
// START,
// /**Indicates that we stopped hosting a channel*/
// STOP }
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.enums.HOSTTARGET_MODE;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.hostTarget;
public class TestHostTarget {
private final static String START_HOST = ":tmi.twitch.tv HOSTTARGET #gikkman :gikkbot 1"; //Gikkman host Gikkbot for 1 viewer
private final static String STOP_HOST_NO_VIEWERS = ":tmi.twitch.tv HOSTTARGET #gikkman :-"; //Gikkbot stopped hosting for 0 viewers
private final static String STOP_HOST_VIEWERS = ":tmi.twitch.tv HOSTTARGET #gikkman :- 5"; //Gikkbot stopped hosting for 0 viewers
public static void test(Consumer<String> twirkInput, TestConsumer<HostTarget> test ) throws Exception{
TestResult resStart = test.assign(TestHostTarget::testStart);
twirkInput.accept(START_HOST);
resStart.await();
TestResult resStopNoView = test.assign(TestHostTarget::testStopNoView);
twirkInput.accept(STOP_HOST_NO_VIEWERS);
resStopNoView.await();
TestResult resStopView = test.assign(TestHostTarget::testStopView);
twirkInput.accept(STOP_HOST_VIEWERS);
resStopView.await();
}
static boolean testStart(HostTarget host){ | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/enums/HOSTTARGET_MODE.java
// public enum HOSTTARGET_MODE {
// /**Indicates that we started hosting a channel*/
// START,
// /**Indicates that we stopped hosting a channel*/
// STOP }
// Path: src/test/java/com/gikk/twirk/types/hostTarget/TestHostTarget.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.enums.HOSTTARGET_MODE;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.hostTarget;
public class TestHostTarget {
private final static String START_HOST = ":tmi.twitch.tv HOSTTARGET #gikkman :gikkbot 1"; //Gikkman host Gikkbot for 1 viewer
private final static String STOP_HOST_NO_VIEWERS = ":tmi.twitch.tv HOSTTARGET #gikkman :-"; //Gikkbot stopped hosting for 0 viewers
private final static String STOP_HOST_VIEWERS = ":tmi.twitch.tv HOSTTARGET #gikkman :- 5"; //Gikkbot stopped hosting for 0 viewers
public static void test(Consumer<String> twirkInput, TestConsumer<HostTarget> test ) throws Exception{
TestResult resStart = test.assign(TestHostTarget::testStart);
twirkInput.accept(START_HOST);
resStart.await();
TestResult resStopNoView = test.assign(TestHostTarget::testStopNoView);
twirkInput.accept(STOP_HOST_NO_VIEWERS);
resStopNoView.await();
TestResult resStopView = test.assign(TestHostTarget::testStopView);
twirkInput.accept(STOP_HOST_VIEWERS);
resStopView.await();
}
static boolean testStart(HostTarget host){ | doTest(host, START_HOST, HOSTTARGET_MODE.START, 1, "gikkbot" ); |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/notice/TestNotice.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/enums/NOTICE_EVENT.java
// public enum NOTICE_EVENT {
// /** [User] is already banned in this room. */
// ALREADY_BANNED("already_banned"),
// /** This room is not in emote-only mode. */
// ALREADY_EMOTES_ONLY_OFF("already_emote_only_off"),
// /** This room is already in emote-only mode. */
// ALREADY_EMOTES_ONLY_ON("already_emote_only_on"),
// /** This room is not in r9k mode. */
// ALREADY_R9K_OFF("already_r9k_off"),
// /** This room is already in r9k mode. */
// ALREADY_R9K_ON("already_r9k_on"),
// /** This room is not in subscribers-only mode. */
// ALREADY_SUBS_OFF("already_subs_off"),
// /** This room is already in subscribers-only mode. */
// ALREADY_SUBS_ON("already_subs_on"),
// /** This channel is hosting [Channel}. */
// BAD_HOST_HOSTING("bad_host_hosting"),
// /** [User] is not banned from this room. (See #getTargetDisplayName())*/
// BAD_UNBAN_NO_BAN("bad_unban_no_ban"),
// /** [User] is banned from this room. */
// BAN_SUCCESS("ban_success"),
// /** This room is no longer in emote-only mode. */
// EMOTE_ONLY_OFF("emote_only_off"),
// /** This room is now in emote-only mode. */
// EMOTE_ONLY_ON("emote_only_on"),
// /** Exited host mode. */
// HOST_OFF("host_off"),
// /** Now hosting [Channel]. */
// HOST_ON("host_on"),
// /** There are [Number] host commands remaining this half hour. */
// HOST_REMAINING("hosts_remaining"),
// /** This channel is suspended. */
// MESSAGE_CHANNEL_SUSPENDED("msg_channel_suspended"),
// /**This room is no longer in r9k mode. */
// R9K_OFF("r9k_off"),
// /** This room is now in r9k mode. */
// R9K_ON("r9k_on"),
// /** This room is no longer in slow mode. */
// SLOW_OFF("slow_off"),
// /** This room is now in slow mode. You may send messages every [Seconds] seconds.*/
// SLOW_ON("slow_on"),
// /** This room is no longer in subscribers-only mode. */
// SUBSCRIBER_MODE_OFF("subs_off"),
// /** This room is now in subscribers-only mode. */
// SUBSCRIBER_MODE_ON("subs_on"),
// /** [User] has been timed out for [Seconds] seconds. */
// TIMEOUT_SUCCESS("timeout_success"),
// /** [User] is no longer banned from this chat room. */
// UNBAN_SUCCESS("unban_success"),
// /** Unrecognized command: [Command] */
// UNRECOGNIZED_COMMAND("unrecognized_cmd"),
//
// /**We default to this one if we do not recognize this NOTICE's event type. Since Twitch uses a lot of different undocumented
// * NOTICE types, there is need for a event type that works as a catch-all. <br>
// * Consider parsing the {@link Notice#getRawNoticeID()}.
// */
// OTHER("");
//
// private final String msgID;
// private NOTICE_EVENT(String msgID){
// this.msgID = msgID;
// }
//
// private final static Map<String, NOTICE_EVENT> mapping = new HashMap<>();
// static{
// for(NOTICE_EVENT n : values()){
// mapping.put(n.msgID, n);
// }
// }
//
// public static NOTICE_EVENT of(String msgID){
// return mapping.getOrDefault(msgID, OTHER);
// }
// };
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.enums.NOTICE_EVENT;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.notice;
public class TestNotice {
private final static String SUB_MODE_ON_MESSAGE = "@msg-id=subs_on :tmi.twitch.tv NOTICE #gikkman :This room is now in subscribers-only mode.";
private final static String SUB_MODE_OFF_MESSAGE = "@msg-id=subs_off :tmi.twitch.tv NOTICE #gikkman :This room is no longer in subscribers-only mode.";
private final static String R9K_MODE_ON_MESSAGE = "@msg-id=r9k_on :tmi.twitch.tv NOTICE #gikkman :This room is now in r9k mode.";
private final static String R9K_MODE_OFF_MESSAGE = "@msg-id=r9k_off :tmi.twitch.tv NOTICE #gikkman :This room is no longer in r9k mode.";
private final static String CUSTOM_MESSAGE = "@msg-id=msg_channel_suspended :tmi.twitch.tv NOTICE #gikkman :This ma' message now.";
| // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/enums/NOTICE_EVENT.java
// public enum NOTICE_EVENT {
// /** [User] is already banned in this room. */
// ALREADY_BANNED("already_banned"),
// /** This room is not in emote-only mode. */
// ALREADY_EMOTES_ONLY_OFF("already_emote_only_off"),
// /** This room is already in emote-only mode. */
// ALREADY_EMOTES_ONLY_ON("already_emote_only_on"),
// /** This room is not in r9k mode. */
// ALREADY_R9K_OFF("already_r9k_off"),
// /** This room is already in r9k mode. */
// ALREADY_R9K_ON("already_r9k_on"),
// /** This room is not in subscribers-only mode. */
// ALREADY_SUBS_OFF("already_subs_off"),
// /** This room is already in subscribers-only mode. */
// ALREADY_SUBS_ON("already_subs_on"),
// /** This channel is hosting [Channel}. */
// BAD_HOST_HOSTING("bad_host_hosting"),
// /** [User] is not banned from this room. (See #getTargetDisplayName())*/
// BAD_UNBAN_NO_BAN("bad_unban_no_ban"),
// /** [User] is banned from this room. */
// BAN_SUCCESS("ban_success"),
// /** This room is no longer in emote-only mode. */
// EMOTE_ONLY_OFF("emote_only_off"),
// /** This room is now in emote-only mode. */
// EMOTE_ONLY_ON("emote_only_on"),
// /** Exited host mode. */
// HOST_OFF("host_off"),
// /** Now hosting [Channel]. */
// HOST_ON("host_on"),
// /** There are [Number] host commands remaining this half hour. */
// HOST_REMAINING("hosts_remaining"),
// /** This channel is suspended. */
// MESSAGE_CHANNEL_SUSPENDED("msg_channel_suspended"),
// /**This room is no longer in r9k mode. */
// R9K_OFF("r9k_off"),
// /** This room is now in r9k mode. */
// R9K_ON("r9k_on"),
// /** This room is no longer in slow mode. */
// SLOW_OFF("slow_off"),
// /** This room is now in slow mode. You may send messages every [Seconds] seconds.*/
// SLOW_ON("slow_on"),
// /** This room is no longer in subscribers-only mode. */
// SUBSCRIBER_MODE_OFF("subs_off"),
// /** This room is now in subscribers-only mode. */
// SUBSCRIBER_MODE_ON("subs_on"),
// /** [User] has been timed out for [Seconds] seconds. */
// TIMEOUT_SUCCESS("timeout_success"),
// /** [User] is no longer banned from this chat room. */
// UNBAN_SUCCESS("unban_success"),
// /** Unrecognized command: [Command] */
// UNRECOGNIZED_COMMAND("unrecognized_cmd"),
//
// /**We default to this one if we do not recognize this NOTICE's event type. Since Twitch uses a lot of different undocumented
// * NOTICE types, there is need for a event type that works as a catch-all. <br>
// * Consider parsing the {@link Notice#getRawNoticeID()}.
// */
// OTHER("");
//
// private final String msgID;
// private NOTICE_EVENT(String msgID){
// this.msgID = msgID;
// }
//
// private final static Map<String, NOTICE_EVENT> mapping = new HashMap<>();
// static{
// for(NOTICE_EVENT n : values()){
// mapping.put(n.msgID, n);
// }
// }
//
// public static NOTICE_EVENT of(String msgID){
// return mapping.getOrDefault(msgID, OTHER);
// }
// };
// Path: src/test/java/com/gikk/twirk/types/notice/TestNotice.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.enums.NOTICE_EVENT;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.notice;
public class TestNotice {
private final static String SUB_MODE_ON_MESSAGE = "@msg-id=subs_on :tmi.twitch.tv NOTICE #gikkman :This room is now in subscribers-only mode.";
private final static String SUB_MODE_OFF_MESSAGE = "@msg-id=subs_off :tmi.twitch.tv NOTICE #gikkman :This room is no longer in subscribers-only mode.";
private final static String R9K_MODE_ON_MESSAGE = "@msg-id=r9k_on :tmi.twitch.tv NOTICE #gikkman :This room is now in r9k mode.";
private final static String R9K_MODE_OFF_MESSAGE = "@msg-id=r9k_off :tmi.twitch.tv NOTICE #gikkman :This room is no longer in r9k mode.";
private final static String CUSTOM_MESSAGE = "@msg-id=msg_channel_suspended :tmi.twitch.tv NOTICE #gikkman :This ma' message now.";
| public static void test(Consumer<String> twirkInput, TestConsumer<Notice> test ) throws Exception{ |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/notice/TestNotice.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/enums/NOTICE_EVENT.java
// public enum NOTICE_EVENT {
// /** [User] is already banned in this room. */
// ALREADY_BANNED("already_banned"),
// /** This room is not in emote-only mode. */
// ALREADY_EMOTES_ONLY_OFF("already_emote_only_off"),
// /** This room is already in emote-only mode. */
// ALREADY_EMOTES_ONLY_ON("already_emote_only_on"),
// /** This room is not in r9k mode. */
// ALREADY_R9K_OFF("already_r9k_off"),
// /** This room is already in r9k mode. */
// ALREADY_R9K_ON("already_r9k_on"),
// /** This room is not in subscribers-only mode. */
// ALREADY_SUBS_OFF("already_subs_off"),
// /** This room is already in subscribers-only mode. */
// ALREADY_SUBS_ON("already_subs_on"),
// /** This channel is hosting [Channel}. */
// BAD_HOST_HOSTING("bad_host_hosting"),
// /** [User] is not banned from this room. (See #getTargetDisplayName())*/
// BAD_UNBAN_NO_BAN("bad_unban_no_ban"),
// /** [User] is banned from this room. */
// BAN_SUCCESS("ban_success"),
// /** This room is no longer in emote-only mode. */
// EMOTE_ONLY_OFF("emote_only_off"),
// /** This room is now in emote-only mode. */
// EMOTE_ONLY_ON("emote_only_on"),
// /** Exited host mode. */
// HOST_OFF("host_off"),
// /** Now hosting [Channel]. */
// HOST_ON("host_on"),
// /** There are [Number] host commands remaining this half hour. */
// HOST_REMAINING("hosts_remaining"),
// /** This channel is suspended. */
// MESSAGE_CHANNEL_SUSPENDED("msg_channel_suspended"),
// /**This room is no longer in r9k mode. */
// R9K_OFF("r9k_off"),
// /** This room is now in r9k mode. */
// R9K_ON("r9k_on"),
// /** This room is no longer in slow mode. */
// SLOW_OFF("slow_off"),
// /** This room is now in slow mode. You may send messages every [Seconds] seconds.*/
// SLOW_ON("slow_on"),
// /** This room is no longer in subscribers-only mode. */
// SUBSCRIBER_MODE_OFF("subs_off"),
// /** This room is now in subscribers-only mode. */
// SUBSCRIBER_MODE_ON("subs_on"),
// /** [User] has been timed out for [Seconds] seconds. */
// TIMEOUT_SUCCESS("timeout_success"),
// /** [User] is no longer banned from this chat room. */
// UNBAN_SUCCESS("unban_success"),
// /** Unrecognized command: [Command] */
// UNRECOGNIZED_COMMAND("unrecognized_cmd"),
//
// /**We default to this one if we do not recognize this NOTICE's event type. Since Twitch uses a lot of different undocumented
// * NOTICE types, there is need for a event type that works as a catch-all. <br>
// * Consider parsing the {@link Notice#getRawNoticeID()}.
// */
// OTHER("");
//
// private final String msgID;
// private NOTICE_EVENT(String msgID){
// this.msgID = msgID;
// }
//
// private final static Map<String, NOTICE_EVENT> mapping = new HashMap<>();
// static{
// for(NOTICE_EVENT n : values()){
// mapping.put(n.msgID, n);
// }
// }
//
// public static NOTICE_EVENT of(String msgID){
// return mapping.getOrDefault(msgID, OTHER);
// }
// };
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.enums.NOTICE_EVENT;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.notice;
public class TestNotice {
private final static String SUB_MODE_ON_MESSAGE = "@msg-id=subs_on :tmi.twitch.tv NOTICE #gikkman :This room is now in subscribers-only mode.";
private final static String SUB_MODE_OFF_MESSAGE = "@msg-id=subs_off :tmi.twitch.tv NOTICE #gikkman :This room is no longer in subscribers-only mode.";
private final static String R9K_MODE_ON_MESSAGE = "@msg-id=r9k_on :tmi.twitch.tv NOTICE #gikkman :This room is now in r9k mode.";
private final static String R9K_MODE_OFF_MESSAGE = "@msg-id=r9k_off :tmi.twitch.tv NOTICE #gikkman :This room is no longer in r9k mode.";
private final static String CUSTOM_MESSAGE = "@msg-id=msg_channel_suspended :tmi.twitch.tv NOTICE #gikkman :This ma' message now.";
public static void test(Consumer<String> twirkInput, TestConsumer<Notice> test ) throws Exception{ | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/enums/NOTICE_EVENT.java
// public enum NOTICE_EVENT {
// /** [User] is already banned in this room. */
// ALREADY_BANNED("already_banned"),
// /** This room is not in emote-only mode. */
// ALREADY_EMOTES_ONLY_OFF("already_emote_only_off"),
// /** This room is already in emote-only mode. */
// ALREADY_EMOTES_ONLY_ON("already_emote_only_on"),
// /** This room is not in r9k mode. */
// ALREADY_R9K_OFF("already_r9k_off"),
// /** This room is already in r9k mode. */
// ALREADY_R9K_ON("already_r9k_on"),
// /** This room is not in subscribers-only mode. */
// ALREADY_SUBS_OFF("already_subs_off"),
// /** This room is already in subscribers-only mode. */
// ALREADY_SUBS_ON("already_subs_on"),
// /** This channel is hosting [Channel}. */
// BAD_HOST_HOSTING("bad_host_hosting"),
// /** [User] is not banned from this room. (See #getTargetDisplayName())*/
// BAD_UNBAN_NO_BAN("bad_unban_no_ban"),
// /** [User] is banned from this room. */
// BAN_SUCCESS("ban_success"),
// /** This room is no longer in emote-only mode. */
// EMOTE_ONLY_OFF("emote_only_off"),
// /** This room is now in emote-only mode. */
// EMOTE_ONLY_ON("emote_only_on"),
// /** Exited host mode. */
// HOST_OFF("host_off"),
// /** Now hosting [Channel]. */
// HOST_ON("host_on"),
// /** There are [Number] host commands remaining this half hour. */
// HOST_REMAINING("hosts_remaining"),
// /** This channel is suspended. */
// MESSAGE_CHANNEL_SUSPENDED("msg_channel_suspended"),
// /**This room is no longer in r9k mode. */
// R9K_OFF("r9k_off"),
// /** This room is now in r9k mode. */
// R9K_ON("r9k_on"),
// /** This room is no longer in slow mode. */
// SLOW_OFF("slow_off"),
// /** This room is now in slow mode. You may send messages every [Seconds] seconds.*/
// SLOW_ON("slow_on"),
// /** This room is no longer in subscribers-only mode. */
// SUBSCRIBER_MODE_OFF("subs_off"),
// /** This room is now in subscribers-only mode. */
// SUBSCRIBER_MODE_ON("subs_on"),
// /** [User] has been timed out for [Seconds] seconds. */
// TIMEOUT_SUCCESS("timeout_success"),
// /** [User] is no longer banned from this chat room. */
// UNBAN_SUCCESS("unban_success"),
// /** Unrecognized command: [Command] */
// UNRECOGNIZED_COMMAND("unrecognized_cmd"),
//
// /**We default to this one if we do not recognize this NOTICE's event type. Since Twitch uses a lot of different undocumented
// * NOTICE types, there is need for a event type that works as a catch-all. <br>
// * Consider parsing the {@link Notice#getRawNoticeID()}.
// */
// OTHER("");
//
// private final String msgID;
// private NOTICE_EVENT(String msgID){
// this.msgID = msgID;
// }
//
// private final static Map<String, NOTICE_EVENT> mapping = new HashMap<>();
// static{
// for(NOTICE_EVENT n : values()){
// mapping.put(n.msgID, n);
// }
// }
//
// public static NOTICE_EVENT of(String msgID){
// return mapping.getOrDefault(msgID, OTHER);
// }
// };
// Path: src/test/java/com/gikk/twirk/types/notice/TestNotice.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.enums.NOTICE_EVENT;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.notice;
public class TestNotice {
private final static String SUB_MODE_ON_MESSAGE = "@msg-id=subs_on :tmi.twitch.tv NOTICE #gikkman :This room is now in subscribers-only mode.";
private final static String SUB_MODE_OFF_MESSAGE = "@msg-id=subs_off :tmi.twitch.tv NOTICE #gikkman :This room is no longer in subscribers-only mode.";
private final static String R9K_MODE_ON_MESSAGE = "@msg-id=r9k_on :tmi.twitch.tv NOTICE #gikkman :This room is now in r9k mode.";
private final static String R9K_MODE_OFF_MESSAGE = "@msg-id=r9k_off :tmi.twitch.tv NOTICE #gikkman :This room is no longer in r9k mode.";
private final static String CUSTOM_MESSAGE = "@msg-id=msg_channel_suspended :tmi.twitch.tv NOTICE #gikkman :This ma' message now.";
public static void test(Consumer<String> twirkInput, TestConsumer<Notice> test ) throws Exception{ | TestResult res1 = test.assign(TestNotice::testSubModeOn); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/users/TwitchUserImpl.java | // Path: src/main/java/com/gikk/twirk/enums/USER_TYPE.java
// public enum USER_TYPE{
// /** Type for the owner of the channel (i.e. the user with the
// * same user name as the channel's name. This type has the highest value, 9*/
// OWNER(9),
//
// /** Type for mods in the channel. This type has the second highest value, 6 */
// MOD(6),
//
// /** Type for Twitch's global mods. This type has a value of 4*/
// GLOBAL_MOD(4),
//
// /** Type for Twitch's admins. This type has a value of 4*/
// ADMIN(4),
//
// /** Type for Twitch's staff members. This type has a value of 4*/
// STAFF(4),
//
// /** Type for channel subscribers. This type has a value of 2.
// * Note that both Turbo and Subs are given this type.
// * For more granularity, check out {@link TwitchUser#isSub()} and {@link TwitchUser#isMod()}
// */
// SUBSCRIBER(2),
//
// /** Type for users that does not fit into any other classes. This type has a value of 0*/
// DEFAULT(0);
//
// /** This type's value. Useful for regulating which kind of users should trigger / can perform
// * certain actions. <br><br>
// *
// * For example:<br>
// * <pre><code>if( user.USER_TYPE.value == USER_TYPE.MOD.value )</code>
// * <code>doSomething();</code></pre>
// */
// public final int value;
//
// private USER_TYPE(int value) {
// this.value = value;
// }
// }
| import com.gikk.twirk.enums.USER_TYPE; | package com.gikk.twirk.types.users;
class TwitchUserImpl implements TwitchUser{
//***********************************************************
// VARIABLES
//***********************************************************
private final String userName;
private final String displayName;
private final boolean isOwner;
private final boolean isMod;
private final boolean isSub;
private final boolean isTurbo;
private final int color;
private final long userID; | // Path: src/main/java/com/gikk/twirk/enums/USER_TYPE.java
// public enum USER_TYPE{
// /** Type for the owner of the channel (i.e. the user with the
// * same user name as the channel's name. This type has the highest value, 9*/
// OWNER(9),
//
// /** Type for mods in the channel. This type has the second highest value, 6 */
// MOD(6),
//
// /** Type for Twitch's global mods. This type has a value of 4*/
// GLOBAL_MOD(4),
//
// /** Type for Twitch's admins. This type has a value of 4*/
// ADMIN(4),
//
// /** Type for Twitch's staff members. This type has a value of 4*/
// STAFF(4),
//
// /** Type for channel subscribers. This type has a value of 2.
// * Note that both Turbo and Subs are given this type.
// * For more granularity, check out {@link TwitchUser#isSub()} and {@link TwitchUser#isMod()}
// */
// SUBSCRIBER(2),
//
// /** Type for users that does not fit into any other classes. This type has a value of 0*/
// DEFAULT(0);
//
// /** This type's value. Useful for regulating which kind of users should trigger / can perform
// * certain actions. <br><br>
// *
// * For example:<br>
// * <pre><code>if( user.USER_TYPE.value == USER_TYPE.MOD.value )</code>
// * <code>doSomething();</code></pre>
// */
// public final int value;
//
// private USER_TYPE(int value) {
// this.value = value;
// }
// }
// Path: src/main/java/com/gikk/twirk/types/users/TwitchUserImpl.java
import com.gikk.twirk.enums.USER_TYPE;
package com.gikk.twirk.types.users;
class TwitchUserImpl implements TwitchUser{
//***********************************************************
// VARIABLES
//***********************************************************
private final String userName;
private final String displayName;
private final boolean isOwner;
private final boolean isMod;
private final boolean isSub;
private final boolean isTurbo;
private final int color;
private final long userID; | private final USER_TYPE userType; |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/usernotice/SubscriptionImpl.java | // Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/SubscriptionGift.java
// public interface SubscriptionGift {
// /**
// * Fetches the recipients display name (as configured by the user).
// * @return the display name
// */
// public String getRecipiantDisplayName();
//
// /**
// * Fetches the recipients user name (i.e. their login name).
// * @return the user name
// */
// public String getRecipiantUserName();
//
// /**
// *Fetches the recipients user ID
// * @return the user ID
// */
// public long getRecipiantUserID();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/SubscriptionPlan.java
// public enum SubscriptionPlan {
// /** Subscribed with Twitch Prime
// */
// SUB_PRIME("Prime", "Prime"),
//
// /** Subscribed with a 4.99$ plan
// */
// SUB_LOW("1000", "4.99$"),
//
// /** Subscribed with a 9.99$ plan
// */
// SUB_MID("2000", "9.99$"),
//
// /** Subscribed with a 24.99$ plan
// */
// SUB_HIGH("3000", "24.99$");
//
// private final String message;
// private final String value;
// private SubscriptionPlan(String msg, String val){
// this.message = msg;
// this.value = val;
// }
//
// public String getValue(){
// return value;
// }
//
// /**Attempts to parse which Subscription plan that's been used, given the
// * subscription notice message.
// * <p>
// * If no match is found (i.e. the input parameter is unknown) this defaults
// * to returning {@link SubscriptionPlan#SUB_LOW}
// *
// * @param paramSubPlan the sub-plan message
// * @return a SubscriptionPlan
// */
// public static SubscriptionPlan of(String paramSubPlan){
// for(SubscriptionPlan s : values()){
// if(s.message.equals(paramSubPlan)) {
// return s;
// }
// }
// return SUB_LOW;
// }
// }
| import com.gikk.twirk.types.usernotice.subtype.Subscription;
import com.gikk.twirk.types.usernotice.subtype.SubscriptionGift;
import com.gikk.twirk.types.usernotice.subtype.SubscriptionPlan;
import java.util.Optional; | package com.gikk.twirk.types.usernotice;
/**
*
* @author Gikkman
*/
class SubscriptionImpl implements Subscription {
private final SubscriptionPlan plan;
private final int months;
private final int streak;
private final boolean shareStreak;
private final String planName; | // Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/SubscriptionGift.java
// public interface SubscriptionGift {
// /**
// * Fetches the recipients display name (as configured by the user).
// * @return the display name
// */
// public String getRecipiantDisplayName();
//
// /**
// * Fetches the recipients user name (i.e. their login name).
// * @return the user name
// */
// public String getRecipiantUserName();
//
// /**
// *Fetches the recipients user ID
// * @return the user ID
// */
// public long getRecipiantUserID();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/SubscriptionPlan.java
// public enum SubscriptionPlan {
// /** Subscribed with Twitch Prime
// */
// SUB_PRIME("Prime", "Prime"),
//
// /** Subscribed with a 4.99$ plan
// */
// SUB_LOW("1000", "4.99$"),
//
// /** Subscribed with a 9.99$ plan
// */
// SUB_MID("2000", "9.99$"),
//
// /** Subscribed with a 24.99$ plan
// */
// SUB_HIGH("3000", "24.99$");
//
// private final String message;
// private final String value;
// private SubscriptionPlan(String msg, String val){
// this.message = msg;
// this.value = val;
// }
//
// public String getValue(){
// return value;
// }
//
// /**Attempts to parse which Subscription plan that's been used, given the
// * subscription notice message.
// * <p>
// * If no match is found (i.e. the input parameter is unknown) this defaults
// * to returning {@link SubscriptionPlan#SUB_LOW}
// *
// * @param paramSubPlan the sub-plan message
// * @return a SubscriptionPlan
// */
// public static SubscriptionPlan of(String paramSubPlan){
// for(SubscriptionPlan s : values()){
// if(s.message.equals(paramSubPlan)) {
// return s;
// }
// }
// return SUB_LOW;
// }
// }
// Path: src/main/java/com/gikk/twirk/types/usernotice/SubscriptionImpl.java
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import com.gikk.twirk.types.usernotice.subtype.SubscriptionGift;
import com.gikk.twirk.types.usernotice.subtype.SubscriptionPlan;
import java.util.Optional;
package com.gikk.twirk.types.usernotice;
/**
*
* @author Gikkman
*/
class SubscriptionImpl implements Subscription {
private final SubscriptionPlan plan;
private final int months;
private final int streak;
private final boolean shareStreak;
private final String planName; | private final Optional<SubscriptionGift> subGift; |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/users/UserstateBuilder.java | // Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
| import com.gikk.twirk.types.twitchMessage.TwitchMessage; | package com.gikk.twirk.types.users;
/**Constructs a {@link Userstate} object. To create a {@link Userstate} object, call the {@link #build(TwitchMessage)} method
*
* @author Gikkman
*
*/
public interface UserstateBuilder {
public static UserstateBuilder getDefault() {
return new DefaultUserstateBuilder();
}
/**Constructs a new {@link Userstate} object from a {@link TwitchMessage}, received from Twitch. The user
* is responsible for making sure that this message can actually be made into a {@link Userstate} object.
* Make sure that the COMMAND equals "USERSTATE"
*
* @param message The message we received from Twitch
* @return A {@link Userstate}, or <code>null</code> if a {@link Userstate} could not be created
*/ | // Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
// Path: src/main/java/com/gikk/twirk/types/users/UserstateBuilder.java
import com.gikk.twirk.types.twitchMessage.TwitchMessage;
package com.gikk.twirk.types.users;
/**Constructs a {@link Userstate} object. To create a {@link Userstate} object, call the {@link #build(TwitchMessage)} method
*
* @author Gikkman
*
*/
public interface UserstateBuilder {
public static UserstateBuilder getDefault() {
return new DefaultUserstateBuilder();
}
/**Constructs a new {@link Userstate} object from a {@link TwitchMessage}, received from Twitch. The user
* is responsible for making sure that this message can actually be made into a {@link Userstate} object.
* Make sure that the COMMAND equals "USERSTATE"
*
* @param message The message we received from Twitch
* @return A {@link Userstate}, or <code>null</code> if a {@link Userstate} could not be created
*/ | public Userstate build(TwitchMessage message); |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/emote/TestEmote.java | // Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessageBuilder.java
// public interface TwitchMessageBuilder {
//
// /**Constructs a new {@link TwitchMessage} object from a chat line received from Twitch.<br>
// * A valid chat line has 2-5 segments:<br>
// * <code>@TAG<optional> :PREFIX COMMAND TARGET<optional> :CONTENT<optional></code>
// * <br><br>
// * From this chat line, we create a {@link TwitchMessage}. If certain parts are not present, the corresponding
// * <code>get</code> method on the {@link TwitchMessage} will return an empty string.
// *
// * @param chatLine The chat line, <b>exactly</b> as received from Twitch
// * @return A {@link TwitchMessage}, or <code>null</code> if a {@link TwitchMessage} could not be created
// */
// public TwitchMessage build(String chatLine);
//
// static TwitchMessageBuilder getDefault(){
// return new DefaultTwitchMessageBuilder();
// }
// }
| import com.gikk.twirk.types.twitchMessage.TwitchMessage;
import com.gikk.twirk.types.twitchMessage.TwitchMessageBuilder;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*; | package com.gikk.twirk.types.emote;
/**
*
* @author Gikkman
*/
public class TestEmote {
@Test
public void noEmotesTest_whenNoEmotesNodeInTag_thenParsesNoEmotes(){
// Given
String input = "@badges=;color=;display-name=Gikkman;mod=0;room-id=1;subscriber=0;turbo=0;user-id=1;user-type= :gikkman!gikkman@gikkman.tmi.twitch.tv PRIVMSG #gikkman :userMessage";
// When | // Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessageBuilder.java
// public interface TwitchMessageBuilder {
//
// /**Constructs a new {@link TwitchMessage} object from a chat line received from Twitch.<br>
// * A valid chat line has 2-5 segments:<br>
// * <code>@TAG<optional> :PREFIX COMMAND TARGET<optional> :CONTENT<optional></code>
// * <br><br>
// * From this chat line, we create a {@link TwitchMessage}. If certain parts are not present, the corresponding
// * <code>get</code> method on the {@link TwitchMessage} will return an empty string.
// *
// * @param chatLine The chat line, <b>exactly</b> as received from Twitch
// * @return A {@link TwitchMessage}, or <code>null</code> if a {@link TwitchMessage} could not be created
// */
// public TwitchMessage build(String chatLine);
//
// static TwitchMessageBuilder getDefault(){
// return new DefaultTwitchMessageBuilder();
// }
// }
// Path: src/test/java/com/gikk/twirk/types/emote/TestEmote.java
import com.gikk.twirk.types.twitchMessage.TwitchMessage;
import com.gikk.twirk.types.twitchMessage.TwitchMessageBuilder;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*;
package com.gikk.twirk.types.emote;
/**
*
* @author Gikkman
*/
public class TestEmote {
@Test
public void noEmotesTest_whenNoEmotesNodeInTag_thenParsesNoEmotes(){
// Given
String input = "@badges=;color=;display-name=Gikkman;mod=0;room-id=1;subscriber=0;turbo=0;user-id=1;user-type= :gikkman!gikkman@gikkman.tmi.twitch.tv PRIVMSG #gikkman :userMessage";
// When | TwitchMessage message = TwitchMessageBuilder.getDefault().build(input); |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/emote/TestEmote.java | // Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessageBuilder.java
// public interface TwitchMessageBuilder {
//
// /**Constructs a new {@link TwitchMessage} object from a chat line received from Twitch.<br>
// * A valid chat line has 2-5 segments:<br>
// * <code>@TAG<optional> :PREFIX COMMAND TARGET<optional> :CONTENT<optional></code>
// * <br><br>
// * From this chat line, we create a {@link TwitchMessage}. If certain parts are not present, the corresponding
// * <code>get</code> method on the {@link TwitchMessage} will return an empty string.
// *
// * @param chatLine The chat line, <b>exactly</b> as received from Twitch
// * @return A {@link TwitchMessage}, or <code>null</code> if a {@link TwitchMessage} could not be created
// */
// public TwitchMessage build(String chatLine);
//
// static TwitchMessageBuilder getDefault(){
// return new DefaultTwitchMessageBuilder();
// }
// }
| import com.gikk.twirk.types.twitchMessage.TwitchMessage;
import com.gikk.twirk.types.twitchMessage.TwitchMessageBuilder;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*; | package com.gikk.twirk.types.emote;
/**
*
* @author Gikkman
*/
public class TestEmote {
@Test
public void noEmotesTest_whenNoEmotesNodeInTag_thenParsesNoEmotes(){
// Given
String input = "@badges=;color=;display-name=Gikkman;mod=0;room-id=1;subscriber=0;turbo=0;user-id=1;user-type= :gikkman!gikkman@gikkman.tmi.twitch.tv PRIVMSG #gikkman :userMessage";
// When | // Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessageBuilder.java
// public interface TwitchMessageBuilder {
//
// /**Constructs a new {@link TwitchMessage} object from a chat line received from Twitch.<br>
// * A valid chat line has 2-5 segments:<br>
// * <code>@TAG<optional> :PREFIX COMMAND TARGET<optional> :CONTENT<optional></code>
// * <br><br>
// * From this chat line, we create a {@link TwitchMessage}. If certain parts are not present, the corresponding
// * <code>get</code> method on the {@link TwitchMessage} will return an empty string.
// *
// * @param chatLine The chat line, <b>exactly</b> as received from Twitch
// * @return A {@link TwitchMessage}, or <code>null</code> if a {@link TwitchMessage} could not be created
// */
// public TwitchMessage build(String chatLine);
//
// static TwitchMessageBuilder getDefault(){
// return new DefaultTwitchMessageBuilder();
// }
// }
// Path: src/test/java/com/gikk/twirk/types/emote/TestEmote.java
import com.gikk.twirk.types.twitchMessage.TwitchMessage;
import com.gikk.twirk.types.twitchMessage.TwitchMessageBuilder;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*;
package com.gikk.twirk.types.emote;
/**
*
* @author Gikkman
*/
public class TestEmote {
@Test
public void noEmotesTest_whenNoEmotesNodeInTag_thenParsesNoEmotes(){
// Given
String input = "@badges=;color=;display-name=Gikkman;mod=0;room-id=1;subscriber=0;turbo=0;user-id=1;user-type= :gikkman!gikkman@gikkman.tmi.twitch.tv PRIVMSG #gikkman :userMessage";
// When | TwitchMessage message = TwitchMessageBuilder.getDefault().build(input); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/users/Userstate.java | // Path: src/main/java/com/gikk/twirk/enums/USER_TYPE.java
// public enum USER_TYPE{
// /** Type for the owner of the channel (i.e. the user with the
// * same user name as the channel's name. This type has the highest value, 9*/
// OWNER(9),
//
// /** Type for mods in the channel. This type has the second highest value, 6 */
// MOD(6),
//
// /** Type for Twitch's global mods. This type has a value of 4*/
// GLOBAL_MOD(4),
//
// /** Type for Twitch's admins. This type has a value of 4*/
// ADMIN(4),
//
// /** Type for Twitch's staff members. This type has a value of 4*/
// STAFF(4),
//
// /** Type for channel subscribers. This type has a value of 2.
// * Note that both Turbo and Subs are given this type.
// * For more granularity, check out {@link TwitchUser#isSub()} and {@link TwitchUser#isMod()}
// */
// SUBSCRIBER(2),
//
// /** Type for users that does not fit into any other classes. This type has a value of 0*/
// DEFAULT(0);
//
// /** This type's value. Useful for regulating which kind of users should trigger / can perform
// * certain actions. <br><br>
// *
// * For example:<br>
// * <pre><code>if( user.USER_TYPE.value == USER_TYPE.MOD.value )</code>
// * <code>doSomething();</code></pre>
// */
// public final int value;
//
// private USER_TYPE(int value) {
// this.value = value;
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/AbstractType.java
// public interface AbstractType {
// /**Get the raw chat line, which this type was constructed from
// *
// * @return The raw chat line, just as seen from the server
// */
// public String getRaw();
// }
| import com.gikk.twirk.enums.USER_TYPE;
import com.gikk.twirk.types.AbstractType; | package com.gikk.twirk.types.users;
/**Class for representing a CLEARCHAT from Twitch.<br><br>
*
* Twitch sends us USERSTATE as a response whenever we send them a message. The USERSTATE message will tell
* us certain properties related to ourselves, such as our display name, our color, if we're mod and so on. Objects
* of this class can thus be used to inspect what properties we have on Twitch's side.<br><br>
*
* For documentation about how Twitch communicates via IRC,
* see <a href="https://github.com/justintv/Twitch-API/blob/master/IRC.md">
* https://github.com/justintv/Twitch-API/blob/master/IRC.md </a>
*
* @author Gikkman
*
*/
public interface Userstate extends AbstractType{
/**Retrieves our display color, as a hex-number. <br>
* If we have no color set on Twitch's side, a semi-random color will be generated
*
* @return Our display color
*/
public int getColor();
/**Retrieves our display name, as seen in chat on Twitch
*
* @return Our display name
*/
public String getDisplayName();
/**Retrieves information on whether we are a mod in this channel or not.
*
* @return <code>true</code> if we are mod
*/
public boolean isMod();
/**Retrieves information on whether we are a sub in this channel or not.
*
* @return <code>true</code> if we are sub
*/
public boolean isSub();
/**Retrieves information on whether we have Turbo, or not
*
* @return <code>true</code> if we have turbo
*/
public boolean isTurbo();
/**Retrieves information on what type of user we are in this channel. See {@link USER_TYPE}
*
* @return Our {@link USER_TYPE}
*/ | // Path: src/main/java/com/gikk/twirk/enums/USER_TYPE.java
// public enum USER_TYPE{
// /** Type for the owner of the channel (i.e. the user with the
// * same user name as the channel's name. This type has the highest value, 9*/
// OWNER(9),
//
// /** Type for mods in the channel. This type has the second highest value, 6 */
// MOD(6),
//
// /** Type for Twitch's global mods. This type has a value of 4*/
// GLOBAL_MOD(4),
//
// /** Type for Twitch's admins. This type has a value of 4*/
// ADMIN(4),
//
// /** Type for Twitch's staff members. This type has a value of 4*/
// STAFF(4),
//
// /** Type for channel subscribers. This type has a value of 2.
// * Note that both Turbo and Subs are given this type.
// * For more granularity, check out {@link TwitchUser#isSub()} and {@link TwitchUser#isMod()}
// */
// SUBSCRIBER(2),
//
// /** Type for users that does not fit into any other classes. This type has a value of 0*/
// DEFAULT(0);
//
// /** This type's value. Useful for regulating which kind of users should trigger / can perform
// * certain actions. <br><br>
// *
// * For example:<br>
// * <pre><code>if( user.USER_TYPE.value == USER_TYPE.MOD.value )</code>
// * <code>doSomething();</code></pre>
// */
// public final int value;
//
// private USER_TYPE(int value) {
// this.value = value;
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/AbstractType.java
// public interface AbstractType {
// /**Get the raw chat line, which this type was constructed from
// *
// * @return The raw chat line, just as seen from the server
// */
// public String getRaw();
// }
// Path: src/main/java/com/gikk/twirk/types/users/Userstate.java
import com.gikk.twirk.enums.USER_TYPE;
import com.gikk.twirk.types.AbstractType;
package com.gikk.twirk.types.users;
/**Class for representing a CLEARCHAT from Twitch.<br><br>
*
* Twitch sends us USERSTATE as a response whenever we send them a message. The USERSTATE message will tell
* us certain properties related to ourselves, such as our display name, our color, if we're mod and so on. Objects
* of this class can thus be used to inspect what properties we have on Twitch's side.<br><br>
*
* For documentation about how Twitch communicates via IRC,
* see <a href="https://github.com/justintv/Twitch-API/blob/master/IRC.md">
* https://github.com/justintv/Twitch-API/blob/master/IRC.md </a>
*
* @author Gikkman
*
*/
public interface Userstate extends AbstractType{
/**Retrieves our display color, as a hex-number. <br>
* If we have no color set on Twitch's side, a semi-random color will be generated
*
* @return Our display color
*/
public int getColor();
/**Retrieves our display name, as seen in chat on Twitch
*
* @return Our display name
*/
public String getDisplayName();
/**Retrieves information on whether we are a mod in this channel or not.
*
* @return <code>true</code> if we are mod
*/
public boolean isMod();
/**Retrieves information on whether we are a sub in this channel or not.
*
* @return <code>true</code> if we are sub
*/
public boolean isSub();
/**Retrieves information on whether we have Turbo, or not
*
* @return <code>true</code> if we have turbo
*/
public boolean isTurbo();
/**Retrieves information on what type of user we are in this channel. See {@link USER_TYPE}
*
* @return Our {@link USER_TYPE}
*/ | public USER_TYPE getUserType(); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/mode/ModeBuilder.java | // Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
| import com.gikk.twirk.types.twitchMessage.TwitchMessage; | package com.gikk.twirk.types.mode;
/**Constructs a {@link Mode} object. To create a {@link Mode} object, call the {@link #build(TwitchMessage)} method
*
* @author Gikkman
*
*/
public interface ModeBuilder {
public static ModeBuilder getDefault() {
return new DefaultModeBuilder();
}
/**Constructs a new {@link Mode} object from a {@link TwitchMessage}, received from Twitch. The user
* is responsible for making sure that this message can actually be made into a {@link Mode} object.
* Make sure that the COMMAND of the message equals "MODE"
*
* @param message The message we received from Twitch
* @return A {@link Mode}, or <code>null</code> if a {@link Mode} could not be created
*/ | // Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
// Path: src/main/java/com/gikk/twirk/types/mode/ModeBuilder.java
import com.gikk.twirk.types.twitchMessage.TwitchMessage;
package com.gikk.twirk.types.mode;
/**Constructs a {@link Mode} object. To create a {@link Mode} object, call the {@link #build(TwitchMessage)} method
*
* @author Gikkman
*
*/
public interface ModeBuilder {
public static ModeBuilder getDefault() {
return new DefaultModeBuilder();
}
/**Constructs a new {@link Mode} object from a {@link TwitchMessage}, received from Twitch. The user
* is responsible for making sure that this message can actually be made into a {@link Mode} object.
* Make sure that the COMMAND of the message equals "MODE"
*
* @param message The message we received from Twitch
* @return A {@link Mode}, or <code>null</code> if a {@link Mode} could not be created
*/ | public Mode build(TwitchMessage message); |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/TestNamelist.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import java.util.Arrays;
import java.util.Collection;
import java.util.function.Consumer;
import org.junit.Assert; | package com.gikk.twirk.types;
/**
*
* @author Gikkman
*/
public class TestNamelist {
public static void test(Consumer<String> twirkIn, | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
// Path: src/test/java/com/gikk/twirk/types/TestNamelist.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import java.util.Arrays;
import java.util.Collection;
import java.util.function.Consumer;
import org.junit.Assert;
package com.gikk.twirk.types;
/**
*
* @author Gikkman
*/
public class TestNamelist {
public static void test(Consumer<String> twirkIn, | TestConsumer<Collection<String>> test) throws Exception{ |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/TestNamelist.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import java.util.Arrays;
import java.util.Collection;
import java.util.function.Consumer;
import org.junit.Assert; | package com.gikk.twirk.types;
/**
*
* @author Gikkman
*/
public class TestNamelist {
public static void test(Consumer<String> twirkIn,
TestConsumer<Collection<String>> test) throws Exception{ | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
// Path: src/test/java/com/gikk/twirk/types/TestNamelist.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import java.util.Arrays;
import java.util.Collection;
import java.util.function.Consumer;
import org.junit.Assert;
package com.gikk.twirk.types;
/**
*
* @author Gikkman
*/
public class TestNamelist {
public static void test(Consumer<String> twirkIn,
TestConsumer<Collection<String>> test) throws Exception{ | TestResult res = test.assign( (list) -> { |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/notice/NoticeBuilder.java | // Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
| import com.gikk.twirk.types.twitchMessage.TwitchMessage; | package com.gikk.twirk.types.notice;
/**Constructs a {@link Notice} object. To create a {@link Notice} object, call the {@link #build(TwitchMessage)} method
*
* @author Gikkman
*
*/
public interface NoticeBuilder {
public static NoticeBuilder getDefault() {
return new DefaultNoticeBuilder();
}
/**Constructs a new {@link Notice} object from a {@link TwitchMessage}, received from Twitch. The user
* is responsible for making sure that this message can actually be made into a {@link Notice} object.
* Make sure that the COMMAND of the message equals "NOTICE"
*
* @param message The message we received from Twitch
* @return A {@link Notice}, or <code>null</code> if a {@link Notice} could not be created
*/ | // Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
// Path: src/main/java/com/gikk/twirk/types/notice/NoticeBuilder.java
import com.gikk.twirk.types.twitchMessage.TwitchMessage;
package com.gikk.twirk.types.notice;
/**Constructs a {@link Notice} object. To create a {@link Notice} object, call the {@link #build(TwitchMessage)} method
*
* @author Gikkman
*
*/
public interface NoticeBuilder {
public static NoticeBuilder getDefault() {
return new DefaultNoticeBuilder();
}
/**Constructs a new {@link Notice} object from a {@link TwitchMessage}, received from Twitch. The user
* is responsible for making sure that this message can actually be made into a {@link Notice} object.
* Make sure that the COMMAND of the message equals "NOTICE"
*
* @param message The message we received from Twitch
* @return A {@link Notice}, or <code>null</code> if a {@link Notice} could not be created
*/ | public Notice build(TwitchMessage message); |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/clearChat/TestClearChat.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/enums/CLEARCHAT_MODE.java
// public enum CLEARCHAT_MODE{
// /** A user has been purged/banned
// */
// USER,
//
// /** The entire chat has been pruged
// */
// COMPLETE };
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.enums.CLEARCHAT_MODE;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.clearChat;
public class TestClearChat {
private static final String COMPLETE = ":tmi.twitch.tv CLEARCHAT #gikkman";
private static final String DURATION_NO_REASON = "@ban-duration=20;ban-reason= :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String NO_DURATION_NO_REASON = "@ban-reason= :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String DURATION_REASON = "@ban-duration=10;ban-reason=Bad :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String NO_DURATION_REASON = "@ban-reason=Bad\\sargument :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
| // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/enums/CLEARCHAT_MODE.java
// public enum CLEARCHAT_MODE{
// /** A user has been purged/banned
// */
// USER,
//
// /** The entire chat has been pruged
// */
// COMPLETE };
// Path: src/test/java/com/gikk/twirk/types/clearChat/TestClearChat.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.enums.CLEARCHAT_MODE;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.clearChat;
public class TestClearChat {
private static final String COMPLETE = ":tmi.twitch.tv CLEARCHAT #gikkman";
private static final String DURATION_NO_REASON = "@ban-duration=20;ban-reason= :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String NO_DURATION_NO_REASON = "@ban-reason= :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String DURATION_REASON = "@ban-duration=10;ban-reason=Bad :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String NO_DURATION_REASON = "@ban-reason=Bad\\sargument :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
| public static void test(Consumer<String> twirkInput, TestConsumer<ClearChat> test ) throws Exception{ |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/clearChat/TestClearChat.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/enums/CLEARCHAT_MODE.java
// public enum CLEARCHAT_MODE{
// /** A user has been purged/banned
// */
// USER,
//
// /** The entire chat has been pruged
// */
// COMPLETE };
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.enums.CLEARCHAT_MODE;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.clearChat;
public class TestClearChat {
private static final String COMPLETE = ":tmi.twitch.tv CLEARCHAT #gikkman";
private static final String DURATION_NO_REASON = "@ban-duration=20;ban-reason= :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String NO_DURATION_NO_REASON = "@ban-reason= :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String DURATION_REASON = "@ban-duration=10;ban-reason=Bad :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String NO_DURATION_REASON = "@ban-reason=Bad\\sargument :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
public static void test(Consumer<String> twirkInput, TestConsumer<ClearChat> test ) throws Exception{ | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/enums/CLEARCHAT_MODE.java
// public enum CLEARCHAT_MODE{
// /** A user has been purged/banned
// */
// USER,
//
// /** The entire chat has been pruged
// */
// COMPLETE };
// Path: src/test/java/com/gikk/twirk/types/clearChat/TestClearChat.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.enums.CLEARCHAT_MODE;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.clearChat;
public class TestClearChat {
private static final String COMPLETE = ":tmi.twitch.tv CLEARCHAT #gikkman";
private static final String DURATION_NO_REASON = "@ban-duration=20;ban-reason= :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String NO_DURATION_NO_REASON = "@ban-reason= :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String DURATION_REASON = "@ban-duration=10;ban-reason=Bad :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String NO_DURATION_REASON = "@ban-reason=Bad\\sargument :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
public static void test(Consumer<String> twirkInput, TestConsumer<ClearChat> test ) throws Exception{ | TestResult resComplete = test.assign(TestClearChat::testComplete); |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/clearChat/TestClearChat.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/enums/CLEARCHAT_MODE.java
// public enum CLEARCHAT_MODE{
// /** A user has been purged/banned
// */
// USER,
//
// /** The entire chat has been pruged
// */
// COMPLETE };
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.enums.CLEARCHAT_MODE;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.clearChat;
public class TestClearChat {
private static final String COMPLETE = ":tmi.twitch.tv CLEARCHAT #gikkman";
private static final String DURATION_NO_REASON = "@ban-duration=20;ban-reason= :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String NO_DURATION_NO_REASON = "@ban-reason= :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String DURATION_REASON = "@ban-duration=10;ban-reason=Bad :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String NO_DURATION_REASON = "@ban-reason=Bad\\sargument :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
public static void test(Consumer<String> twirkInput, TestConsumer<ClearChat> test ) throws Exception{
TestResult resComplete = test.assign(TestClearChat::testComplete);
twirkInput.accept(COMPLETE);
resComplete.await();
TestResult resDNR = test.assign(TestClearChat::testDurationNoReason);
twirkInput.accept(DURATION_NO_REASON);
resDNR.await();
TestResult resNDNR = test.assign(TestClearChat::testNoDurationNoReason);
twirkInput.accept(NO_DURATION_NO_REASON);
resNDNR.await();
TestResult resDR = test.assign(TestClearChat::testDurationReason);
twirkInput.accept(DURATION_REASON);
resDR.await();
TestResult resNDR = test.assign(TestClearChat::testNoDurationReason);
twirkInput.accept(NO_DURATION_REASON);
resNDR.await();
}
static boolean testComplete(ClearChat c){ | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/enums/CLEARCHAT_MODE.java
// public enum CLEARCHAT_MODE{
// /** A user has been purged/banned
// */
// USER,
//
// /** The entire chat has been pruged
// */
// COMPLETE };
// Path: src/test/java/com/gikk/twirk/types/clearChat/TestClearChat.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.enums.CLEARCHAT_MODE;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.clearChat;
public class TestClearChat {
private static final String COMPLETE = ":tmi.twitch.tv CLEARCHAT #gikkman";
private static final String DURATION_NO_REASON = "@ban-duration=20;ban-reason= :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String NO_DURATION_NO_REASON = "@ban-reason= :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String DURATION_REASON = "@ban-duration=10;ban-reason=Bad :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
private static final String NO_DURATION_REASON = "@ban-reason=Bad\\sargument :tmi.twitch.tv CLEARCHAT #gikkman :gikkbot";
public static void test(Consumer<String> twirkInput, TestConsumer<ClearChat> test ) throws Exception{
TestResult resComplete = test.assign(TestClearChat::testComplete);
twirkInput.accept(COMPLETE);
resComplete.await();
TestResult resDNR = test.assign(TestClearChat::testDurationNoReason);
twirkInput.accept(DURATION_NO_REASON);
resDNR.await();
TestResult resNDNR = test.assign(TestClearChat::testNoDurationNoReason);
twirkInput.accept(NO_DURATION_NO_REASON);
resNDNR.await();
TestResult resDR = test.assign(TestClearChat::testDurationReason);
twirkInput.accept(DURATION_REASON);
resDR.await();
TestResult resNDR = test.assign(TestClearChat::testNoDurationReason);
twirkInput.accept(NO_DURATION_REASON);
resNDR.await();
}
static boolean testComplete(ClearChat c){ | test(c, CLEARCHAT_MODE.COMPLETE, "", -1, ""); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/emote/Emote.java | // Path: src/main/java/com/gikk/twirk/enums/EMOTE_SIZE.java
// public enum EMOTE_SIZE{
// SMALL("/1.0"),
// MEDIUM("/2.0"),
// LARGE("/3.0");
// public final String value;
// private EMOTE_SIZE(String val){ this.value = val; }
// }
| import java.util.LinkedList;
import com.gikk.twirk.enums.EMOTE_SIZE; | package com.gikk.twirk.types.emote;
/**Class for representing a Twitch emote, which can be embedded into chat messages.<br><br>
*
* An emote has three features: <ul>
* <li>EmoteID - The numeric ID for the emote.
* <li>Pattern - The emote's string pattern (Ex. 'Kappa')
* <li>Indices - For each time an emote is present in a message, the emotes begin- and end index must be listed. Begin is inclusive, end is exclusive
* </ul>
* For example, if the message is: {@code Kappa PogChamp Kappa}<br> the TwirkEmote for Kappa will be:<ul>
* <li>EmoteID = 25
* <li>Pattern = Kappa
* <li>Indices = (0,5), (15,20)
*
* @author Gikkman
*
*/
public interface Emote {
/** Fetches the emotes ID as String. This became necessary after Twitch start
* including other characters than numbers in emote IDs
*
* @return The emotes ID
*/
String getEmoteIDString();
/** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
*
* For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
* <li> (0,5)
* <li> (15,20)
* </ul>
*
* @return The indices this emote takes up in the associated message
*/
LinkedList<EmoteIndices> getIndices();
/** The emote's pattern. For example: 'Kappa'
*
* @return The emote's pattern
*/
String getPattern();
/**Emote images can be downloaded from Twitch's server, and come in three
* sizes. Use this method to get the address for the emote.
*
* @param imageSize Emotes comes in three sizes. Specify which size you want
* @return The address for the emote's image
*/ | // Path: src/main/java/com/gikk/twirk/enums/EMOTE_SIZE.java
// public enum EMOTE_SIZE{
// SMALL("/1.0"),
// MEDIUM("/2.0"),
// LARGE("/3.0");
// public final String value;
// private EMOTE_SIZE(String val){ this.value = val; }
// }
// Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
import java.util.LinkedList;
import com.gikk.twirk.enums.EMOTE_SIZE;
package com.gikk.twirk.types.emote;
/**Class for representing a Twitch emote, which can be embedded into chat messages.<br><br>
*
* An emote has three features: <ul>
* <li>EmoteID - The numeric ID for the emote.
* <li>Pattern - The emote's string pattern (Ex. 'Kappa')
* <li>Indices - For each time an emote is present in a message, the emotes begin- and end index must be listed. Begin is inclusive, end is exclusive
* </ul>
* For example, if the message is: {@code Kappa PogChamp Kappa}<br> the TwirkEmote for Kappa will be:<ul>
* <li>EmoteID = 25
* <li>Pattern = Kappa
* <li>Indices = (0,5), (15,20)
*
* @author Gikkman
*
*/
public interface Emote {
/** Fetches the emotes ID as String. This became necessary after Twitch start
* including other characters than numbers in emote IDs
*
* @return The emotes ID
*/
String getEmoteIDString();
/** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
*
* For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
* <li> (0,5)
* <li> (15,20)
* </ul>
*
* @return The indices this emote takes up in the associated message
*/
LinkedList<EmoteIndices> getIndices();
/** The emote's pattern. For example: 'Kappa'
*
* @return The emote's pattern
*/
String getPattern();
/**Emote images can be downloaded from Twitch's server, and come in three
* sizes. Use this method to get the address for the emote.
*
* @param imageSize Emotes comes in three sizes. Specify which size you want
* @return The address for the emote's image
*/ | String getEmoteImageUrl(EMOTE_SIZE imageSize); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/emote/EmoteParser.java | // Path: src/main/java/com/gikk/twirk/types/TagMap.java
// public interface TagMap extends Map<String, String>{
// //***********************************************************
// // PUBLIC
// //***********************************************************
// /**Fetches a certain field value that might have been present in the tag.
// * If the field was not present in the tag, or the field's value was empty,
// * this method returns <code>NULL</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if there was any. <code>NULL</code> otherwise
// */
// public String getAsString(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into an <code>int</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and an int. <code>-1</code> otherwise
// */
// public int getAsInt(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>long</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and a long. <code>-1</code> otherwise
// */
// long getAsLong(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>boolean</code>. For parsing purpose, <code>1</code> is interpreted
// * as <code>true</code>, anything else as <code>false</code>.
// * If the field was not present in the tag, or the field's value was empty, this method returns <code>false</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and could be parsed to a boolean. <code>false</code> otherwise
// */
// public boolean getAsBoolean(String identifier);
//
// /**Creates a new TagMap using the default TagMap implementation.
// *
// * @param tag
// * @return the default tag map
// */
// static TagMap getDefault(String tag){
// return new TagMapImpl(tag);
// }
// }
| import com.gikk.twirk.types.TagMap;
import java.util.List; | package com.gikk.twirk.types.emote;
public interface EmoteParser {
/**
* @deprecated Use {{@link #parseEmotes(TagMap, String)} instead. This will be removed in a future release}
*/
@Deprecated
static List<Emote> parseEmotes(String content, String tag) { | // Path: src/main/java/com/gikk/twirk/types/TagMap.java
// public interface TagMap extends Map<String, String>{
// //***********************************************************
// // PUBLIC
// //***********************************************************
// /**Fetches a certain field value that might have been present in the tag.
// * If the field was not present in the tag, or the field's value was empty,
// * this method returns <code>NULL</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if there was any. <code>NULL</code> otherwise
// */
// public String getAsString(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into an <code>int</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and an int. <code>-1</code> otherwise
// */
// public int getAsInt(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>long</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and a long. <code>-1</code> otherwise
// */
// long getAsLong(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>boolean</code>. For parsing purpose, <code>1</code> is interpreted
// * as <code>true</code>, anything else as <code>false</code>.
// * If the field was not present in the tag, or the field's value was empty, this method returns <code>false</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and could be parsed to a boolean. <code>false</code> otherwise
// */
// public boolean getAsBoolean(String identifier);
//
// /**Creates a new TagMap using the default TagMap implementation.
// *
// * @param tag
// * @return the default tag map
// */
// static TagMap getDefault(String tag){
// return new TagMapImpl(tag);
// }
// }
// Path: src/main/java/com/gikk/twirk/types/emote/EmoteParser.java
import com.gikk.twirk.types.TagMap;
import java.util.List;
package com.gikk.twirk.types.emote;
public interface EmoteParser {
/**
* @deprecated Use {{@link #parseEmotes(TagMap, String)} instead. This will be removed in a future release}
*/
@Deprecated
static List<Emote> parseEmotes(String content, String tag) { | TagMap tagMap = TagMap.getDefault(tag); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/hostTarget/HostTargetBuilder.java | // Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
| import com.gikk.twirk.types.twitchMessage.TwitchMessage; | package com.gikk.twirk.types.hostTarget;
/**Constructs a {@link HostTarget} object. To create a {@link HostTarget} object, call the {@link #build(TwitchMessage)} method
*
* @author Gikkman
*
*/
public interface HostTargetBuilder {
public static HostTargetBuilder getDefault() {
return new DefaultHostTargetBuilder();
}
/**Constructs a new {@link HostTarget} object from a {@link TwitchMessage}, received from Twitch. The user
* is responsible for making sure that this message can actually be made into a {@link HostTarget} object.
* Make sure that the COMMAND of the message equals "HOSTTARGET"
*
* @param message The message we received from Twitch
* @return A {@link HostTarget}, or <code>null</code> if a {@link HostTarget} could not be created
*/ | // Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
// Path: src/main/java/com/gikk/twirk/types/hostTarget/HostTargetBuilder.java
import com.gikk.twirk.types.twitchMessage.TwitchMessage;
package com.gikk.twirk.types.hostTarget;
/**Constructs a {@link HostTarget} object. To create a {@link HostTarget} object, call the {@link #build(TwitchMessage)} method
*
* @author Gikkman
*
*/
public interface HostTargetBuilder {
public static HostTargetBuilder getDefault() {
return new DefaultHostTargetBuilder();
}
/**Constructs a new {@link HostTarget} object from a {@link TwitchMessage}, received from Twitch. The user
* is responsible for making sure that this message can actually be made into a {@link HostTarget} object.
* Make sure that the COMMAND of the message equals "HOSTTARGET"
*
* @param message The message we received from Twitch
* @return A {@link HostTarget}, or <code>null</code> if a {@link HostTarget} could not be created
*/ | public HostTarget build(TwitchMessage message); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/usernotice/UsernoticeImpl.java | // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
| import com.gikk.twirk.types.emote.Emote;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.List;
import java.util.Optional; | package com.gikk.twirk.types.usernotice;
class UsernoticeImpl implements Usernotice{
private final String raw;
| // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
// Path: src/main/java/com/gikk/twirk/types/usernotice/UsernoticeImpl.java
import com.gikk.twirk.types.emote.Emote;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.List;
import java.util.Optional;
package com.gikk.twirk.types.usernotice;
class UsernoticeImpl implements Usernotice{
private final String raw;
| private final Optional<Raid> raid; |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/usernotice/UsernoticeImpl.java | // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
| import com.gikk.twirk.types.emote.Emote;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.List;
import java.util.Optional; | package com.gikk.twirk.types.usernotice;
class UsernoticeImpl implements Usernotice{
private final String raw;
private final Optional<Raid> raid; | // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
// Path: src/main/java/com/gikk/twirk/types/usernotice/UsernoticeImpl.java
import com.gikk.twirk.types.emote.Emote;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.List;
import java.util.Optional;
package com.gikk.twirk.types.usernotice;
class UsernoticeImpl implements Usernotice{
private final String raw;
private final Optional<Raid> raid; | private final Optional<Subscription> subscription; |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/usernotice/UsernoticeImpl.java | // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
| import com.gikk.twirk.types.emote.Emote;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.List;
import java.util.Optional; | package com.gikk.twirk.types.usernotice;
class UsernoticeImpl implements Usernotice{
private final String raw;
private final Optional<Raid> raid;
private final Optional<Subscription> subscription; | // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
// Path: src/main/java/com/gikk/twirk/types/usernotice/UsernoticeImpl.java
import com.gikk.twirk.types.emote.Emote;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.List;
import java.util.Optional;
package com.gikk.twirk.types.usernotice;
class UsernoticeImpl implements Usernotice{
private final String raw;
private final Optional<Raid> raid;
private final Optional<Subscription> subscription; | private final Optional<Ritual> ritual; |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/usernotice/UsernoticeImpl.java | // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
| import com.gikk.twirk.types.emote.Emote;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.List;
import java.util.Optional; | package com.gikk.twirk.types.usernotice;
class UsernoticeImpl implements Usernotice{
private final String raw;
private final Optional<Raid> raid;
private final Optional<Subscription> subscription;
private final Optional<Ritual> ritual;
private final String systemMessage;
private final String message; | // Path: src/main/java/com/gikk/twirk/types/emote/Emote.java
// public interface Emote {
// /** Fetches the emotes ID as String. This became necessary after Twitch start
// * including other characters than numbers in emote IDs
// *
// * @return The emotes ID
// */
// String getEmoteIDString();
//
// /** A list of pairs on indices. Each pair is a BEGIN-END pair of a emote occurrence in the message.<br><br>
// *
// * For example, if the message is: {@code Kappa PogChamp Kappa}<br> the list for emote 'Kappa' will include these pairs:<ul>
// * <li> (0,5)
// * <li> (15,20)
// * </ul>
// *
// * @return The indices this emote takes up in the associated message
// */
// LinkedList<EmoteIndices> getIndices();
//
// /** The emote's pattern. For example: 'Kappa'
// *
// * @return The emote's pattern
// */
// String getPattern();
//
// /**Emote images can be downloaded from Twitch's server, and come in three
// * sizes. Use this method to get the address for the emote.
// *
// * @param imageSize Emotes comes in three sizes. Specify which size you want
// * @return The address for the emote's image
// */
// String getEmoteImageUrl(EMOTE_SIZE imageSize);
//
// /**Class for representing the beginning and end of an emote occurrence within a message
// *
// * @author Gikkman
// */
// class EmoteIndices{
// public final int beingIndex;
// public final int endIndex;
//
// public EmoteIndices(int begin, int end){
// this.beingIndex = begin;
// this.endIndex = end;
// }
//
// public String toString(){
// return "(" +beingIndex + "," + endIndex + ")";
// }
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
// Path: src/main/java/com/gikk/twirk/types/usernotice/UsernoticeImpl.java
import com.gikk.twirk.types.emote.Emote;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.List;
import java.util.Optional;
package com.gikk.twirk.types.usernotice;
class UsernoticeImpl implements Usernotice{
private final String raw;
private final Optional<Raid> raid;
private final Optional<Subscription> subscription;
private final Optional<Ritual> ritual;
private final String systemMessage;
private final String message; | private final List<Emote> emotes; |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/mode/TestMode.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/mode/Mode.java
// public static enum MODE_EVENT{ GAINED_MOD, LOST_MOD }
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.mode.Mode.MODE_EVENT;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.mode;
public class TestMode {
public static String GAIN_MOD = ":jtv MODE #gikkman +o gikkbot";
public static String LOST_MOD = ":jtv MODE #gikkman -o gikkbot";
| // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/mode/Mode.java
// public static enum MODE_EVENT{ GAINED_MOD, LOST_MOD }
// Path: src/test/java/com/gikk/twirk/types/mode/TestMode.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.mode.Mode.MODE_EVENT;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.mode;
public class TestMode {
public static String GAIN_MOD = ":jtv MODE #gikkman +o gikkbot";
public static String LOST_MOD = ":jtv MODE #gikkman -o gikkbot";
| public static void test(Consumer<String> twirkInput, TestConsumer<Mode> test ) throws Exception{ |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/mode/TestMode.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/mode/Mode.java
// public static enum MODE_EVENT{ GAINED_MOD, LOST_MOD }
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.mode.Mode.MODE_EVENT;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.mode;
public class TestMode {
public static String GAIN_MOD = ":jtv MODE #gikkman +o gikkbot";
public static String LOST_MOD = ":jtv MODE #gikkman -o gikkbot";
public static void test(Consumer<String> twirkInput, TestConsumer<Mode> test ) throws Exception{ | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/mode/Mode.java
// public static enum MODE_EVENT{ GAINED_MOD, LOST_MOD }
// Path: src/test/java/com/gikk/twirk/types/mode/TestMode.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.mode.Mode.MODE_EVENT;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.mode;
public class TestMode {
public static String GAIN_MOD = ":jtv MODE #gikkman +o gikkbot";
public static String LOST_MOD = ":jtv MODE #gikkman -o gikkbot";
public static void test(Consumer<String> twirkInput, TestConsumer<Mode> test ) throws Exception{ | TestResult resGain = test.assign(TestMode::testGainMod); |
Gikkman/Java-Twirk | src/test/java/com/gikk/twirk/types/mode/TestMode.java | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/mode/Mode.java
// public static enum MODE_EVENT{ GAINED_MOD, LOST_MOD }
| import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.mode.Mode.MODE_EVENT;
import java.util.function.Consumer;
import static org.junit.Assert.*; | package com.gikk.twirk.types.mode;
public class TestMode {
public static String GAIN_MOD = ":jtv MODE #gikkman +o gikkbot";
public static String LOST_MOD = ":jtv MODE #gikkman -o gikkbot";
public static void test(Consumer<String> twirkInput, TestConsumer<Mode> test ) throws Exception{
TestResult resGain = test.assign(TestMode::testGainMod);
twirkInput.accept(GAIN_MOD);
resGain.await();
TestResult resLost = test.assign(TestMode::testLostMod);
twirkInput.accept(LOST_MOD);
resLost.await();
}
private static boolean testGainMod(Mode mode){ | // Path: src/test/java/com/gikk/twirk/TestConsumer.java
// public class TestConsumer<T> {
// private Function<T, Boolean> test;
// private TestResult res;
//
// public TestResult assign(Function<T, Boolean> test){
// this.test = test;
// return res = new TestResult();
// }
//
// public void consume(T input){
// if(test != null) {
// res.complete(test.apply(input));
// }
// }
// }
//
// Path: src/test/java/com/gikk/twirk/TestResult.java
// public class TestResult {
// CompletableFuture<Boolean> res = new CompletableFuture<>();
//
// TestResult(){ }
//
// void complete(boolean result){
// res.complete(result);
// }
//
// public boolean await() throws Exception {
// return res.get(TestSuit.WAIT_TIME, TestSuit.UNIT);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/mode/Mode.java
// public static enum MODE_EVENT{ GAINED_MOD, LOST_MOD }
// Path: src/test/java/com/gikk/twirk/types/mode/TestMode.java
import com.gikk.twirk.TestConsumer;
import com.gikk.twirk.TestResult;
import com.gikk.twirk.types.mode.Mode.MODE_EVENT;
import java.util.function.Consumer;
import static org.junit.Assert.*;
package com.gikk.twirk.types.mode;
public class TestMode {
public static String GAIN_MOD = ":jtv MODE #gikkman +o gikkbot";
public static String LOST_MOD = ":jtv MODE #gikkman -o gikkbot";
public static void test(Consumer<String> twirkInput, TestConsumer<Mode> test ) throws Exception{
TestResult resGain = test.assign(TestMode::testGainMod);
twirkInput.accept(GAIN_MOD);
resGain.await();
TestResult resLost = test.assign(TestMode::testLostMod);
twirkInput.accept(LOST_MOD);
resLost.await();
}
private static boolean testGainMod(Mode mode){ | doTest(mode, GAIN_MOD, MODE_EVENT.GAINED_MOD, "gikkbot"); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/usernotice/Usernotice.java | // Path: src/main/java/com/gikk/twirk/types/AbstractEmoteMessage.java
// public interface AbstractEmoteMessage extends AbstractType{
//
// /**Checks whether this message contains emotes or not
// *
// * @return {@code true} if the message contains emotes
// */
// public boolean hasEmotes();
//
// /**Fetches a list of all all emotes in this message. Each emote is encapsulated in a {@link Emote}.
// * The list might be empty, if the message contained no emotes.
// *
// * @return List of emotes (might be empty)
// */
// public List<Emote> getEmotes();
//
// /**Fetches the timestamp of when the message reached the Twitch message server.
// *
// * @return UNIX timestap, or -1 (if none was present)
// */
// public long getSentTimestamp();
//
// /**Fetches the chat room's unique ID.
// *
// * @return the room ID.
// */
// public long getRoomID();
//
// /**Fetches the message's unique ID.
// *
// * @return the message ID.
// */
// public String getMessageID();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
| import com.gikk.twirk.types.AbstractEmoteMessage;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.Optional; | package com.gikk.twirk.types.usernotice;
/**Class for representing the Usernotice event. Usernotices can fire under 4
* different conditions:
* <ul>
* <li> New subscription & Resubscription
* <li> Raid
* <li> Ritual
* </ul>
* Since this class might contain 3 different event types, the getSubscription(),
* getRaid() and getRitual methods all return {@link Optional} objects.
*
* @author Gikkman
*/
public interface Usernotice extends AbstractEmoteMessage {
/**Retrieves the message, as input by the user. This message might contain
* emotes (see {@link #hasEmotes()} and {@link #getEmotes()}.
* It might also be empty, in which case, the message is {@code ""}
*
* @return The message. Might be {@code ""}
*/
public String getMessage();
/**The system message contains the text which'll be printed in the Twitch
* Chat on Twitch's side. It might look like this: <br>
* {@code system-msg=TWITCH_UserName\shas\ssubscribed\sfor\s6\smonths!;}.
* <p>
* This is basically the message printed in chat to tell other viewers
* what just occred (a raid, a subscription and so on).
* <p>
* This method returns the system message like it looks from server side.
* It will, however, replace all {@code \s} with spaces.
*
* @return The system message
*/
public String getSystemMessage();
/**Tells whether this Usernotice is a subscription (or re-subscription) alert.
*
* @return {@code true} if this is a subscription alert
*/
public boolean isSubscription();
/**Retrieves the Subscription object. The Optional object wraps the
* Subscription object (as an alternative to returning {@code null}).
*
* @return the Subscription
*/ | // Path: src/main/java/com/gikk/twirk/types/AbstractEmoteMessage.java
// public interface AbstractEmoteMessage extends AbstractType{
//
// /**Checks whether this message contains emotes or not
// *
// * @return {@code true} if the message contains emotes
// */
// public boolean hasEmotes();
//
// /**Fetches a list of all all emotes in this message. Each emote is encapsulated in a {@link Emote}.
// * The list might be empty, if the message contained no emotes.
// *
// * @return List of emotes (might be empty)
// */
// public List<Emote> getEmotes();
//
// /**Fetches the timestamp of when the message reached the Twitch message server.
// *
// * @return UNIX timestap, or -1 (if none was present)
// */
// public long getSentTimestamp();
//
// /**Fetches the chat room's unique ID.
// *
// * @return the room ID.
// */
// public long getRoomID();
//
// /**Fetches the message's unique ID.
// *
// * @return the message ID.
// */
// public String getMessageID();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
// Path: src/main/java/com/gikk/twirk/types/usernotice/Usernotice.java
import com.gikk.twirk.types.AbstractEmoteMessage;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.Optional;
package com.gikk.twirk.types.usernotice;
/**Class for representing the Usernotice event. Usernotices can fire under 4
* different conditions:
* <ul>
* <li> New subscription & Resubscription
* <li> Raid
* <li> Ritual
* </ul>
* Since this class might contain 3 different event types, the getSubscription(),
* getRaid() and getRitual methods all return {@link Optional} objects.
*
* @author Gikkman
*/
public interface Usernotice extends AbstractEmoteMessage {
/**Retrieves the message, as input by the user. This message might contain
* emotes (see {@link #hasEmotes()} and {@link #getEmotes()}.
* It might also be empty, in which case, the message is {@code ""}
*
* @return The message. Might be {@code ""}
*/
public String getMessage();
/**The system message contains the text which'll be printed in the Twitch
* Chat on Twitch's side. It might look like this: <br>
* {@code system-msg=TWITCH_UserName\shas\ssubscribed\sfor\s6\smonths!;}.
* <p>
* This is basically the message printed in chat to tell other viewers
* what just occred (a raid, a subscription and so on).
* <p>
* This method returns the system message like it looks from server side.
* It will, however, replace all {@code \s} with spaces.
*
* @return The system message
*/
public String getSystemMessage();
/**Tells whether this Usernotice is a subscription (or re-subscription) alert.
*
* @return {@code true} if this is a subscription alert
*/
public boolean isSubscription();
/**Retrieves the Subscription object. The Optional object wraps the
* Subscription object (as an alternative to returning {@code null}).
*
* @return the Subscription
*/ | public Optional<Subscription> getSubscription(); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/usernotice/Usernotice.java | // Path: src/main/java/com/gikk/twirk/types/AbstractEmoteMessage.java
// public interface AbstractEmoteMessage extends AbstractType{
//
// /**Checks whether this message contains emotes or not
// *
// * @return {@code true} if the message contains emotes
// */
// public boolean hasEmotes();
//
// /**Fetches a list of all all emotes in this message. Each emote is encapsulated in a {@link Emote}.
// * The list might be empty, if the message contained no emotes.
// *
// * @return List of emotes (might be empty)
// */
// public List<Emote> getEmotes();
//
// /**Fetches the timestamp of when the message reached the Twitch message server.
// *
// * @return UNIX timestap, or -1 (if none was present)
// */
// public long getSentTimestamp();
//
// /**Fetches the chat room's unique ID.
// *
// * @return the room ID.
// */
// public long getRoomID();
//
// /**Fetches the message's unique ID.
// *
// * @return the message ID.
// */
// public String getMessageID();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
| import com.gikk.twirk.types.AbstractEmoteMessage;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.Optional; | package com.gikk.twirk.types.usernotice;
/**Class for representing the Usernotice event. Usernotices can fire under 4
* different conditions:
* <ul>
* <li> New subscription & Resubscription
* <li> Raid
* <li> Ritual
* </ul>
* Since this class might contain 3 different event types, the getSubscription(),
* getRaid() and getRitual methods all return {@link Optional} objects.
*
* @author Gikkman
*/
public interface Usernotice extends AbstractEmoteMessage {
/**Retrieves the message, as input by the user. This message might contain
* emotes (see {@link #hasEmotes()} and {@link #getEmotes()}.
* It might also be empty, in which case, the message is {@code ""}
*
* @return The message. Might be {@code ""}
*/
public String getMessage();
/**The system message contains the text which'll be printed in the Twitch
* Chat on Twitch's side. It might look like this: <br>
* {@code system-msg=TWITCH_UserName\shas\ssubscribed\sfor\s6\smonths!;}.
* <p>
* This is basically the message printed in chat to tell other viewers
* what just occred (a raid, a subscription and so on).
* <p>
* This method returns the system message like it looks from server side.
* It will, however, replace all {@code \s} with spaces.
*
* @return The system message
*/
public String getSystemMessage();
/**Tells whether this Usernotice is a subscription (or re-subscription) alert.
*
* @return {@code true} if this is a subscription alert
*/
public boolean isSubscription();
/**Retrieves the Subscription object. The Optional object wraps the
* Subscription object (as an alternative to returning {@code null}).
*
* @return the Subscription
*/
public Optional<Subscription> getSubscription();
/**Tells whether this Usernotice is a raid alert.
*
* @return {@code true} if this is a raid alert
*/
public boolean isRaid();
/**Retrieves the Raid object. The Optional object wraps the
* Raid object (as an alternative to returning {@code null}).
*
* @return the Raid
*/ | // Path: src/main/java/com/gikk/twirk/types/AbstractEmoteMessage.java
// public interface AbstractEmoteMessage extends AbstractType{
//
// /**Checks whether this message contains emotes or not
// *
// * @return {@code true} if the message contains emotes
// */
// public boolean hasEmotes();
//
// /**Fetches a list of all all emotes in this message. Each emote is encapsulated in a {@link Emote}.
// * The list might be empty, if the message contained no emotes.
// *
// * @return List of emotes (might be empty)
// */
// public List<Emote> getEmotes();
//
// /**Fetches the timestamp of when the message reached the Twitch message server.
// *
// * @return UNIX timestap, or -1 (if none was present)
// */
// public long getSentTimestamp();
//
// /**Fetches the chat room's unique ID.
// *
// * @return the room ID.
// */
// public long getRoomID();
//
// /**Fetches the message's unique ID.
// *
// * @return the message ID.
// */
// public String getMessageID();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Raid.java
// public interface Raid {
//
// /**Fetches the display name of the user whom initiated the raid.
// *
// * @return the display name of the raid initiator
// */
// public String getSourceDisplayName();
//
// /**Fetches the login name of the user whom initiated the raid. This will
// * also give you the name of the channel which the raid originated from.
// *
// * @return the login name of the raid initiator
// */
// public String getSourceLoginName();
//
//
// /**Fetches the number of users participating in the raid.
// *
// * @return number of raiders
// */
// public int getRaidCount();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Ritual.java
// public interface Ritual {
// /**Fetches the name of the Ritual
// *
// * @return the ritual name
// */
// public String getRitualName();
// }
//
// Path: src/main/java/com/gikk/twirk/types/usernotice/subtype/Subscription.java
// public interface Subscription {
// public SubscriptionPlan getSubscriptionPlan();
//
// /**Get the number of month's the subscription's been active. New subscriptions
// * return 1, whilst re-subscriptions tells which month was just activated.
// *
// * @return number of months
// */
// public int getMonths();
//
// /**Get the number of month's the subscription's been active consecutive.
// *
// * @return number of months
// */
// public int getStreak();
//
// /** Returns if user decide to share the streak, this decide if the value of {@code getStreak} its zero or another.
// *
// * @return {@code true} if user share the streak
// */
// public boolean isSharedStreak();
//
// /**Returns the name of the purchased subscription plan. This may be a
// * default name or one created by the channel owner.
// *
// * @return display name of the subscription plan
// */
// public String getSubscriptionPlanName();
//
// /**Returns whether this was a new sub or a re-sub.
// *
// * @return {@code true} if this was a re-subscription
// */
// public boolean isResub();
//
// /**Tells whether this is a subscription gift or not.
// *
// * @return {@code true} if this was a gift
// */
// public boolean isGift();
//
// /**Retrieves the SubscriptionGift item, which holds information about the
// * gift and the recipiant of the gift. The Optional object wraps the
// * SubscriptionGift object (as an alternative to returning {@code null}).
// *
// * @return the subscription gift, wrapped in a {@link Optional}
// */
// public Optional<SubscriptionGift> getSubscriptionGift();
// }
// Path: src/main/java/com/gikk/twirk/types/usernotice/Usernotice.java
import com.gikk.twirk.types.AbstractEmoteMessage;
import com.gikk.twirk.types.usernotice.subtype.Raid;
import com.gikk.twirk.types.usernotice.subtype.Ritual;
import com.gikk.twirk.types.usernotice.subtype.Subscription;
import java.util.Optional;
package com.gikk.twirk.types.usernotice;
/**Class for representing the Usernotice event. Usernotices can fire under 4
* different conditions:
* <ul>
* <li> New subscription & Resubscription
* <li> Raid
* <li> Ritual
* </ul>
* Since this class might contain 3 different event types, the getSubscription(),
* getRaid() and getRitual methods all return {@link Optional} objects.
*
* @author Gikkman
*/
public interface Usernotice extends AbstractEmoteMessage {
/**Retrieves the message, as input by the user. This message might contain
* emotes (see {@link #hasEmotes()} and {@link #getEmotes()}.
* It might also be empty, in which case, the message is {@code ""}
*
* @return The message. Might be {@code ""}
*/
public String getMessage();
/**The system message contains the text which'll be printed in the Twitch
* Chat on Twitch's side. It might look like this: <br>
* {@code system-msg=TWITCH_UserName\shas\ssubscribed\sfor\s6\smonths!;}.
* <p>
* This is basically the message printed in chat to tell other viewers
* what just occred (a raid, a subscription and so on).
* <p>
* This method returns the system message like it looks from server side.
* It will, however, replace all {@code \s} with spaces.
*
* @return The system message
*/
public String getSystemMessage();
/**Tells whether this Usernotice is a subscription (or re-subscription) alert.
*
* @return {@code true} if this is a subscription alert
*/
public boolean isSubscription();
/**Retrieves the Subscription object. The Optional object wraps the
* Subscription object (as an alternative to returning {@code null}).
*
* @return the Subscription
*/
public Optional<Subscription> getSubscription();
/**Tells whether this Usernotice is a raid alert.
*
* @return {@code true} if this is a raid alert
*/
public boolean isRaid();
/**Retrieves the Raid object. The Optional object wraps the
* Raid object (as an alternative to returning {@code null}).
*
* @return the Raid
*/ | public Optional<Raid> getRaid(); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/privmsg/PrivateMessage.java | // Path: src/main/java/com/gikk/twirk/types/AbstractEmoteMessage.java
// public interface AbstractEmoteMessage extends AbstractType{
//
// /**Checks whether this message contains emotes or not
// *
// * @return {@code true} if the message contains emotes
// */
// public boolean hasEmotes();
//
// /**Fetches a list of all all emotes in this message. Each emote is encapsulated in a {@link Emote}.
// * The list might be empty, if the message contained no emotes.
// *
// * @return List of emotes (might be empty)
// */
// public List<Emote> getEmotes();
//
// /**Fetches the timestamp of when the message reached the Twitch message server.
// *
// * @return UNIX timestap, or -1 (if none was present)
// */
// public long getSentTimestamp();
//
// /**Fetches the chat room's unique ID.
// *
// * @return the room ID.
// */
// public long getRoomID();
//
// /**Fetches the message's unique ID.
// *
// * @return the message ID.
// */
// public String getMessageID();
// }
//
// Path: src/main/java/com/gikk/twirk/types/cheer/Cheer.java
// public interface Cheer {
// public int getBits();
// public String getMessage();
// public String getImageURL(CheerTheme theme, CheerType type, CheerSize size);
// }
| import com.gikk.twirk.types.AbstractEmoteMessage;
import com.gikk.twirk.types.cheer.Cheer;
import java.util.List; | package com.gikk.twirk.types.privmsg;
/**
*
* @author Gikkman
*/
public interface PrivateMessage extends AbstractEmoteMessage{
/**Tells whether this message was a cheer event or not.
*
* @return {@code true} if the message contains bits, <code>false</code> otherwise
*/
public boolean isCheer();
/**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
* The list might be empty, if the message contained no cheers.
*
* @return List of emotes (might be empty)
*/ | // Path: src/main/java/com/gikk/twirk/types/AbstractEmoteMessage.java
// public interface AbstractEmoteMessage extends AbstractType{
//
// /**Checks whether this message contains emotes or not
// *
// * @return {@code true} if the message contains emotes
// */
// public boolean hasEmotes();
//
// /**Fetches a list of all all emotes in this message. Each emote is encapsulated in a {@link Emote}.
// * The list might be empty, if the message contained no emotes.
// *
// * @return List of emotes (might be empty)
// */
// public List<Emote> getEmotes();
//
// /**Fetches the timestamp of when the message reached the Twitch message server.
// *
// * @return UNIX timestap, or -1 (if none was present)
// */
// public long getSentTimestamp();
//
// /**Fetches the chat room's unique ID.
// *
// * @return the room ID.
// */
// public long getRoomID();
//
// /**Fetches the message's unique ID.
// *
// * @return the message ID.
// */
// public String getMessageID();
// }
//
// Path: src/main/java/com/gikk/twirk/types/cheer/Cheer.java
// public interface Cheer {
// public int getBits();
// public String getMessage();
// public String getImageURL(CheerTheme theme, CheerType type, CheerSize size);
// }
// Path: src/main/java/com/gikk/twirk/types/privmsg/PrivateMessage.java
import com.gikk.twirk.types.AbstractEmoteMessage;
import com.gikk.twirk.types.cheer.Cheer;
import java.util.List;
package com.gikk.twirk.types.privmsg;
/**
*
* @author Gikkman
*/
public interface PrivateMessage extends AbstractEmoteMessage{
/**Tells whether this message was a cheer event or not.
*
* @return {@code true} if the message contains bits, <code>false</code> otherwise
*/
public boolean isCheer();
/**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
* The list might be empty, if the message contained no cheers.
*
* @return List of emotes (might be empty)
*/ | public List<Cheer> getCheers(); |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/hostTarget/DefaultHostTargetBuilder.java | // Path: src/main/java/com/gikk/twirk/enums/HOSTTARGET_MODE.java
// public enum HOSTTARGET_MODE {
// /**Indicates that we started hosting a channel*/
// START,
// /**Indicates that we stopped hosting a channel*/
// STOP }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
| import com.gikk.twirk.enums.HOSTTARGET_MODE;
import com.gikk.twirk.types.twitchMessage.TwitchMessage; | package com.gikk.twirk.types.hostTarget;
class DefaultHostTargetBuilder implements HostTargetBuilder {
HOSTTARGET_MODE mode;
String target;
int viwerAmount;
String rawLine;
@Override | // Path: src/main/java/com/gikk/twirk/enums/HOSTTARGET_MODE.java
// public enum HOSTTARGET_MODE {
// /**Indicates that we started hosting a channel*/
// START,
// /**Indicates that we stopped hosting a channel*/
// STOP }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
// Path: src/main/java/com/gikk/twirk/types/hostTarget/DefaultHostTargetBuilder.java
import com.gikk.twirk.enums.HOSTTARGET_MODE;
import com.gikk.twirk.types.twitchMessage.TwitchMessage;
package com.gikk.twirk.types.hostTarget;
class DefaultHostTargetBuilder implements HostTargetBuilder {
HOSTTARGET_MODE mode;
String target;
int viwerAmount;
String rawLine;
@Override | public HostTarget build(TwitchMessage message) { |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/mode/DefaultModeBuilder.java | // Path: src/main/java/com/gikk/twirk/types/mode/Mode.java
// public static enum MODE_EVENT{ GAINED_MOD, LOST_MOD }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
| import com.gikk.twirk.types.mode.Mode.MODE_EVENT;
import com.gikk.twirk.types.twitchMessage.TwitchMessage; | package com.gikk.twirk.types.mode;
class DefaultModeBuilder implements ModeBuilder{
MODE_EVENT event;
String user;
String rawLine;
@Override | // Path: src/main/java/com/gikk/twirk/types/mode/Mode.java
// public static enum MODE_EVENT{ GAINED_MOD, LOST_MOD }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
// Path: src/main/java/com/gikk/twirk/types/mode/DefaultModeBuilder.java
import com.gikk.twirk.types.mode.Mode.MODE_EVENT;
import com.gikk.twirk.types.twitchMessage.TwitchMessage;
package com.gikk.twirk.types.mode;
class DefaultModeBuilder implements ModeBuilder{
MODE_EVENT event;
String user;
String rawLine;
@Override | public Mode build(TwitchMessage message) { |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/clearMsg/DefaultClearMsgBuilder.java | // Path: src/main/java/com/gikk/twirk/types/TagMap.java
// public interface TagMap extends Map<String, String>{
// //***********************************************************
// // PUBLIC
// //***********************************************************
// /**Fetches a certain field value that might have been present in the tag.
// * If the field was not present in the tag, or the field's value was empty,
// * this method returns <code>NULL</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if there was any. <code>NULL</code> otherwise
// */
// public String getAsString(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into an <code>int</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and an int. <code>-1</code> otherwise
// */
// public int getAsInt(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>long</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and a long. <code>-1</code> otherwise
// */
// long getAsLong(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>boolean</code>. For parsing purpose, <code>1</code> is interpreted
// * as <code>true</code>, anything else as <code>false</code>.
// * If the field was not present in the tag, or the field's value was empty, this method returns <code>false</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and could be parsed to a boolean. <code>false</code> otherwise
// */
// public boolean getAsBoolean(String identifier);
//
// /**Creates a new TagMap using the default TagMap implementation.
// *
// * @param tag
// * @return the default tag map
// */
// static TagMap getDefault(String tag){
// return new TagMapImpl(tag);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
| import com.gikk.twirk.types.TagMap;
import com.gikk.twirk.types.twitchMessage.TwitchMessage; | package com.gikk.twirk.types.clearMsg;
class DefaultClearMsgBuilder implements ClearMsgBuilder{
String sender;
String msgId;
String msgContents;
String rawLine;
@Override | // Path: src/main/java/com/gikk/twirk/types/TagMap.java
// public interface TagMap extends Map<String, String>{
// //***********************************************************
// // PUBLIC
// //***********************************************************
// /**Fetches a certain field value that might have been present in the tag.
// * If the field was not present in the tag, or the field's value was empty,
// * this method returns <code>NULL</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if there was any. <code>NULL</code> otherwise
// */
// public String getAsString(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into an <code>int</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and an int. <code>-1</code> otherwise
// */
// public int getAsInt(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>long</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and a long. <code>-1</code> otherwise
// */
// long getAsLong(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>boolean</code>. For parsing purpose, <code>1</code> is interpreted
// * as <code>true</code>, anything else as <code>false</code>.
// * If the field was not present in the tag, or the field's value was empty, this method returns <code>false</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and could be parsed to a boolean. <code>false</code> otherwise
// */
// public boolean getAsBoolean(String identifier);
//
// /**Creates a new TagMap using the default TagMap implementation.
// *
// * @param tag
// * @return the default tag map
// */
// static TagMap getDefault(String tag){
// return new TagMapImpl(tag);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
// Path: src/main/java/com/gikk/twirk/types/clearMsg/DefaultClearMsgBuilder.java
import com.gikk.twirk.types.TagMap;
import com.gikk.twirk.types.twitchMessage.TwitchMessage;
package com.gikk.twirk.types.clearMsg;
class DefaultClearMsgBuilder implements ClearMsgBuilder{
String sender;
String msgId;
String msgContents;
String rawLine;
@Override | public ClearMsg build(TwitchMessage twitchMessage) { |
Gikkman/Java-Twirk | src/main/java/com/gikk/twirk/types/clearMsg/DefaultClearMsgBuilder.java | // Path: src/main/java/com/gikk/twirk/types/TagMap.java
// public interface TagMap extends Map<String, String>{
// //***********************************************************
// // PUBLIC
// //***********************************************************
// /**Fetches a certain field value that might have been present in the tag.
// * If the field was not present in the tag, or the field's value was empty,
// * this method returns <code>NULL</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if there was any. <code>NULL</code> otherwise
// */
// public String getAsString(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into an <code>int</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and an int. <code>-1</code> otherwise
// */
// public int getAsInt(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>long</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and a long. <code>-1</code> otherwise
// */
// long getAsLong(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>boolean</code>. For parsing purpose, <code>1</code> is interpreted
// * as <code>true</code>, anything else as <code>false</code>.
// * If the field was not present in the tag, or the field's value was empty, this method returns <code>false</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and could be parsed to a boolean. <code>false</code> otherwise
// */
// public boolean getAsBoolean(String identifier);
//
// /**Creates a new TagMap using the default TagMap implementation.
// *
// * @param tag
// * @return the default tag map
// */
// static TagMap getDefault(String tag){
// return new TagMapImpl(tag);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
| import com.gikk.twirk.types.TagMap;
import com.gikk.twirk.types.twitchMessage.TwitchMessage; | package com.gikk.twirk.types.clearMsg;
class DefaultClearMsgBuilder implements ClearMsgBuilder{
String sender;
String msgId;
String msgContents;
String rawLine;
@Override
public ClearMsg build(TwitchMessage twitchMessage) {
this.rawLine = twitchMessage.getRaw();
| // Path: src/main/java/com/gikk/twirk/types/TagMap.java
// public interface TagMap extends Map<String, String>{
// //***********************************************************
// // PUBLIC
// //***********************************************************
// /**Fetches a certain field value that might have been present in the tag.
// * If the field was not present in the tag, or the field's value was empty,
// * this method returns <code>NULL</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if there was any. <code>NULL</code> otherwise
// */
// public String getAsString(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into an <code>int</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and an int. <code>-1</code> otherwise
// */
// public int getAsInt(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>long</code>. If the field was not present in the tag,
// * or the field's value was empty, this method returns <code>-1</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and a long. <code>-1</code> otherwise
// */
// long getAsLong(String identifier);
//
// /**Fetches a certain field value that might have been present in the tag, and
// * tries to parse it into a <code>boolean</code>. For parsing purpose, <code>1</code> is interpreted
// * as <code>true</code>, anything else as <code>false</code>.
// * If the field was not present in the tag, or the field's value was empty, this method returns <code>false</code>
// *
// * @param identifier The fields identifier. See {@link TwitchTags}
// * @return The fields value, if it was present and could be parsed to a boolean. <code>false</code> otherwise
// */
// public boolean getAsBoolean(String identifier);
//
// /**Creates a new TagMap using the default TagMap implementation.
// *
// * @param tag
// * @return the default tag map
// */
// static TagMap getDefault(String tag){
// return new TagMapImpl(tag);
// }
// }
//
// Path: src/main/java/com/gikk/twirk/types/twitchMessage/TwitchMessage.java
// public interface TwitchMessage extends AbstractEmoteMessage {
//
// /**Retrieves this message's tag segment. Should always starts with a @. Note that the
// * Tag segment will look vastly different for different Twitch commands, and some won't
// * even have a tag.
// *
// * @return The tag segment, or {@code ""} if no tag was present
// */
// public String getTag();
//
// /**Retrieves the message's prefix.<br><br>
// *
// * A typical Twitch message looks something line this:<br>
// * <code>:name!name@name.tmi.twitch.tv COMMAND #channel :message</code> <br><br>
// *
// * The prefix is the part before the first space. It usually only contains data about the sender of
// * the message, but it might sometimes contain other information (PING messages for example just have PING as
// * their prefix).<br><br>
// *
// * @return The messages prefix
// */
// public String getPrefix();
//
// /**Retrieves the message's command.<br>
// * The command tells us what action triggered this message being sent.<br><br>
// *
// * @return The message's command
// */
// public String getCommand();
//
// /**Retrieves the message's target.<br>
// * The target tells us whom the message is intended towards. It can be a user,
// * a channel, or something else (though mostly the channel).
// * <p>
// * This segment is not always present.
// *
// * @return The message's target, or {@code ""} if no target
// */
// public String getTarget();
//
// /**Retrieves the message's content.<br>
// * The content is the commands parameters. Most often, this is the actual chat message, but it may be many
// * other things for other commands.<br><br>
// *
// * This segment is not always present.
// *
// * @return The message's content, or {@code ""} if no content
// */
// public String getContent();
//
// /**Tells whether this message was a cheer event or not.
// *
// * @return {@code true} if the message contains bits, <code>false</code> otherwise
// */
// public boolean isCheer();
//
// /**Fetches a list of all all cheers in this message. Each cheer is encapsulated in a {@link Cheer}.
// * The list might be empty, if the message contained no cheers.
// *
// * @return List of emotes (might be empty)
// */
// public List<Cheer> getCheers();
//
// /**Fetches the total number of bits that this message contained.
// * This method is short-hand for:
// * <pre>
// * int bits = 0;
// * for(Cheer c : getCheers())
// * bits += c.getBits();
// * return bits;
// * </pre>
// * @return number of bits
// */
// public int getBits();
//
// /**Fetches the {@link TagMap} that has parsed the message's tag into a key-value map.
// * For a list of different identifiers that can occur in a tag, check the {@link TwitchTags} class.
// */
// public TagMap getTagMap();
// }
// Path: src/main/java/com/gikk/twirk/types/clearMsg/DefaultClearMsgBuilder.java
import com.gikk.twirk.types.TagMap;
import com.gikk.twirk.types.twitchMessage.TwitchMessage;
package com.gikk.twirk.types.clearMsg;
class DefaultClearMsgBuilder implements ClearMsgBuilder{
String sender;
String msgId;
String msgContents;
String rawLine;
@Override
public ClearMsg build(TwitchMessage twitchMessage) {
this.rawLine = twitchMessage.getRaw();
| TagMap r = twitchMessage.getTagMap(); |
okinawaopenlabs/of-patch-manager | src/main/java/org/okinawaopenlabs/orientdb/client/ConnectionUtilsImpl.java | // Path: src/main/java/org/okinawaopenlabs/ofpm/utils/Config.java
// public interface Config {
// /**
// * Get value to corresponding to the key.
// *
// * @param key
// * @return
// * string value.
// */
// String getString(String key);
//
// /**
// * Get value to corresponding to the key.
// * Specified value is returned if not contains key to config file.
// *
// * @param key
// * @param defaultValue
// * @return
// * String value.
// */
// String getString(String key, String defaultValue);
//
// /**
// * Get value to corresponding to the key.
// *
// * @param key
// * @return
// * int value.
// */
// int getInt(String key);
//
// /**
// * Get value to corresponding to the key.
// * Specified value is returned if not contains key to config file.
// *
// * @param key
// * @param defaultValue
// * @return
// * int value.
// */
// int getInt(String key, int defaultValue);
//
// /**
// * Return with string in contents of config file.
// *
// * @return
// * Contents of config file.
// */
// String getContents();
//
// /**
// * Return with Configuration object in contents of config file.
// *
// * @return
// * Contents of Configuration object.
// */
// Configuration getConfiguration();
//
// List<Object> getList(String key);
// }
//
// Path: src/main/java/org/okinawaopenlabs/ofpm/utils/ConfigImpl.java
// public class ConfigImpl implements Config {
//
// private static final Logger logger = Logger.getLogger(ConfigImpl.class);
//
// private Configuration config = null;
//
// /**
// * Load config file.
// *
// * @throws RuntimeException
// * Failed to load config file.
// */
// public ConfigImpl() {
// this(DEFAULT_PROPERTIY_FILE);
// }
//
// /**
// * Specify config file and then create instance.
// *
// * @param config
// * File path.
// */
// public ConfigImpl(String config) {
// try {
// this.config = new PropertiesConfiguration(config);
// } catch (ConfigurationException e) {
// String message = "failed to read config file.";
// logger.error(message);
// throw new RuntimeException(message, e);
// }
// }
//
// /**
// * Specify config object and then create instance.
// *
// * @param config
// * Config object.
// */
// public ConfigImpl(Configuration config) {
// this.config = config;
// }
//
// @Override
// public String getString(String key) {
// String value = getConfiguration().getString(key);
// return value;
// }
//
// @Override
// public String getString(String key, String defaultValue) {
// try {
// String value = getConfiguration().getString(key, defaultValue);
// return value;
// } catch (ConversionException e) {
// return defaultValue;
// }
// }
//
// @Override
// public int getInt(String key) {
// return getConfiguration().getInt(key);
// }
//
// @Override
// public int getInt(String key, int defaultValue) {
// try {
// int value = getConfiguration().getInt(key, defaultValue);
// return value;
// } catch (ConversionException e) {
// return defaultValue;
// }
// }
//
// @Override
// public String getContents() {
// PropertiesConfiguration prop = new PropertiesConfiguration();
// prop.append(this.config);
// StringWriter sw = new StringWriter();
// try {
// prop.save(sw);
// } catch (ConfigurationException e) {
// logger.error(e.getMessage());
// throw new RuntimeException(e);
// }
// return sw.toString();
// }
//
// /**
// * Configuration object is returned, it to provide reference to config file.
// *
// * @return
// * Configuration object to provide reference to config file.
// */
// @Override
// public Configuration getConfiguration() {
// return this.config;
// }
//
// @Override
// public List<Object> getList(String key) {
// List<Object> values = getConfiguration().getList(key);
// return values;
// }
// }
| import java.sql.SQLException;
import java.util.List;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import org.okinawaopenlabs.ofpm.utils.Config;
import org.okinawaopenlabs.ofpm.utils.ConfigImpl; | /*
* Copyright 2015 Okinawa Open Laboratory, General Incorporated Association
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.okinawaopenlabs.orientdb.client;
public class ConnectionUtilsImpl implements ConnectionUtils {
/**
* 設定ファイル
*/
private Config config;
/**
* デフォルトのコンストラクタ.
*/
public ConnectionUtilsImpl() { | // Path: src/main/java/org/okinawaopenlabs/ofpm/utils/Config.java
// public interface Config {
// /**
// * Get value to corresponding to the key.
// *
// * @param key
// * @return
// * string value.
// */
// String getString(String key);
//
// /**
// * Get value to corresponding to the key.
// * Specified value is returned if not contains key to config file.
// *
// * @param key
// * @param defaultValue
// * @return
// * String value.
// */
// String getString(String key, String defaultValue);
//
// /**
// * Get value to corresponding to the key.
// *
// * @param key
// * @return
// * int value.
// */
// int getInt(String key);
//
// /**
// * Get value to corresponding to the key.
// * Specified value is returned if not contains key to config file.
// *
// * @param key
// * @param defaultValue
// * @return
// * int value.
// */
// int getInt(String key, int defaultValue);
//
// /**
// * Return with string in contents of config file.
// *
// * @return
// * Contents of config file.
// */
// String getContents();
//
// /**
// * Return with Configuration object in contents of config file.
// *
// * @return
// * Contents of Configuration object.
// */
// Configuration getConfiguration();
//
// List<Object> getList(String key);
// }
//
// Path: src/main/java/org/okinawaopenlabs/ofpm/utils/ConfigImpl.java
// public class ConfigImpl implements Config {
//
// private static final Logger logger = Logger.getLogger(ConfigImpl.class);
//
// private Configuration config = null;
//
// /**
// * Load config file.
// *
// * @throws RuntimeException
// * Failed to load config file.
// */
// public ConfigImpl() {
// this(DEFAULT_PROPERTIY_FILE);
// }
//
// /**
// * Specify config file and then create instance.
// *
// * @param config
// * File path.
// */
// public ConfigImpl(String config) {
// try {
// this.config = new PropertiesConfiguration(config);
// } catch (ConfigurationException e) {
// String message = "failed to read config file.";
// logger.error(message);
// throw new RuntimeException(message, e);
// }
// }
//
// /**
// * Specify config object and then create instance.
// *
// * @param config
// * Config object.
// */
// public ConfigImpl(Configuration config) {
// this.config = config;
// }
//
// @Override
// public String getString(String key) {
// String value = getConfiguration().getString(key);
// return value;
// }
//
// @Override
// public String getString(String key, String defaultValue) {
// try {
// String value = getConfiguration().getString(key, defaultValue);
// return value;
// } catch (ConversionException e) {
// return defaultValue;
// }
// }
//
// @Override
// public int getInt(String key) {
// return getConfiguration().getInt(key);
// }
//
// @Override
// public int getInt(String key, int defaultValue) {
// try {
// int value = getConfiguration().getInt(key, defaultValue);
// return value;
// } catch (ConversionException e) {
// return defaultValue;
// }
// }
//
// @Override
// public String getContents() {
// PropertiesConfiguration prop = new PropertiesConfiguration();
// prop.append(this.config);
// StringWriter sw = new StringWriter();
// try {
// prop.save(sw);
// } catch (ConfigurationException e) {
// logger.error(e.getMessage());
// throw new RuntimeException(e);
// }
// return sw.toString();
// }
//
// /**
// * Configuration object is returned, it to provide reference to config file.
// *
// * @return
// * Configuration object to provide reference to config file.
// */
// @Override
// public Configuration getConfiguration() {
// return this.config;
// }
//
// @Override
// public List<Object> getList(String key) {
// List<Object> values = getConfiguration().getList(key);
// return values;
// }
// }
// Path: src/main/java/org/okinawaopenlabs/orientdb/client/ConnectionUtilsImpl.java
import java.sql.SQLException;
import java.util.List;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import org.okinawaopenlabs.ofpm.utils.Config;
import org.okinawaopenlabs.ofpm.utils.ConfigImpl;
/*
* Copyright 2015 Okinawa Open Laboratory, General Incorporated Association
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.okinawaopenlabs.orientdb.client;
public class ConnectionUtilsImpl implements ConnectionUtils {
/**
* 設定ファイル
*/
private Config config;
/**
* デフォルトのコンストラクタ.
*/
public ConnectionUtilsImpl() { | this.config = new ConfigImpl(); |
okinawaopenlabs/of-patch-manager | src/main/java/org/okinawaopenlabs/ofpm/json/topology/physical/PhysicalLink.java | // Path: src/main/java/org/okinawaopenlabs/ofpm/json/device/PortData.java
// public class PortData extends PortInfo implements Cloneable {
// private String deviceName;
//
// @Override
// public PortData clone() {
// PortData newObj = (PortData)super.clone();
// if (this.deviceName != null) {
// newObj.deviceName = new String(this.deviceName);
// }
// return newObj;
// }
// @Override
// public boolean equals(Object obj) {
// if (obj == this) return true;
// if (obj == null) return false;
// if (obj.getClass() != this.getClass()) return false;
// PortData other = (PortData)obj;
// if (!StringUtils.equals(other.deviceName, this.deviceName)) return false;
// return super.equals(obj);
// }
// @Override
// public int hashCode() {
// int hash = super.hashCode();
// if (this.deviceName != null) {
// hash += this.deviceName.hashCode();
// }
// return hash;
// }
// @Override
// public String toString() {
// Gson gson = new Gson();
// return gson.toJson(this);
// }
//
// /* Setters and Getters */
// public String getDeviceName() {
// return deviceName;
// }
// public void setDeviceName(String deviceName) {
// this.deviceName = deviceName;
// }
// }
| import java.lang.reflect.Type;
import java.util.List;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.okinawaopenlabs.ofpm.json.device.PortData; | /*
* Copyright 2015 Okinawa Open Laboratory, General Incorporated Association
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.okinawaopenlabs.ofpm.json.topology.physical;
public class PhysicalLink {
private String band; | // Path: src/main/java/org/okinawaopenlabs/ofpm/json/device/PortData.java
// public class PortData extends PortInfo implements Cloneable {
// private String deviceName;
//
// @Override
// public PortData clone() {
// PortData newObj = (PortData)super.clone();
// if (this.deviceName != null) {
// newObj.deviceName = new String(this.deviceName);
// }
// return newObj;
// }
// @Override
// public boolean equals(Object obj) {
// if (obj == this) return true;
// if (obj == null) return false;
// if (obj.getClass() != this.getClass()) return false;
// PortData other = (PortData)obj;
// if (!StringUtils.equals(other.deviceName, this.deviceName)) return false;
// return super.equals(obj);
// }
// @Override
// public int hashCode() {
// int hash = super.hashCode();
// if (this.deviceName != null) {
// hash += this.deviceName.hashCode();
// }
// return hash;
// }
// @Override
// public String toString() {
// Gson gson = new Gson();
// return gson.toJson(this);
// }
//
// /* Setters and Getters */
// public String getDeviceName() {
// return deviceName;
// }
// public void setDeviceName(String deviceName) {
// this.deviceName = deviceName;
// }
// }
// Path: src/main/java/org/okinawaopenlabs/ofpm/json/topology/physical/PhysicalLink.java
import java.lang.reflect.Type;
import java.util.List;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.okinawaopenlabs.ofpm.json.device.PortData;
/*
* Copyright 2015 Okinawa Open Laboratory, General Incorporated Association
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.okinawaopenlabs.ofpm.json.topology.physical;
public class PhysicalLink {
private String band; | private List<PortData> link; |
okinawaopenlabs/of-patch-manager | src/main/java/org/okinawaopenlabs/orientdb/client/ConnectionUtilsJdbcImpl.java | // Path: src/main/java/org/okinawaopenlabs/ofpm/utils/Config.java
// public interface Config {
// /**
// * Get value to corresponding to the key.
// *
// * @param key
// * @return
// * string value.
// */
// String getString(String key);
//
// /**
// * Get value to corresponding to the key.
// * Specified value is returned if not contains key to config file.
// *
// * @param key
// * @param defaultValue
// * @return
// * String value.
// */
// String getString(String key, String defaultValue);
//
// /**
// * Get value to corresponding to the key.
// *
// * @param key
// * @return
// * int value.
// */
// int getInt(String key);
//
// /**
// * Get value to corresponding to the key.
// * Specified value is returned if not contains key to config file.
// *
// * @param key
// * @param defaultValue
// * @return
// * int value.
// */
// int getInt(String key, int defaultValue);
//
// /**
// * Return with string in contents of config file.
// *
// * @return
// * Contents of config file.
// */
// String getContents();
//
// /**
// * Return with Configuration object in contents of config file.
// *
// * @return
// * Contents of Configuration object.
// */
// Configuration getConfiguration();
//
// List<Object> getList(String key);
// }
//
// Path: src/main/java/org/okinawaopenlabs/ofpm/utils/ConfigImpl.java
// public class ConfigImpl implements Config {
//
// private static final Logger logger = Logger.getLogger(ConfigImpl.class);
//
// private Configuration config = null;
//
// /**
// * Load config file.
// *
// * @throws RuntimeException
// * Failed to load config file.
// */
// public ConfigImpl() {
// this(DEFAULT_PROPERTIY_FILE);
// }
//
// /**
// * Specify config file and then create instance.
// *
// * @param config
// * File path.
// */
// public ConfigImpl(String config) {
// try {
// this.config = new PropertiesConfiguration(config);
// } catch (ConfigurationException e) {
// String message = "failed to read config file.";
// logger.error(message);
// throw new RuntimeException(message, e);
// }
// }
//
// /**
// * Specify config object and then create instance.
// *
// * @param config
// * Config object.
// */
// public ConfigImpl(Configuration config) {
// this.config = config;
// }
//
// @Override
// public String getString(String key) {
// String value = getConfiguration().getString(key);
// return value;
// }
//
// @Override
// public String getString(String key, String defaultValue) {
// try {
// String value = getConfiguration().getString(key, defaultValue);
// return value;
// } catch (ConversionException e) {
// return defaultValue;
// }
// }
//
// @Override
// public int getInt(String key) {
// return getConfiguration().getInt(key);
// }
//
// @Override
// public int getInt(String key, int defaultValue) {
// try {
// int value = getConfiguration().getInt(key, defaultValue);
// return value;
// } catch (ConversionException e) {
// return defaultValue;
// }
// }
//
// @Override
// public String getContents() {
// PropertiesConfiguration prop = new PropertiesConfiguration();
// prop.append(this.config);
// StringWriter sw = new StringWriter();
// try {
// prop.save(sw);
// } catch (ConfigurationException e) {
// logger.error(e.getMessage());
// throw new RuntimeException(e);
// }
// return sw.toString();
// }
//
// /**
// * Configuration object is returned, it to provide reference to config file.
// *
// * @return
// * Configuration object to provide reference to config file.
// */
// @Override
// public Configuration getConfiguration() {
// return this.config;
// }
//
// @Override
// public List<Object> getList(String key) {
// List<Object> values = getConfiguration().getList(key);
// return values;
// }
// }
| import java.sql.Connection;
import java.sql.SQLException;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.log4j.Logger;
import org.okinawaopenlabs.ofpm.utils.Config;
import org.okinawaopenlabs.ofpm.utils.ConfigImpl; | /*
* Copyright 2015 Okinawa Open Laboratory, General Incorporated Association
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.okinawaopenlabs.orientdb.client;
public class ConnectionUtilsJdbcImpl implements ConnectionUtilsJdbc {
private static final Logger logger = Logger.getLogger(ConnectionUtilsJdbcImpl.class);
/**
* setting file
*/ | // Path: src/main/java/org/okinawaopenlabs/ofpm/utils/Config.java
// public interface Config {
// /**
// * Get value to corresponding to the key.
// *
// * @param key
// * @return
// * string value.
// */
// String getString(String key);
//
// /**
// * Get value to corresponding to the key.
// * Specified value is returned if not contains key to config file.
// *
// * @param key
// * @param defaultValue
// * @return
// * String value.
// */
// String getString(String key, String defaultValue);
//
// /**
// * Get value to corresponding to the key.
// *
// * @param key
// * @return
// * int value.
// */
// int getInt(String key);
//
// /**
// * Get value to corresponding to the key.
// * Specified value is returned if not contains key to config file.
// *
// * @param key
// * @param defaultValue
// * @return
// * int value.
// */
// int getInt(String key, int defaultValue);
//
// /**
// * Return with string in contents of config file.
// *
// * @return
// * Contents of config file.
// */
// String getContents();
//
// /**
// * Return with Configuration object in contents of config file.
// *
// * @return
// * Contents of Configuration object.
// */
// Configuration getConfiguration();
//
// List<Object> getList(String key);
// }
//
// Path: src/main/java/org/okinawaopenlabs/ofpm/utils/ConfigImpl.java
// public class ConfigImpl implements Config {
//
// private static final Logger logger = Logger.getLogger(ConfigImpl.class);
//
// private Configuration config = null;
//
// /**
// * Load config file.
// *
// * @throws RuntimeException
// * Failed to load config file.
// */
// public ConfigImpl() {
// this(DEFAULT_PROPERTIY_FILE);
// }
//
// /**
// * Specify config file and then create instance.
// *
// * @param config
// * File path.
// */
// public ConfigImpl(String config) {
// try {
// this.config = new PropertiesConfiguration(config);
// } catch (ConfigurationException e) {
// String message = "failed to read config file.";
// logger.error(message);
// throw new RuntimeException(message, e);
// }
// }
//
// /**
// * Specify config object and then create instance.
// *
// * @param config
// * Config object.
// */
// public ConfigImpl(Configuration config) {
// this.config = config;
// }
//
// @Override
// public String getString(String key) {
// String value = getConfiguration().getString(key);
// return value;
// }
//
// @Override
// public String getString(String key, String defaultValue) {
// try {
// String value = getConfiguration().getString(key, defaultValue);
// return value;
// } catch (ConversionException e) {
// return defaultValue;
// }
// }
//
// @Override
// public int getInt(String key) {
// return getConfiguration().getInt(key);
// }
//
// @Override
// public int getInt(String key, int defaultValue) {
// try {
// int value = getConfiguration().getInt(key, defaultValue);
// return value;
// } catch (ConversionException e) {
// return defaultValue;
// }
// }
//
// @Override
// public String getContents() {
// PropertiesConfiguration prop = new PropertiesConfiguration();
// prop.append(this.config);
// StringWriter sw = new StringWriter();
// try {
// prop.save(sw);
// } catch (ConfigurationException e) {
// logger.error(e.getMessage());
// throw new RuntimeException(e);
// }
// return sw.toString();
// }
//
// /**
// * Configuration object is returned, it to provide reference to config file.
// *
// * @return
// * Configuration object to provide reference to config file.
// */
// @Override
// public Configuration getConfiguration() {
// return this.config;
// }
//
// @Override
// public List<Object> getList(String key) {
// List<Object> values = getConfiguration().getList(key);
// return values;
// }
// }
// Path: src/main/java/org/okinawaopenlabs/orientdb/client/ConnectionUtilsJdbcImpl.java
import java.sql.Connection;
import java.sql.SQLException;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.log4j.Logger;
import org.okinawaopenlabs.ofpm.utils.Config;
import org.okinawaopenlabs.ofpm.utils.ConfigImpl;
/*
* Copyright 2015 Okinawa Open Laboratory, General Incorporated Association
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.okinawaopenlabs.orientdb.client;
public class ConnectionUtilsJdbcImpl implements ConnectionUtilsJdbc {
private static final Logger logger = Logger.getLogger(ConnectionUtilsJdbcImpl.class);
/**
* setting file
*/ | private Config config; |
okinawaopenlabs/of-patch-manager | src/main/java/org/okinawaopenlabs/orientdb/client/ConnectionUtilsJdbcImpl.java | // Path: src/main/java/org/okinawaopenlabs/ofpm/utils/Config.java
// public interface Config {
// /**
// * Get value to corresponding to the key.
// *
// * @param key
// * @return
// * string value.
// */
// String getString(String key);
//
// /**
// * Get value to corresponding to the key.
// * Specified value is returned if not contains key to config file.
// *
// * @param key
// * @param defaultValue
// * @return
// * String value.
// */
// String getString(String key, String defaultValue);
//
// /**
// * Get value to corresponding to the key.
// *
// * @param key
// * @return
// * int value.
// */
// int getInt(String key);
//
// /**
// * Get value to corresponding to the key.
// * Specified value is returned if not contains key to config file.
// *
// * @param key
// * @param defaultValue
// * @return
// * int value.
// */
// int getInt(String key, int defaultValue);
//
// /**
// * Return with string in contents of config file.
// *
// * @return
// * Contents of config file.
// */
// String getContents();
//
// /**
// * Return with Configuration object in contents of config file.
// *
// * @return
// * Contents of Configuration object.
// */
// Configuration getConfiguration();
//
// List<Object> getList(String key);
// }
//
// Path: src/main/java/org/okinawaopenlabs/ofpm/utils/ConfigImpl.java
// public class ConfigImpl implements Config {
//
// private static final Logger logger = Logger.getLogger(ConfigImpl.class);
//
// private Configuration config = null;
//
// /**
// * Load config file.
// *
// * @throws RuntimeException
// * Failed to load config file.
// */
// public ConfigImpl() {
// this(DEFAULT_PROPERTIY_FILE);
// }
//
// /**
// * Specify config file and then create instance.
// *
// * @param config
// * File path.
// */
// public ConfigImpl(String config) {
// try {
// this.config = new PropertiesConfiguration(config);
// } catch (ConfigurationException e) {
// String message = "failed to read config file.";
// logger.error(message);
// throw new RuntimeException(message, e);
// }
// }
//
// /**
// * Specify config object and then create instance.
// *
// * @param config
// * Config object.
// */
// public ConfigImpl(Configuration config) {
// this.config = config;
// }
//
// @Override
// public String getString(String key) {
// String value = getConfiguration().getString(key);
// return value;
// }
//
// @Override
// public String getString(String key, String defaultValue) {
// try {
// String value = getConfiguration().getString(key, defaultValue);
// return value;
// } catch (ConversionException e) {
// return defaultValue;
// }
// }
//
// @Override
// public int getInt(String key) {
// return getConfiguration().getInt(key);
// }
//
// @Override
// public int getInt(String key, int defaultValue) {
// try {
// int value = getConfiguration().getInt(key, defaultValue);
// return value;
// } catch (ConversionException e) {
// return defaultValue;
// }
// }
//
// @Override
// public String getContents() {
// PropertiesConfiguration prop = new PropertiesConfiguration();
// prop.append(this.config);
// StringWriter sw = new StringWriter();
// try {
// prop.save(sw);
// } catch (ConfigurationException e) {
// logger.error(e.getMessage());
// throw new RuntimeException(e);
// }
// return sw.toString();
// }
//
// /**
// * Configuration object is returned, it to provide reference to config file.
// *
// * @return
// * Configuration object to provide reference to config file.
// */
// @Override
// public Configuration getConfiguration() {
// return this.config;
// }
//
// @Override
// public List<Object> getList(String key) {
// List<Object> values = getConfiguration().getList(key);
// return values;
// }
// }
| import java.sql.Connection;
import java.sql.SQLException;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.log4j.Logger;
import org.okinawaopenlabs.ofpm.utils.Config;
import org.okinawaopenlabs.ofpm.utils.ConfigImpl; | /*
* Copyright 2015 Okinawa Open Laboratory, General Incorporated Association
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.okinawaopenlabs.orientdb.client;
public class ConnectionUtilsJdbcImpl implements ConnectionUtilsJdbc {
private static final Logger logger = Logger.getLogger(ConnectionUtilsJdbcImpl.class);
/**
* setting file
*/
private Config config;
/**
* default constructor
*/
public ConnectionUtilsJdbcImpl() { | // Path: src/main/java/org/okinawaopenlabs/ofpm/utils/Config.java
// public interface Config {
// /**
// * Get value to corresponding to the key.
// *
// * @param key
// * @return
// * string value.
// */
// String getString(String key);
//
// /**
// * Get value to corresponding to the key.
// * Specified value is returned if not contains key to config file.
// *
// * @param key
// * @param defaultValue
// * @return
// * String value.
// */
// String getString(String key, String defaultValue);
//
// /**
// * Get value to corresponding to the key.
// *
// * @param key
// * @return
// * int value.
// */
// int getInt(String key);
//
// /**
// * Get value to corresponding to the key.
// * Specified value is returned if not contains key to config file.
// *
// * @param key
// * @param defaultValue
// * @return
// * int value.
// */
// int getInt(String key, int defaultValue);
//
// /**
// * Return with string in contents of config file.
// *
// * @return
// * Contents of config file.
// */
// String getContents();
//
// /**
// * Return with Configuration object in contents of config file.
// *
// * @return
// * Contents of Configuration object.
// */
// Configuration getConfiguration();
//
// List<Object> getList(String key);
// }
//
// Path: src/main/java/org/okinawaopenlabs/ofpm/utils/ConfigImpl.java
// public class ConfigImpl implements Config {
//
// private static final Logger logger = Logger.getLogger(ConfigImpl.class);
//
// private Configuration config = null;
//
// /**
// * Load config file.
// *
// * @throws RuntimeException
// * Failed to load config file.
// */
// public ConfigImpl() {
// this(DEFAULT_PROPERTIY_FILE);
// }
//
// /**
// * Specify config file and then create instance.
// *
// * @param config
// * File path.
// */
// public ConfigImpl(String config) {
// try {
// this.config = new PropertiesConfiguration(config);
// } catch (ConfigurationException e) {
// String message = "failed to read config file.";
// logger.error(message);
// throw new RuntimeException(message, e);
// }
// }
//
// /**
// * Specify config object and then create instance.
// *
// * @param config
// * Config object.
// */
// public ConfigImpl(Configuration config) {
// this.config = config;
// }
//
// @Override
// public String getString(String key) {
// String value = getConfiguration().getString(key);
// return value;
// }
//
// @Override
// public String getString(String key, String defaultValue) {
// try {
// String value = getConfiguration().getString(key, defaultValue);
// return value;
// } catch (ConversionException e) {
// return defaultValue;
// }
// }
//
// @Override
// public int getInt(String key) {
// return getConfiguration().getInt(key);
// }
//
// @Override
// public int getInt(String key, int defaultValue) {
// try {
// int value = getConfiguration().getInt(key, defaultValue);
// return value;
// } catch (ConversionException e) {
// return defaultValue;
// }
// }
//
// @Override
// public String getContents() {
// PropertiesConfiguration prop = new PropertiesConfiguration();
// prop.append(this.config);
// StringWriter sw = new StringWriter();
// try {
// prop.save(sw);
// } catch (ConfigurationException e) {
// logger.error(e.getMessage());
// throw new RuntimeException(e);
// }
// return sw.toString();
// }
//
// /**
// * Configuration object is returned, it to provide reference to config file.
// *
// * @return
// * Configuration object to provide reference to config file.
// */
// @Override
// public Configuration getConfiguration() {
// return this.config;
// }
//
// @Override
// public List<Object> getList(String key) {
// List<Object> values = getConfiguration().getList(key);
// return values;
// }
// }
// Path: src/main/java/org/okinawaopenlabs/orientdb/client/ConnectionUtilsJdbcImpl.java
import java.sql.Connection;
import java.sql.SQLException;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.log4j.Logger;
import org.okinawaopenlabs.ofpm.utils.Config;
import org.okinawaopenlabs.ofpm.utils.ConfigImpl;
/*
* Copyright 2015 Okinawa Open Laboratory, General Incorporated Association
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.okinawaopenlabs.orientdb.client;
public class ConnectionUtilsJdbcImpl implements ConnectionUtilsJdbc {
private static final Logger logger = Logger.getLogger(ConnectionUtilsJdbcImpl.class);
/**
* setting file
*/
private Config config;
/**
* default constructor
*/
public ConnectionUtilsJdbcImpl() { | this.config = new ConfigImpl(); |
okinawaopenlabs/of-patch-manager | src/main/java/org/okinawaopenlabs/ofpm/json/common/GraphDevicePort.java | // Path: src/main/java/org/okinawaopenlabs/ofpm/json/device/DeviceType.java
// public enum DeviceType {
// SWITCH("Switch"),
// SERVER("Server");
// private final String param;
// private DeviceType(final String param) {
// this.param = param;
// }
// @Override
// public String toString() {
// return this.param;
// }
// }
| import java.lang.reflect.Type;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.okinawaopenlabs.ofpm.json.device.DeviceType; | /*
* Copyright 2015 Okinawa Open Laboratory, General Incorporated Association
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.okinawaopenlabs.ofpm.json.common;
public class GraphDevicePort {
private String deviceName; | // Path: src/main/java/org/okinawaopenlabs/ofpm/json/device/DeviceType.java
// public enum DeviceType {
// SWITCH("Switch"),
// SERVER("Server");
// private final String param;
// private DeviceType(final String param) {
// this.param = param;
// }
// @Override
// public String toString() {
// return this.param;
// }
// }
// Path: src/main/java/org/okinawaopenlabs/ofpm/json/common/GraphDevicePort.java
import java.lang.reflect.Type;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.okinawaopenlabs.ofpm.json.device.DeviceType;
/*
* Copyright 2015 Okinawa Open Laboratory, General Incorporated Association
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.okinawaopenlabs.ofpm.json.common;
public class GraphDevicePort {
private String deviceName; | private DeviceType deviceType; |
okinawaopenlabs/of-patch-manager | src/main/java/org/okinawaopenlabs/ofpm/validate/common/BaseValidate.java | // Path: src/main/java/org/okinawaopenlabs/constants/ErrorMessage.java
// public class ErrorMessage {
// public static final String CONNECTION_FAIL = "Connection failed: %s.";
// public static final String WRONG_RESPONSE = "Response of %s is wrong.";
// public static final String INVALID_JSON = "Invalid json syntax.";
// public static final String INVALID_PARAMETER = "%s is invalid parameter.";
//
// public static final String IS_NULL = "%s is null.";
// public static final String IS_BLANK = "%s is blank.";
// public static final String IS_NOT_NULL = "%s is not null.";
// public static final String IS_NOT_BLANK = "%s is not blank.";
// public static final String IS_NOT_INCLUDED = "%s is not included %s.";
// public static final String IS_OVERLAPPED = "%s is overlapped.";
// public static final String THERE_IS_NULL = "There is null in %s.";
// public static final String THERE_IS_BLANK = "There is blank in %s";
// public static final String THERE_IS_INVALID_PARAMETER = "There is invalid parameter %s.";
// public static final String THERE_ARE_OVERLAPPED = "There are overlapped %s.";
//
// public static final String ALREADY_EXIST = "%s is already exists";
// public static final String FIND_NULL = "Find %s thats %s is null";
// public static final String NOT_FOUND = "%s is not found.";
// public static final String IS_FULL = "%s is full.";
// public static final String UNEXPECTED_ERROR = "Unexpected error.";
// public static final String RETURNED_NULL = "%s returned null.";
// public static final String NOW_USED = "%s is now assigned.";
//
// public static final String IS_PATCHED = "%s is patched";
// public static final String IS_NO_ROUTE = "There is no route between %s and %s.";
// public static final String IS_NOT_NUMBER = "%s is not number.";
//
// public static final String PARSE_ERROR = "Parse error: %s";
//
// public static final String COULD_NOT_DELETE = "Couldn't delete %s";
// public static final String INVALID_NUMBER_OF = "Invalid number of %s.";
// public static final String PATCH_INSERT_FAILD = "patchWiring insert failed. %s[%s]-%s[%s]@%s(%s,%s)";
// public static final String ROUTE_INSERT_FAILD = "route insert failed. sequence_num=%s, logical_link_id=%s, node_id=%s, node_name=%s, in_port_id=%s, in_port_name=%s, in_port_number=%s, out_port_id=%s, out_port_name=%s, out_port_number=%s";
// }
//
// Path: src/main/java/org/okinawaopenlabs/ofpm/exception/ValidateException.java
// public class ValidateException extends Exception {
// public ValidateException(String mes) {
// super(mes);
// }
// }
| import java.util.List;
import org.apache.commons.lang3.StringUtils;
import static org.okinawaopenlabs.constants.ErrorMessage.*;
import org.okinawaopenlabs.ofpm.exception.ValidateException; | /*
* Copyright 2015 Okinawa Open Laboratory, General Incorporated Association
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.okinawaopenlabs.ofpm.validate.common;
public abstract class BaseValidate {
/**
* Determine if Object is null.
*
* @param value
* @return
* true : Not null. <br>
* false: null.
*/
protected static boolean checkNull(Object value) {
return value == null;
}
/**
* Determine if length of string is less than or equal length.
*
* @param value
* @param length
* @return
* true : Not over. <br>
* false: Over.
*/
protected static boolean checkOverLength(String value, int length) {
if (value.length() > length) {
return true;
}
return false;
}
/**
* Determine if string contains multi-byte charactor.
*
* @param value
* @return
* true : Not contains multi-byte charactor. <br>
* false: Contains multi-byte charactor.
*/
protected static boolean checkHalfNum(String value) {
if (value == null || !value.matches("^[0-9]+$")) {
return false;
}
return true;
}
| // Path: src/main/java/org/okinawaopenlabs/constants/ErrorMessage.java
// public class ErrorMessage {
// public static final String CONNECTION_FAIL = "Connection failed: %s.";
// public static final String WRONG_RESPONSE = "Response of %s is wrong.";
// public static final String INVALID_JSON = "Invalid json syntax.";
// public static final String INVALID_PARAMETER = "%s is invalid parameter.";
//
// public static final String IS_NULL = "%s is null.";
// public static final String IS_BLANK = "%s is blank.";
// public static final String IS_NOT_NULL = "%s is not null.";
// public static final String IS_NOT_BLANK = "%s is not blank.";
// public static final String IS_NOT_INCLUDED = "%s is not included %s.";
// public static final String IS_OVERLAPPED = "%s is overlapped.";
// public static final String THERE_IS_NULL = "There is null in %s.";
// public static final String THERE_IS_BLANK = "There is blank in %s";
// public static final String THERE_IS_INVALID_PARAMETER = "There is invalid parameter %s.";
// public static final String THERE_ARE_OVERLAPPED = "There are overlapped %s.";
//
// public static final String ALREADY_EXIST = "%s is already exists";
// public static final String FIND_NULL = "Find %s thats %s is null";
// public static final String NOT_FOUND = "%s is not found.";
// public static final String IS_FULL = "%s is full.";
// public static final String UNEXPECTED_ERROR = "Unexpected error.";
// public static final String RETURNED_NULL = "%s returned null.";
// public static final String NOW_USED = "%s is now assigned.";
//
// public static final String IS_PATCHED = "%s is patched";
// public static final String IS_NO_ROUTE = "There is no route between %s and %s.";
// public static final String IS_NOT_NUMBER = "%s is not number.";
//
// public static final String PARSE_ERROR = "Parse error: %s";
//
// public static final String COULD_NOT_DELETE = "Couldn't delete %s";
// public static final String INVALID_NUMBER_OF = "Invalid number of %s.";
// public static final String PATCH_INSERT_FAILD = "patchWiring insert failed. %s[%s]-%s[%s]@%s(%s,%s)";
// public static final String ROUTE_INSERT_FAILD = "route insert failed. sequence_num=%s, logical_link_id=%s, node_id=%s, node_name=%s, in_port_id=%s, in_port_name=%s, in_port_number=%s, out_port_id=%s, out_port_name=%s, out_port_number=%s";
// }
//
// Path: src/main/java/org/okinawaopenlabs/ofpm/exception/ValidateException.java
// public class ValidateException extends Exception {
// public ValidateException(String mes) {
// super(mes);
// }
// }
// Path: src/main/java/org/okinawaopenlabs/ofpm/validate/common/BaseValidate.java
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import static org.okinawaopenlabs.constants.ErrorMessage.*;
import org.okinawaopenlabs.ofpm.exception.ValidateException;
/*
* Copyright 2015 Okinawa Open Laboratory, General Incorporated Association
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.okinawaopenlabs.ofpm.validate.common;
public abstract class BaseValidate {
/**
* Determine if Object is null.
*
* @param value
* @return
* true : Not null. <br>
* false: null.
*/
protected static boolean checkNull(Object value) {
return value == null;
}
/**
* Determine if length of string is less than or equal length.
*
* @param value
* @param length
* @return
* true : Not over. <br>
* false: Over.
*/
protected static boolean checkOverLength(String value, int length) {
if (value.length() > length) {
return true;
}
return false;
}
/**
* Determine if string contains multi-byte charactor.
*
* @param value
* @return
* true : Not contains multi-byte charactor. <br>
* false: Contains multi-byte charactor.
*/
protected static boolean checkHalfNum(String value) {
if (value == null || !value.matches("^[0-9]+$")) {
return false;
}
return true;
}
| public static void checkArrayStringBlank(List<String> params) throws ValidateException { |
amplitude/Amplitude-Android | src/test/java/com/amplitude/api/ConfigManagerTest.java | // Path: src/test/java/com/amplitude/api/util/MockHttpURLConnectionHelper.java
// public class MockHttpURLConnectionHelper {
//
// public static HttpURLConnection getMockHttpURLConnection(int code, String response)
// throws IOException {
// HttpURLConnection connection = mock(HttpURLConnection.class);
// OutputStream outputStream = mock(OutputStream.class);
// when(connection.getOutputStream()).thenReturn(outputStream);
// when(connection.getResponseCode()).thenReturn(code);
// InputStream inputStream = new ByteArrayInputStream(response.getBytes(StandardCharsets.UTF_8));
// if (code == 200) {
// when(connection.getInputStream()).thenReturn(inputStream);
// } else {
// when(connection.getErrorStream()).thenReturn(inputStream);
// }
// return connection;
// }
// }
//
// Path: src/test/java/com/amplitude/api/util/MockURLStreamHandler.java
// public class MockURLStreamHandler extends URLStreamHandler implements URLStreamHandlerFactory {
//
// private final Map<URL, URLConnection> connections = new HashMap<>();
//
// private static final MockURLStreamHandler instance = new MockURLStreamHandler();
//
// public static MockURLStreamHandler getInstance() {
// return instance;
// }
//
// @Override
// protected URLConnection openConnection(URL url) throws IOException {
// return connections.get(url);
// }
//
// public void resetConnections() {
// connections.clear();
// }
//
// public MockURLStreamHandler setConnection(URL url, URLConnection urlConnection) {
// connections.put(url, urlConnection);
// return this;
// }
//
// @Override
// public URLStreamHandler createURLStreamHandler(String protocol) {
// return getInstance();
// }
// }
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.amplitude.api.util.MockHttpURLConnectionHelper;
import com.amplitude.api.util.MockURLStreamHandler;
import org.json.JSONObject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import java.net.HttpURLConnection;
import java.net.URL;
import static org.junit.Assert.assertEquals; | package com.amplitude.api;
@RunWith(AndroidJUnit4.class)
@Config(manifest=Config.NONE)
public class ConfigManagerTest { | // Path: src/test/java/com/amplitude/api/util/MockHttpURLConnectionHelper.java
// public class MockHttpURLConnectionHelper {
//
// public static HttpURLConnection getMockHttpURLConnection(int code, String response)
// throws IOException {
// HttpURLConnection connection = mock(HttpURLConnection.class);
// OutputStream outputStream = mock(OutputStream.class);
// when(connection.getOutputStream()).thenReturn(outputStream);
// when(connection.getResponseCode()).thenReturn(code);
// InputStream inputStream = new ByteArrayInputStream(response.getBytes(StandardCharsets.UTF_8));
// if (code == 200) {
// when(connection.getInputStream()).thenReturn(inputStream);
// } else {
// when(connection.getErrorStream()).thenReturn(inputStream);
// }
// return connection;
// }
// }
//
// Path: src/test/java/com/amplitude/api/util/MockURLStreamHandler.java
// public class MockURLStreamHandler extends URLStreamHandler implements URLStreamHandlerFactory {
//
// private final Map<URL, URLConnection> connections = new HashMap<>();
//
// private static final MockURLStreamHandler instance = new MockURLStreamHandler();
//
// public static MockURLStreamHandler getInstance() {
// return instance;
// }
//
// @Override
// protected URLConnection openConnection(URL url) throws IOException {
// return connections.get(url);
// }
//
// public void resetConnections() {
// connections.clear();
// }
//
// public MockURLStreamHandler setConnection(URL url, URLConnection urlConnection) {
// connections.put(url, urlConnection);
// return this;
// }
//
// @Override
// public URLStreamHandler createURLStreamHandler(String protocol) {
// return getInstance();
// }
// }
// Path: src/test/java/com/amplitude/api/ConfigManagerTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.amplitude.api.util.MockHttpURLConnectionHelper;
import com.amplitude.api.util.MockURLStreamHandler;
import org.json.JSONObject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import java.net.HttpURLConnection;
import java.net.URL;
import static org.junit.Assert.assertEquals;
package com.amplitude.api;
@RunWith(AndroidJUnit4.class)
@Config(manifest=Config.NONE)
public class ConfigManagerTest { | private final MockURLStreamHandler mockURLStreamHandler = MockURLStreamHandler.getInstance(); |
amplitude/Amplitude-Android | src/test/java/com/amplitude/api/ConfigManagerTest.java | // Path: src/test/java/com/amplitude/api/util/MockHttpURLConnectionHelper.java
// public class MockHttpURLConnectionHelper {
//
// public static HttpURLConnection getMockHttpURLConnection(int code, String response)
// throws IOException {
// HttpURLConnection connection = mock(HttpURLConnection.class);
// OutputStream outputStream = mock(OutputStream.class);
// when(connection.getOutputStream()).thenReturn(outputStream);
// when(connection.getResponseCode()).thenReturn(code);
// InputStream inputStream = new ByteArrayInputStream(response.getBytes(StandardCharsets.UTF_8));
// if (code == 200) {
// when(connection.getInputStream()).thenReturn(inputStream);
// } else {
// when(connection.getErrorStream()).thenReturn(inputStream);
// }
// return connection;
// }
// }
//
// Path: src/test/java/com/amplitude/api/util/MockURLStreamHandler.java
// public class MockURLStreamHandler extends URLStreamHandler implements URLStreamHandlerFactory {
//
// private final Map<URL, URLConnection> connections = new HashMap<>();
//
// private static final MockURLStreamHandler instance = new MockURLStreamHandler();
//
// public static MockURLStreamHandler getInstance() {
// return instance;
// }
//
// @Override
// protected URLConnection openConnection(URL url) throws IOException {
// return connections.get(url);
// }
//
// public void resetConnections() {
// connections.clear();
// }
//
// public MockURLStreamHandler setConnection(URL url, URLConnection urlConnection) {
// connections.put(url, urlConnection);
// return this;
// }
//
// @Override
// public URLStreamHandler createURLStreamHandler(String protocol) {
// return getInstance();
// }
// }
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.amplitude.api.util.MockHttpURLConnectionHelper;
import com.amplitude.api.util.MockURLStreamHandler;
import org.json.JSONObject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import java.net.HttpURLConnection;
import java.net.URL;
import static org.junit.Assert.assertEquals; | package com.amplitude.api;
@RunWith(AndroidJUnit4.class)
@Config(manifest=Config.NONE)
public class ConfigManagerTest {
private final MockURLStreamHandler mockURLStreamHandler = MockURLStreamHandler.getInstance();
@Test
public void testRefreshForEU() throws Exception {
assertEquals(Constants.EVENT_LOG_URL, ConfigManager.getInstance().getIngestionEndpoint());
JSONObject responseObject = new JSONObject();
responseObject.put("code", 200);
responseObject.put("ingestionEndpoint", "api.eu.amplitude.com");
URL url = new URL(Constants.DYNAMIC_CONFIG_EU_URL);
AmplitudeServerZone euZone = AmplitudeServerZone.EU;
HttpURLConnection connection = | // Path: src/test/java/com/amplitude/api/util/MockHttpURLConnectionHelper.java
// public class MockHttpURLConnectionHelper {
//
// public static HttpURLConnection getMockHttpURLConnection(int code, String response)
// throws IOException {
// HttpURLConnection connection = mock(HttpURLConnection.class);
// OutputStream outputStream = mock(OutputStream.class);
// when(connection.getOutputStream()).thenReturn(outputStream);
// when(connection.getResponseCode()).thenReturn(code);
// InputStream inputStream = new ByteArrayInputStream(response.getBytes(StandardCharsets.UTF_8));
// if (code == 200) {
// when(connection.getInputStream()).thenReturn(inputStream);
// } else {
// when(connection.getErrorStream()).thenReturn(inputStream);
// }
// return connection;
// }
// }
//
// Path: src/test/java/com/amplitude/api/util/MockURLStreamHandler.java
// public class MockURLStreamHandler extends URLStreamHandler implements URLStreamHandlerFactory {
//
// private final Map<URL, URLConnection> connections = new HashMap<>();
//
// private static final MockURLStreamHandler instance = new MockURLStreamHandler();
//
// public static MockURLStreamHandler getInstance() {
// return instance;
// }
//
// @Override
// protected URLConnection openConnection(URL url) throws IOException {
// return connections.get(url);
// }
//
// public void resetConnections() {
// connections.clear();
// }
//
// public MockURLStreamHandler setConnection(URL url, URLConnection urlConnection) {
// connections.put(url, urlConnection);
// return this;
// }
//
// @Override
// public URLStreamHandler createURLStreamHandler(String protocol) {
// return getInstance();
// }
// }
// Path: src/test/java/com/amplitude/api/ConfigManagerTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.amplitude.api.util.MockHttpURLConnectionHelper;
import com.amplitude.api.util.MockURLStreamHandler;
import org.json.JSONObject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import java.net.HttpURLConnection;
import java.net.URL;
import static org.junit.Assert.assertEquals;
package com.amplitude.api;
@RunWith(AndroidJUnit4.class)
@Config(manifest=Config.NONE)
public class ConfigManagerTest {
private final MockURLStreamHandler mockURLStreamHandler = MockURLStreamHandler.getInstance();
@Test
public void testRefreshForEU() throws Exception {
assertEquals(Constants.EVENT_LOG_URL, ConfigManager.getInstance().getIngestionEndpoint());
JSONObject responseObject = new JSONObject();
responseObject.put("code", 200);
responseObject.put("ingestionEndpoint", "api.eu.amplitude.com");
URL url = new URL(Constants.DYNAMIC_CONFIG_EU_URL);
AmplitudeServerZone euZone = AmplitudeServerZone.EU;
HttpURLConnection connection = | MockHttpURLConnectionHelper.getMockHttpURLConnection(200, responseObject.toString()); |
amplitude/Amplitude-Android | src/main/java/com/amplitude/api/PinnedAmplitudeClient.java | // Path: src/main/java/com/amplitude/util/DoubleCheck.java
// public class DoubleCheck<T> implements Provider<T> {
// private static final Object UNINITIALIZED = new Object();
//
// private volatile Provider<T> provider;
// private volatile Object instance = UNINITIALIZED;
//
// private DoubleCheck(Provider<T> provider) {
// assert provider != null;
// this.provider = provider;
// }
//
// @SuppressWarnings("unchecked") // cast only happens when result comes from the provider
// @Override
// public T get() {
// Object result = instance;
// if (result == UNINITIALIZED) {
// synchronized (this) {
// result = instance;
// if (result == UNINITIALIZED) {
// result = provider.get();
// instance = reentrantCheck(instance, result);
// /* Null out the reference to the provider. We are never going to need it again, so we
// * can make it eligible for GC. */
// provider = null;
// }
// }
// }
// return (T) result;
// }
//
// /**
// * Checks to see if creating the new instance has resulted in a recursive call. If it has, and the
// * new instance is the same as the current instance, return the instance. However, if the new
// * instance differs from the current instance, an {@link IllegalStateException} is thrown.
// */
// public static Object reentrantCheck(Object currentInstance, Object newInstance) {
// boolean isReentrant = !(currentInstance == UNINITIALIZED);
//
// if (isReentrant && currentInstance != newInstance) {
// throw new IllegalStateException("Scoped provider was invoked recursively returning "
// + "different results: " + currentInstance + " & " + newInstance + ". This is likely "
// + "due to a circular dependency.");
// }
// return newInstance;
// }
//
// /** Returns a {@link Provider} that caches the value from the given delegate provider. */
// public static <P extends Provider<T>, T> Provider<T> provider(P delegate) {
// if (delegate == null) {
// throw new IllegalArgumentException("delegate cannot be null");
// }
// if (delegate instanceof DoubleCheck) {
// /* This should be a rare case, but if we have a scoped @Binds that delegates to a scoped
// * binding, we shouldn't cache the value again. */
// return delegate;
// }
// return new DoubleCheck<T>(delegate);
// }
// }
//
// Path: src/main/java/com/amplitude/util/Provider.java
// public interface Provider<T> {
// T get();
// }
| import android.content.Context;
import com.amplitude.util.DoubleCheck;
import com.amplitude.util.Provider;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import okhttp3.OkHttpClient;
import okio.Buffer;
import okio.ByteString; | instance = Utils.normalizeInstanceName(instance);
PinnedAmplitudeClient client = instances.get(instance);
if (client == null) {
client = new PinnedAmplitudeClient(instance);
instances.put(instance, client);
}
return client;
}
/**
* The SSl socket factory.
*/
protected SSLSocketFactory sslSocketFactory;
/**
* Instantiates a new Pinned amplitude client.
*/
public PinnedAmplitudeClient(String instance) {
super(instance);
}
/**
* The Initialized ssl socket factory.
*/
protected boolean initializedSSLSocketFactory = false;
public synchronized AmplitudeClient initializeInternal(
Context context,
String apiKey,
String userId, | // Path: src/main/java/com/amplitude/util/DoubleCheck.java
// public class DoubleCheck<T> implements Provider<T> {
// private static final Object UNINITIALIZED = new Object();
//
// private volatile Provider<T> provider;
// private volatile Object instance = UNINITIALIZED;
//
// private DoubleCheck(Provider<T> provider) {
// assert provider != null;
// this.provider = provider;
// }
//
// @SuppressWarnings("unchecked") // cast only happens when result comes from the provider
// @Override
// public T get() {
// Object result = instance;
// if (result == UNINITIALIZED) {
// synchronized (this) {
// result = instance;
// if (result == UNINITIALIZED) {
// result = provider.get();
// instance = reentrantCheck(instance, result);
// /* Null out the reference to the provider. We are never going to need it again, so we
// * can make it eligible for GC. */
// provider = null;
// }
// }
// }
// return (T) result;
// }
//
// /**
// * Checks to see if creating the new instance has resulted in a recursive call. If it has, and the
// * new instance is the same as the current instance, return the instance. However, if the new
// * instance differs from the current instance, an {@link IllegalStateException} is thrown.
// */
// public static Object reentrantCheck(Object currentInstance, Object newInstance) {
// boolean isReentrant = !(currentInstance == UNINITIALIZED);
//
// if (isReentrant && currentInstance != newInstance) {
// throw new IllegalStateException("Scoped provider was invoked recursively returning "
// + "different results: " + currentInstance + " & " + newInstance + ". This is likely "
// + "due to a circular dependency.");
// }
// return newInstance;
// }
//
// /** Returns a {@link Provider} that caches the value from the given delegate provider. */
// public static <P extends Provider<T>, T> Provider<T> provider(P delegate) {
// if (delegate == null) {
// throw new IllegalArgumentException("delegate cannot be null");
// }
// if (delegate instanceof DoubleCheck) {
// /* This should be a rare case, but if we have a scoped @Binds that delegates to a scoped
// * binding, we shouldn't cache the value again. */
// return delegate;
// }
// return new DoubleCheck<T>(delegate);
// }
// }
//
// Path: src/main/java/com/amplitude/util/Provider.java
// public interface Provider<T> {
// T get();
// }
// Path: src/main/java/com/amplitude/api/PinnedAmplitudeClient.java
import android.content.Context;
import com.amplitude.util.DoubleCheck;
import com.amplitude.util.Provider;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import okhttp3.OkHttpClient;
import okio.Buffer;
import okio.ByteString;
instance = Utils.normalizeInstanceName(instance);
PinnedAmplitudeClient client = instances.get(instance);
if (client == null) {
client = new PinnedAmplitudeClient(instance);
instances.put(instance, client);
}
return client;
}
/**
* The SSl socket factory.
*/
protected SSLSocketFactory sslSocketFactory;
/**
* Instantiates a new Pinned amplitude client.
*/
public PinnedAmplitudeClient(String instance) {
super(instance);
}
/**
* The Initialized ssl socket factory.
*/
protected boolean initializedSSLSocketFactory = false;
public synchronized AmplitudeClient initializeInternal(
Context context,
String apiKey,
String userId, | Provider<OkHttpClient> clientProvider |
amplitude/Amplitude-Android | src/main/java/com/amplitude/api/PinnedAmplitudeClient.java | // Path: src/main/java/com/amplitude/util/DoubleCheck.java
// public class DoubleCheck<T> implements Provider<T> {
// private static final Object UNINITIALIZED = new Object();
//
// private volatile Provider<T> provider;
// private volatile Object instance = UNINITIALIZED;
//
// private DoubleCheck(Provider<T> provider) {
// assert provider != null;
// this.provider = provider;
// }
//
// @SuppressWarnings("unchecked") // cast only happens when result comes from the provider
// @Override
// public T get() {
// Object result = instance;
// if (result == UNINITIALIZED) {
// synchronized (this) {
// result = instance;
// if (result == UNINITIALIZED) {
// result = provider.get();
// instance = reentrantCheck(instance, result);
// /* Null out the reference to the provider. We are never going to need it again, so we
// * can make it eligible for GC. */
// provider = null;
// }
// }
// }
// return (T) result;
// }
//
// /**
// * Checks to see if creating the new instance has resulted in a recursive call. If it has, and the
// * new instance is the same as the current instance, return the instance. However, if the new
// * instance differs from the current instance, an {@link IllegalStateException} is thrown.
// */
// public static Object reentrantCheck(Object currentInstance, Object newInstance) {
// boolean isReentrant = !(currentInstance == UNINITIALIZED);
//
// if (isReentrant && currentInstance != newInstance) {
// throw new IllegalStateException("Scoped provider was invoked recursively returning "
// + "different results: " + currentInstance + " & " + newInstance + ". This is likely "
// + "due to a circular dependency.");
// }
// return newInstance;
// }
//
// /** Returns a {@link Provider} that caches the value from the given delegate provider. */
// public static <P extends Provider<T>, T> Provider<T> provider(P delegate) {
// if (delegate == null) {
// throw new IllegalArgumentException("delegate cannot be null");
// }
// if (delegate instanceof DoubleCheck) {
// /* This should be a rare case, but if we have a scoped @Binds that delegates to a scoped
// * binding, we shouldn't cache the value again. */
// return delegate;
// }
// return new DoubleCheck<T>(delegate);
// }
// }
//
// Path: src/main/java/com/amplitude/util/Provider.java
// public interface Provider<T> {
// T get();
// }
| import android.content.Context;
import com.amplitude.util.DoubleCheck;
import com.amplitude.util.Provider;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import okhttp3.OkHttpClient;
import okio.Buffer;
import okio.ByteString; | SSLSocketFactory factory = getPinnedCertSslSocketFactory();
if (factory != null) {
try {
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(
TrustManagerFactory.getDefaultAlgorithm());
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, null); // Use a null input stream + password to create an empty key store.
List<String> certificateBase64s = new ArrayList<String>();
certificateBase64s.add(CERTIFICATE_1);
// Decode the certificates and add 'em to the key store.
int nextName = 1;
for (String certificateBase64 : certificateBase64s) {
Buffer certificateBuffer = new Buffer().write(ByteString.decodeBase64(certificateBase64));
X509Certificate certificate = (X509Certificate) certificateFactory.generateCertificate(
certificateBuffer.inputStream());
keyStore.setCertificateEntry(Integer.toString(nextName++), certificate);
}
// Create an SSL context that uses these certificates as its trust store.
trustManagerFactory.init(keyStore);
TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) {
throw new IllegalStateException("Unexpected default trust managers:"
+ Arrays.toString(trustManagers));
}
X509TrustManager trustManager = (X509TrustManager) trustManagers[0]; | // Path: src/main/java/com/amplitude/util/DoubleCheck.java
// public class DoubleCheck<T> implements Provider<T> {
// private static final Object UNINITIALIZED = new Object();
//
// private volatile Provider<T> provider;
// private volatile Object instance = UNINITIALIZED;
//
// private DoubleCheck(Provider<T> provider) {
// assert provider != null;
// this.provider = provider;
// }
//
// @SuppressWarnings("unchecked") // cast only happens when result comes from the provider
// @Override
// public T get() {
// Object result = instance;
// if (result == UNINITIALIZED) {
// synchronized (this) {
// result = instance;
// if (result == UNINITIALIZED) {
// result = provider.get();
// instance = reentrantCheck(instance, result);
// /* Null out the reference to the provider. We are never going to need it again, so we
// * can make it eligible for GC. */
// provider = null;
// }
// }
// }
// return (T) result;
// }
//
// /**
// * Checks to see if creating the new instance has resulted in a recursive call. If it has, and the
// * new instance is the same as the current instance, return the instance. However, if the new
// * instance differs from the current instance, an {@link IllegalStateException} is thrown.
// */
// public static Object reentrantCheck(Object currentInstance, Object newInstance) {
// boolean isReentrant = !(currentInstance == UNINITIALIZED);
//
// if (isReentrant && currentInstance != newInstance) {
// throw new IllegalStateException("Scoped provider was invoked recursively returning "
// + "different results: " + currentInstance + " & " + newInstance + ". This is likely "
// + "due to a circular dependency.");
// }
// return newInstance;
// }
//
// /** Returns a {@link Provider} that caches the value from the given delegate provider. */
// public static <P extends Provider<T>, T> Provider<T> provider(P delegate) {
// if (delegate == null) {
// throw new IllegalArgumentException("delegate cannot be null");
// }
// if (delegate instanceof DoubleCheck) {
// /* This should be a rare case, but if we have a scoped @Binds that delegates to a scoped
// * binding, we shouldn't cache the value again. */
// return delegate;
// }
// return new DoubleCheck<T>(delegate);
// }
// }
//
// Path: src/main/java/com/amplitude/util/Provider.java
// public interface Provider<T> {
// T get();
// }
// Path: src/main/java/com/amplitude/api/PinnedAmplitudeClient.java
import android.content.Context;
import com.amplitude.util.DoubleCheck;
import com.amplitude.util.Provider;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import okhttp3.OkHttpClient;
import okio.Buffer;
import okio.ByteString;
SSLSocketFactory factory = getPinnedCertSslSocketFactory();
if (factory != null) {
try {
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(
TrustManagerFactory.getDefaultAlgorithm());
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, null); // Use a null input stream + password to create an empty key store.
List<String> certificateBase64s = new ArrayList<String>();
certificateBase64s.add(CERTIFICATE_1);
// Decode the certificates and add 'em to the key store.
int nextName = 1;
for (String certificateBase64 : certificateBase64s) {
Buffer certificateBuffer = new Buffer().write(ByteString.decodeBase64(certificateBase64));
X509Certificate certificate = (X509Certificate) certificateFactory.generateCertificate(
certificateBuffer.inputStream());
keyStore.setCertificateEntry(Integer.toString(nextName++), certificate);
}
// Create an SSL context that uses these certificates as its trust store.
trustManagerFactory.init(keyStore);
TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) {
throw new IllegalStateException("Unexpected default trust managers:"
+ Arrays.toString(trustManagers));
}
X509TrustManager trustManager = (X509TrustManager) trustManagers[0]; | final Provider<OkHttpClient> finalClientProvider = DoubleCheck.provider(() -> { |
bfabiszewski/ulogger-android | app/src/main/java/net/fabiszewski/ulogger/ListWithEditTextPreference.java | // Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
| import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import androidx.core.text.BidiFormatter;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceManager;
import static net.fabiszewski.ulogger.Alert.showAlert; | }
return super.getSummary();
}
/**
* Returns the index of the given value (in the entry values array).
*
* @param value The value whose index should be returned
* @return The index of the value, or -1 if not found
*/
@Override
public int findIndexOfValue(String value) {
int index = super.findIndexOfValue(value);
if (index == -1) {
return super.findIndexOfValue(OTHER);
} else {
return index;
}
}
/**
* Show dialog with EditText
* @param preference Preference
*/
private void showOtherDialog(Preference preference) {
Activity context = getActivity();
if (context == null) {
return;
}
final String key = preference.getKey(); | // Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
// Path: app/src/main/java/net/fabiszewski/ulogger/ListWithEditTextPreference.java
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import androidx.core.text.BidiFormatter;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceManager;
import static net.fabiszewski.ulogger.Alert.showAlert;
}
return super.getSummary();
}
/**
* Returns the index of the given value (in the entry values array).
*
* @param value The value whose index should be returned
* @return The index of the value, or -1 if not found
*/
@Override
public int findIndexOfValue(String value) {
int index = super.findIndexOfValue(value);
if (index == -1) {
return super.findIndexOfValue(OTHER);
} else {
return index;
}
}
/**
* Show dialog with EditText
* @param preference Preference
*/
private void showOtherDialog(Preference preference) {
Activity context = getActivity();
if (context == null) {
return;
}
final String key = preference.getKey(); | final AlertDialog dialog = showAlert(context, |
bfabiszewski/ulogger-android | app/src/main/java/net/fabiszewski/ulogger/MainFragment.java | // Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static void showConfirm(Context context, CharSequence title, CharSequence message,
// DialogInterface.OnClickListener yesCallback) {
// AlertDialog alertDialog = initDialog(context, title, message);
// alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback);
// alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel),
// (dialog, which) -> dialog.dismiss());
// alertDialog.show();
// }
| import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import android.Manifest;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.core.widget.TextViewCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone; | * @param view View
*/
private void uploadData(View view) {
Context context = view.getContext();
if (!SettingsFragment.isValidServerSetup(context)) {
showToast(getString(R.string.provide_user_pass_url));
} else if (DbAccess.needsSync(context)) {
Intent syncIntent = new Intent(context, WebSyncService.class);
context.startService(syncIntent);
showToast(getString(R.string.uploading_started));
isUploading = true;
} else {
showToast(getString(R.string.nothing_to_synchronize));
}
}
/**
* Called when the user clicks the track text view
* @param view View
*/
private void trackSummary(View view) {
Context context = view.getContext();
final TrackSummary summary = DbAccess.getTrackSummary(context);
if (summary == null) {
showToast(getString(R.string.no_positions));
return;
}
MainActivity activity = (MainActivity) getActivity();
if (activity != null) { | // Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static void showConfirm(Context context, CharSequence title, CharSequence message,
// DialogInterface.OnClickListener yesCallback) {
// AlertDialog alertDialog = initDialog(context, title, message);
// alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback);
// alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel),
// (dialog, which) -> dialog.dismiss());
// alertDialog.show();
// }
// Path: app/src/main/java/net/fabiszewski/ulogger/MainFragment.java
import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import android.Manifest;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.core.widget.TextViewCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
* @param view View
*/
private void uploadData(View view) {
Context context = view.getContext();
if (!SettingsFragment.isValidServerSetup(context)) {
showToast(getString(R.string.provide_user_pass_url));
} else if (DbAccess.needsSync(context)) {
Intent syncIntent = new Intent(context, WebSyncService.class);
context.startService(syncIntent);
showToast(getString(R.string.uploading_started));
isUploading = true;
} else {
showToast(getString(R.string.nothing_to_synchronize));
}
}
/**
* Called when the user clicks the track text view
* @param view View
*/
private void trackSummary(View view) {
Context context = view.getContext();
final TrackSummary summary = DbAccess.getTrackSummary(context);
if (summary == null) {
showToast(getString(R.string.no_positions));
return;
}
MainActivity activity = (MainActivity) getActivity();
if (activity != null) { | final AlertDialog dialog = showAlert(activity, |
bfabiszewski/ulogger-android | app/src/main/java/net/fabiszewski/ulogger/MainFragment.java | // Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static void showConfirm(Context context, CharSequence title, CharSequence message,
// DialogInterface.OnClickListener yesCallback) {
// AlertDialog alertDialog = initDialog(context, title, message);
// alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback);
// alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel),
// (dialog, which) -> dialog.dismiss());
// alertDialog.show();
// }
| import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import android.Manifest;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.core.widget.TextViewCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone; | distance *= KM_MILE;
unitName = getString(R.string.unit_mile);
} else if (activity.preferenceUnits.equals(getString(R.string.pref_units_nautical))) {
distance *= KM_NMILE;
unitName = getString(R.string.unit_nmile);
}
final NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(2);
final String distanceString = nf.format(distance);
if (summaryDistance != null) {
summaryDistance.setText(getString(R.string.summary_distance, distanceString, unitName));
}
final long h = summary.getDuration() / 3600;
final long m = summary.getDuration() % 3600 / 60;
if (summaryDuration != null) {
summaryDuration.setText(getString(R.string.summary_duration, h, m));
}
int positionsCount = (int) summary.getPositionsCount();
if (summaryPositions != null) {
summaryPositions.setText(getResources().getQuantityString(R.plurals.summary_positions, positionsCount, positionsCount));
}
}
}
/**
* Display warning before deleting not synchronized track
*/
private void showNotSyncedWarning() {
Context context = getContext();
if (context != null) { | // Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static void showConfirm(Context context, CharSequence title, CharSequence message,
// DialogInterface.OnClickListener yesCallback) {
// AlertDialog alertDialog = initDialog(context, title, message);
// alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback);
// alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel),
// (dialog, which) -> dialog.dismiss());
// alertDialog.show();
// }
// Path: app/src/main/java/net/fabiszewski/ulogger/MainFragment.java
import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import android.Manifest;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.core.widget.TextViewCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
distance *= KM_MILE;
unitName = getString(R.string.unit_mile);
} else if (activity.preferenceUnits.equals(getString(R.string.pref_units_nautical))) {
distance *= KM_NMILE;
unitName = getString(R.string.unit_nmile);
}
final NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(2);
final String distanceString = nf.format(distance);
if (summaryDistance != null) {
summaryDistance.setText(getString(R.string.summary_distance, distanceString, unitName));
}
final long h = summary.getDuration() / 3600;
final long m = summary.getDuration() % 3600 / 60;
if (summaryDuration != null) {
summaryDuration.setText(getString(R.string.summary_duration, h, m));
}
int positionsCount = (int) summary.getPositionsCount();
if (summaryPositions != null) {
summaryPositions.setText(getResources().getQuantityString(R.plurals.summary_positions, positionsCount, positionsCount));
}
}
}
/**
* Display warning before deleting not synchronized track
*/
private void showNotSyncedWarning() {
Context context = getContext();
if (context != null) { | showConfirm(context, |
bfabiszewski/ulogger-android | app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java | // Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
| import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map; | /*
* Copyright (c) 2018 Bartek Fabiszewski
* http://www.fabiszewski.net
*
* This file is part of μlogger-android.
* Licensed under GPL, either version 3, or any later.
* See <http://www.gnu.org/licenses/>
*/
package net.fabiszewski.ulogger;
@SuppressWarnings("WeakerAccess")
public class SettingsFragment extends PreferenceFragmentCompat {
private static final String TAG = SettingsFragment.class.getSimpleName();
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey);
setListeners();
}
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) { | // Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/*
* Copyright (c) 2018 Bartek Fabiszewski
* http://www.fabiszewski.net
*
* This file is part of μlogger-android.
* Licensed under GPL, either version 3, or any later.
* See <http://www.gnu.org/licenses/>
*/
package net.fabiszewski.ulogger;
@SuppressWarnings("WeakerAccess")
public class SettingsFragment extends PreferenceFragmentCompat {
private static final String TAG = SettingsFragment.class.getSimpleName();
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey);
setListeners();
}
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) { | if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) { |
bfabiszewski/ulogger-android | app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java | // Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
| import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map; | /*
* Copyright (c) 2018 Bartek Fabiszewski
* http://www.fabiszewski.net
*
* This file is part of μlogger-android.
* Licensed under GPL, either version 3, or any later.
* See <http://www.gnu.org/licenses/>
*/
package net.fabiszewski.ulogger;
@SuppressWarnings("WeakerAccess")
public class SettingsFragment extends PreferenceFragmentCompat {
private static final String TAG = SettingsFragment.class.getSimpleName();
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey);
setListeners();
}
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment"); | // Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/*
* Copyright (c) 2018 Bartek Fabiszewski
* http://www.fabiszewski.net
*
* This file is part of μlogger-android.
* Licensed under GPL, either version 3, or any later.
* See <http://www.gnu.org/licenses/>
*/
package net.fabiszewski.ulogger;
@SuppressWarnings("WeakerAccess")
public class SettingsFragment extends PreferenceFragmentCompat {
private static final String TAG = SettingsFragment.class.getSimpleName();
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey);
setListeners();
}
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment"); | } else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) { |
bfabiszewski/ulogger-android | app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java | // Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
| import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map; | /*
* Copyright (c) 2018 Bartek Fabiszewski
* http://www.fabiszewski.net
*
* This file is part of μlogger-android.
* Licensed under GPL, either version 3, or any later.
* See <http://www.gnu.org/licenses/>
*/
package net.fabiszewski.ulogger;
@SuppressWarnings("WeakerAccess")
public class SettingsFragment extends PreferenceFragmentCompat {
private static final String TAG = SettingsFragment.class.getSimpleName();
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey);
setListeners();
}
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
} else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment"); | // Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/*
* Copyright (c) 2018 Bartek Fabiszewski
* http://www.fabiszewski.net
*
* This file is part of μlogger-android.
* Licensed under GPL, either version 3, or any later.
* See <http://www.gnu.org/licenses/>
*/
package net.fabiszewski.ulogger;
@SuppressWarnings("WeakerAccess")
public class SettingsFragment extends PreferenceFragmentCompat {
private static final String TAG = SettingsFragment.class.getSimpleName();
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey);
setListeners();
}
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
} else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment"); | } else if (preference instanceof ListPreference && KEY_PROVIDER.equals(preference.getKey())) { |
bfabiszewski/ulogger-android | app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java | // Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
| import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map; | }
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
} else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment");
} else if (preference instanceof ListPreference && KEY_PROVIDER.equals(preference.getKey())) {
final ProviderPreferenceDialogFragment fragment = ProviderPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ProviderPreferenceDialogFragment");
} else if (preference instanceof ListPreference) {
final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() { | // Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
}
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
} else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment");
} else if (preference instanceof ListPreference && KEY_PROVIDER.equals(preference.getKey())) {
final ProviderPreferenceDialogFragment fragment = ProviderPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ProviderPreferenceDialogFragment");
} else if (preference instanceof ListPreference) {
final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() { | final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC); |
bfabiszewski/ulogger-android | app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java | // Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
| import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map; |
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
} else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment");
} else if (preference instanceof ListPreference && KEY_PROVIDER.equals(preference.getKey())) {
final ProviderPreferenceDialogFragment fragment = ProviderPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ProviderPreferenceDialogFragment");
} else if (preference instanceof ListPreference) {
final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() {
final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC); | // Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
} else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment");
} else if (preference instanceof ListPreference && KEY_PROVIDER.equals(preference.getKey())) {
final ProviderPreferenceDialogFragment fragment = ProviderPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ProviderPreferenceDialogFragment");
} else if (preference instanceof ListPreference) {
final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() {
final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC); | final Preference prefUsername = findPreference(KEY_USERNAME); |
bfabiszewski/ulogger-android | app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java | // Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
| import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map; | @SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
} else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment");
} else if (preference instanceof ListPreference && KEY_PROVIDER.equals(preference.getKey())) {
final ProviderPreferenceDialogFragment fragment = ProviderPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ProviderPreferenceDialogFragment");
} else if (preference instanceof ListPreference) {
final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() {
final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC);
final Preference prefUsername = findPreference(KEY_USERNAME); | // Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
} else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment");
} else if (preference instanceof ListPreference && KEY_PROVIDER.equals(preference.getKey())) {
final ProviderPreferenceDialogFragment fragment = ProviderPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ProviderPreferenceDialogFragment");
} else if (preference instanceof ListPreference) {
final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() {
final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC);
final Preference prefUsername = findPreference(KEY_USERNAME); | final Preference prefPass = findPreference(KEY_PASS); |
bfabiszewski/ulogger-android | app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java | // Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
| import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map; | final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() {
final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC);
final Preference prefUsername = findPreference(KEY_USERNAME);
final Preference prefPass = findPreference(KEY_PASS);
final Preference prefHost = findPreference(KEY_HOST);
// on change listeners
if (prefLiveSync != null) {
prefLiveSync.setOnPreferenceChangeListener(liveSyncChanged);
}
if (prefUsername != null) {
prefUsername.setOnPreferenceChangeListener(serverSetupChanged);
}
if (prefPass != null) {
prefPass.setOnPreferenceChangeListener(serverSetupChanged);
}
if (prefHost != null) {
prefHost.setOnPreferenceChangeListener(serverSetupChanged);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { | // Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() {
final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC);
final Preference prefUsername = findPreference(KEY_USERNAME);
final Preference prefPass = findPreference(KEY_PASS);
final Preference prefHost = findPreference(KEY_HOST);
// on change listeners
if (prefLiveSync != null) {
prefLiveSync.setOnPreferenceChangeListener(liveSyncChanged);
}
if (prefUsername != null) {
prefUsername.setOnPreferenceChangeListener(serverSetupChanged);
}
if (prefPass != null) {
prefPass.setOnPreferenceChangeListener(serverSetupChanged);
}
if (prefHost != null) {
prefHost.setOnPreferenceChangeListener(serverSetupChanged);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { | final Preference prefAutoStart = findPreference(KEY_AUTO_START); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.