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 |
|---|---|---|---|---|---|---|
ChristinGorman/baxter | src/main/java/no/gorman/database/BigBrother.java | // Path: src/main/java/no/gorman/database/DBFunctions.java
// public static Object get(Field f, Object instance) {
// try {
// return f.get(instance);
// }catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// Path: src/main/java/no/gorman/database/DBFunctions.java
// public static List<Field> getMappedFields(Class<?> clazz) {
// List<Field> columnFields = asList(clazz.getDeclaredFields()).stream()
// .filter(f -> f.isAnnotationPresent(Column.class))
// .collect(toList());
// columnFields.forEach(f->f.setAccessible(true));
//
// if (clazz.getSuperclass() != null) {
// columnFields.addAll(getMappedFields(clazz.getSuperclass()));
// }
// return columnFields;
// }
//
// Path: src/main/java/no/gorman/database/DBFunctions.java
// public static <T> Field getPrimaryKeyField(T obj) {
// return getMappedFields(obj.getClass()).stream().filter(f-> getColumn(f).getType() == PrimaryKey).findFirst().orElseThrow(() -> new IllegalArgumentException(obj.getClass().getName() + " has no primary key defined"));
// }
| import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static no.gorman.database.DBFunctions.get;
import static no.gorman.database.DBFunctions.getMappedFields;
import static no.gorman.database.DBFunctions.getPrimaryKeyField; | public static void inform(RowIdentifier rowIdentifier, Object suspect) {
getSpies(rowIdentifier).orElse(new HashSet<>()).forEach(spy -> spy.suspectAltered(suspect));
}
public static void informAllAgents(Object... suspects) {
for (Object suspect : suspects) {
findWhoMightBeInterested(suspect).forEach(row -> inform(row, suspect));
}
}
public static void spyOn(Object suspect, Spy spy) {
for (RowIdentifier key : findRowsToSpyOn(suspect)) {
if (!spies.containsKey(key)) {
spies.put(key, new WeakHashMap<>());
}
spyRefs.add(new WeakReference<>(spy, terminatedSpies));
spies.get(key).put(spy, true);
}
}
/**
* Example:
* findRowsToSpyOn(<child with child_id=42>) would return the
* primary key row of the child table: child_id = 42,
* plus the foreign references referring to this entry. For example
* the Schedule table's schedule_child_id=42
*
*/
public static <T> Collection<RowIdentifier> findRowsToSpyOn(T suspect) {
List<RowIdentifier> keys = new ArrayList<>(); | // Path: src/main/java/no/gorman/database/DBFunctions.java
// public static Object get(Field f, Object instance) {
// try {
// return f.get(instance);
// }catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// Path: src/main/java/no/gorman/database/DBFunctions.java
// public static List<Field> getMappedFields(Class<?> clazz) {
// List<Field> columnFields = asList(clazz.getDeclaredFields()).stream()
// .filter(f -> f.isAnnotationPresent(Column.class))
// .collect(toList());
// columnFields.forEach(f->f.setAccessible(true));
//
// if (clazz.getSuperclass() != null) {
// columnFields.addAll(getMappedFields(clazz.getSuperclass()));
// }
// return columnFields;
// }
//
// Path: src/main/java/no/gorman/database/DBFunctions.java
// public static <T> Field getPrimaryKeyField(T obj) {
// return getMappedFields(obj.getClass()).stream().filter(f-> getColumn(f).getType() == PrimaryKey).findFirst().orElseThrow(() -> new IllegalArgumentException(obj.getClass().getName() + " has no primary key defined"));
// }
// Path: src/main/java/no/gorman/database/BigBrother.java
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static no.gorman.database.DBFunctions.get;
import static no.gorman.database.DBFunctions.getMappedFields;
import static no.gorman.database.DBFunctions.getPrimaryKeyField;
public static void inform(RowIdentifier rowIdentifier, Object suspect) {
getSpies(rowIdentifier).orElse(new HashSet<>()).forEach(spy -> spy.suspectAltered(suspect));
}
public static void informAllAgents(Object... suspects) {
for (Object suspect : suspects) {
findWhoMightBeInterested(suspect).forEach(row -> inform(row, suspect));
}
}
public static void spyOn(Object suspect, Spy spy) {
for (RowIdentifier key : findRowsToSpyOn(suspect)) {
if (!spies.containsKey(key)) {
spies.put(key, new WeakHashMap<>());
}
spyRefs.add(new WeakReference<>(spy, terminatedSpies));
spies.get(key).put(spy, true);
}
}
/**
* Example:
* findRowsToSpyOn(<child with child_id=42>) would return the
* primary key row of the child table: child_id = 42,
* plus the foreign references referring to this entry. For example
* the Schedule table's schedule_child_id=42
*
*/
public static <T> Collection<RowIdentifier> findRowsToSpyOn(T suspect) {
List<RowIdentifier> keys = new ArrayList<>(); | Field pkField = getPrimaryKeyField(suspect); |
ChristinGorman/baxter | src/main/java/no/gorman/database/BigBrother.java | // Path: src/main/java/no/gorman/database/DBFunctions.java
// public static Object get(Field f, Object instance) {
// try {
// return f.get(instance);
// }catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// Path: src/main/java/no/gorman/database/DBFunctions.java
// public static List<Field> getMappedFields(Class<?> clazz) {
// List<Field> columnFields = asList(clazz.getDeclaredFields()).stream()
// .filter(f -> f.isAnnotationPresent(Column.class))
// .collect(toList());
// columnFields.forEach(f->f.setAccessible(true));
//
// if (clazz.getSuperclass() != null) {
// columnFields.addAll(getMappedFields(clazz.getSuperclass()));
// }
// return columnFields;
// }
//
// Path: src/main/java/no/gorman/database/DBFunctions.java
// public static <T> Field getPrimaryKeyField(T obj) {
// return getMappedFields(obj.getClass()).stream().filter(f-> getColumn(f).getType() == PrimaryKey).findFirst().orElseThrow(() -> new IllegalArgumentException(obj.getClass().getName() + " has no primary key defined"));
// }
| import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static no.gorman.database.DBFunctions.get;
import static no.gorman.database.DBFunctions.getMappedFields;
import static no.gorman.database.DBFunctions.getPrimaryKeyField; | * plus the foreign references referring to this entry. For example
* the Schedule table's schedule_child_id=42
*
*/
public static <T> Collection<RowIdentifier> findRowsToSpyOn(T suspect) {
List<RowIdentifier> keys = new ArrayList<>();
Field pkField = getPrimaryKeyField(suspect);
Object suspectId = get(pkField, suspect);
DatabaseColumns pkColumn = pkField.getAnnotation(Column.class).column();
keys.add(new RowIdentifier(pkColumn, suspectId));
DatabaseColumns.incomingReferenceColumns(pkColumn.getTable()).forEach(col -> keys.add(new RowIdentifier(col, suspectId)));
return keys;
}
/**
* Example:
* findWhoMightBeInterested(<child with child_id=23 and child_daycare_id=2>) would return the
* primary key row of the child table: child_id=23, and would also
* return rows this child "belongs to". Like the day care center with daycare_id=2.
* It won't return any other fields than what the type <T> actually has defined.
* If T is a child-class, but does not specify any link to the daycare center,
* those listening for updates on the daycare center won't be notified.
* Could fix this by querying the database from here, will maybe have to do this later,
* but haven't had the need to so far.
*/
public static <T> Collection<RowIdentifier> findWhoMightBeInterested(T suspect) {
List<RowIdentifier> keys = new ArrayList<>();
Field pkField = getPrimaryKeyField(suspect);
Object suspectId = get(pkField, suspect);
keys.add(new RowIdentifier(pkField.getAnnotation(Column.class).column(), suspectId)); | // Path: src/main/java/no/gorman/database/DBFunctions.java
// public static Object get(Field f, Object instance) {
// try {
// return f.get(instance);
// }catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// Path: src/main/java/no/gorman/database/DBFunctions.java
// public static List<Field> getMappedFields(Class<?> clazz) {
// List<Field> columnFields = asList(clazz.getDeclaredFields()).stream()
// .filter(f -> f.isAnnotationPresent(Column.class))
// .collect(toList());
// columnFields.forEach(f->f.setAccessible(true));
//
// if (clazz.getSuperclass() != null) {
// columnFields.addAll(getMappedFields(clazz.getSuperclass()));
// }
// return columnFields;
// }
//
// Path: src/main/java/no/gorman/database/DBFunctions.java
// public static <T> Field getPrimaryKeyField(T obj) {
// return getMappedFields(obj.getClass()).stream().filter(f-> getColumn(f).getType() == PrimaryKey).findFirst().orElseThrow(() -> new IllegalArgumentException(obj.getClass().getName() + " has no primary key defined"));
// }
// Path: src/main/java/no/gorman/database/BigBrother.java
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static no.gorman.database.DBFunctions.get;
import static no.gorman.database.DBFunctions.getMappedFields;
import static no.gorman.database.DBFunctions.getPrimaryKeyField;
* plus the foreign references referring to this entry. For example
* the Schedule table's schedule_child_id=42
*
*/
public static <T> Collection<RowIdentifier> findRowsToSpyOn(T suspect) {
List<RowIdentifier> keys = new ArrayList<>();
Field pkField = getPrimaryKeyField(suspect);
Object suspectId = get(pkField, suspect);
DatabaseColumns pkColumn = pkField.getAnnotation(Column.class).column();
keys.add(new RowIdentifier(pkColumn, suspectId));
DatabaseColumns.incomingReferenceColumns(pkColumn.getTable()).forEach(col -> keys.add(new RowIdentifier(col, suspectId)));
return keys;
}
/**
* Example:
* findWhoMightBeInterested(<child with child_id=23 and child_daycare_id=2>) would return the
* primary key row of the child table: child_id=23, and would also
* return rows this child "belongs to". Like the day care center with daycare_id=2.
* It won't return any other fields than what the type <T> actually has defined.
* If T is a child-class, but does not specify any link to the daycare center,
* those listening for updates on the daycare center won't be notified.
* Could fix this by querying the database from here, will maybe have to do this later,
* but haven't had the need to so far.
*/
public static <T> Collection<RowIdentifier> findWhoMightBeInterested(T suspect) {
List<RowIdentifier> keys = new ArrayList<>();
Field pkField = getPrimaryKeyField(suspect);
Object suspectId = get(pkField, suspect);
keys.add(new RowIdentifier(pkField.getAnnotation(Column.class).column(), suspectId)); | for (Field f : getMappedFields(suspect.getClass())){ |
ChristinGorman/baxter | src/main/java/no/gorman/please/LoginFilter.java | // Path: src/main/java/no/gorman/please/LoginServlet.java
// public static final String LOGGED_IN = "logged_in";
| import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import static no.gorman.please.LoginServlet.LOGGED_IN; | package no.gorman.please;
public class LoginFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
if (request.getServletContext().getContextPath().contains("login"))return; | // Path: src/main/java/no/gorman/please/LoginServlet.java
// public static final String LOGGED_IN = "logged_in";
// Path: src/main/java/no/gorman/please/LoginFilter.java
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import static no.gorman.please.LoginServlet.LOGGED_IN;
package no.gorman.please;
public class LoginFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
if (request.getServletContext().getContextPath().contains("login"))return; | RegisteredUser currentUser = (RegisteredUser) ((HttpServletRequest)request).getSession().getAttribute(LOGGED_IN); |
ChristinGorman/baxter | src/test/java/no/gorman/database/BigBrotherTest.java | // Path: src/main/java/no/gorman/database/BigBrother.java
// public static interface Spy { void suspectAltered(Object suspect); }
//
// Path: src/main/java/no/gorman/please/common/Child.java
// public class Child implements NameMethods {
//
// public Child() {
//
// }
//
// @Column(column=DatabaseColumns.child_id)
// private Long child_id;
//
// @Column(column=DatabaseColumns.dob)
// private LocalDate DOB;
//
// @Column(column=DatabaseColumns.child_first_name)
// private String child_first_name;
//
// @Column(column=DatabaseColumns.child_middle_name)
// private String child_middle_name;
//
// @Column(column=DatabaseColumns.child_last_name)
// private String child_last_name;
//
// @Column(column=DatabaseColumns.nickname)
// private String nickname;
//
// @Column(column=DatabaseColumns.child_version)
// private int child_version = 0;
//
// @Column(column=DatabaseColumns.color)
// private String color;
//
// @Column(column=DatabaseColumns.child_daycare_id)
// private Long child_daycare_id;
//
// public Long getChildId() {
// return child_id;
// }
// public void setChildId(Long childId) {
// this.child_id = childId;
// }
// public LocalDate getDOB() {
// return DOB;
// }
// public void setDOB(LocalDate dOB) {
// DOB = dOB;
// }
//
// @Override
// public String getFirstName() {
// return child_first_name;
// }
// public void setFirstName(String firstName) {
// this.child_first_name = firstName;
// }
//
// @Override
// public String getMiddleName() {
// return child_middle_name;
// }
// public void setMiddleName(String middleName) {
// this.child_middle_name = middleName;
// }
//
// @Override
// public String getLastName() {
// return child_last_name;
// }
// public void setLastName(String lastName) {
// this.child_last_name = lastName;
// }
//
// @Override
// public String getNickname() {
// return nickname;
// }
// public void setNickname(String nickname) {
// this.nickname = nickname;
// }
// public int getVersion() {
// return child_version;
// }
// public void setVersion(int version) {
// this.child_version = version;
// }
// public String getColor() {
// return color;
// }
// public void setColor(String color) {
// this.color = color;
// }
//
// public Long getDaycareId() {
// return child_daycare_id;
// }
//
// public void setDaycareId(Long daycare) {
// this.child_daycare_id = daycare;
// }
//
// @Override
// public String toString() {
// return nickname + "(" + child_version + ")";
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(child_id, child_version);
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Child other = (Child)obj;
// return Objects.equals(other.child_id, child_id) && (Objects.equals(other.child_version, child_version));
// }
//
// public static Child withNickname(String nick) {
// Child child = new Child();
// child.setNickname(nick);
// return child;
// }
// }
| import java.lang.ref.WeakReference;
import no.gorman.database.BigBrother.Spy;
import no.gorman.please.common.Child;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test; | package no.gorman.database;
public class BigBrotherTest {
Child you = new Child();
@Before
public void setUp() {
you.setChildId(1l);
}
@Test
public void removes_entry_when_all_spies_are_dead() throws InterruptedException { | // Path: src/main/java/no/gorman/database/BigBrother.java
// public static interface Spy { void suspectAltered(Object suspect); }
//
// Path: src/main/java/no/gorman/please/common/Child.java
// public class Child implements NameMethods {
//
// public Child() {
//
// }
//
// @Column(column=DatabaseColumns.child_id)
// private Long child_id;
//
// @Column(column=DatabaseColumns.dob)
// private LocalDate DOB;
//
// @Column(column=DatabaseColumns.child_first_name)
// private String child_first_name;
//
// @Column(column=DatabaseColumns.child_middle_name)
// private String child_middle_name;
//
// @Column(column=DatabaseColumns.child_last_name)
// private String child_last_name;
//
// @Column(column=DatabaseColumns.nickname)
// private String nickname;
//
// @Column(column=DatabaseColumns.child_version)
// private int child_version = 0;
//
// @Column(column=DatabaseColumns.color)
// private String color;
//
// @Column(column=DatabaseColumns.child_daycare_id)
// private Long child_daycare_id;
//
// public Long getChildId() {
// return child_id;
// }
// public void setChildId(Long childId) {
// this.child_id = childId;
// }
// public LocalDate getDOB() {
// return DOB;
// }
// public void setDOB(LocalDate dOB) {
// DOB = dOB;
// }
//
// @Override
// public String getFirstName() {
// return child_first_name;
// }
// public void setFirstName(String firstName) {
// this.child_first_name = firstName;
// }
//
// @Override
// public String getMiddleName() {
// return child_middle_name;
// }
// public void setMiddleName(String middleName) {
// this.child_middle_name = middleName;
// }
//
// @Override
// public String getLastName() {
// return child_last_name;
// }
// public void setLastName(String lastName) {
// this.child_last_name = lastName;
// }
//
// @Override
// public String getNickname() {
// return nickname;
// }
// public void setNickname(String nickname) {
// this.nickname = nickname;
// }
// public int getVersion() {
// return child_version;
// }
// public void setVersion(int version) {
// this.child_version = version;
// }
// public String getColor() {
// return color;
// }
// public void setColor(String color) {
// this.color = color;
// }
//
// public Long getDaycareId() {
// return child_daycare_id;
// }
//
// public void setDaycareId(Long daycare) {
// this.child_daycare_id = daycare;
// }
//
// @Override
// public String toString() {
// return nickname + "(" + child_version + ")";
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(child_id, child_version);
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Child other = (Child)obj;
// return Objects.equals(other.child_id, child_id) && (Objects.equals(other.child_version, child_version));
// }
//
// public static Child withNickname(String nick) {
// Child child = new Child();
// child.setNickname(nick);
// return child;
// }
// }
// Path: src/test/java/no/gorman/database/BigBrotherTest.java
import java.lang.ref.WeakReference;
import no.gorman.database.BigBrother.Spy;
import no.gorman.please.common.Child;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
package no.gorman.database;
public class BigBrotherTest {
Child you = new Child();
@Before
public void setUp() {
you.setChildId(1l);
}
@Test
public void removes_entry_when_all_spies_are_dead() throws InterruptedException { | WeakReference<Spy> spyRef = addSpy(); |
ChristinGorman/baxter | src/main/java/no/gorman/database/DBFunctions.java | // Path: src/main/java/no/gorman/please/utils/Pair.java
// public class Pair<First, Second> {
// public final First from;
// public final Second to;
//
// public Pair(First from, Second to) {
// this.from = from;
// this.to = to;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(from, to) + Objects.hash(to, from);
// }
//
// @Override
// public boolean equals(Object obj) {
// return (Objects.equals(from, ((Pair)obj).from ) && Objects.equals(to, ((Pair)obj).to))
// || (Objects.equals(from, ((Pair)obj).to ) && Objects.equals(to, ((Pair)obj).from));
// }
// }
| import com.mchange.v2.c3p0.ComboPooledDataSource;
import no.gorman.please.utils.Pair;
import org.jgrapht.alg.DijkstraShortestPath;
import org.jgrapht.graph.DefaultWeightedEdge;
import org.jgrapht.graph.SimpleWeightedGraph;
import java.beans.PropertyVetoException;
import java.lang.reflect.Field;
import java.sql.Connection;
import java.sql.SQLException;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Stream;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
import static no.gorman.database.ColumnType.ForeignKey;
import static no.gorman.database.ColumnType.PrimaryKey;
import static no.gorman.database.DatabaseColumns.getPrimaryKey;
import static org.apache.commons.lang.StringUtils.join; | .filter(where -> where.value != null)
.map(where -> where.value)
.collect(toList());
}
public static Set<Table> getTables(Class<?> clazz, Where... searchParams) {
Set<Table> tables = getMappedFields(clazz).stream().map(field -> getColumn(field).getTable()).collect(toSet());
if (searchParams != null) {
Stream<Table> tableStream = asList(searchParams).stream()
.map(param -> param.column.getTable());
tables.addAll((Collection<Table>)tableStream.collect(toList()));
}
return tables;
}
public static List<Field> getMappedFields(Class<?> clazz) {
List<Field> columnFields = asList(clazz.getDeclaredFields()).stream()
.filter(f -> f.isAnnotationPresent(Column.class))
.collect(toList());
columnFields.forEach(f->f.setAccessible(true));
if (clazz.getSuperclass() != null) {
columnFields.addAll(getMappedFields(clazz.getSuperclass()));
}
return columnFields;
}
public static Collection<Join> findJoins(Collection<Table> tables) {
Set<Join> joins = new HashSet<>(); | // Path: src/main/java/no/gorman/please/utils/Pair.java
// public class Pair<First, Second> {
// public final First from;
// public final Second to;
//
// public Pair(First from, Second to) {
// this.from = from;
// this.to = to;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(from, to) + Objects.hash(to, from);
// }
//
// @Override
// public boolean equals(Object obj) {
// return (Objects.equals(from, ((Pair)obj).from ) && Objects.equals(to, ((Pair)obj).to))
// || (Objects.equals(from, ((Pair)obj).to ) && Objects.equals(to, ((Pair)obj).from));
// }
// }
// Path: src/main/java/no/gorman/database/DBFunctions.java
import com.mchange.v2.c3p0.ComboPooledDataSource;
import no.gorman.please.utils.Pair;
import org.jgrapht.alg.DijkstraShortestPath;
import org.jgrapht.graph.DefaultWeightedEdge;
import org.jgrapht.graph.SimpleWeightedGraph;
import java.beans.PropertyVetoException;
import java.lang.reflect.Field;
import java.sql.Connection;
import java.sql.SQLException;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Stream;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
import static no.gorman.database.ColumnType.ForeignKey;
import static no.gorman.database.ColumnType.PrimaryKey;
import static no.gorman.database.DatabaseColumns.getPrimaryKey;
import static org.apache.commons.lang.StringUtils.join;
.filter(where -> where.value != null)
.map(where -> where.value)
.collect(toList());
}
public static Set<Table> getTables(Class<?> clazz, Where... searchParams) {
Set<Table> tables = getMappedFields(clazz).stream().map(field -> getColumn(field).getTable()).collect(toSet());
if (searchParams != null) {
Stream<Table> tableStream = asList(searchParams).stream()
.map(param -> param.column.getTable());
tables.addAll((Collection<Table>)tableStream.collect(toList()));
}
return tables;
}
public static List<Field> getMappedFields(Class<?> clazz) {
List<Field> columnFields = asList(clazz.getDeclaredFields()).stream()
.filter(f -> f.isAnnotationPresent(Column.class))
.collect(toList());
columnFields.forEach(f->f.setAccessible(true));
if (clazz.getSuperclass() != null) {
columnFields.addAll(getMappedFields(clazz.getSuperclass()));
}
return columnFields;
}
public static Collection<Join> findJoins(Collection<Table> tables) {
Set<Join> joins = new HashSet<>(); | Set<Pair<Table, Table>> alreadyTried = new HashSet<>(); |
ChristinGorman/baxter | src/main/java/no/gorman/database/DatabaseColumns.java | // Path: src/main/java/no/gorman/database/ColumnType.java
// public enum ColumnType {
//
// PrimaryKey,
// Field,
// ForeignKey,
// Version;
// }
//
// Path: src/main/java/no/gorman/database/Table.java
// public enum Table {
//
// daycare,
// child,
// grownup_child,
// grownup,
// event,
// event_child,
// attachment,
// schedule,
// club,
// club_child,
// club_grownup,
// event_club;
//
// }
| import java.time.LocalDate;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import static no.gorman.database.ColumnType.*;
import static no.gorman.database.Table.*; | package no.gorman.database;
public enum DatabaseColumns {
UNDEFINED(null, null),
| // Path: src/main/java/no/gorman/database/ColumnType.java
// public enum ColumnType {
//
// PrimaryKey,
// Field,
// ForeignKey,
// Version;
// }
//
// Path: src/main/java/no/gorman/database/Table.java
// public enum Table {
//
// daycare,
// child,
// grownup_child,
// grownup,
// event,
// event_child,
// attachment,
// schedule,
// club,
// club_child,
// club_grownup,
// event_club;
//
// }
// Path: src/main/java/no/gorman/database/DatabaseColumns.java
import java.time.LocalDate;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import static no.gorman.database.ColumnType.*;
import static no.gorman.database.Table.*;
package no.gorman.database;
public enum DatabaseColumns {
UNDEFINED(null, null),
| daycare_id(Long.TYPE, Table.daycare, PrimaryKey), |
ChristinGorman/baxter | src/main/java/no/gorman/database/DatabaseColumns.java | // Path: src/main/java/no/gorman/database/ColumnType.java
// public enum ColumnType {
//
// PrimaryKey,
// Field,
// ForeignKey,
// Version;
// }
//
// Path: src/main/java/no/gorman/database/Table.java
// public enum Table {
//
// daycare,
// child,
// grownup_child,
// grownup,
// event,
// event_child,
// attachment,
// schedule,
// club,
// club_child,
// club_grownup,
// event_club;
//
// }
| import java.time.LocalDate;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import static no.gorman.database.ColumnType.*;
import static no.gorman.database.Table.*; | ec_event_id(Long.TYPE, Table.event_child, ForeignKey, Table.event),
attachment_id(Long.TYPE, Table.attachment, PrimaryKey),
attachment(byte[].class, Table.attachment),
thumbnail(byte[].class, Table.attachment),
attachment_event_id(Long.TYPE, Table.attachment, ForeignKey, Table.event),
content_type(String.class, Table.attachment, 50),
schedule_id(Long.TYPE, Table.schedule, PrimaryKey),
schedule_child_id(Long.TYPE, Table.schedule, ForeignKey, Table.child),
last_event(Long.TYPE, Table.schedule),
interval(Integer.TYPE, Table.schedule),
schedule_name(String.class, Table.schedule),
club_id(Long.TYPE, Table.club, PrimaryKey),
club_name(String.class, Table.club),
club_color(String.class, Table.club),
club_daycare_id(Long.TYPE, Table.club, ForeignKey, daycare),
grc_child_id(Long.TYPE, Table.club_child, ForeignKey, child),
grc_club_id(Long.TYPE, Table.club_child, ForeignKey, club),
grg_grownup_id(Long.TYPE, Table.club_grownup, ForeignKey, grownup),
grg_club_id(Long.TYPE, Table.club_grownup, ForeignKey, club),
ecl_club_id(Long.TYPE, Table.event_club, ForeignKey, club),
ecl_event_id(Long.TYPE, Table.event_club, ForeignKey, Table.event);
private final Table table;
private final Table joinedTo; | // Path: src/main/java/no/gorman/database/ColumnType.java
// public enum ColumnType {
//
// PrimaryKey,
// Field,
// ForeignKey,
// Version;
// }
//
// Path: src/main/java/no/gorman/database/Table.java
// public enum Table {
//
// daycare,
// child,
// grownup_child,
// grownup,
// event,
// event_child,
// attachment,
// schedule,
// club,
// club_child,
// club_grownup,
// event_club;
//
// }
// Path: src/main/java/no/gorman/database/DatabaseColumns.java
import java.time.LocalDate;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import static no.gorman.database.ColumnType.*;
import static no.gorman.database.Table.*;
ec_event_id(Long.TYPE, Table.event_child, ForeignKey, Table.event),
attachment_id(Long.TYPE, Table.attachment, PrimaryKey),
attachment(byte[].class, Table.attachment),
thumbnail(byte[].class, Table.attachment),
attachment_event_id(Long.TYPE, Table.attachment, ForeignKey, Table.event),
content_type(String.class, Table.attachment, 50),
schedule_id(Long.TYPE, Table.schedule, PrimaryKey),
schedule_child_id(Long.TYPE, Table.schedule, ForeignKey, Table.child),
last_event(Long.TYPE, Table.schedule),
interval(Integer.TYPE, Table.schedule),
schedule_name(String.class, Table.schedule),
club_id(Long.TYPE, Table.club, PrimaryKey),
club_name(String.class, Table.club),
club_color(String.class, Table.club),
club_daycare_id(Long.TYPE, Table.club, ForeignKey, daycare),
grc_child_id(Long.TYPE, Table.club_child, ForeignKey, child),
grc_club_id(Long.TYPE, Table.club_child, ForeignKey, club),
grg_grownup_id(Long.TYPE, Table.club_grownup, ForeignKey, grownup),
grg_club_id(Long.TYPE, Table.club_grownup, ForeignKey, club),
ecl_club_id(Long.TYPE, Table.event_club, ForeignKey, club),
ecl_event_id(Long.TYPE, Table.event_club, ForeignKey, Table.event);
private final Table table;
private final Table joinedTo; | private final ColumnType type; |
ChristinGorman/baxter | src/main/java/no/gorman/please/child/ChildCRUD.java | // Path: src/main/java/no/gorman/database/Where.java
// public class Where {
//
// public final DatabaseColumns column;
// public final String operator;
// public final Object value;
//
// public Where(DatabaseColumns column, String operator) {
// this.column = column;
// this.operator = operator;
// this.value = null;
// }
//
// public Where(DatabaseColumns column, String operator, Object value) {
// this.column = column;
// this.operator = operator;
// this.value = value;
// }
//
// @Override
// public String toString() {
// return column.getTable() + "." + column.name() + " " + operator + " " + value;
// }
// }
//
// Path: src/main/java/no/gorman/please/common/Child.java
// public class Child implements NameMethods {
//
// public Child() {
//
// }
//
// @Column(column=DatabaseColumns.child_id)
// private Long child_id;
//
// @Column(column=DatabaseColumns.dob)
// private LocalDate DOB;
//
// @Column(column=DatabaseColumns.child_first_name)
// private String child_first_name;
//
// @Column(column=DatabaseColumns.child_middle_name)
// private String child_middle_name;
//
// @Column(column=DatabaseColumns.child_last_name)
// private String child_last_name;
//
// @Column(column=DatabaseColumns.nickname)
// private String nickname;
//
// @Column(column=DatabaseColumns.child_version)
// private int child_version = 0;
//
// @Column(column=DatabaseColumns.color)
// private String color;
//
// @Column(column=DatabaseColumns.child_daycare_id)
// private Long child_daycare_id;
//
// public Long getChildId() {
// return child_id;
// }
// public void setChildId(Long childId) {
// this.child_id = childId;
// }
// public LocalDate getDOB() {
// return DOB;
// }
// public void setDOB(LocalDate dOB) {
// DOB = dOB;
// }
//
// @Override
// public String getFirstName() {
// return child_first_name;
// }
// public void setFirstName(String firstName) {
// this.child_first_name = firstName;
// }
//
// @Override
// public String getMiddleName() {
// return child_middle_name;
// }
// public void setMiddleName(String middleName) {
// this.child_middle_name = middleName;
// }
//
// @Override
// public String getLastName() {
// return child_last_name;
// }
// public void setLastName(String lastName) {
// this.child_last_name = lastName;
// }
//
// @Override
// public String getNickname() {
// return nickname;
// }
// public void setNickname(String nickname) {
// this.nickname = nickname;
// }
// public int getVersion() {
// return child_version;
// }
// public void setVersion(int version) {
// this.child_version = version;
// }
// public String getColor() {
// return color;
// }
// public void setColor(String color) {
// this.color = color;
// }
//
// public Long getDaycareId() {
// return child_daycare_id;
// }
//
// public void setDaycareId(Long daycare) {
// this.child_daycare_id = daycare;
// }
//
// @Override
// public String toString() {
// return nickname + "(" + child_version + ")";
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(child_id, child_version);
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Child other = (Child)obj;
// return Objects.equals(other.child_id, child_id) && (Objects.equals(other.child_version, child_version));
// }
//
// public static Child withNickname(String nick) {
// Child child = new Child();
// child.setNickname(nick);
// return child;
// }
// }
//
// Path: src/main/java/no/gorman/please/utils/WithDatabase.java
// public abstract class WithDatabase {
//
// private final ThreadLocal<DB> db;
//
// public WithDatabase() {
// this(null);
// }
//
// public WithDatabase(DB db) {
// this.db = new ThreadLocal<>();
// this.db.set(db);
// }
//
// public void setDB(DB db) {
// this.db.set(db);
// }
//
// public DB getDB() {
// return db.get();
// }
//
// }
| import no.gorman.database.Where;
import no.gorman.please.common.Child;
import no.gorman.please.utils.WithDatabase;
import static no.gorman.database.DatabaseColumns.child_id;
import static no.gorman.database.DatabaseColumns.gc_grownup_id; | package no.gorman.please.child;
public class ChildCRUD extends WithDatabase {
public void newChild(Child newOne) {
getDB().insert(newOne);
}
public void updateChild(Child updated) {
getDB().update(updated);
}
public Child findChild(long grownupId, int childId) {
return getDB().selectOnlyOne(Child.class, | // Path: src/main/java/no/gorman/database/Where.java
// public class Where {
//
// public final DatabaseColumns column;
// public final String operator;
// public final Object value;
//
// public Where(DatabaseColumns column, String operator) {
// this.column = column;
// this.operator = operator;
// this.value = null;
// }
//
// public Where(DatabaseColumns column, String operator, Object value) {
// this.column = column;
// this.operator = operator;
// this.value = value;
// }
//
// @Override
// public String toString() {
// return column.getTable() + "." + column.name() + " " + operator + " " + value;
// }
// }
//
// Path: src/main/java/no/gorman/please/common/Child.java
// public class Child implements NameMethods {
//
// public Child() {
//
// }
//
// @Column(column=DatabaseColumns.child_id)
// private Long child_id;
//
// @Column(column=DatabaseColumns.dob)
// private LocalDate DOB;
//
// @Column(column=DatabaseColumns.child_first_name)
// private String child_first_name;
//
// @Column(column=DatabaseColumns.child_middle_name)
// private String child_middle_name;
//
// @Column(column=DatabaseColumns.child_last_name)
// private String child_last_name;
//
// @Column(column=DatabaseColumns.nickname)
// private String nickname;
//
// @Column(column=DatabaseColumns.child_version)
// private int child_version = 0;
//
// @Column(column=DatabaseColumns.color)
// private String color;
//
// @Column(column=DatabaseColumns.child_daycare_id)
// private Long child_daycare_id;
//
// public Long getChildId() {
// return child_id;
// }
// public void setChildId(Long childId) {
// this.child_id = childId;
// }
// public LocalDate getDOB() {
// return DOB;
// }
// public void setDOB(LocalDate dOB) {
// DOB = dOB;
// }
//
// @Override
// public String getFirstName() {
// return child_first_name;
// }
// public void setFirstName(String firstName) {
// this.child_first_name = firstName;
// }
//
// @Override
// public String getMiddleName() {
// return child_middle_name;
// }
// public void setMiddleName(String middleName) {
// this.child_middle_name = middleName;
// }
//
// @Override
// public String getLastName() {
// return child_last_name;
// }
// public void setLastName(String lastName) {
// this.child_last_name = lastName;
// }
//
// @Override
// public String getNickname() {
// return nickname;
// }
// public void setNickname(String nickname) {
// this.nickname = nickname;
// }
// public int getVersion() {
// return child_version;
// }
// public void setVersion(int version) {
// this.child_version = version;
// }
// public String getColor() {
// return color;
// }
// public void setColor(String color) {
// this.color = color;
// }
//
// public Long getDaycareId() {
// return child_daycare_id;
// }
//
// public void setDaycareId(Long daycare) {
// this.child_daycare_id = daycare;
// }
//
// @Override
// public String toString() {
// return nickname + "(" + child_version + ")";
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(child_id, child_version);
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Child other = (Child)obj;
// return Objects.equals(other.child_id, child_id) && (Objects.equals(other.child_version, child_version));
// }
//
// public static Child withNickname(String nick) {
// Child child = new Child();
// child.setNickname(nick);
// return child;
// }
// }
//
// Path: src/main/java/no/gorman/please/utils/WithDatabase.java
// public abstract class WithDatabase {
//
// private final ThreadLocal<DB> db;
//
// public WithDatabase() {
// this(null);
// }
//
// public WithDatabase(DB db) {
// this.db = new ThreadLocal<>();
// this.db.set(db);
// }
//
// public void setDB(DB db) {
// this.db.set(db);
// }
//
// public DB getDB() {
// return db.get();
// }
//
// }
// Path: src/main/java/no/gorman/please/child/ChildCRUD.java
import no.gorman.database.Where;
import no.gorman.please.common.Child;
import no.gorman.please.utils.WithDatabase;
import static no.gorman.database.DatabaseColumns.child_id;
import static no.gorman.database.DatabaseColumns.gc_grownup_id;
package no.gorman.please.child;
public class ChildCRUD extends WithDatabase {
public void newChild(Child newOne) {
getDB().insert(newOne);
}
public void updateChild(Child updated) {
getDB().update(updated);
}
public Child findChild(long grownupId, int childId) {
return getDB().selectOnlyOne(Child.class, | new Where(child_id, " = ", childId), |
philliphsu/NumberPadTimePicker | library/src/main/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerAlertComponent.java | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
| import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull; | package com.philliphsu.numberpadtimepicker;
/**
* Component that install {@link NumberPadTimePicker#LAYOUT_ALERT alert dialog} functionality
* to a {@link NumberPadTimePicker}.
*/
final class NumberPadTimePickerAlertComponent extends
NumberPadTimePicker.NumberPadTimePickerComponent {
private final TextView mCancelButton;
NumberPadTimePickerAlertComponent(NumberPadTimePicker timePicker, Context context,
AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(timePicker, context, attrs, defStyleAttr, defStyleRes);
mCancelButton = (TextView) timePicker.findViewById(R.id.nptp_button2);
| // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerAlertComponent.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull;
package com.philliphsu.numberpadtimepicker;
/**
* Component that install {@link NumberPadTimePicker#LAYOUT_ALERT alert dialog} functionality
* to a {@link NumberPadTimePicker}.
*/
final class NumberPadTimePickerAlertComponent extends
NumberPadTimePicker.NumberPadTimePickerComponent {
private final TextView mCancelButton;
NumberPadTimePickerAlertComponent(NumberPadTimePicker timePicker, Context context,
AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(timePicker, context, attrs, defStyleAttr, defStyleRes);
mCancelButton = (TextView) timePicker.findViewById(R.id.nptp_button2);
| ((TextView) checkNotNull(mOkButton)).setText(android.R.string.ok); |
philliphsu/NumberPadTimePicker | library/src/main/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerDialog.java | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogPresenter {
// boolean onOkButtonClick();
// void onCancelClick();
// void setBasePresenter(Presenter presenter);
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogView {
// void cancel();
// }
| import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StyleRes;
import android.support.v7.app.AppCompatDialog;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogPresenter;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogView; | package com.philliphsu.numberpadtimepicker;
/**
* Dialog to type in a time.
*/
public class NumberPadTimePickerDialog extends AppCompatDialog implements DialogView {
private final NumberPadTimePickerDialogThemer mThemer;
private final boolean mIs24HourMode;
public NumberPadTimePickerDialog(@NonNull Context context,
@Nullable OnTimeSetListener listener, boolean is24HourMode) {
this(context, 0, listener, is24HourMode);
}
public NumberPadTimePickerDialog(@NonNull Context context, @StyleRes int themeResId,
@Nullable OnTimeSetListener listener, boolean is24HourMode) {
super(context, resolveDialogTheme(context, themeResId));
final View root = getLayoutInflater().inflate(
R.layout.nptp_alert_numberpad_time_picker_dialog, null);
final NumberPadTimePicker timePicker = (NumberPadTimePicker)
root.findViewById(R.id.nptp_time_picker);
final NumberPadTimePickerAlertComponent timePickerComponent =
(NumberPadTimePickerAlertComponent) timePicker.getComponent(); | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogPresenter {
// boolean onOkButtonClick();
// void onCancelClick();
// void setBasePresenter(Presenter presenter);
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogView {
// void cancel();
// }
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerDialog.java
import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StyleRes;
import android.support.v7.app.AppCompatDialog;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogPresenter;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogView;
package com.philliphsu.numberpadtimepicker;
/**
* Dialog to type in a time.
*/
public class NumberPadTimePickerDialog extends AppCompatDialog implements DialogView {
private final NumberPadTimePickerDialogThemer mThemer;
private final boolean mIs24HourMode;
public NumberPadTimePickerDialog(@NonNull Context context,
@Nullable OnTimeSetListener listener, boolean is24HourMode) {
this(context, 0, listener, is24HourMode);
}
public NumberPadTimePickerDialog(@NonNull Context context, @StyleRes int themeResId,
@Nullable OnTimeSetListener listener, boolean is24HourMode) {
super(context, resolveDialogTheme(context, themeResId));
final View root = getLayoutInflater().inflate(
R.layout.nptp_alert_numberpad_time_picker_dialog, null);
final NumberPadTimePicker timePicker = (NumberPadTimePicker)
root.findViewById(R.id.nptp_time_picker);
final NumberPadTimePickerAlertComponent timePickerComponent =
(NumberPadTimePickerAlertComponent) timePicker.getComponent(); | final DialogPresenter presenter = new NumberPadTimePickerDialogPresenter( |
philliphsu/NumberPadTimePicker | library/src/main/java/com/philliphsu/numberpadtimepicker/NumberPadTimePicker.java | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
| import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.ColorInt;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.text.format.DateFormat;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull; | return this;
}
View inflate(Context context, NumberPadTimePicker root) {
return View.inflate(context, R.layout.nptp_numberpad_time_picker, root);
}
@Nullable
View getOkButton() {
return mOkButton;
}
private void setOkButtonCallbacks(OkButtonCallbacks callbacks) {
mCallbacks = callbacks;
}
private static void setBackground(View view, Drawable background) {
if (Build.VERSION.SDK_INT < 16) {
view.setBackgroundDrawable(background);
} else {
view.setBackground(background);
}
}
}
private static class SavedState extends BaseSavedState {
private final INumberPadTimePicker.State mNptpState;
SavedState(Parcelable superState, @NonNull INumberPadTimePicker.State nptpState) {
super(superState); | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/NumberPadTimePicker.java
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.ColorInt;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.text.format.DateFormat;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull;
return this;
}
View inflate(Context context, NumberPadTimePicker root) {
return View.inflate(context, R.layout.nptp_numberpad_time_picker, root);
}
@Nullable
View getOkButton() {
return mOkButton;
}
private void setOkButtonCallbacks(OkButtonCallbacks callbacks) {
mCallbacks = callbacks;
}
private static void setBackground(View view, Drawable background) {
if (Build.VERSION.SDK_INT < 16) {
view.setBackgroundDrawable(background);
} else {
view.setBackground(background);
}
}
}
private static class SavedState extends BaseSavedState {
private final INumberPadTimePicker.State mNptpState;
SavedState(Parcelable superState, @NonNull INumberPadTimePicker.State nptpState) {
super(superState); | mNptpState = checkNotNull(nptpState); |
philliphsu/NumberPadTimePicker | library/src/test/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerPresenterTest.java | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface Presenter {
// void onNumberKeyClick(CharSequence numberKeyText);
// void onAltKeyClick(CharSequence altKeyText);
// void onBackspaceClick();
// boolean onBackspaceLongClick();
// boolean onOkButtonClick();
// void onShow();
// void onSetOkButtonCallbacks();
// /**
// * @param state The state to initialize the time picker with.
// */
// void presentState(@NonNull State state);
// void detachView();
// State getState();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/ButtonTextModel.java
// static String text(int digit) {
// return NUMBERS_TEXTS[digit];
// }
| import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.Presenter;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.Arrays;
import java.util.List;
import static com.philliphsu.numberpadtimepicker.ButtonTextModel.text;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | package com.philliphsu.numberpadtimepicker;
public class NumberPadTimePickerPresenterTest {
private static final int MODE_12HR = 0;
private static final int MODE_24HR = 1;
private final INumberPadTimePicker.View[] mViews = new INumberPadTimePicker.View[2]; | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface Presenter {
// void onNumberKeyClick(CharSequence numberKeyText);
// void onAltKeyClick(CharSequence altKeyText);
// void onBackspaceClick();
// boolean onBackspaceLongClick();
// boolean onOkButtonClick();
// void onShow();
// void onSetOkButtonCallbacks();
// /**
// * @param state The state to initialize the time picker with.
// */
// void presentState(@NonNull State state);
// void detachView();
// State getState();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/ButtonTextModel.java
// static String text(int digit) {
// return NUMBERS_TEXTS[digit];
// }
// Path: library/src/test/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerPresenterTest.java
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.Presenter;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.Arrays;
import java.util.List;
import static com.philliphsu.numberpadtimepicker.ButtonTextModel.text;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
package com.philliphsu.numberpadtimepicker;
public class NumberPadTimePickerPresenterTest {
private static final int MODE_12HR = 0;
private static final int MODE_24HR = 1;
private final INumberPadTimePicker.View[] mViews = new INumberPadTimePicker.View[2]; | private final Presenter[] mPresenters = new Presenter[2]; |
philliphsu/NumberPadTimePicker | library/src/test/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerPresenterTest.java | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface Presenter {
// void onNumberKeyClick(CharSequence numberKeyText);
// void onAltKeyClick(CharSequence altKeyText);
// void onBackspaceClick();
// boolean onBackspaceLongClick();
// boolean onOkButtonClick();
// void onShow();
// void onSetOkButtonCallbacks();
// /**
// * @param state The state to initialize the time picker with.
// */
// void presentState(@NonNull State state);
// void detachView();
// State getState();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/ButtonTextModel.java
// static String text(int digit) {
// return NUMBERS_TEXTS[digit];
// }
| import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.Presenter;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.Arrays;
import java.util.List;
import static com.philliphsu.numberpadtimepicker.ButtonTextModel.text;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | @Test
public void mode12Hr_VerifyOnTimeSetCallback() {
for (int time = 100; time <= 1259; time++) {
if (time % 100 > 59) {
System.out.println("Skipping invalid time " + time);
continue;
}
System.out.println("Testing time " + time);
for (int amOrPm = 0; amOrPm < 2; amOrPm++) {
createNewViewAndPresenter(MODE_12HR);
if (time <= 959) {
inputThreeDigitTime(time, MODE_12HR);
} else {
inputFourDigitTime(time, MODE_12HR);
}
mPresenters[MODE_12HR].onAltKeyClick(altText(amOrPm, MODE_12HR));
final int hour = (time >= 1200 ? 0 : time / 100) + (amOrPm == 1 ? 12 : 0);
final int minute = time % 100;
confirmTimeSelection(mPresenters[MODE_12HR], MODE_12HR, hour, minute);
}
}
}
@Test
public void mode12Hr_VerifyOnTimeSetCallback_UsingAltButtons() {
for (int hour = 1; hour <= 12; hour++) {
System.out.println("Testing time " + String.format("%d:00", hour));
for (int amOrPm = 0; amOrPm < 2; amOrPm++) {
createNewViewAndPresenter(MODE_12HR);
if (hour <= 9) { | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface Presenter {
// void onNumberKeyClick(CharSequence numberKeyText);
// void onAltKeyClick(CharSequence altKeyText);
// void onBackspaceClick();
// boolean onBackspaceLongClick();
// boolean onOkButtonClick();
// void onShow();
// void onSetOkButtonCallbacks();
// /**
// * @param state The state to initialize the time picker with.
// */
// void presentState(@NonNull State state);
// void detachView();
// State getState();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/ButtonTextModel.java
// static String text(int digit) {
// return NUMBERS_TEXTS[digit];
// }
// Path: library/src/test/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerPresenterTest.java
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.Presenter;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.Arrays;
import java.util.List;
import static com.philliphsu.numberpadtimepicker.ButtonTextModel.text;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@Test
public void mode12Hr_VerifyOnTimeSetCallback() {
for (int time = 100; time <= 1259; time++) {
if (time % 100 > 59) {
System.out.println("Skipping invalid time " + time);
continue;
}
System.out.println("Testing time " + time);
for (int amOrPm = 0; amOrPm < 2; amOrPm++) {
createNewViewAndPresenter(MODE_12HR);
if (time <= 959) {
inputThreeDigitTime(time, MODE_12HR);
} else {
inputFourDigitTime(time, MODE_12HR);
}
mPresenters[MODE_12HR].onAltKeyClick(altText(amOrPm, MODE_12HR));
final int hour = (time >= 1200 ? 0 : time / 100) + (amOrPm == 1 ? 12 : 0);
final int minute = time % 100;
confirmTimeSelection(mPresenters[MODE_12HR], MODE_12HR, hour, minute);
}
}
}
@Test
public void mode12Hr_VerifyOnTimeSetCallback_UsingAltButtons() {
for (int hour = 1; hour <= 12; hour++) {
System.out.println("Testing time " + String.format("%d:00", hour));
for (int amOrPm = 0; amOrPm < 2; amOrPm++) {
createNewViewAndPresenter(MODE_12HR);
if (hour <= 9) { | mPresenters[MODE_12HR].onNumberKeyClick(text(hour)); |
philliphsu/NumberPadTimePicker | library/src/main/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerPresenter.java | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/DigitwiseTimeModel.java
// static final int MAX_DIGITS = 4;
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
| import android.support.annotation.NonNull;
import static com.philliphsu.numberpadtimepicker.AmPmState.AM;
import static com.philliphsu.numberpadtimepicker.AmPmState.HRS_24;
import static com.philliphsu.numberpadtimepicker.AmPmState.PM;
import static com.philliphsu.numberpadtimepicker.AmPmState.UNSPECIFIED;
import static com.philliphsu.numberpadtimepicker.DigitwiseTimeModel.MAX_DIGITS;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull; | package com.philliphsu.numberpadtimepicker;
class NumberPadTimePickerPresenter implements INumberPadTimePicker.Presenter,
DigitwiseTimeModel.OnInputChangeListener {
private static final int MAX_CHARS = 5; // 4 digits + time separator
private final DigitwiseTimeModel mTimeModel = new DigitwiseTimeModel(this);
private final DigitwiseTimeParser mTimeParser = new DigitwiseTimeParser(mTimeModel);
private final StringBuilder mFormattedInput = new StringBuilder(MAX_CHARS);
private final String[] mAltTexts = new String[2];
private final @NonNull LocaleModel mLocaleModel;
private final ButtonTextModel mTextModel;
private final String mTimeSeparator;
private final boolean mIs24HourMode;
private INumberPadTimePicker.View mView;
private @AmPmState int mAmPmState = UNSPECIFIED;
private boolean mOkButtonEnabled;
NumberPadTimePickerPresenter(@NonNull INumberPadTimePicker.View view,
@NonNull LocaleModel localeModel,
boolean is24HourMode) { | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/DigitwiseTimeModel.java
// static final int MAX_DIGITS = 4;
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerPresenter.java
import android.support.annotation.NonNull;
import static com.philliphsu.numberpadtimepicker.AmPmState.AM;
import static com.philliphsu.numberpadtimepicker.AmPmState.HRS_24;
import static com.philliphsu.numberpadtimepicker.AmPmState.PM;
import static com.philliphsu.numberpadtimepicker.AmPmState.UNSPECIFIED;
import static com.philliphsu.numberpadtimepicker.DigitwiseTimeModel.MAX_DIGITS;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull;
package com.philliphsu.numberpadtimepicker;
class NumberPadTimePickerPresenter implements INumberPadTimePicker.Presenter,
DigitwiseTimeModel.OnInputChangeListener {
private static final int MAX_CHARS = 5; // 4 digits + time separator
private final DigitwiseTimeModel mTimeModel = new DigitwiseTimeModel(this);
private final DigitwiseTimeParser mTimeParser = new DigitwiseTimeParser(mTimeModel);
private final StringBuilder mFormattedInput = new StringBuilder(MAX_CHARS);
private final String[] mAltTexts = new String[2];
private final @NonNull LocaleModel mLocaleModel;
private final ButtonTextModel mTextModel;
private final String mTimeSeparator;
private final boolean mIs24HourMode;
private INumberPadTimePicker.View mView;
private @AmPmState int mAmPmState = UNSPECIFIED;
private boolean mOkButtonEnabled;
NumberPadTimePickerPresenter(@NonNull INumberPadTimePicker.View view,
@NonNull LocaleModel localeModel,
boolean is24HourMode) { | mView = checkNotNull(view); |
philliphsu/NumberPadTimePicker | library/src/main/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerPresenter.java | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/DigitwiseTimeModel.java
// static final int MAX_DIGITS = 4;
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
| import android.support.annotation.NonNull;
import static com.philliphsu.numberpadtimepicker.AmPmState.AM;
import static com.philliphsu.numberpadtimepicker.AmPmState.HRS_24;
import static com.philliphsu.numberpadtimepicker.AmPmState.PM;
import static com.philliphsu.numberpadtimepicker.AmPmState.UNSPECIFIED;
import static com.philliphsu.numberpadtimepicker.DigitwiseTimeModel.MAX_DIGITS;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull; | }
private void updateViewEnabledStates() {
updateNumberKeysStates();
updateAltKeysStates();
updateBackspaceState();
updateOkButtonState();
}
private void updateOkButtonState() {
mOkButtonEnabled = mTimeParser.checkTimeValid(mAmPmState);
mView.setOkButtonEnabled(mOkButtonEnabled);
}
private void updateBackspaceState() {
mView.setBackspaceEnabled(count() > 0);
}
private void updateAltKeysStates() {
boolean enabled = false;
if (count() == 0) {
// No input, no access!
enabled = false;
} else if (count() == 1) {
// Any of 0-9 inputted, always have access in either clock.
enabled = true;
} else if (count() == 2) {
// Any 2 digits that make a valid hour for either clock are eligible for access
final int time = getDigitsAsInteger();
enabled = is24HourFormat() ? time <= 23 : time >= 10 && time <= 12; | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/DigitwiseTimeModel.java
// static final int MAX_DIGITS = 4;
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerPresenter.java
import android.support.annotation.NonNull;
import static com.philliphsu.numberpadtimepicker.AmPmState.AM;
import static com.philliphsu.numberpadtimepicker.AmPmState.HRS_24;
import static com.philliphsu.numberpadtimepicker.AmPmState.PM;
import static com.philliphsu.numberpadtimepicker.AmPmState.UNSPECIFIED;
import static com.philliphsu.numberpadtimepicker.DigitwiseTimeModel.MAX_DIGITS;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull;
}
private void updateViewEnabledStates() {
updateNumberKeysStates();
updateAltKeysStates();
updateBackspaceState();
updateOkButtonState();
}
private void updateOkButtonState() {
mOkButtonEnabled = mTimeParser.checkTimeValid(mAmPmState);
mView.setOkButtonEnabled(mOkButtonEnabled);
}
private void updateBackspaceState() {
mView.setBackspaceEnabled(count() > 0);
}
private void updateAltKeysStates() {
boolean enabled = false;
if (count() == 0) {
// No input, no access!
enabled = false;
} else if (count() == 1) {
// Any of 0-9 inputted, always have access in either clock.
enabled = true;
} else if (count() == 2) {
// Any 2 digits that make a valid hour for either clock are eligible for access
final int time = getDigitsAsInteger();
enabled = is24HourFormat() ? time <= 23 : time >= 10 && time <= 12; | } else if (count() == 3 || count() == MAX_DIGITS) { |
philliphsu/NumberPadTimePicker | library/src/main/java/com/philliphsu/numberpadtimepicker/DialogViewInitializer.java | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogPresenter {
// boolean onOkButtonClick();
// void onCancelClick();
// void setBasePresenter(Presenter presenter);
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogView {
// void cancel();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface Presenter {
// void onNumberKeyClick(CharSequence numberKeyText);
// void onAltKeyClick(CharSequence altKeyText);
// void onBackspaceClick();
// boolean onBackspaceLongClick();
// boolean onOkButtonClick();
// void onShow();
// void onSetOkButtonCallbacks();
// /**
// * @param state The state to initialize the time picker with.
// */
// void presentState(@NonNull State state);
// void detachView();
// State getState();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
| import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TimePicker;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogPresenter;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogView;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.Presenter;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull; | package com.philliphsu.numberpadtimepicker;
/**
* Provides static setup methods for a {@link DialogView}.
*/
final class DialogViewInitializer {
private DialogViewInitializer() {}
| // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogPresenter {
// boolean onOkButtonClick();
// void onCancelClick();
// void setBasePresenter(Presenter presenter);
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogView {
// void cancel();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface Presenter {
// void onNumberKeyClick(CharSequence numberKeyText);
// void onAltKeyClick(CharSequence altKeyText);
// void onBackspaceClick();
// boolean onBackspaceLongClick();
// boolean onOkButtonClick();
// void onShow();
// void onSetOkButtonCallbacks();
// /**
// * @param state The state to initialize the time picker with.
// */
// void presentState(@NonNull State state);
// void detachView();
// State getState();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/DialogViewInitializer.java
import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TimePicker;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogPresenter;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogView;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.Presenter;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull;
package com.philliphsu.numberpadtimepicker;
/**
* Provides static setup methods for a {@link DialogView}.
*/
final class DialogViewInitializer {
private DialogViewInitializer() {}
| static void setupDialogView(@NonNull DialogView dialogView, @NonNull final Context context, |
philliphsu/NumberPadTimePicker | library/src/main/java/com/philliphsu/numberpadtimepicker/DialogViewInitializer.java | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogPresenter {
// boolean onOkButtonClick();
// void onCancelClick();
// void setBasePresenter(Presenter presenter);
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogView {
// void cancel();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface Presenter {
// void onNumberKeyClick(CharSequence numberKeyText);
// void onAltKeyClick(CharSequence altKeyText);
// void onBackspaceClick();
// boolean onBackspaceLongClick();
// boolean onOkButtonClick();
// void onShow();
// void onSetOkButtonCallbacks();
// /**
// * @param state The state to initialize the time picker with.
// */
// void presentState(@NonNull State state);
// void detachView();
// State getState();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
| import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TimePicker;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogPresenter;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogView;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.Presenter;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull; | package com.philliphsu.numberpadtimepicker;
/**
* Provides static setup methods for a {@link DialogView}.
*/
final class DialogViewInitializer {
private DialogViewInitializer() {}
static void setupDialogView(@NonNull DialogView dialogView, @NonNull final Context context,
@NonNull final NumberPadTimePicker timePicker, @NonNull View okButton,
@Nullable final OnTimeSetListener listener, boolean is24HourMode) { | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogPresenter {
// boolean onOkButtonClick();
// void onCancelClick();
// void setBasePresenter(Presenter presenter);
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogView {
// void cancel();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface Presenter {
// void onNumberKeyClick(CharSequence numberKeyText);
// void onAltKeyClick(CharSequence altKeyText);
// void onBackspaceClick();
// boolean onBackspaceLongClick();
// boolean onOkButtonClick();
// void onShow();
// void onSetOkButtonCallbacks();
// /**
// * @param state The state to initialize the time picker with.
// */
// void presentState(@NonNull State state);
// void detachView();
// State getState();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/DialogViewInitializer.java
import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TimePicker;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogPresenter;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogView;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.Presenter;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull;
package com.philliphsu.numberpadtimepicker;
/**
* Provides static setup methods for a {@link DialogView}.
*/
final class DialogViewInitializer {
private DialogViewInitializer() {}
static void setupDialogView(@NonNull DialogView dialogView, @NonNull final Context context,
@NonNull final NumberPadTimePicker timePicker, @NonNull View okButton,
@Nullable final OnTimeSetListener listener, boolean is24HourMode) { | DialogPresenter presenter = new NumberPadTimePickerDialogPresenter(dialogView, |
philliphsu/NumberPadTimePicker | library/src/main/java/com/philliphsu/numberpadtimepicker/DialogViewInitializer.java | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogPresenter {
// boolean onOkButtonClick();
// void onCancelClick();
// void setBasePresenter(Presenter presenter);
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogView {
// void cancel();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface Presenter {
// void onNumberKeyClick(CharSequence numberKeyText);
// void onAltKeyClick(CharSequence altKeyText);
// void onBackspaceClick();
// boolean onBackspaceLongClick();
// boolean onOkButtonClick();
// void onShow();
// void onSetOkButtonCallbacks();
// /**
// * @param state The state to initialize the time picker with.
// */
// void presentState(@NonNull State state);
// void detachView();
// State getState();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
| import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TimePicker;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogPresenter;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogView;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.Presenter;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull; | package com.philliphsu.numberpadtimepicker;
/**
* Provides static setup methods for a {@link DialogView}.
*/
final class DialogViewInitializer {
private DialogViewInitializer() {}
static void setupDialogView(@NonNull DialogView dialogView, @NonNull final Context context,
@NonNull final NumberPadTimePicker timePicker, @NonNull View okButton,
@Nullable final OnTimeSetListener listener, boolean is24HourMode) {
DialogPresenter presenter = new NumberPadTimePickerDialogPresenter(dialogView,
timePicker.getPresenter());
setupDialogView(dialogView, presenter, context, timePicker, okButton, listener,
is24HourMode);
}
static void setupDialogView(@NonNull DialogView dialogView,
@NonNull final DialogPresenter dialogPresenter, @NonNull final Context context,
@NonNull final NumberPadTimePicker timePicker, @NonNull View okButton,
@Nullable final OnTimeSetListener listener, boolean is24HourMode) { | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogPresenter {
// boolean onOkButtonClick();
// void onCancelClick();
// void setBasePresenter(Presenter presenter);
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogView {
// void cancel();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface Presenter {
// void onNumberKeyClick(CharSequence numberKeyText);
// void onAltKeyClick(CharSequence altKeyText);
// void onBackspaceClick();
// boolean onBackspaceLongClick();
// boolean onOkButtonClick();
// void onShow();
// void onSetOkButtonCallbacks();
// /**
// * @param state The state to initialize the time picker with.
// */
// void presentState(@NonNull State state);
// void detachView();
// State getState();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/DialogViewInitializer.java
import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TimePicker;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogPresenter;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogView;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.Presenter;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull;
package com.philliphsu.numberpadtimepicker;
/**
* Provides static setup methods for a {@link DialogView}.
*/
final class DialogViewInitializer {
private DialogViewInitializer() {}
static void setupDialogView(@NonNull DialogView dialogView, @NonNull final Context context,
@NonNull final NumberPadTimePicker timePicker, @NonNull View okButton,
@Nullable final OnTimeSetListener listener, boolean is24HourMode) {
DialogPresenter presenter = new NumberPadTimePickerDialogPresenter(dialogView,
timePicker.getPresenter());
setupDialogView(dialogView, presenter, context, timePicker, okButton, listener,
is24HourMode);
}
static void setupDialogView(@NonNull DialogView dialogView,
@NonNull final DialogPresenter dialogPresenter, @NonNull final Context context,
@NonNull final NumberPadTimePicker timePicker, @NonNull View okButton,
@Nullable final OnTimeSetListener listener, boolean is24HourMode) { | checkNotNull(dialogView); |
philliphsu/NumberPadTimePicker | library/src/main/java/com/philliphsu/numberpadtimepicker/DialogViewInitializer.java | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogPresenter {
// boolean onOkButtonClick();
// void onCancelClick();
// void setBasePresenter(Presenter presenter);
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogView {
// void cancel();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface Presenter {
// void onNumberKeyClick(CharSequence numberKeyText);
// void onAltKeyClick(CharSequence altKeyText);
// void onBackspaceClick();
// boolean onBackspaceLongClick();
// boolean onOkButtonClick();
// void onShow();
// void onSetOkButtonCallbacks();
// /**
// * @param state The state to initialize the time picker with.
// */
// void presentState(@NonNull State state);
// void detachView();
// State getState();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
| import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TimePicker;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogPresenter;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogView;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.Presenter;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull; | package com.philliphsu.numberpadtimepicker;
/**
* Provides static setup methods for a {@link DialogView}.
*/
final class DialogViewInitializer {
private DialogViewInitializer() {}
static void setupDialogView(@NonNull DialogView dialogView, @NonNull final Context context,
@NonNull final NumberPadTimePicker timePicker, @NonNull View okButton,
@Nullable final OnTimeSetListener listener, boolean is24HourMode) {
DialogPresenter presenter = new NumberPadTimePickerDialogPresenter(dialogView,
timePicker.getPresenter());
setupDialogView(dialogView, presenter, context, timePicker, okButton, listener,
is24HourMode);
}
static void setupDialogView(@NonNull DialogView dialogView,
@NonNull final DialogPresenter dialogPresenter, @NonNull final Context context,
@NonNull final NumberPadTimePicker timePicker, @NonNull View okButton,
@Nullable final OnTimeSetListener listener, boolean is24HourMode) {
checkNotNull(dialogView);
checkNotNull(dialogPresenter);
checkNotNull(context);
checkNotNull(timePicker);
checkNotNull(okButton);
timePicker.setIs24HourMode(is24HourMode, new NumberPadTimePicker.OnTimeModeChangeListener() {
@Override | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogPresenter {
// boolean onOkButtonClick();
// void onCancelClick();
// void setBasePresenter(Presenter presenter);
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface DialogView {
// void cancel();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/INumberPadTimePicker.java
// interface Presenter {
// void onNumberKeyClick(CharSequence numberKeyText);
// void onAltKeyClick(CharSequence altKeyText);
// void onBackspaceClick();
// boolean onBackspaceLongClick();
// boolean onOkButtonClick();
// void onShow();
// void onSetOkButtonCallbacks();
// /**
// * @param state The state to initialize the time picker with.
// */
// void presentState(@NonNull State state);
// void detachView();
// State getState();
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/DialogViewInitializer.java
import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TimePicker;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogPresenter;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.DialogView;
import com.philliphsu.numberpadtimepicker.INumberPadTimePicker.Presenter;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull;
package com.philliphsu.numberpadtimepicker;
/**
* Provides static setup methods for a {@link DialogView}.
*/
final class DialogViewInitializer {
private DialogViewInitializer() {}
static void setupDialogView(@NonNull DialogView dialogView, @NonNull final Context context,
@NonNull final NumberPadTimePicker timePicker, @NonNull View okButton,
@Nullable final OnTimeSetListener listener, boolean is24HourMode) {
DialogPresenter presenter = new NumberPadTimePickerDialogPresenter(dialogView,
timePicker.getPresenter());
setupDialogView(dialogView, presenter, context, timePicker, okButton, listener,
is24HourMode);
}
static void setupDialogView(@NonNull DialogView dialogView,
@NonNull final DialogPresenter dialogPresenter, @NonNull final Context context,
@NonNull final NumberPadTimePicker timePicker, @NonNull View okButton,
@Nullable final OnTimeSetListener listener, boolean is24HourMode) {
checkNotNull(dialogView);
checkNotNull(dialogPresenter);
checkNotNull(context);
checkNotNull(timePicker);
checkNotNull(okButton);
timePicker.setIs24HourMode(is24HourMode, new NumberPadTimePicker.OnTimeModeChangeListener() {
@Override | public void onTimeModeChange(boolean is24HourMode, Presenter newPresenter) { |
philliphsu/NumberPadTimePicker | library/src/test/java/com/philliphsu/numberpadtimepicker/TestSuite.java | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/ButtonTextModel.java
// static String text(int digit) {
// return NUMBERS_TEXTS[digit];
// }
| import java.util.ArrayList;
import java.util.List;
import static com.philliphsu.numberpadtimepicker.AmPmState.UNSPECIFIED;
import static com.philliphsu.numberpadtimepicker.ButtonTextModel.text; | package com.philliphsu.numberpadtimepicker;
final class TestSuite {
static final List<TestCase> MODE_12HR_TESTS_1_TO_9 = new ArrayList<>(9);
static final List<TestCase> MODE_24HR_TESTS_0_TO_9 = new ArrayList<>(10);
static final List<TestCase> MODE_12HR_TESTS_10_TO_95 = new ArrayList<>(54);
static {
build_Mode12Hr_Tests_1_to_9();
build_Mode24Hr_Tests_0_to_9();
build_Mode12Hr_Tests_10_to_95();
}
private static void build_Mode12Hr_Tests_1_to_9() {
for (int i = 1; i <= 9; i++) {
MODE_12HR_TESTS_1_TO_9.add(new TestCase.Builder(array(i), UNSPECIFIED)
.numberKeysEnabled(0, 6 /* 1[0-2]:... or i:[0-5]... */)
.backspaceEnabled(true)
.headerDisplayFocused(true)
.altKeysEnabled(true)
.okButtonEnabled(false) | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/ButtonTextModel.java
// static String text(int digit) {
// return NUMBERS_TEXTS[digit];
// }
// Path: library/src/test/java/com/philliphsu/numberpadtimepicker/TestSuite.java
import java.util.ArrayList;
import java.util.List;
import static com.philliphsu.numberpadtimepicker.AmPmState.UNSPECIFIED;
import static com.philliphsu.numberpadtimepicker.ButtonTextModel.text;
package com.philliphsu.numberpadtimepicker;
final class TestSuite {
static final List<TestCase> MODE_12HR_TESTS_1_TO_9 = new ArrayList<>(9);
static final List<TestCase> MODE_24HR_TESTS_0_TO_9 = new ArrayList<>(10);
static final List<TestCase> MODE_12HR_TESTS_10_TO_95 = new ArrayList<>(54);
static {
build_Mode12Hr_Tests_1_to_9();
build_Mode24Hr_Tests_0_to_9();
build_Mode12Hr_Tests_10_to_95();
}
private static void build_Mode12Hr_Tests_1_to_9() {
for (int i = 1; i <= 9; i++) {
MODE_12HR_TESTS_1_TO_9.add(new TestCase.Builder(array(i), UNSPECIFIED)
.numberKeysEnabled(0, 6 /* 1[0-2]:... or i:[0-5]... */)
.backspaceEnabled(true)
.headerDisplayFocused(true)
.altKeysEnabled(true)
.okButtonEnabled(false) | .timeDisplay(text(i)) |
philliphsu/NumberPadTimePicker | sample/src/main/java/com/philliphsu/numberpadtimepickersample/CustomThemeController.java | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/BottomSheetNumberPadTimePickerThemer.java
// public interface BottomSheetNumberPadTimePickerThemer extends NumberPadTimePickerThemer {
// BottomSheetNumberPadTimePickerThemer setFabBackgroundColor(ColorStateList colors);
//
// BottomSheetNumberPadTimePickerThemer setFabRippleColor(@ColorInt int color);
//
// BottomSheetNumberPadTimePickerThemer setFabIconTint(ColorStateList tint);
//
// BottomSheetNumberPadTimePickerThemer setAnimateFabBackgroundColor(boolean animate);
//
// BottomSheetNumberPadTimePickerThemer setShowFabPolicy(@ShowFabPolicy int policy);
//
// BottomSheetNumberPadTimePickerThemer setAnimateFabIn(boolean animateIn);
//
// BottomSheetNumberPadTimePickerThemer setBackspaceLocation(@BackspaceLocation int location);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setInputTimeTextColor(@ColorInt int color);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setInputAmPmTextColor(@ColorInt int color);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setBackspaceTint(ColorStateList colors);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setNumberKeysTextColor(ColorStateList colors);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setAltKeysTextColor(ColorStateList colors);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setHeaderBackground(Drawable background);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setNumberPadBackground(Drawable background);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setDivider(Drawable divider);
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerThemer.java
// public interface NumberPadTimePickerThemer {
// NumberPadTimePickerThemer setInputTimeTextColor(@ColorInt int color);
//
// NumberPadTimePickerThemer setInputAmPmTextColor(@ColorInt int color);
//
// NumberPadTimePickerThemer setBackspaceTint(ColorStateList colors);
//
// NumberPadTimePickerThemer setNumberKeysTextColor(ColorStateList colors);
//
// NumberPadTimePickerThemer setAltKeysTextColor(ColorStateList colors);
//
// NumberPadTimePickerThemer setHeaderBackground(Drawable background);
//
// NumberPadTimePickerThemer setNumberPadBackground(Drawable background);
//
// NumberPadTimePickerThemer setDivider(Drawable divider);
// }
| import android.content.Context;
import com.philliphsu.numberpadtimepicker.BottomSheetNumberPadTimePickerThemer;
import com.philliphsu.numberpadtimepicker.NumberPadTimePickerThemer; | package com.philliphsu.numberpadtimepickersample;
public class CustomThemeController {
private static CustomThemeController instance;
private final CustomThemeModel model;
private CustomThemeController(Context context) {
model = CustomThemeModel.get(context);
}
public static CustomThemeController get(Context context) {
if (instance == null) {
instance = new CustomThemeController(context);
}
return instance;
}
| // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/BottomSheetNumberPadTimePickerThemer.java
// public interface BottomSheetNumberPadTimePickerThemer extends NumberPadTimePickerThemer {
// BottomSheetNumberPadTimePickerThemer setFabBackgroundColor(ColorStateList colors);
//
// BottomSheetNumberPadTimePickerThemer setFabRippleColor(@ColorInt int color);
//
// BottomSheetNumberPadTimePickerThemer setFabIconTint(ColorStateList tint);
//
// BottomSheetNumberPadTimePickerThemer setAnimateFabBackgroundColor(boolean animate);
//
// BottomSheetNumberPadTimePickerThemer setShowFabPolicy(@ShowFabPolicy int policy);
//
// BottomSheetNumberPadTimePickerThemer setAnimateFabIn(boolean animateIn);
//
// BottomSheetNumberPadTimePickerThemer setBackspaceLocation(@BackspaceLocation int location);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setInputTimeTextColor(@ColorInt int color);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setInputAmPmTextColor(@ColorInt int color);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setBackspaceTint(ColorStateList colors);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setNumberKeysTextColor(ColorStateList colors);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setAltKeysTextColor(ColorStateList colors);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setHeaderBackground(Drawable background);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setNumberPadBackground(Drawable background);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setDivider(Drawable divider);
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerThemer.java
// public interface NumberPadTimePickerThemer {
// NumberPadTimePickerThemer setInputTimeTextColor(@ColorInt int color);
//
// NumberPadTimePickerThemer setInputAmPmTextColor(@ColorInt int color);
//
// NumberPadTimePickerThemer setBackspaceTint(ColorStateList colors);
//
// NumberPadTimePickerThemer setNumberKeysTextColor(ColorStateList colors);
//
// NumberPadTimePickerThemer setAltKeysTextColor(ColorStateList colors);
//
// NumberPadTimePickerThemer setHeaderBackground(Drawable background);
//
// NumberPadTimePickerThemer setNumberPadBackground(Drawable background);
//
// NumberPadTimePickerThemer setDivider(Drawable divider);
// }
// Path: sample/src/main/java/com/philliphsu/numberpadtimepickersample/CustomThemeController.java
import android.content.Context;
import com.philliphsu.numberpadtimepicker.BottomSheetNumberPadTimePickerThemer;
import com.philliphsu.numberpadtimepicker.NumberPadTimePickerThemer;
package com.philliphsu.numberpadtimepickersample;
public class CustomThemeController {
private static CustomThemeController instance;
private final CustomThemeModel model;
private CustomThemeController(Context context) {
model = CustomThemeModel.get(context);
}
public static CustomThemeController get(Context context) {
if (instance == null) {
instance = new CustomThemeController(context);
}
return instance;
}
| public void applyCustomTheme(NumberPadTimePickerThemer themer) { |
philliphsu/NumberPadTimePicker | sample/src/main/java/com/philliphsu/numberpadtimepickersample/CustomThemeController.java | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/BottomSheetNumberPadTimePickerThemer.java
// public interface BottomSheetNumberPadTimePickerThemer extends NumberPadTimePickerThemer {
// BottomSheetNumberPadTimePickerThemer setFabBackgroundColor(ColorStateList colors);
//
// BottomSheetNumberPadTimePickerThemer setFabRippleColor(@ColorInt int color);
//
// BottomSheetNumberPadTimePickerThemer setFabIconTint(ColorStateList tint);
//
// BottomSheetNumberPadTimePickerThemer setAnimateFabBackgroundColor(boolean animate);
//
// BottomSheetNumberPadTimePickerThemer setShowFabPolicy(@ShowFabPolicy int policy);
//
// BottomSheetNumberPadTimePickerThemer setAnimateFabIn(boolean animateIn);
//
// BottomSheetNumberPadTimePickerThemer setBackspaceLocation(@BackspaceLocation int location);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setInputTimeTextColor(@ColorInt int color);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setInputAmPmTextColor(@ColorInt int color);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setBackspaceTint(ColorStateList colors);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setNumberKeysTextColor(ColorStateList colors);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setAltKeysTextColor(ColorStateList colors);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setHeaderBackground(Drawable background);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setNumberPadBackground(Drawable background);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setDivider(Drawable divider);
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerThemer.java
// public interface NumberPadTimePickerThemer {
// NumberPadTimePickerThemer setInputTimeTextColor(@ColorInt int color);
//
// NumberPadTimePickerThemer setInputAmPmTextColor(@ColorInt int color);
//
// NumberPadTimePickerThemer setBackspaceTint(ColorStateList colors);
//
// NumberPadTimePickerThemer setNumberKeysTextColor(ColorStateList colors);
//
// NumberPadTimePickerThemer setAltKeysTextColor(ColorStateList colors);
//
// NumberPadTimePickerThemer setHeaderBackground(Drawable background);
//
// NumberPadTimePickerThemer setNumberPadBackground(Drawable background);
//
// NumberPadTimePickerThemer setDivider(Drawable divider);
// }
| import android.content.Context;
import com.philliphsu.numberpadtimepicker.BottomSheetNumberPadTimePickerThemer;
import com.philliphsu.numberpadtimepicker.NumberPadTimePickerThemer; | package com.philliphsu.numberpadtimepickersample;
public class CustomThemeController {
private static CustomThemeController instance;
private final CustomThemeModel model;
private CustomThemeController(Context context) {
model = CustomThemeModel.get(context);
}
public static CustomThemeController get(Context context) {
if (instance == null) {
instance = new CustomThemeController(context);
}
return instance;
}
public void applyCustomTheme(NumberPadTimePickerThemer themer) {
themer.setHeaderBackground(model.getHeaderBackground())
.setInputTimeTextColor(model.getInputTimeTextColor())
.setInputAmPmTextColor(model.getInputAmPmTextColor())
.setNumberPadBackground(model.getNumberPadBackground())
.setNumberKeysTextColor(model.getNumberKeysTextColor())
.setAltKeysTextColor(model.getAltKeysTextColor())
.setDivider(model.getDivider())
.setBackspaceTint(model.getBackspaceTint()); | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/BottomSheetNumberPadTimePickerThemer.java
// public interface BottomSheetNumberPadTimePickerThemer extends NumberPadTimePickerThemer {
// BottomSheetNumberPadTimePickerThemer setFabBackgroundColor(ColorStateList colors);
//
// BottomSheetNumberPadTimePickerThemer setFabRippleColor(@ColorInt int color);
//
// BottomSheetNumberPadTimePickerThemer setFabIconTint(ColorStateList tint);
//
// BottomSheetNumberPadTimePickerThemer setAnimateFabBackgroundColor(boolean animate);
//
// BottomSheetNumberPadTimePickerThemer setShowFabPolicy(@ShowFabPolicy int policy);
//
// BottomSheetNumberPadTimePickerThemer setAnimateFabIn(boolean animateIn);
//
// BottomSheetNumberPadTimePickerThemer setBackspaceLocation(@BackspaceLocation int location);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setInputTimeTextColor(@ColorInt int color);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setInputAmPmTextColor(@ColorInt int color);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setBackspaceTint(ColorStateList colors);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setNumberKeysTextColor(ColorStateList colors);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setAltKeysTextColor(ColorStateList colors);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setHeaderBackground(Drawable background);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setNumberPadBackground(Drawable background);
//
// @Override
// BottomSheetNumberPadTimePickerThemer setDivider(Drawable divider);
// }
//
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerThemer.java
// public interface NumberPadTimePickerThemer {
// NumberPadTimePickerThemer setInputTimeTextColor(@ColorInt int color);
//
// NumberPadTimePickerThemer setInputAmPmTextColor(@ColorInt int color);
//
// NumberPadTimePickerThemer setBackspaceTint(ColorStateList colors);
//
// NumberPadTimePickerThemer setNumberKeysTextColor(ColorStateList colors);
//
// NumberPadTimePickerThemer setAltKeysTextColor(ColorStateList colors);
//
// NumberPadTimePickerThemer setHeaderBackground(Drawable background);
//
// NumberPadTimePickerThemer setNumberPadBackground(Drawable background);
//
// NumberPadTimePickerThemer setDivider(Drawable divider);
// }
// Path: sample/src/main/java/com/philliphsu/numberpadtimepickersample/CustomThemeController.java
import android.content.Context;
import com.philliphsu.numberpadtimepicker.BottomSheetNumberPadTimePickerThemer;
import com.philliphsu.numberpadtimepicker.NumberPadTimePickerThemer;
package com.philliphsu.numberpadtimepickersample;
public class CustomThemeController {
private static CustomThemeController instance;
private final CustomThemeModel model;
private CustomThemeController(Context context) {
model = CustomThemeModel.get(context);
}
public static CustomThemeController get(Context context) {
if (instance == null) {
instance = new CustomThemeController(context);
}
return instance;
}
public void applyCustomTheme(NumberPadTimePickerThemer themer) {
themer.setHeaderBackground(model.getHeaderBackground())
.setInputTimeTextColor(model.getInputTimeTextColor())
.setInputAmPmTextColor(model.getInputAmPmTextColor())
.setNumberPadBackground(model.getNumberPadBackground())
.setNumberKeysTextColor(model.getNumberKeysTextColor())
.setAltKeysTextColor(model.getAltKeysTextColor())
.setDivider(model.getDivider())
.setBackspaceTint(model.getBackspaceTint()); | if (themer instanceof BottomSheetNumberPadTimePickerThemer) { |
philliphsu/NumberPadTimePicker | library/src/main/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerDialogPresenter.java | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
| import android.support.annotation.NonNull;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull; | package com.philliphsu.numberpadtimepicker;
final class NumberPadTimePickerDialogPresenter implements INumberPadTimePicker.DialogPresenter {
private final INumberPadTimePicker.DialogView mView;
private INumberPadTimePicker.Presenter mBasePresenter;
NumberPadTimePickerDialogPresenter(@NonNull INumberPadTimePicker.DialogView view,
@NonNull INumberPadTimePicker.Presenter basePresenter) { | // Path: library/src/main/java/com/philliphsu/numberpadtimepicker/Preconditions.java
// static <T> T checkNotNull(T t) {
// if (t == null) {
// throw new NullPointerException();
// }
// return t;
// }
// Path: library/src/main/java/com/philliphsu/numberpadtimepicker/NumberPadTimePickerDialogPresenter.java
import android.support.annotation.NonNull;
import static com.philliphsu.numberpadtimepicker.Preconditions.checkNotNull;
package com.philliphsu.numberpadtimepicker;
final class NumberPadTimePickerDialogPresenter implements INumberPadTimePicker.DialogPresenter {
private final INumberPadTimePicker.DialogView mView;
private INumberPadTimePicker.Presenter mBasePresenter;
NumberPadTimePickerDialogPresenter(@NonNull INumberPadTimePicker.DialogView view,
@NonNull INumberPadTimePicker.Presenter basePresenter) { | mView = checkNotNull(view); |
psh/OxfordDictionarySample | app/src/main/java/com/gatebuzz/oxfordapi/api/DictionaryEntriesApi.java | // Path: app/src/main/java/com/gatebuzz/oxfordapi/model/RetrieveEntry.java
// public class RetrieveEntry {
// @SerializedName("metadata")
// private Object metadata = null;
//
// @SerializedName("results")
// private List<HeadwordEntry> results = new ArrayList<HeadwordEntry>();
//
// public RetrieveEntry metadata(Object metadata) {
// this.metadata = metadata;
// return this;
// }
//
// /**
// * Additional Information provided by OUP
// * @return metadata
// **/
// public Object getMetadata() {
// return metadata;
// }
//
// public void setMetadata(Object metadata) {
// this.metadata = metadata;
// }
//
// public RetrieveEntry results(List<HeadwordEntry> results) {
// this.results = results;
// return this;
// }
//
// public RetrieveEntry addResultsItem(HeadwordEntry resultsItem) {
// this.results.add(resultsItem);
// return this;
// }
//
// /**
// * A list of entries and all the data related to them
// * @return results
// **/
// public List<HeadwordEntry> getResults() {
// return results;
// }
//
// public void setResults(List<HeadwordEntry> results) {
// this.results = results;
// }
//
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// RetrieveEntry retrieveEntry = (RetrieveEntry) o;
// return Objects.equals(this.metadata, retrieveEntry.metadata) &&
// Objects.equals(this.results, retrieveEntry.results);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(metadata, results);
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append("class RetrieveEntry {\n");
//
// sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
// sb.append(" results: ").append(toIndentedString(results)).append("\n");
// sb.append("}");
// return sb.toString();
// }
//
// /**
// * Convert the given object to string with each line indented by 4 spaces
// * (except the first line).
// */
// private String toIndentedString(Object o) {
// if (o == null) {
// return "null";
// }
// return o.toString().replace("\n", "\n ");
// }
// }
| import com.gatebuzz.oxfordapi.model.RetrieveEntry;
import java.util.List;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path; | package com.gatebuzz.oxfordapi.api;
@SuppressWarnings("unused")
public interface DictionaryEntriesApi {
/**
* Retrieve only definitions in entry search.
* Find available [dictionary entries](/glossary?tag=#entry&expand) for given word and language. Filter results by categories. <div id=\"dictionary_entries_filters_definitions\"></div>
* @param sourceLang IANA language code (required)
* @param wordId An Entry identifier. Case-sensitive. (required)
* @param appId App ID Authentication Parameter (required)
* @param appKey App Key Authentication Parameter (required)
* @return Call<RetrieveEntry>
*/
@GET("entries/{source_lang}/{word_id}/definitions") | // Path: app/src/main/java/com/gatebuzz/oxfordapi/model/RetrieveEntry.java
// public class RetrieveEntry {
// @SerializedName("metadata")
// private Object metadata = null;
//
// @SerializedName("results")
// private List<HeadwordEntry> results = new ArrayList<HeadwordEntry>();
//
// public RetrieveEntry metadata(Object metadata) {
// this.metadata = metadata;
// return this;
// }
//
// /**
// * Additional Information provided by OUP
// * @return metadata
// **/
// public Object getMetadata() {
// return metadata;
// }
//
// public void setMetadata(Object metadata) {
// this.metadata = metadata;
// }
//
// public RetrieveEntry results(List<HeadwordEntry> results) {
// this.results = results;
// return this;
// }
//
// public RetrieveEntry addResultsItem(HeadwordEntry resultsItem) {
// this.results.add(resultsItem);
// return this;
// }
//
// /**
// * A list of entries and all the data related to them
// * @return results
// **/
// public List<HeadwordEntry> getResults() {
// return results;
// }
//
// public void setResults(List<HeadwordEntry> results) {
// this.results = results;
// }
//
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// RetrieveEntry retrieveEntry = (RetrieveEntry) o;
// return Objects.equals(this.metadata, retrieveEntry.metadata) &&
// Objects.equals(this.results, retrieveEntry.results);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(metadata, results);
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append("class RetrieveEntry {\n");
//
// sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
// sb.append(" results: ").append(toIndentedString(results)).append("\n");
// sb.append("}");
// return sb.toString();
// }
//
// /**
// * Convert the given object to string with each line indented by 4 spaces
// * (except the first line).
// */
// private String toIndentedString(Object o) {
// if (o == null) {
// return "null";
// }
// return o.toString().replace("\n", "\n ");
// }
// }
// Path: app/src/main/java/com/gatebuzz/oxfordapi/api/DictionaryEntriesApi.java
import com.gatebuzz.oxfordapi.model.RetrieveEntry;
import java.util.List;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
package com.gatebuzz.oxfordapi.api;
@SuppressWarnings("unused")
public interface DictionaryEntriesApi {
/**
* Retrieve only definitions in entry search.
* Find available [dictionary entries](/glossary?tag=#entry&expand) for given word and language. Filter results by categories. <div id=\"dictionary_entries_filters_definitions\"></div>
* @param sourceLang IANA language code (required)
* @param wordId An Entry identifier. Case-sensitive. (required)
* @param appId App ID Authentication Parameter (required)
* @param appKey App Key Authentication Parameter (required)
* @return Call<RetrieveEntry>
*/
@GET("entries/{source_lang}/{word_id}/definitions") | Observable<RetrieveEntry> entriesSourceLangWordIdDefinitionsGet( |
psh/OxfordDictionarySample | app/src/main/java/com/gatebuzz/oxfordapi/api/TheSentenceDictionaryApi.java | // Path: app/src/main/java/com/gatebuzz/oxfordapi/model/SentencesResults.java
// public class SentencesResults {
// @SerializedName("metadata")
// private Object metadata = null;
//
// @SerializedName("results")
// private List<SentencesEntry> results = new ArrayList<SentencesEntry>();
//
// public SentencesResults metadata(Object metadata) {
// this.metadata = metadata;
// return this;
// }
//
// /**
// * Additional Information provided by OUP
// * @return metadata
// **/
// public Object getMetadata() {
// return metadata;
// }
//
// public void setMetadata(Object metadata) {
// this.metadata = metadata;
// }
//
// public SentencesResults results(List<SentencesEntry> results) {
// this.results = results;
// return this;
// }
//
// public SentencesResults addResultsItem(SentencesEntry resultsItem) {
// this.results.add(resultsItem);
// return this;
// }
//
// /**
// * A list of entries and all the data related to them
// * @return results
// **/
// public List<SentencesEntry> getResults() {
// return results;
// }
//
// public void setResults(List<SentencesEntry> results) {
// this.results = results;
// }
//
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// SentencesResults sentencesResults = (SentencesResults) o;
// return Objects.equals(this.metadata, sentencesResults.metadata) &&
// Objects.equals(this.results, sentencesResults.results);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(metadata, results);
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append("class SentencesResults {\n");
//
// sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
// sb.append(" results: ").append(toIndentedString(results)).append("\n");
// sb.append("}");
// return sb.toString();
// }
//
// /**
// * Convert the given object to string with each line indented by 4 spaces
// * (except the first line).
// */
// private String toIndentedString(Object o) {
// if (o == null) {
// return "null";
// }
// return o.toString().replace("\n", "\n ");
// }
// }
| import com.gatebuzz.oxfordapi.model.SentencesResults;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path; | package com.gatebuzz.oxfordapi.api;
@SuppressWarnings("unused")
public interface TheSentenceDictionaryApi {
/**
* Retrieve corpus sentences for a given word.
* Retrieve list of sentences and list of [senses](/glossary?tag=#sense&expand) (English language only). <div id=\"sentences\"></div>
* @param sourceLanguage IANA language code. (required)
* @param wordId An Entry identifier. Case-sensitive. (required)
* @param appId App ID Authentication Parameter (required)
* @param appKey App Key Authentication Parameter (required)
* @return Call<SentencesResults>
*/
@GET("entries/{source_language}/{word_id}/sentences") | // Path: app/src/main/java/com/gatebuzz/oxfordapi/model/SentencesResults.java
// public class SentencesResults {
// @SerializedName("metadata")
// private Object metadata = null;
//
// @SerializedName("results")
// private List<SentencesEntry> results = new ArrayList<SentencesEntry>();
//
// public SentencesResults metadata(Object metadata) {
// this.metadata = metadata;
// return this;
// }
//
// /**
// * Additional Information provided by OUP
// * @return metadata
// **/
// public Object getMetadata() {
// return metadata;
// }
//
// public void setMetadata(Object metadata) {
// this.metadata = metadata;
// }
//
// public SentencesResults results(List<SentencesEntry> results) {
// this.results = results;
// return this;
// }
//
// public SentencesResults addResultsItem(SentencesEntry resultsItem) {
// this.results.add(resultsItem);
// return this;
// }
//
// /**
// * A list of entries and all the data related to them
// * @return results
// **/
// public List<SentencesEntry> getResults() {
// return results;
// }
//
// public void setResults(List<SentencesEntry> results) {
// this.results = results;
// }
//
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// SentencesResults sentencesResults = (SentencesResults) o;
// return Objects.equals(this.metadata, sentencesResults.metadata) &&
// Objects.equals(this.results, sentencesResults.results);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(metadata, results);
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append("class SentencesResults {\n");
//
// sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
// sb.append(" results: ").append(toIndentedString(results)).append("\n");
// sb.append("}");
// return sb.toString();
// }
//
// /**
// * Convert the given object to string with each line indented by 4 spaces
// * (except the first line).
// */
// private String toIndentedString(Object o) {
// if (o == null) {
// return "null";
// }
// return o.toString().replace("\n", "\n ");
// }
// }
// Path: app/src/main/java/com/gatebuzz/oxfordapi/api/TheSentenceDictionaryApi.java
import com.gatebuzz.oxfordapi.model.SentencesResults;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
package com.gatebuzz.oxfordapi.api;
@SuppressWarnings("unused")
public interface TheSentenceDictionaryApi {
/**
* Retrieve corpus sentences for a given word.
* Retrieve list of sentences and list of [senses](/glossary?tag=#sense&expand) (English language only). <div id=\"sentences\"></div>
* @param sourceLanguage IANA language code. (required)
* @param wordId An Entry identifier. Case-sensitive. (required)
* @param appId App ID Authentication Parameter (required)
* @param appKey App Key Authentication Parameter (required)
* @return Call<SentencesResults>
*/
@GET("entries/{source_language}/{word_id}/sentences") | Observable<SentencesResults> entriesSourceLanguageWordIdSentencesGet( |
psh/OxfordDictionarySample | app/src/main/java/com/gatebuzz/oxfordapi/api/TranslationApi.java | // Path: app/src/main/java/com/gatebuzz/oxfordapi/model/RetrieveEntry.java
// public class RetrieveEntry {
// @SerializedName("metadata")
// private Object metadata = null;
//
// @SerializedName("results")
// private List<HeadwordEntry> results = new ArrayList<HeadwordEntry>();
//
// public RetrieveEntry metadata(Object metadata) {
// this.metadata = metadata;
// return this;
// }
//
// /**
// * Additional Information provided by OUP
// * @return metadata
// **/
// public Object getMetadata() {
// return metadata;
// }
//
// public void setMetadata(Object metadata) {
// this.metadata = metadata;
// }
//
// public RetrieveEntry results(List<HeadwordEntry> results) {
// this.results = results;
// return this;
// }
//
// public RetrieveEntry addResultsItem(HeadwordEntry resultsItem) {
// this.results.add(resultsItem);
// return this;
// }
//
// /**
// * A list of entries and all the data related to them
// * @return results
// **/
// public List<HeadwordEntry> getResults() {
// return results;
// }
//
// public void setResults(List<HeadwordEntry> results) {
// this.results = results;
// }
//
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// RetrieveEntry retrieveEntry = (RetrieveEntry) o;
// return Objects.equals(this.metadata, retrieveEntry.metadata) &&
// Objects.equals(this.results, retrieveEntry.results);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(metadata, results);
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append("class RetrieveEntry {\n");
//
// sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
// sb.append(" results: ").append(toIndentedString(results)).append("\n");
// sb.append("}");
// return sb.toString();
// }
//
// /**
// * Convert the given object to string with each line indented by 4 spaces
// * (except the first line).
// */
// private String toIndentedString(Object o) {
// if (o == null) {
// return "null";
// }
// return o.toString().replace("\n", "\n ");
// }
// }
| import com.gatebuzz.oxfordapi.model.RetrieveEntry;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path; | package com.gatebuzz.oxfordapi.api;
@SuppressWarnings("unused")
public interface TranslationApi {
/**
* Find translation for a given word.
* Returns target language translations for a given word ID and source language. In the event that a word in the dataset does not have a direct translation, the response will be a [definition](/glossary?tag=#entry&expand) in the target language. <div id=\"translation\"></div>
* @param sourceLang IANA language code (required)
* @param wordId An Entry identifier. Case-sensitive. (required)
* @param targetLang IANA language code (required)
* @param appId App ID Authentication Parameter (required)
* @param appKey App Key Authentication Parameter (required)
* @return Call<RetrieveEntry>
*/
@GET("entries/{source_lang}/{word_id}/translations={target_lang}") | // Path: app/src/main/java/com/gatebuzz/oxfordapi/model/RetrieveEntry.java
// public class RetrieveEntry {
// @SerializedName("metadata")
// private Object metadata = null;
//
// @SerializedName("results")
// private List<HeadwordEntry> results = new ArrayList<HeadwordEntry>();
//
// public RetrieveEntry metadata(Object metadata) {
// this.metadata = metadata;
// return this;
// }
//
// /**
// * Additional Information provided by OUP
// * @return metadata
// **/
// public Object getMetadata() {
// return metadata;
// }
//
// public void setMetadata(Object metadata) {
// this.metadata = metadata;
// }
//
// public RetrieveEntry results(List<HeadwordEntry> results) {
// this.results = results;
// return this;
// }
//
// public RetrieveEntry addResultsItem(HeadwordEntry resultsItem) {
// this.results.add(resultsItem);
// return this;
// }
//
// /**
// * A list of entries and all the data related to them
// * @return results
// **/
// public List<HeadwordEntry> getResults() {
// return results;
// }
//
// public void setResults(List<HeadwordEntry> results) {
// this.results = results;
// }
//
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// RetrieveEntry retrieveEntry = (RetrieveEntry) o;
// return Objects.equals(this.metadata, retrieveEntry.metadata) &&
// Objects.equals(this.results, retrieveEntry.results);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(metadata, results);
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append("class RetrieveEntry {\n");
//
// sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
// sb.append(" results: ").append(toIndentedString(results)).append("\n");
// sb.append("}");
// return sb.toString();
// }
//
// /**
// * Convert the given object to string with each line indented by 4 spaces
// * (except the first line).
// */
// private String toIndentedString(Object o) {
// if (o == null) {
// return "null";
// }
// return o.toString().replace("\n", "\n ");
// }
// }
// Path: app/src/main/java/com/gatebuzz/oxfordapi/api/TranslationApi.java
import com.gatebuzz.oxfordapi.model.RetrieveEntry;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
package com.gatebuzz.oxfordapi.api;
@SuppressWarnings("unused")
public interface TranslationApi {
/**
* Find translation for a given word.
* Returns target language translations for a given word ID and source language. In the event that a word in the dataset does not have a direct translation, the response will be a [definition](/glossary?tag=#entry&expand) in the target language. <div id=\"translation\"></div>
* @param sourceLang IANA language code (required)
* @param wordId An Entry identifier. Case-sensitive. (required)
* @param targetLang IANA language code (required)
* @param appId App ID Authentication Parameter (required)
* @param appKey App Key Authentication Parameter (required)
* @return Call<RetrieveEntry>
*/
@GET("entries/{source_lang}/{word_id}/translations={target_lang}") | Observable<RetrieveEntry> entriesSourceLangWordIdTranslationstargetLangGet( |
psh/OxfordDictionarySample | app/src/main/java/com/gatebuzz/oxfordapi/api/LemmatronApi.java | // Path: app/src/main/java/com/gatebuzz/oxfordapi/model/Lemmatron.java
// public class Lemmatron {
// @SerializedName("metadata")
// private Object metadata = null;
//
// @SerializedName("results")
// private List<HeadwordLemmatron> results = new ArrayList<HeadwordLemmatron>();
//
// public Lemmatron metadata(Object metadata) {
// this.metadata = metadata;
// return this;
// }
//
// /**
// * Additional Information provided by OUP
// * @return metadata
// **/
// public Object getMetadata() {
// return metadata;
// }
//
// public void setMetadata(Object metadata) {
// this.metadata = metadata;
// }
//
// public Lemmatron results(List<HeadwordLemmatron> results) {
// this.results = results;
// return this;
// }
//
// public Lemmatron addResultsItem(HeadwordLemmatron resultsItem) {
// this.results.add(resultsItem);
// return this;
// }
//
// /**
// * A list of inflections matching a given word
// * @return results
// **/
// public List<HeadwordLemmatron> getResults() {
// return results;
// }
//
// public void setResults(List<HeadwordLemmatron> results) {
// this.results = results;
// }
//
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// Lemmatron lemmatron = (Lemmatron) o;
// return Objects.equals(this.metadata, lemmatron.metadata) &&
// Objects.equals(this.results, lemmatron.results);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(metadata, results);
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append("class Lemmatron {\n");
//
// sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
// sb.append(" results: ").append(toIndentedString(results)).append("\n");
// sb.append("}");
// return sb.toString();
// }
//
// /**
// * Convert the given object to string with each line indented by 4 spaces
// * (except the first line).
// */
// private String toIndentedString(Object o) {
// if (o == null) {
// return "null";
// }
// return o.toString().replace("\n", "\n ");
// }
// }
| import com.gatebuzz.oxfordapi.model.Lemmatron;
import java.util.List;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path; | package com.gatebuzz.oxfordapi.api;
@SuppressWarnings("unused")
public interface LemmatronApi {
/**
* Apply filters to Lemmatron response
* Retrieve available [lemmas](/glossary?tag=#lemma&expand) for a given [inflected](/glossary?tag=#inflection&expand) wordform. Filter results by categories. <div id=\"lemmatron_filters\"></div>
* @param sourceLang IANA language code (required)
* @param wordId An inflected wordform. Case-sensitive. (required)
* @param filters Separate filtering conditions using a semicolon. Conditions take values grammaticalFeatures and/or lexicalCategory and are case-sensitive. To list multiple values in single condition divide them with comma. (required)
* @param appId App ID Authentication Parameter (required)
* @param appKey App Key Authentication Parameter (required)
* @return Call<Lemmatron>
*/
@GET("inflections/{source_lang}/{word_id}/{filters}") | // Path: app/src/main/java/com/gatebuzz/oxfordapi/model/Lemmatron.java
// public class Lemmatron {
// @SerializedName("metadata")
// private Object metadata = null;
//
// @SerializedName("results")
// private List<HeadwordLemmatron> results = new ArrayList<HeadwordLemmatron>();
//
// public Lemmatron metadata(Object metadata) {
// this.metadata = metadata;
// return this;
// }
//
// /**
// * Additional Information provided by OUP
// * @return metadata
// **/
// public Object getMetadata() {
// return metadata;
// }
//
// public void setMetadata(Object metadata) {
// this.metadata = metadata;
// }
//
// public Lemmatron results(List<HeadwordLemmatron> results) {
// this.results = results;
// return this;
// }
//
// public Lemmatron addResultsItem(HeadwordLemmatron resultsItem) {
// this.results.add(resultsItem);
// return this;
// }
//
// /**
// * A list of inflections matching a given word
// * @return results
// **/
// public List<HeadwordLemmatron> getResults() {
// return results;
// }
//
// public void setResults(List<HeadwordLemmatron> results) {
// this.results = results;
// }
//
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// Lemmatron lemmatron = (Lemmatron) o;
// return Objects.equals(this.metadata, lemmatron.metadata) &&
// Objects.equals(this.results, lemmatron.results);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(metadata, results);
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append("class Lemmatron {\n");
//
// sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
// sb.append(" results: ").append(toIndentedString(results)).append("\n");
// sb.append("}");
// return sb.toString();
// }
//
// /**
// * Convert the given object to string with each line indented by 4 spaces
// * (except the first line).
// */
// private String toIndentedString(Object o) {
// if (o == null) {
// return "null";
// }
// return o.toString().replace("\n", "\n ");
// }
// }
// Path: app/src/main/java/com/gatebuzz/oxfordapi/api/LemmatronApi.java
import com.gatebuzz.oxfordapi.model.Lemmatron;
import java.util.List;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
package com.gatebuzz.oxfordapi.api;
@SuppressWarnings("unused")
public interface LemmatronApi {
/**
* Apply filters to Lemmatron response
* Retrieve available [lemmas](/glossary?tag=#lemma&expand) for a given [inflected](/glossary?tag=#inflection&expand) wordform. Filter results by categories. <div id=\"lemmatron_filters\"></div>
* @param sourceLang IANA language code (required)
* @param wordId An inflected wordform. Case-sensitive. (required)
* @param filters Separate filtering conditions using a semicolon. Conditions take values grammaticalFeatures and/or lexicalCategory and are case-sensitive. To list multiple values in single condition divide them with comma. (required)
* @param appId App ID Authentication Parameter (required)
* @param appKey App Key Authentication Parameter (required)
* @return Call<Lemmatron>
*/
@GET("inflections/{source_lang}/{word_id}/{filters}") | Observable<Lemmatron> inflectionsSourceLangWordIdFiltersGet( |
psh/OxfordDictionarySample | app/src/main/java/com/gatebuzz/oxfordapi/api/ThesaurusApi.java | // Path: app/src/main/java/com/gatebuzz/oxfordapi/model/Thesaurus.java
// public class Thesaurus {
// @SerializedName("metadata")
// private Object metadata = null;
//
// @SerializedName("results")
// private List<HeadwordThesaurus> results = new ArrayList<HeadwordThesaurus>();
//
// public Thesaurus metadata(Object metadata) {
// this.metadata = metadata;
// return this;
// }
//
// /**
// * Additional Information provided by OUP
// * @return metadata
// **/
// public Object getMetadata() {
// return metadata;
// }
//
// public void setMetadata(Object metadata) {
// this.metadata = metadata;
// }
//
// public Thesaurus results(List<HeadwordThesaurus> results) {
// this.results = results;
// return this;
// }
//
// public Thesaurus addResultsItem(HeadwordThesaurus resultsItem) {
// this.results.add(resultsItem);
// return this;
// }
//
// /**
// * A list of found synonyms or antonyms
// * @return results
// **/
// public List<HeadwordThesaurus> getResults() {
// return results;
// }
//
// public void setResults(List<HeadwordThesaurus> results) {
// this.results = results;
// }
//
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// Thesaurus thesaurus = (Thesaurus) o;
// return Objects.equals(this.metadata, thesaurus.metadata) &&
// Objects.equals(this.results, thesaurus.results);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(metadata, results);
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append("class Thesaurus {\n");
//
// sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
// sb.append(" results: ").append(toIndentedString(results)).append("\n");
// sb.append("}");
// return sb.toString();
// }
//
// /**
// * Convert the given object to string with each line indented by 4 spaces
// * (except the first line).
// */
// private String toIndentedString(Object o) {
// if (o == null) {
// return "null";
// }
// return o.toString().replace("\n", "\n ");
// }
// }
| import com.gatebuzz.oxfordapi.model.Thesaurus;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path; | package com.gatebuzz.oxfordapi.api;
@SuppressWarnings("unused")
public interface ThesaurusApi {
/**
* Retrieve antonyms for a given word.
* Retrieve available [antonyms](/glossary?tag=#thesaurus&expand) for a given word and language. <div id=\"antonyms\"></div>
* @param sourceLang IANA language code (required)
* @param wordId An Entry identifier. Case-sensitive. (required)
* @param appId App ID Authentication Parameter (required)
* @param appKey App Key Authentication Parameter (required)
* @return Call<Thesaurus>
*/
@GET("entries/{source_lang}/{word_id}/antonyms") | // Path: app/src/main/java/com/gatebuzz/oxfordapi/model/Thesaurus.java
// public class Thesaurus {
// @SerializedName("metadata")
// private Object metadata = null;
//
// @SerializedName("results")
// private List<HeadwordThesaurus> results = new ArrayList<HeadwordThesaurus>();
//
// public Thesaurus metadata(Object metadata) {
// this.metadata = metadata;
// return this;
// }
//
// /**
// * Additional Information provided by OUP
// * @return metadata
// **/
// public Object getMetadata() {
// return metadata;
// }
//
// public void setMetadata(Object metadata) {
// this.metadata = metadata;
// }
//
// public Thesaurus results(List<HeadwordThesaurus> results) {
// this.results = results;
// return this;
// }
//
// public Thesaurus addResultsItem(HeadwordThesaurus resultsItem) {
// this.results.add(resultsItem);
// return this;
// }
//
// /**
// * A list of found synonyms or antonyms
// * @return results
// **/
// public List<HeadwordThesaurus> getResults() {
// return results;
// }
//
// public void setResults(List<HeadwordThesaurus> results) {
// this.results = results;
// }
//
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// Thesaurus thesaurus = (Thesaurus) o;
// return Objects.equals(this.metadata, thesaurus.metadata) &&
// Objects.equals(this.results, thesaurus.results);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(metadata, results);
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append("class Thesaurus {\n");
//
// sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
// sb.append(" results: ").append(toIndentedString(results)).append("\n");
// sb.append("}");
// return sb.toString();
// }
//
// /**
// * Convert the given object to string with each line indented by 4 spaces
// * (except the first line).
// */
// private String toIndentedString(Object o) {
// if (o == null) {
// return "null";
// }
// return o.toString().replace("\n", "\n ");
// }
// }
// Path: app/src/main/java/com/gatebuzz/oxfordapi/api/ThesaurusApi.java
import com.gatebuzz.oxfordapi.model.Thesaurus;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
package com.gatebuzz.oxfordapi.api;
@SuppressWarnings("unused")
public interface ThesaurusApi {
/**
* Retrieve antonyms for a given word.
* Retrieve available [antonyms](/glossary?tag=#thesaurus&expand) for a given word and language. <div id=\"antonyms\"></div>
* @param sourceLang IANA language code (required)
* @param wordId An Entry identifier. Case-sensitive. (required)
* @param appId App ID Authentication Parameter (required)
* @param appKey App Key Authentication Parameter (required)
* @return Call<Thesaurus>
*/
@GET("entries/{source_lang}/{word_id}/antonyms") | Observable<Thesaurus> entriesSourceLangWordIdAntonymsGet( |
psh/OxfordDictionarySample | app/src/main/java/com/gatebuzz/oxfordapi/api/SearchApi.java | // Path: app/src/main/java/com/gatebuzz/oxfordapi/model/Wordlist.java
// public class Wordlist {
// @SerializedName("metadata")
// private Map<String, Object> metadata = null;
//
// @SerializedName("results")
// private List<WordlistResults> results = new ArrayList<WordlistResults>();
//
// public Wordlist metadata(Map<String, Object> metadata) {
// this.metadata = metadata;
// return this;
// }
//
// /**
// * Additional Information provided by OUP
// * @return metadata
// **/
// public Map<String, Object> getMetadata() {
// return metadata;
// }
//
// public void setMetadata(Map<String, Object> metadata) {
// this.metadata = metadata;
// }
//
// public Wordlist results(List<WordlistResults> results) {
// this.results = results;
// return this;
// }
//
// public Wordlist addResultsItem(WordlistResults resultsItem) {
// this.results.add(resultsItem);
// return this;
// }
//
// /**
// * A list of found words
// * @return results
// **/
// public List<WordlistResults> getResults() {
// return results;
// }
//
// public void setResults(List<WordlistResults> results) {
// this.results = results;
// }
//
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// Wordlist wordlist = (Wordlist) o;
// return Objects.equals(this.metadata, wordlist.metadata) &&
// Objects.equals(this.results, wordlist.results);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(metadata, results);
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append("class Wordlist {\n");
//
// sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
// sb.append(" results: ").append(toIndentedString(results)).append("\n");
// sb.append("}");
// return sb.toString();
// }
//
// /**
// * Convert the given object to string with each line indented by 4 spaces
// * (except the first line).
// */
// private String toIndentedString(Object o) {
// if (o == null) {
// return "null";
// }
// return o.toString().replace("\n", "\n ");
// }
// }
| import com.gatebuzz.oxfordapi.model.Wordlist;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
import retrofit2.http.Query; | package com.gatebuzz.oxfordapi.api;
@SuppressWarnings("unused")
public interface SearchApi {
/**
* Find results for search query.
* Retrieve available results for a search query and language. <div id=\"search\"></div>
* @param sourceLang IANA language code (required)
* @param appId App ID Authentication Parameter (required)
* @param appKey App Key Authentication Parameter (required)
* @param q Search string. (optional, default to eye)
* @param prefix Set prefix to true if you'd like to get results only starting with search string. (optional, default to false)
* @param regions Filter words with specific region(s) E.g., regions=us. For now gb, us are available for en language. (optional)
* @param limit Limit the number of results per response. Default and maximum limit is 5000. (optional)
* @param offset Offset the start number of the result. (optional)
* @return Call<Wordlist>
*/
@GET("search/{source_lang}") | // Path: app/src/main/java/com/gatebuzz/oxfordapi/model/Wordlist.java
// public class Wordlist {
// @SerializedName("metadata")
// private Map<String, Object> metadata = null;
//
// @SerializedName("results")
// private List<WordlistResults> results = new ArrayList<WordlistResults>();
//
// public Wordlist metadata(Map<String, Object> metadata) {
// this.metadata = metadata;
// return this;
// }
//
// /**
// * Additional Information provided by OUP
// * @return metadata
// **/
// public Map<String, Object> getMetadata() {
// return metadata;
// }
//
// public void setMetadata(Map<String, Object> metadata) {
// this.metadata = metadata;
// }
//
// public Wordlist results(List<WordlistResults> results) {
// this.results = results;
// return this;
// }
//
// public Wordlist addResultsItem(WordlistResults resultsItem) {
// this.results.add(resultsItem);
// return this;
// }
//
// /**
// * A list of found words
// * @return results
// **/
// public List<WordlistResults> getResults() {
// return results;
// }
//
// public void setResults(List<WordlistResults> results) {
// this.results = results;
// }
//
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// Wordlist wordlist = (Wordlist) o;
// return Objects.equals(this.metadata, wordlist.metadata) &&
// Objects.equals(this.results, wordlist.results);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(metadata, results);
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append("class Wordlist {\n");
//
// sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
// sb.append(" results: ").append(toIndentedString(results)).append("\n");
// sb.append("}");
// return sb.toString();
// }
//
// /**
// * Convert the given object to string with each line indented by 4 spaces
// * (except the first line).
// */
// private String toIndentedString(Object o) {
// if (o == null) {
// return "null";
// }
// return o.toString().replace("\n", "\n ");
// }
// }
// Path: app/src/main/java/com/gatebuzz/oxfordapi/api/SearchApi.java
import com.gatebuzz.oxfordapi.model.Wordlist;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
import retrofit2.http.Query;
package com.gatebuzz.oxfordapi.api;
@SuppressWarnings("unused")
public interface SearchApi {
/**
* Find results for search query.
* Retrieve available results for a search query and language. <div id=\"search\"></div>
* @param sourceLang IANA language code (required)
* @param appId App ID Authentication Parameter (required)
* @param appKey App Key Authentication Parameter (required)
* @param q Search string. (optional, default to eye)
* @param prefix Set prefix to true if you'd like to get results only starting with search string. (optional, default to false)
* @param regions Filter words with specific region(s) E.g., regions=us. For now gb, us are available for en language. (optional)
* @param limit Limit the number of results per response. Default and maximum limit is 5000. (optional)
* @param offset Offset the start number of the result. (optional)
* @return Call<Wordlist>
*/
@GET("search/{source_lang}") | Observable<Wordlist> searchSourceLangGet( |
psh/OxfordDictionarySample | app/src/main/java/com/gatebuzz/oxfordapi/api/WordlistApi.java | // Path: app/src/main/java/com/gatebuzz/oxfordapi/model/Wordlist.java
// public class Wordlist {
// @SerializedName("metadata")
// private Map<String, Object> metadata = null;
//
// @SerializedName("results")
// private List<WordlistResults> results = new ArrayList<WordlistResults>();
//
// public Wordlist metadata(Map<String, Object> metadata) {
// this.metadata = metadata;
// return this;
// }
//
// /**
// * Additional Information provided by OUP
// * @return metadata
// **/
// public Map<String, Object> getMetadata() {
// return metadata;
// }
//
// public void setMetadata(Map<String, Object> metadata) {
// this.metadata = metadata;
// }
//
// public Wordlist results(List<WordlistResults> results) {
// this.results = results;
// return this;
// }
//
// public Wordlist addResultsItem(WordlistResults resultsItem) {
// this.results.add(resultsItem);
// return this;
// }
//
// /**
// * A list of found words
// * @return results
// **/
// public List<WordlistResults> getResults() {
// return results;
// }
//
// public void setResults(List<WordlistResults> results) {
// this.results = results;
// }
//
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// Wordlist wordlist = (Wordlist) o;
// return Objects.equals(this.metadata, wordlist.metadata) &&
// Objects.equals(this.results, wordlist.results);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(metadata, results);
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append("class Wordlist {\n");
//
// sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
// sb.append(" results: ").append(toIndentedString(results)).append("\n");
// sb.append("}");
// return sb.toString();
// }
//
// /**
// * Convert the given object to string with each line indented by 4 spaces
// * (except the first line).
// */
// private String toIndentedString(Object o) {
// if (o == null) {
// return "null";
// }
// return o.toString().replace("\n", "\n ");
// }
// }
| import com.gatebuzz.oxfordapi.model.Wordlist;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
import retrofit2.http.Query; | package com.gatebuzz.oxfordapi.api;
@SuppressWarnings("unused")
public interface WordlistApi {
/**
* Retrieve list of words for category with advanced options.
* Advanced options for retrieving [wordlist](/glossary?tag=#wordlist&expand) - exclude filter, filter by word length or match by substring (prefix). <div id=\"wordlist_advanced\"></div>
* @param sourceLang IANA language code (required)
* @param filtersAdvanced Semicolon separated list of wordlist parameters, presented as value pairs: LexicalCategory, domains, regions, registers. Parameters can take comma separated list of values. E.g., lexicalCategory=noun,adjective;domains=sport. Number of values limited to 5. (required)
* @param appId App ID Authentication Parameter (required)
* @param appKey App Key Authentication Parameter (required)
* @param exclude Semicolon separated list of parameters-value pairs (same as filters). Excludes headwords that have any senses in specified exclusion attributes (lexical categories, domains, etc.) from results. (optional)
* @param excludeSenses Semicolon separated list of parameters-value pairs (same as filters). Excludes those senses of a particular headword that match specified exclusion attributes (lexical categories, domains, etc.) from results but includes the headword if it has other permitted senses. (optional)
* @param excludePrimeSenses Semicolon separated list of parameters-value pairs (same as filters). Excludes a headword only if the primary sense matches the specified exclusion attributes (registers, domains only). (optional)
* @param wordLength Parameter to speficy the minimum (>), exact or maximum (<) length of the words required. E.g., >5 - more than 5 chars; <4 - less than 4 chars; >5<10 - from 5 to 10 chars; 3 - exactly 3 chars. (optional, default to >5,<10)
* @param prefix Filter words that start with prefix parameter (optional, default to goal)
* @param exact If exact=true wordlist returns a list of entries that exactly matches the search string. Otherwise wordlist lists entries that start with prefix string. (optional, default to false)
* @param limit Limit the number of results per response. Default and maximum limit is 5000. (optional)
* @param offset Offset the start number of the result. (optional)
* @return Call<Wordlist>
*/
@GET("wordlist/{source_lang}/{filters_advanced}") | // Path: app/src/main/java/com/gatebuzz/oxfordapi/model/Wordlist.java
// public class Wordlist {
// @SerializedName("metadata")
// private Map<String, Object> metadata = null;
//
// @SerializedName("results")
// private List<WordlistResults> results = new ArrayList<WordlistResults>();
//
// public Wordlist metadata(Map<String, Object> metadata) {
// this.metadata = metadata;
// return this;
// }
//
// /**
// * Additional Information provided by OUP
// * @return metadata
// **/
// public Map<String, Object> getMetadata() {
// return metadata;
// }
//
// public void setMetadata(Map<String, Object> metadata) {
// this.metadata = metadata;
// }
//
// public Wordlist results(List<WordlistResults> results) {
// this.results = results;
// return this;
// }
//
// public Wordlist addResultsItem(WordlistResults resultsItem) {
// this.results.add(resultsItem);
// return this;
// }
//
// /**
// * A list of found words
// * @return results
// **/
// public List<WordlistResults> getResults() {
// return results;
// }
//
// public void setResults(List<WordlistResults> results) {
// this.results = results;
// }
//
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// Wordlist wordlist = (Wordlist) o;
// return Objects.equals(this.metadata, wordlist.metadata) &&
// Objects.equals(this.results, wordlist.results);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(metadata, results);
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append("class Wordlist {\n");
//
// sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
// sb.append(" results: ").append(toIndentedString(results)).append("\n");
// sb.append("}");
// return sb.toString();
// }
//
// /**
// * Convert the given object to string with each line indented by 4 spaces
// * (except the first line).
// */
// private String toIndentedString(Object o) {
// if (o == null) {
// return "null";
// }
// return o.toString().replace("\n", "\n ");
// }
// }
// Path: app/src/main/java/com/gatebuzz/oxfordapi/api/WordlistApi.java
import com.gatebuzz.oxfordapi.model.Wordlist;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Path;
import retrofit2.http.Query;
package com.gatebuzz.oxfordapi.api;
@SuppressWarnings("unused")
public interface WordlistApi {
/**
* Retrieve list of words for category with advanced options.
* Advanced options for retrieving [wordlist](/glossary?tag=#wordlist&expand) - exclude filter, filter by word length or match by substring (prefix). <div id=\"wordlist_advanced\"></div>
* @param sourceLang IANA language code (required)
* @param filtersAdvanced Semicolon separated list of wordlist parameters, presented as value pairs: LexicalCategory, domains, regions, registers. Parameters can take comma separated list of values. E.g., lexicalCategory=noun,adjective;domains=sport. Number of values limited to 5. (required)
* @param appId App ID Authentication Parameter (required)
* @param appKey App Key Authentication Parameter (required)
* @param exclude Semicolon separated list of parameters-value pairs (same as filters). Excludes headwords that have any senses in specified exclusion attributes (lexical categories, domains, etc.) from results. (optional)
* @param excludeSenses Semicolon separated list of parameters-value pairs (same as filters). Excludes those senses of a particular headword that match specified exclusion attributes (lexical categories, domains, etc.) from results but includes the headword if it has other permitted senses. (optional)
* @param excludePrimeSenses Semicolon separated list of parameters-value pairs (same as filters). Excludes a headword only if the primary sense matches the specified exclusion attributes (registers, domains only). (optional)
* @param wordLength Parameter to speficy the minimum (>), exact or maximum (<) length of the words required. E.g., >5 - more than 5 chars; <4 - less than 4 chars; >5<10 - from 5 to 10 chars; 3 - exactly 3 chars. (optional, default to >5,<10)
* @param prefix Filter words that start with prefix parameter (optional, default to goal)
* @param exact If exact=true wordlist returns a list of entries that exactly matches the search string. Otherwise wordlist lists entries that start with prefix string. (optional, default to false)
* @param limit Limit the number of results per response. Default and maximum limit is 5000. (optional)
* @param offset Offset the start number of the result. (optional)
* @return Call<Wordlist>
*/
@GET("wordlist/{source_lang}/{filters_advanced}") | Observable<Wordlist> wordlistSourceLangFiltersAdvancedGet( |
xwang1024/SIF-Resource-Explorer | src/main/java/me/xwang1024/sifResExplorer/presentation/DataImportDialog.java | // Path: src/main/java/me/xwang1024/sifResExplorer/presentation/builder/SIFStage.java
// public class SIFStage {
// private boolean isBuild = false;
// private Stage stage;
// private AbsStageBuilder builder;
//
// public Stage getStage() {
// return stage;
// }
//
// public void setStage(Stage stage) {
// this.stage = stage;
// }
//
// public AbsStageBuilder getBuilder() {
// return builder;
// }
//
// public void setBuilder(AbsStageBuilder builder) {
// this.builder = builder;
// }
//
// public void show() throws Exception {
// if (builder != null && !isBuild) {
// builder.build();
// }
// stage.show();
// }
//
// public void hide() {
// stage.hide();
// }
//
// public void close() {
// stage.close();
// }
//
// public SIFStage() {
// // TODO Auto-generated constructor stub
// }
//
// public SIFStage(Stage stage, AbsStageBuilder builder) {
// super();
// this.stage = stage;
// this.builder = builder;
// }
// }
| import java.io.IOException;
import me.xwang1024.sifResExplorer.presentation.builder.SIFStage;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.stage.Modality;
import javafx.stage.Stage;
| package me.xwang1024.sifResExplorer.presentation;
public class DataImportDialog {
private TextField pathField;
private Button verifyBtn;
private Label verifyLabel;
private CheckBox databaseBox;
private CheckBox imageBox;
private CheckBox defaultBox;
private Button continueBtn;
public DataImportDialog(final Stage stg) throws IOException {
final Stage stage = new Stage();
stage.initModality(Modality.APPLICATION_MODAL);
stage.initOwner(stg);
stage.setTitle("Select data source...");
Parent root = FXMLLoader.load(this.getClass().getClassLoader()
.getResource("dataImport.fxml"));
initElements(root);
initListener(root);
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
| // Path: src/main/java/me/xwang1024/sifResExplorer/presentation/builder/SIFStage.java
// public class SIFStage {
// private boolean isBuild = false;
// private Stage stage;
// private AbsStageBuilder builder;
//
// public Stage getStage() {
// return stage;
// }
//
// public void setStage(Stage stage) {
// this.stage = stage;
// }
//
// public AbsStageBuilder getBuilder() {
// return builder;
// }
//
// public void setBuilder(AbsStageBuilder builder) {
// this.builder = builder;
// }
//
// public void show() throws Exception {
// if (builder != null && !isBuild) {
// builder.build();
// }
// stage.show();
// }
//
// public void hide() {
// stage.hide();
// }
//
// public void close() {
// stage.close();
// }
//
// public SIFStage() {
// // TODO Auto-generated constructor stub
// }
//
// public SIFStage(Stage stage, AbsStageBuilder builder) {
// super();
// this.stage = stage;
// this.builder = builder;
// }
// }
// Path: src/main/java/me/xwang1024/sifResExplorer/presentation/DataImportDialog.java
import java.io.IOException;
import me.xwang1024.sifResExplorer.presentation.builder.SIFStage;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.stage.Modality;
import javafx.stage.Stage;
package me.xwang1024.sifResExplorer.presentation;
public class DataImportDialog {
private TextField pathField;
private Button verifyBtn;
private Label verifyLabel;
private CheckBox databaseBox;
private CheckBox imageBox;
private CheckBox defaultBox;
private Button continueBtn;
public DataImportDialog(final Stage stg) throws IOException {
final Stage stage = new Stage();
stage.initModality(Modality.APPLICATION_MODAL);
stage.initOwner(stg);
stage.setTitle("Select data source...");
Parent root = FXMLLoader.load(this.getClass().getClassLoader()
.getResource("dataImport.fxml"));
initElements(root);
initListener(root);
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
| SIFStage importStage = new SIFStage(stage, null);
|
xwang1024/SIF-Resource-Explorer | src/main/java/me/xwang1024/sifResExplorer/presentation/AssetPreviewStage.java | // Path: src/main/java/me/xwang1024/sifResExplorer/presentation/builder/SIFStage.java
// public class SIFStage {
// private boolean isBuild = false;
// private Stage stage;
// private AbsStageBuilder builder;
//
// public Stage getStage() {
// return stage;
// }
//
// public void setStage(Stage stage) {
// this.stage = stage;
// }
//
// public AbsStageBuilder getBuilder() {
// return builder;
// }
//
// public void setBuilder(AbsStageBuilder builder) {
// this.builder = builder;
// }
//
// public void show() throws Exception {
// if (builder != null && !isBuild) {
// builder.build();
// }
// stage.show();
// }
//
// public void hide() {
// stage.hide();
// }
//
// public void close() {
// stage.close();
// }
//
// public SIFStage() {
// // TODO Auto-generated constructor stub
// }
//
// public SIFStage(Stage stage, AbsStageBuilder builder) {
// super();
// this.stage = stage;
// this.builder = builder;
// }
// }
//
// Path: src/main/java/me/xwang1024/sifResExplorer/presentation/builder/impl/AssetPreviewStageBuilder.java
// public class AssetPreviewStageBuilder extends AbsStageBuilder {
// private ImageService imageService = new ImageService();
// private ScrollPane scrollPane;
// private StackPane nodeContainer;
// private ImageView imageView;
//
// private String imagPath;
//
// public AssetPreviewStageBuilder(FXMLLoader root) throws Exception {
// super(root);
// }
//
// public String getImagPath() {
// return imagPath;
// }
//
// public void setImagPath(String imagPath) {
// this.imagPath = imagPath;
// }
//
// private ImageView getImageView() throws IOException {
// BufferedImage bufImage = imageService.getImage(imagPath);
// WritableImage image = SwingFXUtils.toFXImage(bufImage, null);
// ImageView view = new ImageView(image);
// view.setFitWidth(bufImage.getWidth());
// view.setFitHeight(bufImage.getHeight());
// return view;
// }
//
// private void setNewImageView(ImageView newNode) {
// Pane parent = this.imageView != null ? (Pane) this.imageView.getParent() : null;
// if (parent != null) {
// parent.getChildren().remove(this.imageView);
// parent.getChildren().add(newNode);
// }
// this.imageView = newNode;
//
// imageView.boundsInParentProperty().addListener(new ChangeListener<Bounds>() {
// @Override
// public void changed(ObservableValue<? extends Bounds> observableValue,
// Bounds oldBounds, Bounds newBounds) {
// nodeContainer.setPrefSize(
// Math.max(newBounds.getMaxX(), scrollPane.getViewportBounds().getWidth()),
// Math.max(newBounds.getMaxY(), scrollPane.getViewportBounds().getHeight()));
// }
// });
// }
//
// private void initElements() throws IOException {
// scrollPane = (ScrollPane) ((Parent)loader.getRoot()).lookup("#scrollPane");
// nodeContainer = new StackPane();
// imageView = getImageView();
//
// }
//
// private void initScrollPane() throws IOException {
// nodeContainer.setStyle("-fx-background-color: #333;");
// nodeContainer.getChildren().add(imageView);
// scrollPane.setContent(nodeContainer);
// scrollPane.viewportBoundsProperty().addListener(new ChangeListener<Bounds>() {
// @Override
// public void changed(ObservableValue<? extends Bounds> observableValue,
// Bounds oldBounds, Bounds newBounds) {
// nodeContainer.setPrefSize(
// Math.max(imageView.getBoundsInParent().getMaxX(), newBounds.getWidth()),
// Math.max(imageView.getBoundsInParent().getMaxY(), newBounds.getHeight()));
// }
// });
// setNewImageView(getImageView());
// }
//
//
//
// @Override
// public void build() throws IOException {
// initElements();
// initScrollPane();
// }
//
//
// }
| import java.io.File;
import java.io.IOException;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;
import me.xwang1024.sifResExplorer.presentation.builder.SIFStage;
import me.xwang1024.sifResExplorer.presentation.builder.impl.AssetPreviewStageBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
| package me.xwang1024.sifResExplorer.presentation;
public class AssetPreviewStage {
private static final Logger logger = LoggerFactory.getLogger(MainStage.class);
public AssetPreviewStage(final Stage father, final String imagPath) throws Exception {
final Stage stage = new Stage();
stage.initModality(Modality.NONE);
stage.initOwner(father);
stage.setTitle("Asset Preview: " + new File(imagPath).getName());
FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getClassLoader()
.getResource("assetPreview.fxml"));
Parent root = fxmlLoader.load();
Scene scene = new Scene(root);
stage.setScene(scene);
| // Path: src/main/java/me/xwang1024/sifResExplorer/presentation/builder/SIFStage.java
// public class SIFStage {
// private boolean isBuild = false;
// private Stage stage;
// private AbsStageBuilder builder;
//
// public Stage getStage() {
// return stage;
// }
//
// public void setStage(Stage stage) {
// this.stage = stage;
// }
//
// public AbsStageBuilder getBuilder() {
// return builder;
// }
//
// public void setBuilder(AbsStageBuilder builder) {
// this.builder = builder;
// }
//
// public void show() throws Exception {
// if (builder != null && !isBuild) {
// builder.build();
// }
// stage.show();
// }
//
// public void hide() {
// stage.hide();
// }
//
// public void close() {
// stage.close();
// }
//
// public SIFStage() {
// // TODO Auto-generated constructor stub
// }
//
// public SIFStage(Stage stage, AbsStageBuilder builder) {
// super();
// this.stage = stage;
// this.builder = builder;
// }
// }
//
// Path: src/main/java/me/xwang1024/sifResExplorer/presentation/builder/impl/AssetPreviewStageBuilder.java
// public class AssetPreviewStageBuilder extends AbsStageBuilder {
// private ImageService imageService = new ImageService();
// private ScrollPane scrollPane;
// private StackPane nodeContainer;
// private ImageView imageView;
//
// private String imagPath;
//
// public AssetPreviewStageBuilder(FXMLLoader root) throws Exception {
// super(root);
// }
//
// public String getImagPath() {
// return imagPath;
// }
//
// public void setImagPath(String imagPath) {
// this.imagPath = imagPath;
// }
//
// private ImageView getImageView() throws IOException {
// BufferedImage bufImage = imageService.getImage(imagPath);
// WritableImage image = SwingFXUtils.toFXImage(bufImage, null);
// ImageView view = new ImageView(image);
// view.setFitWidth(bufImage.getWidth());
// view.setFitHeight(bufImage.getHeight());
// return view;
// }
//
// private void setNewImageView(ImageView newNode) {
// Pane parent = this.imageView != null ? (Pane) this.imageView.getParent() : null;
// if (parent != null) {
// parent.getChildren().remove(this.imageView);
// parent.getChildren().add(newNode);
// }
// this.imageView = newNode;
//
// imageView.boundsInParentProperty().addListener(new ChangeListener<Bounds>() {
// @Override
// public void changed(ObservableValue<? extends Bounds> observableValue,
// Bounds oldBounds, Bounds newBounds) {
// nodeContainer.setPrefSize(
// Math.max(newBounds.getMaxX(), scrollPane.getViewportBounds().getWidth()),
// Math.max(newBounds.getMaxY(), scrollPane.getViewportBounds().getHeight()));
// }
// });
// }
//
// private void initElements() throws IOException {
// scrollPane = (ScrollPane) ((Parent)loader.getRoot()).lookup("#scrollPane");
// nodeContainer = new StackPane();
// imageView = getImageView();
//
// }
//
// private void initScrollPane() throws IOException {
// nodeContainer.setStyle("-fx-background-color: #333;");
// nodeContainer.getChildren().add(imageView);
// scrollPane.setContent(nodeContainer);
// scrollPane.viewportBoundsProperty().addListener(new ChangeListener<Bounds>() {
// @Override
// public void changed(ObservableValue<? extends Bounds> observableValue,
// Bounds oldBounds, Bounds newBounds) {
// nodeContainer.setPrefSize(
// Math.max(imageView.getBoundsInParent().getMaxX(), newBounds.getWidth()),
// Math.max(imageView.getBoundsInParent().getMaxY(), newBounds.getHeight()));
// }
// });
// setNewImageView(getImageView());
// }
//
//
//
// @Override
// public void build() throws IOException {
// initElements();
// initScrollPane();
// }
//
//
// }
// Path: src/main/java/me/xwang1024/sifResExplorer/presentation/AssetPreviewStage.java
import java.io.File;
import java.io.IOException;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;
import me.xwang1024.sifResExplorer.presentation.builder.SIFStage;
import me.xwang1024.sifResExplorer.presentation.builder.impl.AssetPreviewStageBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package me.xwang1024.sifResExplorer.presentation;
public class AssetPreviewStage {
private static final Logger logger = LoggerFactory.getLogger(MainStage.class);
public AssetPreviewStage(final Stage father, final String imagPath) throws Exception {
final Stage stage = new Stage();
stage.initModality(Modality.NONE);
stage.initOwner(father);
stage.setTitle("Asset Preview: " + new File(imagPath).getName());
FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getClassLoader()
.getResource("assetPreview.fxml"));
Parent root = fxmlLoader.load();
Scene scene = new Scene(root);
stage.setScene(scene);
| AssetPreviewStageBuilder builder = new AssetPreviewStageBuilder(fxmlLoader);
|
xwang1024/SIF-Resource-Explorer | src/main/java/me/xwang1024/sifResExplorer/presentation/AssetPreviewStage.java | // Path: src/main/java/me/xwang1024/sifResExplorer/presentation/builder/SIFStage.java
// public class SIFStage {
// private boolean isBuild = false;
// private Stage stage;
// private AbsStageBuilder builder;
//
// public Stage getStage() {
// return stage;
// }
//
// public void setStage(Stage stage) {
// this.stage = stage;
// }
//
// public AbsStageBuilder getBuilder() {
// return builder;
// }
//
// public void setBuilder(AbsStageBuilder builder) {
// this.builder = builder;
// }
//
// public void show() throws Exception {
// if (builder != null && !isBuild) {
// builder.build();
// }
// stage.show();
// }
//
// public void hide() {
// stage.hide();
// }
//
// public void close() {
// stage.close();
// }
//
// public SIFStage() {
// // TODO Auto-generated constructor stub
// }
//
// public SIFStage(Stage stage, AbsStageBuilder builder) {
// super();
// this.stage = stage;
// this.builder = builder;
// }
// }
//
// Path: src/main/java/me/xwang1024/sifResExplorer/presentation/builder/impl/AssetPreviewStageBuilder.java
// public class AssetPreviewStageBuilder extends AbsStageBuilder {
// private ImageService imageService = new ImageService();
// private ScrollPane scrollPane;
// private StackPane nodeContainer;
// private ImageView imageView;
//
// private String imagPath;
//
// public AssetPreviewStageBuilder(FXMLLoader root) throws Exception {
// super(root);
// }
//
// public String getImagPath() {
// return imagPath;
// }
//
// public void setImagPath(String imagPath) {
// this.imagPath = imagPath;
// }
//
// private ImageView getImageView() throws IOException {
// BufferedImage bufImage = imageService.getImage(imagPath);
// WritableImage image = SwingFXUtils.toFXImage(bufImage, null);
// ImageView view = new ImageView(image);
// view.setFitWidth(bufImage.getWidth());
// view.setFitHeight(bufImage.getHeight());
// return view;
// }
//
// private void setNewImageView(ImageView newNode) {
// Pane parent = this.imageView != null ? (Pane) this.imageView.getParent() : null;
// if (parent != null) {
// parent.getChildren().remove(this.imageView);
// parent.getChildren().add(newNode);
// }
// this.imageView = newNode;
//
// imageView.boundsInParentProperty().addListener(new ChangeListener<Bounds>() {
// @Override
// public void changed(ObservableValue<? extends Bounds> observableValue,
// Bounds oldBounds, Bounds newBounds) {
// nodeContainer.setPrefSize(
// Math.max(newBounds.getMaxX(), scrollPane.getViewportBounds().getWidth()),
// Math.max(newBounds.getMaxY(), scrollPane.getViewportBounds().getHeight()));
// }
// });
// }
//
// private void initElements() throws IOException {
// scrollPane = (ScrollPane) ((Parent)loader.getRoot()).lookup("#scrollPane");
// nodeContainer = new StackPane();
// imageView = getImageView();
//
// }
//
// private void initScrollPane() throws IOException {
// nodeContainer.setStyle("-fx-background-color: #333;");
// nodeContainer.getChildren().add(imageView);
// scrollPane.setContent(nodeContainer);
// scrollPane.viewportBoundsProperty().addListener(new ChangeListener<Bounds>() {
// @Override
// public void changed(ObservableValue<? extends Bounds> observableValue,
// Bounds oldBounds, Bounds newBounds) {
// nodeContainer.setPrefSize(
// Math.max(imageView.getBoundsInParent().getMaxX(), newBounds.getWidth()),
// Math.max(imageView.getBoundsInParent().getMaxY(), newBounds.getHeight()));
// }
// });
// setNewImageView(getImageView());
// }
//
//
//
// @Override
// public void build() throws IOException {
// initElements();
// initScrollPane();
// }
//
//
// }
| import java.io.File;
import java.io.IOException;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;
import me.xwang1024.sifResExplorer.presentation.builder.SIFStage;
import me.xwang1024.sifResExplorer.presentation.builder.impl.AssetPreviewStageBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
| package me.xwang1024.sifResExplorer.presentation;
public class AssetPreviewStage {
private static final Logger logger = LoggerFactory.getLogger(MainStage.class);
public AssetPreviewStage(final Stage father, final String imagPath) throws Exception {
final Stage stage = new Stage();
stage.initModality(Modality.NONE);
stage.initOwner(father);
stage.setTitle("Asset Preview: " + new File(imagPath).getName());
FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getClassLoader()
.getResource("assetPreview.fxml"));
Parent root = fxmlLoader.load();
Scene scene = new Scene(root);
stage.setScene(scene);
AssetPreviewStageBuilder builder = new AssetPreviewStageBuilder(fxmlLoader);
builder.setImagPath(imagPath);
| // Path: src/main/java/me/xwang1024/sifResExplorer/presentation/builder/SIFStage.java
// public class SIFStage {
// private boolean isBuild = false;
// private Stage stage;
// private AbsStageBuilder builder;
//
// public Stage getStage() {
// return stage;
// }
//
// public void setStage(Stage stage) {
// this.stage = stage;
// }
//
// public AbsStageBuilder getBuilder() {
// return builder;
// }
//
// public void setBuilder(AbsStageBuilder builder) {
// this.builder = builder;
// }
//
// public void show() throws Exception {
// if (builder != null && !isBuild) {
// builder.build();
// }
// stage.show();
// }
//
// public void hide() {
// stage.hide();
// }
//
// public void close() {
// stage.close();
// }
//
// public SIFStage() {
// // TODO Auto-generated constructor stub
// }
//
// public SIFStage(Stage stage, AbsStageBuilder builder) {
// super();
// this.stage = stage;
// this.builder = builder;
// }
// }
//
// Path: src/main/java/me/xwang1024/sifResExplorer/presentation/builder/impl/AssetPreviewStageBuilder.java
// public class AssetPreviewStageBuilder extends AbsStageBuilder {
// private ImageService imageService = new ImageService();
// private ScrollPane scrollPane;
// private StackPane nodeContainer;
// private ImageView imageView;
//
// private String imagPath;
//
// public AssetPreviewStageBuilder(FXMLLoader root) throws Exception {
// super(root);
// }
//
// public String getImagPath() {
// return imagPath;
// }
//
// public void setImagPath(String imagPath) {
// this.imagPath = imagPath;
// }
//
// private ImageView getImageView() throws IOException {
// BufferedImage bufImage = imageService.getImage(imagPath);
// WritableImage image = SwingFXUtils.toFXImage(bufImage, null);
// ImageView view = new ImageView(image);
// view.setFitWidth(bufImage.getWidth());
// view.setFitHeight(bufImage.getHeight());
// return view;
// }
//
// private void setNewImageView(ImageView newNode) {
// Pane parent = this.imageView != null ? (Pane) this.imageView.getParent() : null;
// if (parent != null) {
// parent.getChildren().remove(this.imageView);
// parent.getChildren().add(newNode);
// }
// this.imageView = newNode;
//
// imageView.boundsInParentProperty().addListener(new ChangeListener<Bounds>() {
// @Override
// public void changed(ObservableValue<? extends Bounds> observableValue,
// Bounds oldBounds, Bounds newBounds) {
// nodeContainer.setPrefSize(
// Math.max(newBounds.getMaxX(), scrollPane.getViewportBounds().getWidth()),
// Math.max(newBounds.getMaxY(), scrollPane.getViewportBounds().getHeight()));
// }
// });
// }
//
// private void initElements() throws IOException {
// scrollPane = (ScrollPane) ((Parent)loader.getRoot()).lookup("#scrollPane");
// nodeContainer = new StackPane();
// imageView = getImageView();
//
// }
//
// private void initScrollPane() throws IOException {
// nodeContainer.setStyle("-fx-background-color: #333;");
// nodeContainer.getChildren().add(imageView);
// scrollPane.setContent(nodeContainer);
// scrollPane.viewportBoundsProperty().addListener(new ChangeListener<Bounds>() {
// @Override
// public void changed(ObservableValue<? extends Bounds> observableValue,
// Bounds oldBounds, Bounds newBounds) {
// nodeContainer.setPrefSize(
// Math.max(imageView.getBoundsInParent().getMaxX(), newBounds.getWidth()),
// Math.max(imageView.getBoundsInParent().getMaxY(), newBounds.getHeight()));
// }
// });
// setNewImageView(getImageView());
// }
//
//
//
// @Override
// public void build() throws IOException {
// initElements();
// initScrollPane();
// }
//
//
// }
// Path: src/main/java/me/xwang1024/sifResExplorer/presentation/AssetPreviewStage.java
import java.io.File;
import java.io.IOException;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;
import me.xwang1024.sifResExplorer.presentation.builder.SIFStage;
import me.xwang1024.sifResExplorer.presentation.builder.impl.AssetPreviewStageBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package me.xwang1024.sifResExplorer.presentation;
public class AssetPreviewStage {
private static final Logger logger = LoggerFactory.getLogger(MainStage.class);
public AssetPreviewStage(final Stage father, final String imagPath) throws Exception {
final Stage stage = new Stage();
stage.initModality(Modality.NONE);
stage.initOwner(father);
stage.setTitle("Asset Preview: " + new File(imagPath).getName());
FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getClassLoader()
.getResource("assetPreview.fxml"));
Parent root = fxmlLoader.load();
Scene scene = new Scene(root);
stage.setScene(scene);
AssetPreviewStageBuilder builder = new AssetPreviewStageBuilder(fxmlLoader);
builder.setImagPath(imagPath);
| SIFStage showStage = new SIFStage(stage, builder);
|
xwang1024/SIF-Resource-Explorer | src/main/java/me/xwang1024/sifResExplorer/data/impl/ImagDaoImpl.java | // Path: src/main/java/me/xwang1024/sifResExplorer/config/SIFConfig.java
// public class SIFConfig {
// private static final Logger logger = LoggerFactory
// .getLogger(SIFConfig.class);
//
// public static SIFConfig instance;
// private String filePath = "sif.xml";
// private Map<String, String> conf = Collections
// .synchronizedMap(new HashMap<String, String>());
//
// public static SIFConfig getInstance() {
// if (instance == null) {
// instance = new SIFConfig();
// }
// return instance;
// }
//
// private SIFConfig() {
// }
//
// public void loadConfig() throws DocumentException {
// if(!new File(filePath).exists()) {
// logger.info("Could not find sif.xml.");
// return;
// }
// logger.info("Read config file sif.xml");
// SAXReader reader = new SAXReader();
// Document doc = reader.read(new File(filePath));
// List nodes = doc.getRootElement().elements("config");
// for (Iterator it = nodes.iterator(); it.hasNext();) {
// Element elm = (Element) it.next();
// String name = elm.attributeValue("name");
// String value = elm.attributeValue("value");
// if (name != null && value != null) {
// conf.put(name, value);
// logger.info("Read conf: {}={}", name, value);
// }
// }
// }
//
// public void saveConfig() throws IOException {
// logger.info("Save config file sif.xml");
// Document doc = DocumentHelper.createDocument();
// Element root = DocumentHelper.createElement("configuration");
// for (String name : conf.keySet()) {
// String value = "" + conf.get(name);
// Element conf = DocumentHelper.createElement("config");
// conf.addAttribute(new QName("name"), name);
// conf.addAttribute(new QName("value"), value);
// root.add(conf);
// }
// doc.setRootElement(root);
//
// OutputFormat format = OutputFormat.createPrettyPrint();
// format.setEncoding("UTF-8"); // 指定XML编码
// XMLWriter writer = new XMLWriter(new FileWriter(filePath), format);
// writer.write(doc);
// writer.close();
// }
//
// public String get(String name) {
// return conf.get(name);
// }
//
// public String set(String name, String value) {
// return conf.put(name, value);
// }
//
// public static class ConfigName {
// public static final String dbPath = "dbPath";
// public static final String assetsPath = "assetsPath";
// }
// }
//
// Path: src/main/java/me/xwang1024/sifResExplorer/config/SIFConfig.java
// public static class ConfigName {
// public static final String dbPath = "dbPath";
// public static final String assetsPath = "assetsPath";
// }
//
// Path: src/main/java/me/xwang1024/sifResExplorer/data/ImagDao.java
// public interface ImagDao {
// public BufferedImage getImage(String imagPath) throws IOException;
//
// public BufferedImage getImageWithoutSplit(String texbPath) throws IOException;
//
// public String getRefTextureFilePath(String imagPath) throws IOException;
//
// public List<String> getImagList();
//
// public List<String> getTexbList();
// }
| import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.zip.Inflater;
import javax.imageio.ImageIO;
import me.xwang1024.sifResExplorer.config.SIFConfig;
import me.xwang1024.sifResExplorer.config.SIFConfig.ConfigName;
import me.xwang1024.sifResExplorer.data.ImagDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
| BufferedImage cache = null;
for (Timg img : texture.image) {
long x1 = img.vertices[0].u;
long y1 = img.vertices[0].v;
long x2 = img.vertices[img.vertexLen - 1].u;
long y2 = img.vertices[img.vertexLen - 1].v;
BufferedImage bimg = image.getSubimage((int) x1, (int) y1, (int) (x2 - x1),
(int) (y2 - y1));
String pngPath = img.path.replaceAll("\\.imag.*$", "");
File pngFile = new File(tempDir, pngPath);
System.out.println(pngFile.getAbsolutePath());
pngFile.getParentFile().mkdirs();
try {
ImageIO.write(bimg, "png", pngFile);
} catch (IOException e) {
logger.error("{} temp file write error.", pngFile.getAbsolutePath());
e.printStackTrace();
continue;
}
if (img.path.contains(this.imagPath)) {
cache = bimg;
} else {
logger.debug("{}:{}", img.path, this.imagPath);
}
}
return cache;
}
private Texb extractTexb(String texbPath) throws IOException {
// 构造texb文件的位置
| // Path: src/main/java/me/xwang1024/sifResExplorer/config/SIFConfig.java
// public class SIFConfig {
// private static final Logger logger = LoggerFactory
// .getLogger(SIFConfig.class);
//
// public static SIFConfig instance;
// private String filePath = "sif.xml";
// private Map<String, String> conf = Collections
// .synchronizedMap(new HashMap<String, String>());
//
// public static SIFConfig getInstance() {
// if (instance == null) {
// instance = new SIFConfig();
// }
// return instance;
// }
//
// private SIFConfig() {
// }
//
// public void loadConfig() throws DocumentException {
// if(!new File(filePath).exists()) {
// logger.info("Could not find sif.xml.");
// return;
// }
// logger.info("Read config file sif.xml");
// SAXReader reader = new SAXReader();
// Document doc = reader.read(new File(filePath));
// List nodes = doc.getRootElement().elements("config");
// for (Iterator it = nodes.iterator(); it.hasNext();) {
// Element elm = (Element) it.next();
// String name = elm.attributeValue("name");
// String value = elm.attributeValue("value");
// if (name != null && value != null) {
// conf.put(name, value);
// logger.info("Read conf: {}={}", name, value);
// }
// }
// }
//
// public void saveConfig() throws IOException {
// logger.info("Save config file sif.xml");
// Document doc = DocumentHelper.createDocument();
// Element root = DocumentHelper.createElement("configuration");
// for (String name : conf.keySet()) {
// String value = "" + conf.get(name);
// Element conf = DocumentHelper.createElement("config");
// conf.addAttribute(new QName("name"), name);
// conf.addAttribute(new QName("value"), value);
// root.add(conf);
// }
// doc.setRootElement(root);
//
// OutputFormat format = OutputFormat.createPrettyPrint();
// format.setEncoding("UTF-8"); // 指定XML编码
// XMLWriter writer = new XMLWriter(new FileWriter(filePath), format);
// writer.write(doc);
// writer.close();
// }
//
// public String get(String name) {
// return conf.get(name);
// }
//
// public String set(String name, String value) {
// return conf.put(name, value);
// }
//
// public static class ConfigName {
// public static final String dbPath = "dbPath";
// public static final String assetsPath = "assetsPath";
// }
// }
//
// Path: src/main/java/me/xwang1024/sifResExplorer/config/SIFConfig.java
// public static class ConfigName {
// public static final String dbPath = "dbPath";
// public static final String assetsPath = "assetsPath";
// }
//
// Path: src/main/java/me/xwang1024/sifResExplorer/data/ImagDao.java
// public interface ImagDao {
// public BufferedImage getImage(String imagPath) throws IOException;
//
// public BufferedImage getImageWithoutSplit(String texbPath) throws IOException;
//
// public String getRefTextureFilePath(String imagPath) throws IOException;
//
// public List<String> getImagList();
//
// public List<String> getTexbList();
// }
// Path: src/main/java/me/xwang1024/sifResExplorer/data/impl/ImagDaoImpl.java
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.zip.Inflater;
import javax.imageio.ImageIO;
import me.xwang1024.sifResExplorer.config.SIFConfig;
import me.xwang1024.sifResExplorer.config.SIFConfig.ConfigName;
import me.xwang1024.sifResExplorer.data.ImagDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
BufferedImage cache = null;
for (Timg img : texture.image) {
long x1 = img.vertices[0].u;
long y1 = img.vertices[0].v;
long x2 = img.vertices[img.vertexLen - 1].u;
long y2 = img.vertices[img.vertexLen - 1].v;
BufferedImage bimg = image.getSubimage((int) x1, (int) y1, (int) (x2 - x1),
(int) (y2 - y1));
String pngPath = img.path.replaceAll("\\.imag.*$", "");
File pngFile = new File(tempDir, pngPath);
System.out.println(pngFile.getAbsolutePath());
pngFile.getParentFile().mkdirs();
try {
ImageIO.write(bimg, "png", pngFile);
} catch (IOException e) {
logger.error("{} temp file write error.", pngFile.getAbsolutePath());
e.printStackTrace();
continue;
}
if (img.path.contains(this.imagPath)) {
cache = bimg;
} else {
logger.debug("{}:{}", img.path, this.imagPath);
}
}
return cache;
}
private Texb extractTexb(String texbPath) throws IOException {
// 构造texb文件的位置
| String assetsPath = SIFConfig.getInstance().get(ConfigName.assetsPath);
|
xwang1024/SIF-Resource-Explorer | src/main/java/me/xwang1024/sifResExplorer/data/impl/ImagDaoImpl.java | // Path: src/main/java/me/xwang1024/sifResExplorer/config/SIFConfig.java
// public class SIFConfig {
// private static final Logger logger = LoggerFactory
// .getLogger(SIFConfig.class);
//
// public static SIFConfig instance;
// private String filePath = "sif.xml";
// private Map<String, String> conf = Collections
// .synchronizedMap(new HashMap<String, String>());
//
// public static SIFConfig getInstance() {
// if (instance == null) {
// instance = new SIFConfig();
// }
// return instance;
// }
//
// private SIFConfig() {
// }
//
// public void loadConfig() throws DocumentException {
// if(!new File(filePath).exists()) {
// logger.info("Could not find sif.xml.");
// return;
// }
// logger.info("Read config file sif.xml");
// SAXReader reader = new SAXReader();
// Document doc = reader.read(new File(filePath));
// List nodes = doc.getRootElement().elements("config");
// for (Iterator it = nodes.iterator(); it.hasNext();) {
// Element elm = (Element) it.next();
// String name = elm.attributeValue("name");
// String value = elm.attributeValue("value");
// if (name != null && value != null) {
// conf.put(name, value);
// logger.info("Read conf: {}={}", name, value);
// }
// }
// }
//
// public void saveConfig() throws IOException {
// logger.info("Save config file sif.xml");
// Document doc = DocumentHelper.createDocument();
// Element root = DocumentHelper.createElement("configuration");
// for (String name : conf.keySet()) {
// String value = "" + conf.get(name);
// Element conf = DocumentHelper.createElement("config");
// conf.addAttribute(new QName("name"), name);
// conf.addAttribute(new QName("value"), value);
// root.add(conf);
// }
// doc.setRootElement(root);
//
// OutputFormat format = OutputFormat.createPrettyPrint();
// format.setEncoding("UTF-8"); // 指定XML编码
// XMLWriter writer = new XMLWriter(new FileWriter(filePath), format);
// writer.write(doc);
// writer.close();
// }
//
// public String get(String name) {
// return conf.get(name);
// }
//
// public String set(String name, String value) {
// return conf.put(name, value);
// }
//
// public static class ConfigName {
// public static final String dbPath = "dbPath";
// public static final String assetsPath = "assetsPath";
// }
// }
//
// Path: src/main/java/me/xwang1024/sifResExplorer/config/SIFConfig.java
// public static class ConfigName {
// public static final String dbPath = "dbPath";
// public static final String assetsPath = "assetsPath";
// }
//
// Path: src/main/java/me/xwang1024/sifResExplorer/data/ImagDao.java
// public interface ImagDao {
// public BufferedImage getImage(String imagPath) throws IOException;
//
// public BufferedImage getImageWithoutSplit(String texbPath) throws IOException;
//
// public String getRefTextureFilePath(String imagPath) throws IOException;
//
// public List<String> getImagList();
//
// public List<String> getTexbList();
// }
| import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.zip.Inflater;
import javax.imageio.ImageIO;
import me.xwang1024.sifResExplorer.config.SIFConfig;
import me.xwang1024.sifResExplorer.config.SIFConfig.ConfigName;
import me.xwang1024.sifResExplorer.data.ImagDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
| BufferedImage cache = null;
for (Timg img : texture.image) {
long x1 = img.vertices[0].u;
long y1 = img.vertices[0].v;
long x2 = img.vertices[img.vertexLen - 1].u;
long y2 = img.vertices[img.vertexLen - 1].v;
BufferedImage bimg = image.getSubimage((int) x1, (int) y1, (int) (x2 - x1),
(int) (y2 - y1));
String pngPath = img.path.replaceAll("\\.imag.*$", "");
File pngFile = new File(tempDir, pngPath);
System.out.println(pngFile.getAbsolutePath());
pngFile.getParentFile().mkdirs();
try {
ImageIO.write(bimg, "png", pngFile);
} catch (IOException e) {
logger.error("{} temp file write error.", pngFile.getAbsolutePath());
e.printStackTrace();
continue;
}
if (img.path.contains(this.imagPath)) {
cache = bimg;
} else {
logger.debug("{}:{}", img.path, this.imagPath);
}
}
return cache;
}
private Texb extractTexb(String texbPath) throws IOException {
// 构造texb文件的位置
| // Path: src/main/java/me/xwang1024/sifResExplorer/config/SIFConfig.java
// public class SIFConfig {
// private static final Logger logger = LoggerFactory
// .getLogger(SIFConfig.class);
//
// public static SIFConfig instance;
// private String filePath = "sif.xml";
// private Map<String, String> conf = Collections
// .synchronizedMap(new HashMap<String, String>());
//
// public static SIFConfig getInstance() {
// if (instance == null) {
// instance = new SIFConfig();
// }
// return instance;
// }
//
// private SIFConfig() {
// }
//
// public void loadConfig() throws DocumentException {
// if(!new File(filePath).exists()) {
// logger.info("Could not find sif.xml.");
// return;
// }
// logger.info("Read config file sif.xml");
// SAXReader reader = new SAXReader();
// Document doc = reader.read(new File(filePath));
// List nodes = doc.getRootElement().elements("config");
// for (Iterator it = nodes.iterator(); it.hasNext();) {
// Element elm = (Element) it.next();
// String name = elm.attributeValue("name");
// String value = elm.attributeValue("value");
// if (name != null && value != null) {
// conf.put(name, value);
// logger.info("Read conf: {}={}", name, value);
// }
// }
// }
//
// public void saveConfig() throws IOException {
// logger.info("Save config file sif.xml");
// Document doc = DocumentHelper.createDocument();
// Element root = DocumentHelper.createElement("configuration");
// for (String name : conf.keySet()) {
// String value = "" + conf.get(name);
// Element conf = DocumentHelper.createElement("config");
// conf.addAttribute(new QName("name"), name);
// conf.addAttribute(new QName("value"), value);
// root.add(conf);
// }
// doc.setRootElement(root);
//
// OutputFormat format = OutputFormat.createPrettyPrint();
// format.setEncoding("UTF-8"); // 指定XML编码
// XMLWriter writer = new XMLWriter(new FileWriter(filePath), format);
// writer.write(doc);
// writer.close();
// }
//
// public String get(String name) {
// return conf.get(name);
// }
//
// public String set(String name, String value) {
// return conf.put(name, value);
// }
//
// public static class ConfigName {
// public static final String dbPath = "dbPath";
// public static final String assetsPath = "assetsPath";
// }
// }
//
// Path: src/main/java/me/xwang1024/sifResExplorer/config/SIFConfig.java
// public static class ConfigName {
// public static final String dbPath = "dbPath";
// public static final String assetsPath = "assetsPath";
// }
//
// Path: src/main/java/me/xwang1024/sifResExplorer/data/ImagDao.java
// public interface ImagDao {
// public BufferedImage getImage(String imagPath) throws IOException;
//
// public BufferedImage getImageWithoutSplit(String texbPath) throws IOException;
//
// public String getRefTextureFilePath(String imagPath) throws IOException;
//
// public List<String> getImagList();
//
// public List<String> getTexbList();
// }
// Path: src/main/java/me/xwang1024/sifResExplorer/data/impl/ImagDaoImpl.java
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.zip.Inflater;
import javax.imageio.ImageIO;
import me.xwang1024.sifResExplorer.config.SIFConfig;
import me.xwang1024.sifResExplorer.config.SIFConfig.ConfigName;
import me.xwang1024.sifResExplorer.data.ImagDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
BufferedImage cache = null;
for (Timg img : texture.image) {
long x1 = img.vertices[0].u;
long y1 = img.vertices[0].v;
long x2 = img.vertices[img.vertexLen - 1].u;
long y2 = img.vertices[img.vertexLen - 1].v;
BufferedImage bimg = image.getSubimage((int) x1, (int) y1, (int) (x2 - x1),
(int) (y2 - y1));
String pngPath = img.path.replaceAll("\\.imag.*$", "");
File pngFile = new File(tempDir, pngPath);
System.out.println(pngFile.getAbsolutePath());
pngFile.getParentFile().mkdirs();
try {
ImageIO.write(bimg, "png", pngFile);
} catch (IOException e) {
logger.error("{} temp file write error.", pngFile.getAbsolutePath());
e.printStackTrace();
continue;
}
if (img.path.contains(this.imagPath)) {
cache = bimg;
} else {
logger.debug("{}:{}", img.path, this.imagPath);
}
}
return cache;
}
private Texb extractTexb(String texbPath) throws IOException {
// 构造texb文件的位置
| String assetsPath = SIFConfig.getInstance().get(ConfigName.assetsPath);
|
simonwibberley/GramExp | src/main/java/uk/ac/susx/tag/gramexp/PegParser.java | // Path: src/main/java/uk/ac/susx/tag/gramexp/ast/Node.java
// public interface Node<T extends Node<T>> extends GraphNode<T> {
//
// /**
// * @return the index of the first character in the underlying buffer that is covered by this node
// */
// int getStartIndex();
//
// /**
// * @return the index of the character after the last one in the underlying buffer that is covered by this node
// */
// int getEndIndex();
//
// void accept(Visitor visitor);
// }
| import org.parboiled.*;
import org.parboiled.annotations.BuildParseTree;
import org.parboiled.annotations.SuppressSubnodes;
import org.parboiled.common.Tuple2;
import org.parboiled.errors.ErrorUtils;
import org.parboiled.parserunners.ReportingParseRunner;
import org.parboiled.support.ParsingResult;
import org.parboiled.support.Var;
import uk.ac.susx.tag.gramexp.ast.*;
import uk.ac.susx.tag.gramexp.ast.Node;
import java.io.BufferedReader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import static org.parboiled.support.ParseTreeUtils.printNodeTree; | package uk.ac.susx.tag.gramexp;
/**
* Created by simon on 26/05/16.
*/
@BuildParseTree
public class PegParser extends BaseParser<Object> {
public GrammarNode parse(String input) {
ReportingParseRunner runner = new ReportingParseRunner(Grammar());
| // Path: src/main/java/uk/ac/susx/tag/gramexp/ast/Node.java
// public interface Node<T extends Node<T>> extends GraphNode<T> {
//
// /**
// * @return the index of the first character in the underlying buffer that is covered by this node
// */
// int getStartIndex();
//
// /**
// * @return the index of the character after the last one in the underlying buffer that is covered by this node
// */
// int getEndIndex();
//
// void accept(Visitor visitor);
// }
// Path: src/main/java/uk/ac/susx/tag/gramexp/PegParser.java
import org.parboiled.*;
import org.parboiled.annotations.BuildParseTree;
import org.parboiled.annotations.SuppressSubnodes;
import org.parboiled.common.Tuple2;
import org.parboiled.errors.ErrorUtils;
import org.parboiled.parserunners.ReportingParseRunner;
import org.parboiled.support.ParsingResult;
import org.parboiled.support.Var;
import uk.ac.susx.tag.gramexp.ast.*;
import uk.ac.susx.tag.gramexp.ast.Node;
import java.io.BufferedReader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import static org.parboiled.support.ParseTreeUtils.printNodeTree;
package uk.ac.susx.tag.gramexp;
/**
* Created by simon on 26/05/16.
*/
@BuildParseTree
public class PegParser extends BaseParser<Object> {
public GrammarNode parse(String input) {
ReportingParseRunner runner = new ReportingParseRunner(Grammar());
| ParsingResult<Node> result = runner.run(input); |
simonwibberley/GramExp | src/main/java/uk/ac/susx/tag/gramexp/CapturingParser.java | // Path: src/main/java/uk/ac/susx/tag/gramexp/matchers/RegularExpressionMatcher.java
// public class RegularExpressionMatcher extends CustomMatcher {
//
// private final Pattern pattern;
//
// public RegularExpressionMatcher(String re) {
// super("Regexp");
// pattern = Pattern.compile(re);
// }
//
// @Override
// public boolean isSingleCharMatcher() {
// return false;
// }
//
// @Override
// public boolean canMatchEmpty() {
// return pattern.matcher("").find();
// }
//
// @Override
// public boolean isStarterChar(char c) {
// Matcher m = pattern.matcher(c+"");
// return m.find() && m.start()==0;
// }
//
// @Override
// public char getStarterChar() {
// return 0;
// }
//
// @Override
// public <V> boolean match(MatcherContext<V> context) {
//
// int cur = context.getCurrentIndex();
//
// InputBuffer buffer = context.getInputBuffer();
// String content = InputBufferUtils.collectContent(buffer);
// content = content.substring(cur);
// Matcher m = pattern.matcher(content);
//
// if(m.find()) {
//
// int start = m.start();
// if(start == 0) {
// int end = m.end();
//
// int delta = end - start;
//
// context.advanceIndex(delta);
//
// context.createNode();
// return true;
//
// } else {
// return false;
// }
// } else {
//
// return false;
// }
//
// }
// }
//
// Path: src/main/java/uk/ac/susx/tag/gramexp/matchers/StartOfLineMatcher.java
// public class StartOfLineMatcher extends CustomMatcher{
//
// public StartOfLineMatcher() {
// super("StartOfLine");
// }
//
// @Override
// public boolean isSingleCharMatcher() {
// return true;
// }
//
// @Override
// public boolean canMatchEmpty() {
// return true;
// }
//
// @Override
// public boolean isStarterChar(char c) {
// return c == '\n';
// }
//
// @Override
// public char getStarterChar() {
// return '\n';
// }
//
// @Override
// public <V> boolean match(MatcherContext<V> context) {
// int cur = context.getCurrentIndex();
// if(cur == 0) {
// context.createNode();
// return true;
// }
// InputBuffer buffer = context.getInputBuffer();
//
// if(buffer.charAt(cur-1)=='\n') {
// context.createNode();
// return true;
// }
//
// return false;
// }
// }
| import org.parboiled.BaseParser;
import org.parboiled.Rule;
import org.parboiled.annotations.SuppressSubnodes;
import uk.ac.susx.tag.gramexp.matchers.RegularExpressionMatcher;
import uk.ac.susx.tag.gramexp.matchers.StartOfLineMatcher;
import java.util.*; | public boolean matchPop(String match) {
List<Capture> captures = new ArrayList<>();
boolean result = false;
while(true) {
try {
Object val = pop();
if(val instanceof Capture) {
captures.add((Capture)val);
} else {
result = val.equals(match);
break;
}
}catch (IllegalArgumentException e){
break;
}
}
Collections.reverse(captures);
for(Capture c: captures) {
push(c);
}
return result;
}
@SuppressSubnodes
public Rule StartOfLine() {
| // Path: src/main/java/uk/ac/susx/tag/gramexp/matchers/RegularExpressionMatcher.java
// public class RegularExpressionMatcher extends CustomMatcher {
//
// private final Pattern pattern;
//
// public RegularExpressionMatcher(String re) {
// super("Regexp");
// pattern = Pattern.compile(re);
// }
//
// @Override
// public boolean isSingleCharMatcher() {
// return false;
// }
//
// @Override
// public boolean canMatchEmpty() {
// return pattern.matcher("").find();
// }
//
// @Override
// public boolean isStarterChar(char c) {
// Matcher m = pattern.matcher(c+"");
// return m.find() && m.start()==0;
// }
//
// @Override
// public char getStarterChar() {
// return 0;
// }
//
// @Override
// public <V> boolean match(MatcherContext<V> context) {
//
// int cur = context.getCurrentIndex();
//
// InputBuffer buffer = context.getInputBuffer();
// String content = InputBufferUtils.collectContent(buffer);
// content = content.substring(cur);
// Matcher m = pattern.matcher(content);
//
// if(m.find()) {
//
// int start = m.start();
// if(start == 0) {
// int end = m.end();
//
// int delta = end - start;
//
// context.advanceIndex(delta);
//
// context.createNode();
// return true;
//
// } else {
// return false;
// }
// } else {
//
// return false;
// }
//
// }
// }
//
// Path: src/main/java/uk/ac/susx/tag/gramexp/matchers/StartOfLineMatcher.java
// public class StartOfLineMatcher extends CustomMatcher{
//
// public StartOfLineMatcher() {
// super("StartOfLine");
// }
//
// @Override
// public boolean isSingleCharMatcher() {
// return true;
// }
//
// @Override
// public boolean canMatchEmpty() {
// return true;
// }
//
// @Override
// public boolean isStarterChar(char c) {
// return c == '\n';
// }
//
// @Override
// public char getStarterChar() {
// return '\n';
// }
//
// @Override
// public <V> boolean match(MatcherContext<V> context) {
// int cur = context.getCurrentIndex();
// if(cur == 0) {
// context.createNode();
// return true;
// }
// InputBuffer buffer = context.getInputBuffer();
//
// if(buffer.charAt(cur-1)=='\n') {
// context.createNode();
// return true;
// }
//
// return false;
// }
// }
// Path: src/main/java/uk/ac/susx/tag/gramexp/CapturingParser.java
import org.parboiled.BaseParser;
import org.parboiled.Rule;
import org.parboiled.annotations.SuppressSubnodes;
import uk.ac.susx.tag.gramexp.matchers.RegularExpressionMatcher;
import uk.ac.susx.tag.gramexp.matchers.StartOfLineMatcher;
import java.util.*;
public boolean matchPop(String match) {
List<Capture> captures = new ArrayList<>();
boolean result = false;
while(true) {
try {
Object val = pop();
if(val instanceof Capture) {
captures.add((Capture)val);
} else {
result = val.equals(match);
break;
}
}catch (IllegalArgumentException e){
break;
}
}
Collections.reverse(captures);
for(Capture c: captures) {
push(c);
}
return result;
}
@SuppressSubnodes
public Rule StartOfLine() {
| return new StartOfLineMatcher(); |
simonwibberley/GramExp | src/main/java/uk/ac/susx/tag/gramexp/CapturingParser.java | // Path: src/main/java/uk/ac/susx/tag/gramexp/matchers/RegularExpressionMatcher.java
// public class RegularExpressionMatcher extends CustomMatcher {
//
// private final Pattern pattern;
//
// public RegularExpressionMatcher(String re) {
// super("Regexp");
// pattern = Pattern.compile(re);
// }
//
// @Override
// public boolean isSingleCharMatcher() {
// return false;
// }
//
// @Override
// public boolean canMatchEmpty() {
// return pattern.matcher("").find();
// }
//
// @Override
// public boolean isStarterChar(char c) {
// Matcher m = pattern.matcher(c+"");
// return m.find() && m.start()==0;
// }
//
// @Override
// public char getStarterChar() {
// return 0;
// }
//
// @Override
// public <V> boolean match(MatcherContext<V> context) {
//
// int cur = context.getCurrentIndex();
//
// InputBuffer buffer = context.getInputBuffer();
// String content = InputBufferUtils.collectContent(buffer);
// content = content.substring(cur);
// Matcher m = pattern.matcher(content);
//
// if(m.find()) {
//
// int start = m.start();
// if(start == 0) {
// int end = m.end();
//
// int delta = end - start;
//
// context.advanceIndex(delta);
//
// context.createNode();
// return true;
//
// } else {
// return false;
// }
// } else {
//
// return false;
// }
//
// }
// }
//
// Path: src/main/java/uk/ac/susx/tag/gramexp/matchers/StartOfLineMatcher.java
// public class StartOfLineMatcher extends CustomMatcher{
//
// public StartOfLineMatcher() {
// super("StartOfLine");
// }
//
// @Override
// public boolean isSingleCharMatcher() {
// return true;
// }
//
// @Override
// public boolean canMatchEmpty() {
// return true;
// }
//
// @Override
// public boolean isStarterChar(char c) {
// return c == '\n';
// }
//
// @Override
// public char getStarterChar() {
// return '\n';
// }
//
// @Override
// public <V> boolean match(MatcherContext<V> context) {
// int cur = context.getCurrentIndex();
// if(cur == 0) {
// context.createNode();
// return true;
// }
// InputBuffer buffer = context.getInputBuffer();
//
// if(buffer.charAt(cur-1)=='\n') {
// context.createNode();
// return true;
// }
//
// return false;
// }
// }
| import org.parboiled.BaseParser;
import org.parboiled.Rule;
import org.parboiled.annotations.SuppressSubnodes;
import uk.ac.susx.tag.gramexp.matchers.RegularExpressionMatcher;
import uk.ac.susx.tag.gramexp.matchers.StartOfLineMatcher;
import java.util.*; | Object val = pop();
if(val instanceof Capture) {
captures.add((Capture)val);
} else {
result = val.equals(match);
break;
}
}catch (IllegalArgumentException e){
break;
}
}
Collections.reverse(captures);
for(Capture c: captures) {
push(c);
}
return result;
}
@SuppressSubnodes
public Rule StartOfLine() {
return new StartOfLineMatcher();
}
@SuppressSubnodes
public Rule Re(String pattern) {
| // Path: src/main/java/uk/ac/susx/tag/gramexp/matchers/RegularExpressionMatcher.java
// public class RegularExpressionMatcher extends CustomMatcher {
//
// private final Pattern pattern;
//
// public RegularExpressionMatcher(String re) {
// super("Regexp");
// pattern = Pattern.compile(re);
// }
//
// @Override
// public boolean isSingleCharMatcher() {
// return false;
// }
//
// @Override
// public boolean canMatchEmpty() {
// return pattern.matcher("").find();
// }
//
// @Override
// public boolean isStarterChar(char c) {
// Matcher m = pattern.matcher(c+"");
// return m.find() && m.start()==0;
// }
//
// @Override
// public char getStarterChar() {
// return 0;
// }
//
// @Override
// public <V> boolean match(MatcherContext<V> context) {
//
// int cur = context.getCurrentIndex();
//
// InputBuffer buffer = context.getInputBuffer();
// String content = InputBufferUtils.collectContent(buffer);
// content = content.substring(cur);
// Matcher m = pattern.matcher(content);
//
// if(m.find()) {
//
// int start = m.start();
// if(start == 0) {
// int end = m.end();
//
// int delta = end - start;
//
// context.advanceIndex(delta);
//
// context.createNode();
// return true;
//
// } else {
// return false;
// }
// } else {
//
// return false;
// }
//
// }
// }
//
// Path: src/main/java/uk/ac/susx/tag/gramexp/matchers/StartOfLineMatcher.java
// public class StartOfLineMatcher extends CustomMatcher{
//
// public StartOfLineMatcher() {
// super("StartOfLine");
// }
//
// @Override
// public boolean isSingleCharMatcher() {
// return true;
// }
//
// @Override
// public boolean canMatchEmpty() {
// return true;
// }
//
// @Override
// public boolean isStarterChar(char c) {
// return c == '\n';
// }
//
// @Override
// public char getStarterChar() {
// return '\n';
// }
//
// @Override
// public <V> boolean match(MatcherContext<V> context) {
// int cur = context.getCurrentIndex();
// if(cur == 0) {
// context.createNode();
// return true;
// }
// InputBuffer buffer = context.getInputBuffer();
//
// if(buffer.charAt(cur-1)=='\n') {
// context.createNode();
// return true;
// }
//
// return false;
// }
// }
// Path: src/main/java/uk/ac/susx/tag/gramexp/CapturingParser.java
import org.parboiled.BaseParser;
import org.parboiled.Rule;
import org.parboiled.annotations.SuppressSubnodes;
import uk.ac.susx.tag.gramexp.matchers.RegularExpressionMatcher;
import uk.ac.susx.tag.gramexp.matchers.StartOfLineMatcher;
import java.util.*;
Object val = pop();
if(val instanceof Capture) {
captures.add((Capture)val);
} else {
result = val.equals(match);
break;
}
}catch (IllegalArgumentException e){
break;
}
}
Collections.reverse(captures);
for(Capture c: captures) {
push(c);
}
return result;
}
@SuppressSubnodes
public Rule StartOfLine() {
return new StartOfLineMatcher();
}
@SuppressSubnodes
public Rule Re(String pattern) {
| return new RegularExpressionMatcher(pattern); |
Meituan-Dianping/Robust | app/src/main/java/com/meituan/sample/RobustCallBackSample.java | // Path: patch/src/main/java/com/meituan/robust/Patch.java
// public class Patch implements Cloneable {
// //补丁的编号,补丁的唯一标识符
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name=name;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
// //原始补丁文件的路径,推荐放到私有目录
// public String getLocalPath() {
// return localPath + ".jar";
// }
//
// public void setLocalPath(String localPath) {
// this.localPath = localPath;
// }
// //原始补丁的md5,确保原始补丁文件没有被篡改
// public String getMd5() {
// return md5;
// }
//
// public void setMd5(String md5) {
// this.md5 = md5;
// }
//
// private String patchesInfoImplClassFullName;
// /**
// * 补丁名称
// */
// private String name;
//
// /**
// * 补丁的下载url
// */
// private String url;
// /**
// * 补丁本地保存路径
// */
// private String localPath;
//
// private String tempPath;
//
// /**
// * 补丁md5值
// */
// private String md5;
//
// /**
// * app hash值,避免应用内升级导致低版本app的补丁应用到了高版本app上
// */
// private String appHash;
//
// public boolean isAppliedSuccess() {
// return isAppliedSuccess;
// }
//
// public void setAppliedSuccess(boolean appliedSuccess) {
// isAppliedSuccess = appliedSuccess;
// }
//
// /**
// * 补丁是否已经applied success
// */
// private boolean isAppliedSuccess;
//
// /**
// * 删除文件
// */
// public void delete(String path) {
// File f = new File(path);
// f.delete();
// }
//
// public String getPatchesInfoImplClassFullName() {
// return patchesInfoImplClassFullName;
// }
//
// public void setPatchesInfoImplClassFullName(String patchesInfoImplClassFullName) {
// this.patchesInfoImplClassFullName = patchesInfoImplClassFullName;
// }
//
// public String getAppHash() {
// return appHash;
// }
//
// public void setAppHash(String appHash) {
// this.appHash = appHash;
// }
// //解密之后的补丁文件,可以直接运行的补丁文件,建议加载之后立刻删除,保证安全性
// public String getTempPath() {
// return tempPath + "_temp" + ".jar";
// }
//
// public void setTempPath(String tempPath) {
// this.tempPath = tempPath;
// }
//
// @Override
// public Patch clone() {
// Patch clone = null;
// try {
// clone = (Patch) super.clone();
// } catch (CloneNotSupportedException e) {
// // throw e;
// }
// return clone;
// }
// }
//
// Path: patch/src/main/java/com/meituan/robust/RobustCallBack.java
// public interface RobustCallBack {
// /**
// * 获取补丁列表后,回调此方法
// *
// * @param result 补丁
// * @param isNet 补丁
// */
// void onPatchListFetched(boolean result, boolean isNet, List<Patch> patches);
//
//
// /**
// * 在获取补丁后,回调此方法
// *
// * @param result 结果
// * @param patch 补丁
// */
// void onPatchFetched(boolean result, boolean isNet, Patch patch);
//
//
// /**
// * 在补丁应用后,回调此方法
// *
// * @param result 结果
// * @param patch 补丁
// */
// void onPatchApplied(boolean result, Patch patch);
//
//
// void logNotify(String log, String where);
//
//
// void exceptionNotify(Throwable throwable, String where);
// }
| import android.util.Log;
import com.meituan.robust.Patch;
import com.meituan.robust.RobustCallBack;
import java.util.List; | package com.meituan.sample;
/**
* Created by hedingxu on 17/11/26.
*/
public class RobustCallBackSample implements RobustCallBack {
@Override | // Path: patch/src/main/java/com/meituan/robust/Patch.java
// public class Patch implements Cloneable {
// //补丁的编号,补丁的唯一标识符
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name=name;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
// //原始补丁文件的路径,推荐放到私有目录
// public String getLocalPath() {
// return localPath + ".jar";
// }
//
// public void setLocalPath(String localPath) {
// this.localPath = localPath;
// }
// //原始补丁的md5,确保原始补丁文件没有被篡改
// public String getMd5() {
// return md5;
// }
//
// public void setMd5(String md5) {
// this.md5 = md5;
// }
//
// private String patchesInfoImplClassFullName;
// /**
// * 补丁名称
// */
// private String name;
//
// /**
// * 补丁的下载url
// */
// private String url;
// /**
// * 补丁本地保存路径
// */
// private String localPath;
//
// private String tempPath;
//
// /**
// * 补丁md5值
// */
// private String md5;
//
// /**
// * app hash值,避免应用内升级导致低版本app的补丁应用到了高版本app上
// */
// private String appHash;
//
// public boolean isAppliedSuccess() {
// return isAppliedSuccess;
// }
//
// public void setAppliedSuccess(boolean appliedSuccess) {
// isAppliedSuccess = appliedSuccess;
// }
//
// /**
// * 补丁是否已经applied success
// */
// private boolean isAppliedSuccess;
//
// /**
// * 删除文件
// */
// public void delete(String path) {
// File f = new File(path);
// f.delete();
// }
//
// public String getPatchesInfoImplClassFullName() {
// return patchesInfoImplClassFullName;
// }
//
// public void setPatchesInfoImplClassFullName(String patchesInfoImplClassFullName) {
// this.patchesInfoImplClassFullName = patchesInfoImplClassFullName;
// }
//
// public String getAppHash() {
// return appHash;
// }
//
// public void setAppHash(String appHash) {
// this.appHash = appHash;
// }
// //解密之后的补丁文件,可以直接运行的补丁文件,建议加载之后立刻删除,保证安全性
// public String getTempPath() {
// return tempPath + "_temp" + ".jar";
// }
//
// public void setTempPath(String tempPath) {
// this.tempPath = tempPath;
// }
//
// @Override
// public Patch clone() {
// Patch clone = null;
// try {
// clone = (Patch) super.clone();
// } catch (CloneNotSupportedException e) {
// // throw e;
// }
// return clone;
// }
// }
//
// Path: patch/src/main/java/com/meituan/robust/RobustCallBack.java
// public interface RobustCallBack {
// /**
// * 获取补丁列表后,回调此方法
// *
// * @param result 补丁
// * @param isNet 补丁
// */
// void onPatchListFetched(boolean result, boolean isNet, List<Patch> patches);
//
//
// /**
// * 在获取补丁后,回调此方法
// *
// * @param result 结果
// * @param patch 补丁
// */
// void onPatchFetched(boolean result, boolean isNet, Patch patch);
//
//
// /**
// * 在补丁应用后,回调此方法
// *
// * @param result 结果
// * @param patch 补丁
// */
// void onPatchApplied(boolean result, Patch patch);
//
//
// void logNotify(String log, String where);
//
//
// void exceptionNotify(Throwable throwable, String where);
// }
// Path: app/src/main/java/com/meituan/sample/RobustCallBackSample.java
import android.util.Log;
import com.meituan.robust.Patch;
import com.meituan.robust.RobustCallBack;
import java.util.List;
package com.meituan.sample;
/**
* Created by hedingxu on 17/11/26.
*/
public class RobustCallBackSample implements RobustCallBack {
@Override | public void onPatchListFetched(boolean result, boolean isNet, List<Patch> patches) { |
neowu/core-ng-demo-project | demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
| import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.PUT;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus; | package app.demo.api;
public interface CustomerWebService {
@GET
@Path("/customer/:id") | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
// Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.PUT;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus;
package app.demo.api;
public interface CustomerWebService {
@GET
@Path("/customer/:id") | CustomerView get(@PathParam("id") Long id); |
neowu/core-ng-demo-project | demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
| import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.PUT;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus; | package app.demo.api;
public interface CustomerWebService {
@GET
@Path("/customer/:id")
CustomerView get(@PathParam("id") Long id);
@POST
@Path("/customer")
@ResponseStatus(HTTPStatus.CREATED) | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
// Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.PUT;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus;
package app.demo.api;
public interface CustomerWebService {
@GET
@Path("/customer/:id")
CustomerView get(@PathParam("id") Long id);
@POST
@Path("/customer")
@ResponseStatus(HTTPStatus.CREATED) | CustomerView create(CreateCustomerRequest request); |
neowu/core-ng-demo-project | demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
| import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.PUT;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus; | package app.demo.api;
public interface CustomerWebService {
@GET
@Path("/customer/:id")
CustomerView get(@PathParam("id") Long id);
@POST
@Path("/customer")
@ResponseStatus(HTTPStatus.CREATED)
CustomerView create(CreateCustomerRequest request);
@PUT
@Path("/customer/:id") | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
// Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.PUT;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus;
package app.demo.api;
public interface CustomerWebService {
@GET
@Path("/customer/:id")
CustomerView get(@PathParam("id") Long id);
@POST
@Path("/customer")
@ResponseStatus(HTTPStatus.CREATED)
CustomerView create(CreateCustomerRequest request);
@PUT
@Path("/customer/:id") | CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request); |
neowu/core-ng-demo-project | demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
| import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.PUT;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus; | package app.demo.api;
public interface CustomerWebService {
@GET
@Path("/customer/:id")
CustomerView get(@PathParam("id") Long id);
@POST
@Path("/customer")
@ResponseStatus(HTTPStatus.CREATED)
CustomerView create(CreateCustomerRequest request);
@PUT
@Path("/customer/:id")
CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
@GET
@Path("/customer") | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
// Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.PUT;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus;
package app.demo.api;
public interface CustomerWebService {
@GET
@Path("/customer/:id")
CustomerView get(@PathParam("id") Long id);
@POST
@Path("/customer")
@ResponseStatus(HTTPStatus.CREATED)
CustomerView create(CreateCustomerRequest request);
@PUT
@Path("/customer/:id")
CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
@GET
@Path("/customer") | SearchCustomerResponse search(SearchCustomerRequest request); |
neowu/core-ng-demo-project | demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
| import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.PUT;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus; | package app.demo.api;
public interface CustomerWebService {
@GET
@Path("/customer/:id")
CustomerView get(@PathParam("id") Long id);
@POST
@Path("/customer")
@ResponseStatus(HTTPStatus.CREATED)
CustomerView create(CreateCustomerRequest request);
@PUT
@Path("/customer/:id")
CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
@GET
@Path("/customer") | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
// Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.PUT;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus;
package app.demo.api;
public interface CustomerWebService {
@GET
@Path("/customer/:id")
CustomerView get(@PathParam("id") Long id);
@POST
@Path("/customer")
@ResponseStatus(HTTPStatus.CREATED)
CustomerView create(CreateCustomerRequest request);
@PUT
@Path("/customer/:id")
CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
@GET
@Path("/customer") | SearchCustomerResponse search(SearchCustomerRequest request); |
neowu/core-ng-demo-project | demo-service/src/main/java/app/CustomerModule.java | // Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
// public interface CustomerWebService {
// @GET
// @Path("/customer/:id")
// CustomerView get(@PathParam("id") Long id);
//
// @POST
// @Path("/customer")
// @ResponseStatus(HTTPStatus.CREATED)
// CustomerView create(CreateCustomerRequest request);
//
// @PUT
// @Path("/customer/:id")
// CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
//
// @GET
// @Path("/customer")
// SearchCustomerResponse search(SearchCustomerRequest request);
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
// public class CustomerService {
// @Inject
// Repository<Customer> customerRepository;
//
// public CustomerView get(Long id) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// return view(customer);
// }
//
// public CustomerView create(CreateCustomerRequest request) {
// Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
// if (existingCustomer.isPresent()) {
// throw new ConflictException("customer already exists, email=" + request.email);
// }
//
// Customer customer = new Customer();
// customer.status = CustomerStatus.ACTIVE;
// customer.email = request.email;
// customer.firstName = request.firstName;
// customer.lastName = request.lastName;
// customer.updatedTime = LocalDateTime.now();
// customer.id = customerRepository.insert(customer).orElseThrow();
//
// return view(customer);
// }
//
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// customer.updatedTime = LocalDateTime.now();
// customer.firstName = request.firstName;
// if (request.lastName != null) {
// customer.lastName = request.lastName;
// }
// customerRepository.partialUpdate(customer);
// return view(customer);
// }
//
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// SearchCustomerResponse result = new SearchCustomerResponse();
// Query<Customer> query = customerRepository.select();
// query.skip(request.skip);
// query.limit(request.limit);
// if (!Strings.isBlank(request.email)) {
// query.where("email = ?", request.email);
// }
// if (!Strings.isBlank(request.firstName)) {
// query.where("first_name like ?", Strings.format("{}%", request.firstName));
// }
// if (!Strings.isBlank(request.lastName)) {
// query.where("last_name like ?", Strings.format("{}%", request.lastName));
// }
// result.customers = query.fetch().stream().map(this::view).collect(Collectors.toList());
// result.total = query.count();
//
// return result;
// }
//
// private CustomerView view(Customer customer) {
// CustomerView result = new CustomerView();
// result.id = customer.id;
// result.email = customer.email;
// result.firstName = customer.firstName;
// result.lastName = customer.lastName;
// result.updatedTime = customer.updatedTime;
// return result;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/customer/web/CustomerWebServiceImpl.java
// public class CustomerWebServiceImpl implements CustomerWebService {
// @Inject
// CustomerService customerService;
//
// @Override
// public CustomerView get(Long id) {
// return customerService.get(id);
// }
//
// @Override
// public CustomerView create(CreateCustomerRequest request) {
// return customerService.create(request);
// }
//
// @Override
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// return customerService.update(id, request);
// }
//
// @Override
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// return customerService.search(request);
// }
// }
| import app.demo.api.CustomerWebService;
import app.demo.customer.domain.Customer;
import app.demo.customer.service.CustomerService;
import app.demo.customer.web.CustomerWebServiceImpl;
import core.framework.module.Module; | package app;
public class CustomerModule extends Module {
@Override
protected void initialize() { | // Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
// public interface CustomerWebService {
// @GET
// @Path("/customer/:id")
// CustomerView get(@PathParam("id") Long id);
//
// @POST
// @Path("/customer")
// @ResponseStatus(HTTPStatus.CREATED)
// CustomerView create(CreateCustomerRequest request);
//
// @PUT
// @Path("/customer/:id")
// CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
//
// @GET
// @Path("/customer")
// SearchCustomerResponse search(SearchCustomerRequest request);
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
// public class CustomerService {
// @Inject
// Repository<Customer> customerRepository;
//
// public CustomerView get(Long id) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// return view(customer);
// }
//
// public CustomerView create(CreateCustomerRequest request) {
// Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
// if (existingCustomer.isPresent()) {
// throw new ConflictException("customer already exists, email=" + request.email);
// }
//
// Customer customer = new Customer();
// customer.status = CustomerStatus.ACTIVE;
// customer.email = request.email;
// customer.firstName = request.firstName;
// customer.lastName = request.lastName;
// customer.updatedTime = LocalDateTime.now();
// customer.id = customerRepository.insert(customer).orElseThrow();
//
// return view(customer);
// }
//
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// customer.updatedTime = LocalDateTime.now();
// customer.firstName = request.firstName;
// if (request.lastName != null) {
// customer.lastName = request.lastName;
// }
// customerRepository.partialUpdate(customer);
// return view(customer);
// }
//
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// SearchCustomerResponse result = new SearchCustomerResponse();
// Query<Customer> query = customerRepository.select();
// query.skip(request.skip);
// query.limit(request.limit);
// if (!Strings.isBlank(request.email)) {
// query.where("email = ?", request.email);
// }
// if (!Strings.isBlank(request.firstName)) {
// query.where("first_name like ?", Strings.format("{}%", request.firstName));
// }
// if (!Strings.isBlank(request.lastName)) {
// query.where("last_name like ?", Strings.format("{}%", request.lastName));
// }
// result.customers = query.fetch().stream().map(this::view).collect(Collectors.toList());
// result.total = query.count();
//
// return result;
// }
//
// private CustomerView view(Customer customer) {
// CustomerView result = new CustomerView();
// result.id = customer.id;
// result.email = customer.email;
// result.firstName = customer.firstName;
// result.lastName = customer.lastName;
// result.updatedTime = customer.updatedTime;
// return result;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/customer/web/CustomerWebServiceImpl.java
// public class CustomerWebServiceImpl implements CustomerWebService {
// @Inject
// CustomerService customerService;
//
// @Override
// public CustomerView get(Long id) {
// return customerService.get(id);
// }
//
// @Override
// public CustomerView create(CreateCustomerRequest request) {
// return customerService.create(request);
// }
//
// @Override
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// return customerService.update(id, request);
// }
//
// @Override
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// return customerService.search(request);
// }
// }
// Path: demo-service/src/main/java/app/CustomerModule.java
import app.demo.api.CustomerWebService;
import app.demo.customer.domain.Customer;
import app.demo.customer.service.CustomerService;
import app.demo.customer.web.CustomerWebServiceImpl;
import core.framework.module.Module;
package app;
public class CustomerModule extends Module {
@Override
protected void initialize() { | db().repository(Customer.class); |
neowu/core-ng-demo-project | demo-service/src/main/java/app/CustomerModule.java | // Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
// public interface CustomerWebService {
// @GET
// @Path("/customer/:id")
// CustomerView get(@PathParam("id") Long id);
//
// @POST
// @Path("/customer")
// @ResponseStatus(HTTPStatus.CREATED)
// CustomerView create(CreateCustomerRequest request);
//
// @PUT
// @Path("/customer/:id")
// CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
//
// @GET
// @Path("/customer")
// SearchCustomerResponse search(SearchCustomerRequest request);
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
// public class CustomerService {
// @Inject
// Repository<Customer> customerRepository;
//
// public CustomerView get(Long id) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// return view(customer);
// }
//
// public CustomerView create(CreateCustomerRequest request) {
// Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
// if (existingCustomer.isPresent()) {
// throw new ConflictException("customer already exists, email=" + request.email);
// }
//
// Customer customer = new Customer();
// customer.status = CustomerStatus.ACTIVE;
// customer.email = request.email;
// customer.firstName = request.firstName;
// customer.lastName = request.lastName;
// customer.updatedTime = LocalDateTime.now();
// customer.id = customerRepository.insert(customer).orElseThrow();
//
// return view(customer);
// }
//
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// customer.updatedTime = LocalDateTime.now();
// customer.firstName = request.firstName;
// if (request.lastName != null) {
// customer.lastName = request.lastName;
// }
// customerRepository.partialUpdate(customer);
// return view(customer);
// }
//
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// SearchCustomerResponse result = new SearchCustomerResponse();
// Query<Customer> query = customerRepository.select();
// query.skip(request.skip);
// query.limit(request.limit);
// if (!Strings.isBlank(request.email)) {
// query.where("email = ?", request.email);
// }
// if (!Strings.isBlank(request.firstName)) {
// query.where("first_name like ?", Strings.format("{}%", request.firstName));
// }
// if (!Strings.isBlank(request.lastName)) {
// query.where("last_name like ?", Strings.format("{}%", request.lastName));
// }
// result.customers = query.fetch().stream().map(this::view).collect(Collectors.toList());
// result.total = query.count();
//
// return result;
// }
//
// private CustomerView view(Customer customer) {
// CustomerView result = new CustomerView();
// result.id = customer.id;
// result.email = customer.email;
// result.firstName = customer.firstName;
// result.lastName = customer.lastName;
// result.updatedTime = customer.updatedTime;
// return result;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/customer/web/CustomerWebServiceImpl.java
// public class CustomerWebServiceImpl implements CustomerWebService {
// @Inject
// CustomerService customerService;
//
// @Override
// public CustomerView get(Long id) {
// return customerService.get(id);
// }
//
// @Override
// public CustomerView create(CreateCustomerRequest request) {
// return customerService.create(request);
// }
//
// @Override
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// return customerService.update(id, request);
// }
//
// @Override
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// return customerService.search(request);
// }
// }
| import app.demo.api.CustomerWebService;
import app.demo.customer.domain.Customer;
import app.demo.customer.service.CustomerService;
import app.demo.customer.web.CustomerWebServiceImpl;
import core.framework.module.Module; | package app;
public class CustomerModule extends Module {
@Override
protected void initialize() {
db().repository(Customer.class); | // Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
// public interface CustomerWebService {
// @GET
// @Path("/customer/:id")
// CustomerView get(@PathParam("id") Long id);
//
// @POST
// @Path("/customer")
// @ResponseStatus(HTTPStatus.CREATED)
// CustomerView create(CreateCustomerRequest request);
//
// @PUT
// @Path("/customer/:id")
// CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
//
// @GET
// @Path("/customer")
// SearchCustomerResponse search(SearchCustomerRequest request);
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
// public class CustomerService {
// @Inject
// Repository<Customer> customerRepository;
//
// public CustomerView get(Long id) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// return view(customer);
// }
//
// public CustomerView create(CreateCustomerRequest request) {
// Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
// if (existingCustomer.isPresent()) {
// throw new ConflictException("customer already exists, email=" + request.email);
// }
//
// Customer customer = new Customer();
// customer.status = CustomerStatus.ACTIVE;
// customer.email = request.email;
// customer.firstName = request.firstName;
// customer.lastName = request.lastName;
// customer.updatedTime = LocalDateTime.now();
// customer.id = customerRepository.insert(customer).orElseThrow();
//
// return view(customer);
// }
//
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// customer.updatedTime = LocalDateTime.now();
// customer.firstName = request.firstName;
// if (request.lastName != null) {
// customer.lastName = request.lastName;
// }
// customerRepository.partialUpdate(customer);
// return view(customer);
// }
//
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// SearchCustomerResponse result = new SearchCustomerResponse();
// Query<Customer> query = customerRepository.select();
// query.skip(request.skip);
// query.limit(request.limit);
// if (!Strings.isBlank(request.email)) {
// query.where("email = ?", request.email);
// }
// if (!Strings.isBlank(request.firstName)) {
// query.where("first_name like ?", Strings.format("{}%", request.firstName));
// }
// if (!Strings.isBlank(request.lastName)) {
// query.where("last_name like ?", Strings.format("{}%", request.lastName));
// }
// result.customers = query.fetch().stream().map(this::view).collect(Collectors.toList());
// result.total = query.count();
//
// return result;
// }
//
// private CustomerView view(Customer customer) {
// CustomerView result = new CustomerView();
// result.id = customer.id;
// result.email = customer.email;
// result.firstName = customer.firstName;
// result.lastName = customer.lastName;
// result.updatedTime = customer.updatedTime;
// return result;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/customer/web/CustomerWebServiceImpl.java
// public class CustomerWebServiceImpl implements CustomerWebService {
// @Inject
// CustomerService customerService;
//
// @Override
// public CustomerView get(Long id) {
// return customerService.get(id);
// }
//
// @Override
// public CustomerView create(CreateCustomerRequest request) {
// return customerService.create(request);
// }
//
// @Override
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// return customerService.update(id, request);
// }
//
// @Override
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// return customerService.search(request);
// }
// }
// Path: demo-service/src/main/java/app/CustomerModule.java
import app.demo.api.CustomerWebService;
import app.demo.customer.domain.Customer;
import app.demo.customer.service.CustomerService;
import app.demo.customer.web.CustomerWebServiceImpl;
import core.framework.module.Module;
package app;
public class CustomerModule extends Module {
@Override
protected void initialize() {
db().repository(Customer.class); | bind(CustomerService.class); |
neowu/core-ng-demo-project | demo-service/src/main/java/app/CustomerModule.java | // Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
// public interface CustomerWebService {
// @GET
// @Path("/customer/:id")
// CustomerView get(@PathParam("id") Long id);
//
// @POST
// @Path("/customer")
// @ResponseStatus(HTTPStatus.CREATED)
// CustomerView create(CreateCustomerRequest request);
//
// @PUT
// @Path("/customer/:id")
// CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
//
// @GET
// @Path("/customer")
// SearchCustomerResponse search(SearchCustomerRequest request);
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
// public class CustomerService {
// @Inject
// Repository<Customer> customerRepository;
//
// public CustomerView get(Long id) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// return view(customer);
// }
//
// public CustomerView create(CreateCustomerRequest request) {
// Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
// if (existingCustomer.isPresent()) {
// throw new ConflictException("customer already exists, email=" + request.email);
// }
//
// Customer customer = new Customer();
// customer.status = CustomerStatus.ACTIVE;
// customer.email = request.email;
// customer.firstName = request.firstName;
// customer.lastName = request.lastName;
// customer.updatedTime = LocalDateTime.now();
// customer.id = customerRepository.insert(customer).orElseThrow();
//
// return view(customer);
// }
//
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// customer.updatedTime = LocalDateTime.now();
// customer.firstName = request.firstName;
// if (request.lastName != null) {
// customer.lastName = request.lastName;
// }
// customerRepository.partialUpdate(customer);
// return view(customer);
// }
//
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// SearchCustomerResponse result = new SearchCustomerResponse();
// Query<Customer> query = customerRepository.select();
// query.skip(request.skip);
// query.limit(request.limit);
// if (!Strings.isBlank(request.email)) {
// query.where("email = ?", request.email);
// }
// if (!Strings.isBlank(request.firstName)) {
// query.where("first_name like ?", Strings.format("{}%", request.firstName));
// }
// if (!Strings.isBlank(request.lastName)) {
// query.where("last_name like ?", Strings.format("{}%", request.lastName));
// }
// result.customers = query.fetch().stream().map(this::view).collect(Collectors.toList());
// result.total = query.count();
//
// return result;
// }
//
// private CustomerView view(Customer customer) {
// CustomerView result = new CustomerView();
// result.id = customer.id;
// result.email = customer.email;
// result.firstName = customer.firstName;
// result.lastName = customer.lastName;
// result.updatedTime = customer.updatedTime;
// return result;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/customer/web/CustomerWebServiceImpl.java
// public class CustomerWebServiceImpl implements CustomerWebService {
// @Inject
// CustomerService customerService;
//
// @Override
// public CustomerView get(Long id) {
// return customerService.get(id);
// }
//
// @Override
// public CustomerView create(CreateCustomerRequest request) {
// return customerService.create(request);
// }
//
// @Override
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// return customerService.update(id, request);
// }
//
// @Override
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// return customerService.search(request);
// }
// }
| import app.demo.api.CustomerWebService;
import app.demo.customer.domain.Customer;
import app.demo.customer.service.CustomerService;
import app.demo.customer.web.CustomerWebServiceImpl;
import core.framework.module.Module; | package app;
public class CustomerModule extends Module {
@Override
protected void initialize() {
db().repository(Customer.class);
bind(CustomerService.class); | // Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
// public interface CustomerWebService {
// @GET
// @Path("/customer/:id")
// CustomerView get(@PathParam("id") Long id);
//
// @POST
// @Path("/customer")
// @ResponseStatus(HTTPStatus.CREATED)
// CustomerView create(CreateCustomerRequest request);
//
// @PUT
// @Path("/customer/:id")
// CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
//
// @GET
// @Path("/customer")
// SearchCustomerResponse search(SearchCustomerRequest request);
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
// public class CustomerService {
// @Inject
// Repository<Customer> customerRepository;
//
// public CustomerView get(Long id) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// return view(customer);
// }
//
// public CustomerView create(CreateCustomerRequest request) {
// Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
// if (existingCustomer.isPresent()) {
// throw new ConflictException("customer already exists, email=" + request.email);
// }
//
// Customer customer = new Customer();
// customer.status = CustomerStatus.ACTIVE;
// customer.email = request.email;
// customer.firstName = request.firstName;
// customer.lastName = request.lastName;
// customer.updatedTime = LocalDateTime.now();
// customer.id = customerRepository.insert(customer).orElseThrow();
//
// return view(customer);
// }
//
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// customer.updatedTime = LocalDateTime.now();
// customer.firstName = request.firstName;
// if (request.lastName != null) {
// customer.lastName = request.lastName;
// }
// customerRepository.partialUpdate(customer);
// return view(customer);
// }
//
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// SearchCustomerResponse result = new SearchCustomerResponse();
// Query<Customer> query = customerRepository.select();
// query.skip(request.skip);
// query.limit(request.limit);
// if (!Strings.isBlank(request.email)) {
// query.where("email = ?", request.email);
// }
// if (!Strings.isBlank(request.firstName)) {
// query.where("first_name like ?", Strings.format("{}%", request.firstName));
// }
// if (!Strings.isBlank(request.lastName)) {
// query.where("last_name like ?", Strings.format("{}%", request.lastName));
// }
// result.customers = query.fetch().stream().map(this::view).collect(Collectors.toList());
// result.total = query.count();
//
// return result;
// }
//
// private CustomerView view(Customer customer) {
// CustomerView result = new CustomerView();
// result.id = customer.id;
// result.email = customer.email;
// result.firstName = customer.firstName;
// result.lastName = customer.lastName;
// result.updatedTime = customer.updatedTime;
// return result;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/customer/web/CustomerWebServiceImpl.java
// public class CustomerWebServiceImpl implements CustomerWebService {
// @Inject
// CustomerService customerService;
//
// @Override
// public CustomerView get(Long id) {
// return customerService.get(id);
// }
//
// @Override
// public CustomerView create(CreateCustomerRequest request) {
// return customerService.create(request);
// }
//
// @Override
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// return customerService.update(id, request);
// }
//
// @Override
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// return customerService.search(request);
// }
// }
// Path: demo-service/src/main/java/app/CustomerModule.java
import app.demo.api.CustomerWebService;
import app.demo.customer.domain.Customer;
import app.demo.customer.service.CustomerService;
import app.demo.customer.web.CustomerWebServiceImpl;
import core.framework.module.Module;
package app;
public class CustomerModule extends Module {
@Override
protected void initialize() {
db().repository(Customer.class);
bind(CustomerService.class); | api().service(CustomerWebService.class, bind(CustomerWebServiceImpl.class)); |
neowu/core-ng-demo-project | demo-service/src/main/java/app/CustomerModule.java | // Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
// public interface CustomerWebService {
// @GET
// @Path("/customer/:id")
// CustomerView get(@PathParam("id") Long id);
//
// @POST
// @Path("/customer")
// @ResponseStatus(HTTPStatus.CREATED)
// CustomerView create(CreateCustomerRequest request);
//
// @PUT
// @Path("/customer/:id")
// CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
//
// @GET
// @Path("/customer")
// SearchCustomerResponse search(SearchCustomerRequest request);
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
// public class CustomerService {
// @Inject
// Repository<Customer> customerRepository;
//
// public CustomerView get(Long id) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// return view(customer);
// }
//
// public CustomerView create(CreateCustomerRequest request) {
// Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
// if (existingCustomer.isPresent()) {
// throw new ConflictException("customer already exists, email=" + request.email);
// }
//
// Customer customer = new Customer();
// customer.status = CustomerStatus.ACTIVE;
// customer.email = request.email;
// customer.firstName = request.firstName;
// customer.lastName = request.lastName;
// customer.updatedTime = LocalDateTime.now();
// customer.id = customerRepository.insert(customer).orElseThrow();
//
// return view(customer);
// }
//
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// customer.updatedTime = LocalDateTime.now();
// customer.firstName = request.firstName;
// if (request.lastName != null) {
// customer.lastName = request.lastName;
// }
// customerRepository.partialUpdate(customer);
// return view(customer);
// }
//
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// SearchCustomerResponse result = new SearchCustomerResponse();
// Query<Customer> query = customerRepository.select();
// query.skip(request.skip);
// query.limit(request.limit);
// if (!Strings.isBlank(request.email)) {
// query.where("email = ?", request.email);
// }
// if (!Strings.isBlank(request.firstName)) {
// query.where("first_name like ?", Strings.format("{}%", request.firstName));
// }
// if (!Strings.isBlank(request.lastName)) {
// query.where("last_name like ?", Strings.format("{}%", request.lastName));
// }
// result.customers = query.fetch().stream().map(this::view).collect(Collectors.toList());
// result.total = query.count();
//
// return result;
// }
//
// private CustomerView view(Customer customer) {
// CustomerView result = new CustomerView();
// result.id = customer.id;
// result.email = customer.email;
// result.firstName = customer.firstName;
// result.lastName = customer.lastName;
// result.updatedTime = customer.updatedTime;
// return result;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/customer/web/CustomerWebServiceImpl.java
// public class CustomerWebServiceImpl implements CustomerWebService {
// @Inject
// CustomerService customerService;
//
// @Override
// public CustomerView get(Long id) {
// return customerService.get(id);
// }
//
// @Override
// public CustomerView create(CreateCustomerRequest request) {
// return customerService.create(request);
// }
//
// @Override
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// return customerService.update(id, request);
// }
//
// @Override
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// return customerService.search(request);
// }
// }
| import app.demo.api.CustomerWebService;
import app.demo.customer.domain.Customer;
import app.demo.customer.service.CustomerService;
import app.demo.customer.web.CustomerWebServiceImpl;
import core.framework.module.Module; | package app;
public class CustomerModule extends Module {
@Override
protected void initialize() {
db().repository(Customer.class);
bind(CustomerService.class); | // Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
// public interface CustomerWebService {
// @GET
// @Path("/customer/:id")
// CustomerView get(@PathParam("id") Long id);
//
// @POST
// @Path("/customer")
// @ResponseStatus(HTTPStatus.CREATED)
// CustomerView create(CreateCustomerRequest request);
//
// @PUT
// @Path("/customer/:id")
// CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
//
// @GET
// @Path("/customer")
// SearchCustomerResponse search(SearchCustomerRequest request);
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
// public class CustomerService {
// @Inject
// Repository<Customer> customerRepository;
//
// public CustomerView get(Long id) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// return view(customer);
// }
//
// public CustomerView create(CreateCustomerRequest request) {
// Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
// if (existingCustomer.isPresent()) {
// throw new ConflictException("customer already exists, email=" + request.email);
// }
//
// Customer customer = new Customer();
// customer.status = CustomerStatus.ACTIVE;
// customer.email = request.email;
// customer.firstName = request.firstName;
// customer.lastName = request.lastName;
// customer.updatedTime = LocalDateTime.now();
// customer.id = customerRepository.insert(customer).orElseThrow();
//
// return view(customer);
// }
//
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// customer.updatedTime = LocalDateTime.now();
// customer.firstName = request.firstName;
// if (request.lastName != null) {
// customer.lastName = request.lastName;
// }
// customerRepository.partialUpdate(customer);
// return view(customer);
// }
//
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// SearchCustomerResponse result = new SearchCustomerResponse();
// Query<Customer> query = customerRepository.select();
// query.skip(request.skip);
// query.limit(request.limit);
// if (!Strings.isBlank(request.email)) {
// query.where("email = ?", request.email);
// }
// if (!Strings.isBlank(request.firstName)) {
// query.where("first_name like ?", Strings.format("{}%", request.firstName));
// }
// if (!Strings.isBlank(request.lastName)) {
// query.where("last_name like ?", Strings.format("{}%", request.lastName));
// }
// result.customers = query.fetch().stream().map(this::view).collect(Collectors.toList());
// result.total = query.count();
//
// return result;
// }
//
// private CustomerView view(Customer customer) {
// CustomerView result = new CustomerView();
// result.id = customer.id;
// result.email = customer.email;
// result.firstName = customer.firstName;
// result.lastName = customer.lastName;
// result.updatedTime = customer.updatedTime;
// return result;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/customer/web/CustomerWebServiceImpl.java
// public class CustomerWebServiceImpl implements CustomerWebService {
// @Inject
// CustomerService customerService;
//
// @Override
// public CustomerView get(Long id) {
// return customerService.get(id);
// }
//
// @Override
// public CustomerView create(CreateCustomerRequest request) {
// return customerService.create(request);
// }
//
// @Override
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// return customerService.update(id, request);
// }
//
// @Override
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// return customerService.search(request);
// }
// }
// Path: demo-service/src/main/java/app/CustomerModule.java
import app.demo.api.CustomerWebService;
import app.demo.customer.domain.Customer;
import app.demo.customer.service.CustomerService;
import app.demo.customer.web.CustomerWebServiceImpl;
import core.framework.module.Module;
package app;
public class CustomerModule extends Module {
@Override
protected void initialize() {
db().repository(Customer.class);
bind(CustomerService.class); | api().service(CustomerWebService.class, bind(CustomerWebServiceImpl.class)); |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/product/web/ProductUpdatedMessageTestController.java | // Path: demo-service-interface/src/main/java/app/demo/api/product/kafka/ProductUpdatedMessage.java
// public class ProductUpdatedMessage {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotBlank
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String desc;
// }
| import app.demo.api.product.kafka.ProductUpdatedMessage;
import core.framework.inject.Inject;
import core.framework.kafka.MessagePublisher;
import core.framework.log.ActionLogContext;
import core.framework.web.Controller;
import core.framework.web.Request;
import core.framework.web.Response; | package app.demo.product.web;
/**
* @author neo
*/
public class ProductUpdatedMessageTestController implements Controller {
@Inject | // Path: demo-service-interface/src/main/java/app/demo/api/product/kafka/ProductUpdatedMessage.java
// public class ProductUpdatedMessage {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotBlank
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String desc;
// }
// Path: demo-service/src/main/java/app/demo/product/web/ProductUpdatedMessageTestController.java
import app.demo.api.product.kafka.ProductUpdatedMessage;
import core.framework.inject.Inject;
import core.framework.kafka.MessagePublisher;
import core.framework.log.ActionLogContext;
import core.framework.web.Controller;
import core.framework.web.Request;
import core.framework.web.Response;
package app.demo.product.web;
/**
* @author neo
*/
public class ProductUpdatedMessageTestController implements Controller {
@Inject | MessagePublisher<ProductUpdatedMessage> publisher; |
neowu/core-ng-demo-project | demo-service/src/test/java/app/demo/TestModule.java | // Path: demo-service/src/main/java/app/DemoServiceApp.java
// public class DemoServiceApp extends App {
// @Override
// protected void initialize() {
// http().httpsPort(8443);
// load(new SystemModule("sys.properties"));
//
// http().httpPort(8081);
//
// load(new ProductModule());
// load(new JobModule());
// // load(new CustomerModule());
// }
// }
| import app.DemoServiceApp;
import core.framework.test.module.AbstractTestModule; | package app.demo;
/**
* @author neo
*/
public class TestModule extends AbstractTestModule {
@Override
protected void initialize() { | // Path: demo-service/src/main/java/app/DemoServiceApp.java
// public class DemoServiceApp extends App {
// @Override
// protected void initialize() {
// http().httpsPort(8443);
// load(new SystemModule("sys.properties"));
//
// http().httpPort(8081);
//
// load(new ProductModule());
// load(new JobModule());
// // load(new CustomerModule());
// }
// }
// Path: demo-service/src/test/java/app/demo/TestModule.java
import app.DemoServiceApp;
import core.framework.test.module.AbstractTestModule;
package app.demo;
/**
* @author neo
*/
public class TestModule extends AbstractTestModule {
@Override
protected void initialize() { | load(new DemoServiceApp()); |
neowu/core-ng-demo-project | demo-service/src/main/java/app/ProductModule.java | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/kafka/ProductUpdatedMessage.java
// public class ProductUpdatedMessage {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotBlank
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String desc;
// }
//
// Path: demo-service/src/main/java/app/demo/product/kafka/ProductUpdatedMessageHandler.java
// public class ProductUpdatedMessageHandler implements MessageHandler<ProductUpdatedMessage> {
// private final Logger logger = LoggerFactory.getLogger(ProductUpdatedMessageHandler.class);
//
// @Override
// public void handle(String key, ProductUpdatedMessage messages) {
// logger.debug("{}-{}", key, messages.name);
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductUpdatedMessageTestController.java
// public class ProductUpdatedMessageTestController implements Controller {
// @Inject
// MessagePublisher<ProductUpdatedMessage> publisher;
//
// @Override
// public Response execute(Request request) {
// ActionLogContext.triggerTrace(true);
// for (int i = 0; i < 10; i++) {
// ProductUpdatedMessage value = new ProductUpdatedMessage();
// value.id = String.valueOf(i);
// value.name = "name-" + i;
// publisher.publish(value.id, value);
// }
// return Response.empty();
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
// public class ProductWebServiceImpl implements ProductWebService {
// @Inject
// ProductService productService;
//
// @Override
// public SearchProductResponse search(SearchProductRequest request) {
// SearchProductResponse response = new SearchProductResponse();
// response.products = Lists.newArrayList();
// return response;
// }
//
// @LimitRate("product")
// @Override
// public Optional<ProductView> get(String id) {
// ActionLogContext.put("pid", id);
// return productService.get(id);
// }
//
// @Override
// public void create(CreateProductRequest request) {
// productService.create(request);
// }
//
// @Override
// public void update(String id, UpdateProductRequest request) {
// productService.update(id, request);
// }
// }
| import app.demo.api.ProductWebService;
import app.demo.api.product.ProductView;
import app.demo.api.product.kafka.ProductUpdatedMessage;
import app.demo.product.kafka.ProductUpdatedMessageHandler;
import app.demo.product.service.ProductService;
import app.demo.product.web.ProductUpdatedMessageTestController;
import app.demo.product.web.ProductWebServiceImpl;
import core.framework.http.HTTPClient;
import core.framework.module.Module;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import static core.framework.http.HTTPMethod.GET; | package app;
/**
* @author neo
*/
public class ProductModule extends Module {
@Override
protected void initialize() {
bind(HTTPClient.class, HTTPClient.builder().build());
| // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/kafka/ProductUpdatedMessage.java
// public class ProductUpdatedMessage {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotBlank
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String desc;
// }
//
// Path: demo-service/src/main/java/app/demo/product/kafka/ProductUpdatedMessageHandler.java
// public class ProductUpdatedMessageHandler implements MessageHandler<ProductUpdatedMessage> {
// private final Logger logger = LoggerFactory.getLogger(ProductUpdatedMessageHandler.class);
//
// @Override
// public void handle(String key, ProductUpdatedMessage messages) {
// logger.debug("{}-{}", key, messages.name);
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductUpdatedMessageTestController.java
// public class ProductUpdatedMessageTestController implements Controller {
// @Inject
// MessagePublisher<ProductUpdatedMessage> publisher;
//
// @Override
// public Response execute(Request request) {
// ActionLogContext.triggerTrace(true);
// for (int i = 0; i < 10; i++) {
// ProductUpdatedMessage value = new ProductUpdatedMessage();
// value.id = String.valueOf(i);
// value.name = "name-" + i;
// publisher.publish(value.id, value);
// }
// return Response.empty();
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
// public class ProductWebServiceImpl implements ProductWebService {
// @Inject
// ProductService productService;
//
// @Override
// public SearchProductResponse search(SearchProductRequest request) {
// SearchProductResponse response = new SearchProductResponse();
// response.products = Lists.newArrayList();
// return response;
// }
//
// @LimitRate("product")
// @Override
// public Optional<ProductView> get(String id) {
// ActionLogContext.put("pid", id);
// return productService.get(id);
// }
//
// @Override
// public void create(CreateProductRequest request) {
// productService.create(request);
// }
//
// @Override
// public void update(String id, UpdateProductRequest request) {
// productService.update(id, request);
// }
// }
// Path: demo-service/src/main/java/app/ProductModule.java
import app.demo.api.ProductWebService;
import app.demo.api.product.ProductView;
import app.demo.api.product.kafka.ProductUpdatedMessage;
import app.demo.product.kafka.ProductUpdatedMessageHandler;
import app.demo.product.service.ProductService;
import app.demo.product.web.ProductUpdatedMessageTestController;
import app.demo.product.web.ProductWebServiceImpl;
import core.framework.http.HTTPClient;
import core.framework.module.Module;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import static core.framework.http.HTTPMethod.GET;
package app;
/**
* @author neo
*/
public class ProductModule extends Module {
@Override
protected void initialize() {
bind(HTTPClient.class, HTTPClient.builder().build());
| cache().add(ProductView.class, Duration.ofHours(2)).local(); |
neowu/core-ng-demo-project | demo-service/src/main/java/app/ProductModule.java | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/kafka/ProductUpdatedMessage.java
// public class ProductUpdatedMessage {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotBlank
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String desc;
// }
//
// Path: demo-service/src/main/java/app/demo/product/kafka/ProductUpdatedMessageHandler.java
// public class ProductUpdatedMessageHandler implements MessageHandler<ProductUpdatedMessage> {
// private final Logger logger = LoggerFactory.getLogger(ProductUpdatedMessageHandler.class);
//
// @Override
// public void handle(String key, ProductUpdatedMessage messages) {
// logger.debug("{}-{}", key, messages.name);
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductUpdatedMessageTestController.java
// public class ProductUpdatedMessageTestController implements Controller {
// @Inject
// MessagePublisher<ProductUpdatedMessage> publisher;
//
// @Override
// public Response execute(Request request) {
// ActionLogContext.triggerTrace(true);
// for (int i = 0; i < 10; i++) {
// ProductUpdatedMessage value = new ProductUpdatedMessage();
// value.id = String.valueOf(i);
// value.name = "name-" + i;
// publisher.publish(value.id, value);
// }
// return Response.empty();
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
// public class ProductWebServiceImpl implements ProductWebService {
// @Inject
// ProductService productService;
//
// @Override
// public SearchProductResponse search(SearchProductRequest request) {
// SearchProductResponse response = new SearchProductResponse();
// response.products = Lists.newArrayList();
// return response;
// }
//
// @LimitRate("product")
// @Override
// public Optional<ProductView> get(String id) {
// ActionLogContext.put("pid", id);
// return productService.get(id);
// }
//
// @Override
// public void create(CreateProductRequest request) {
// productService.create(request);
// }
//
// @Override
// public void update(String id, UpdateProductRequest request) {
// productService.update(id, request);
// }
// }
| import app.demo.api.ProductWebService;
import app.demo.api.product.ProductView;
import app.demo.api.product.kafka.ProductUpdatedMessage;
import app.demo.product.kafka.ProductUpdatedMessageHandler;
import app.demo.product.service.ProductService;
import app.demo.product.web.ProductUpdatedMessageTestController;
import app.demo.product.web.ProductWebServiceImpl;
import core.framework.http.HTTPClient;
import core.framework.module.Module;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import static core.framework.http.HTTPMethod.GET; | package app;
/**
* @author neo
*/
public class ProductModule extends Module {
@Override
protected void initialize() {
bind(HTTPClient.class, HTTPClient.builder().build());
cache().add(ProductView.class, Duration.ofHours(2)).local();
| // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/kafka/ProductUpdatedMessage.java
// public class ProductUpdatedMessage {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotBlank
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String desc;
// }
//
// Path: demo-service/src/main/java/app/demo/product/kafka/ProductUpdatedMessageHandler.java
// public class ProductUpdatedMessageHandler implements MessageHandler<ProductUpdatedMessage> {
// private final Logger logger = LoggerFactory.getLogger(ProductUpdatedMessageHandler.class);
//
// @Override
// public void handle(String key, ProductUpdatedMessage messages) {
// logger.debug("{}-{}", key, messages.name);
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductUpdatedMessageTestController.java
// public class ProductUpdatedMessageTestController implements Controller {
// @Inject
// MessagePublisher<ProductUpdatedMessage> publisher;
//
// @Override
// public Response execute(Request request) {
// ActionLogContext.triggerTrace(true);
// for (int i = 0; i < 10; i++) {
// ProductUpdatedMessage value = new ProductUpdatedMessage();
// value.id = String.valueOf(i);
// value.name = "name-" + i;
// publisher.publish(value.id, value);
// }
// return Response.empty();
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
// public class ProductWebServiceImpl implements ProductWebService {
// @Inject
// ProductService productService;
//
// @Override
// public SearchProductResponse search(SearchProductRequest request) {
// SearchProductResponse response = new SearchProductResponse();
// response.products = Lists.newArrayList();
// return response;
// }
//
// @LimitRate("product")
// @Override
// public Optional<ProductView> get(String id) {
// ActionLogContext.put("pid", id);
// return productService.get(id);
// }
//
// @Override
// public void create(CreateProductRequest request) {
// productService.create(request);
// }
//
// @Override
// public void update(String id, UpdateProductRequest request) {
// productService.update(id, request);
// }
// }
// Path: demo-service/src/main/java/app/ProductModule.java
import app.demo.api.ProductWebService;
import app.demo.api.product.ProductView;
import app.demo.api.product.kafka.ProductUpdatedMessage;
import app.demo.product.kafka.ProductUpdatedMessageHandler;
import app.demo.product.service.ProductService;
import app.demo.product.web.ProductUpdatedMessageTestController;
import app.demo.product.web.ProductWebServiceImpl;
import core.framework.http.HTTPClient;
import core.framework.module.Module;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import static core.framework.http.HTTPMethod.GET;
package app;
/**
* @author neo
*/
public class ProductModule extends Module {
@Override
protected void initialize() {
bind(HTTPClient.class, HTTPClient.builder().build());
cache().add(ProductView.class, Duration.ofHours(2)).local();
| bind(ProductService.class); |
neowu/core-ng-demo-project | demo-service/src/main/java/app/ProductModule.java | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/kafka/ProductUpdatedMessage.java
// public class ProductUpdatedMessage {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotBlank
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String desc;
// }
//
// Path: demo-service/src/main/java/app/demo/product/kafka/ProductUpdatedMessageHandler.java
// public class ProductUpdatedMessageHandler implements MessageHandler<ProductUpdatedMessage> {
// private final Logger logger = LoggerFactory.getLogger(ProductUpdatedMessageHandler.class);
//
// @Override
// public void handle(String key, ProductUpdatedMessage messages) {
// logger.debug("{}-{}", key, messages.name);
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductUpdatedMessageTestController.java
// public class ProductUpdatedMessageTestController implements Controller {
// @Inject
// MessagePublisher<ProductUpdatedMessage> publisher;
//
// @Override
// public Response execute(Request request) {
// ActionLogContext.triggerTrace(true);
// for (int i = 0; i < 10; i++) {
// ProductUpdatedMessage value = new ProductUpdatedMessage();
// value.id = String.valueOf(i);
// value.name = "name-" + i;
// publisher.publish(value.id, value);
// }
// return Response.empty();
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
// public class ProductWebServiceImpl implements ProductWebService {
// @Inject
// ProductService productService;
//
// @Override
// public SearchProductResponse search(SearchProductRequest request) {
// SearchProductResponse response = new SearchProductResponse();
// response.products = Lists.newArrayList();
// return response;
// }
//
// @LimitRate("product")
// @Override
// public Optional<ProductView> get(String id) {
// ActionLogContext.put("pid", id);
// return productService.get(id);
// }
//
// @Override
// public void create(CreateProductRequest request) {
// productService.create(request);
// }
//
// @Override
// public void update(String id, UpdateProductRequest request) {
// productService.update(id, request);
// }
// }
| import app.demo.api.ProductWebService;
import app.demo.api.product.ProductView;
import app.demo.api.product.kafka.ProductUpdatedMessage;
import app.demo.product.kafka.ProductUpdatedMessageHandler;
import app.demo.product.service.ProductService;
import app.demo.product.web.ProductUpdatedMessageTestController;
import app.demo.product.web.ProductWebServiceImpl;
import core.framework.http.HTTPClient;
import core.framework.module.Module;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import static core.framework.http.HTTPMethod.GET; | package app;
/**
* @author neo
*/
public class ProductModule extends Module {
@Override
protected void initialize() {
bind(HTTPClient.class, HTTPClient.builder().build());
cache().add(ProductView.class, Duration.ofHours(2)).local();
bind(ProductService.class);
// configureKafka();
| // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/kafka/ProductUpdatedMessage.java
// public class ProductUpdatedMessage {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotBlank
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String desc;
// }
//
// Path: demo-service/src/main/java/app/demo/product/kafka/ProductUpdatedMessageHandler.java
// public class ProductUpdatedMessageHandler implements MessageHandler<ProductUpdatedMessage> {
// private final Logger logger = LoggerFactory.getLogger(ProductUpdatedMessageHandler.class);
//
// @Override
// public void handle(String key, ProductUpdatedMessage messages) {
// logger.debug("{}-{}", key, messages.name);
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductUpdatedMessageTestController.java
// public class ProductUpdatedMessageTestController implements Controller {
// @Inject
// MessagePublisher<ProductUpdatedMessage> publisher;
//
// @Override
// public Response execute(Request request) {
// ActionLogContext.triggerTrace(true);
// for (int i = 0; i < 10; i++) {
// ProductUpdatedMessage value = new ProductUpdatedMessage();
// value.id = String.valueOf(i);
// value.name = "name-" + i;
// publisher.publish(value.id, value);
// }
// return Response.empty();
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
// public class ProductWebServiceImpl implements ProductWebService {
// @Inject
// ProductService productService;
//
// @Override
// public SearchProductResponse search(SearchProductRequest request) {
// SearchProductResponse response = new SearchProductResponse();
// response.products = Lists.newArrayList();
// return response;
// }
//
// @LimitRate("product")
// @Override
// public Optional<ProductView> get(String id) {
// ActionLogContext.put("pid", id);
// return productService.get(id);
// }
//
// @Override
// public void create(CreateProductRequest request) {
// productService.create(request);
// }
//
// @Override
// public void update(String id, UpdateProductRequest request) {
// productService.update(id, request);
// }
// }
// Path: demo-service/src/main/java/app/ProductModule.java
import app.demo.api.ProductWebService;
import app.demo.api.product.ProductView;
import app.demo.api.product.kafka.ProductUpdatedMessage;
import app.demo.product.kafka.ProductUpdatedMessageHandler;
import app.demo.product.service.ProductService;
import app.demo.product.web.ProductUpdatedMessageTestController;
import app.demo.product.web.ProductWebServiceImpl;
import core.framework.http.HTTPClient;
import core.framework.module.Module;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import static core.framework.http.HTTPMethod.GET;
package app;
/**
* @author neo
*/
public class ProductModule extends Module {
@Override
protected void initialize() {
bind(HTTPClient.class, HTTPClient.builder().build());
cache().add(ProductView.class, Duration.ofHours(2)).local();
bind(ProductService.class);
// configureKafka();
| api().service(ProductWebService.class, bind(ProductWebServiceImpl.class)); |
neowu/core-ng-demo-project | demo-service/src/main/java/app/ProductModule.java | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/kafka/ProductUpdatedMessage.java
// public class ProductUpdatedMessage {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotBlank
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String desc;
// }
//
// Path: demo-service/src/main/java/app/demo/product/kafka/ProductUpdatedMessageHandler.java
// public class ProductUpdatedMessageHandler implements MessageHandler<ProductUpdatedMessage> {
// private final Logger logger = LoggerFactory.getLogger(ProductUpdatedMessageHandler.class);
//
// @Override
// public void handle(String key, ProductUpdatedMessage messages) {
// logger.debug("{}-{}", key, messages.name);
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductUpdatedMessageTestController.java
// public class ProductUpdatedMessageTestController implements Controller {
// @Inject
// MessagePublisher<ProductUpdatedMessage> publisher;
//
// @Override
// public Response execute(Request request) {
// ActionLogContext.triggerTrace(true);
// for (int i = 0; i < 10; i++) {
// ProductUpdatedMessage value = new ProductUpdatedMessage();
// value.id = String.valueOf(i);
// value.name = "name-" + i;
// publisher.publish(value.id, value);
// }
// return Response.empty();
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
// public class ProductWebServiceImpl implements ProductWebService {
// @Inject
// ProductService productService;
//
// @Override
// public SearchProductResponse search(SearchProductRequest request) {
// SearchProductResponse response = new SearchProductResponse();
// response.products = Lists.newArrayList();
// return response;
// }
//
// @LimitRate("product")
// @Override
// public Optional<ProductView> get(String id) {
// ActionLogContext.put("pid", id);
// return productService.get(id);
// }
//
// @Override
// public void create(CreateProductRequest request) {
// productService.create(request);
// }
//
// @Override
// public void update(String id, UpdateProductRequest request) {
// productService.update(id, request);
// }
// }
| import app.demo.api.ProductWebService;
import app.demo.api.product.ProductView;
import app.demo.api.product.kafka.ProductUpdatedMessage;
import app.demo.product.kafka.ProductUpdatedMessageHandler;
import app.demo.product.service.ProductService;
import app.demo.product.web.ProductUpdatedMessageTestController;
import app.demo.product.web.ProductWebServiceImpl;
import core.framework.http.HTTPClient;
import core.framework.module.Module;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import static core.framework.http.HTTPMethod.GET; | package app;
/**
* @author neo
*/
public class ProductModule extends Module {
@Override
protected void initialize() {
bind(HTTPClient.class, HTTPClient.builder().build());
cache().add(ProductView.class, Duration.ofHours(2)).local();
bind(ProductService.class);
// configureKafka();
| // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/kafka/ProductUpdatedMessage.java
// public class ProductUpdatedMessage {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotBlank
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String desc;
// }
//
// Path: demo-service/src/main/java/app/demo/product/kafka/ProductUpdatedMessageHandler.java
// public class ProductUpdatedMessageHandler implements MessageHandler<ProductUpdatedMessage> {
// private final Logger logger = LoggerFactory.getLogger(ProductUpdatedMessageHandler.class);
//
// @Override
// public void handle(String key, ProductUpdatedMessage messages) {
// logger.debug("{}-{}", key, messages.name);
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductUpdatedMessageTestController.java
// public class ProductUpdatedMessageTestController implements Controller {
// @Inject
// MessagePublisher<ProductUpdatedMessage> publisher;
//
// @Override
// public Response execute(Request request) {
// ActionLogContext.triggerTrace(true);
// for (int i = 0; i < 10; i++) {
// ProductUpdatedMessage value = new ProductUpdatedMessage();
// value.id = String.valueOf(i);
// value.name = "name-" + i;
// publisher.publish(value.id, value);
// }
// return Response.empty();
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
// public class ProductWebServiceImpl implements ProductWebService {
// @Inject
// ProductService productService;
//
// @Override
// public SearchProductResponse search(SearchProductRequest request) {
// SearchProductResponse response = new SearchProductResponse();
// response.products = Lists.newArrayList();
// return response;
// }
//
// @LimitRate("product")
// @Override
// public Optional<ProductView> get(String id) {
// ActionLogContext.put("pid", id);
// return productService.get(id);
// }
//
// @Override
// public void create(CreateProductRequest request) {
// productService.create(request);
// }
//
// @Override
// public void update(String id, UpdateProductRequest request) {
// productService.update(id, request);
// }
// }
// Path: demo-service/src/main/java/app/ProductModule.java
import app.demo.api.ProductWebService;
import app.demo.api.product.ProductView;
import app.demo.api.product.kafka.ProductUpdatedMessage;
import app.demo.product.kafka.ProductUpdatedMessageHandler;
import app.demo.product.service.ProductService;
import app.demo.product.web.ProductUpdatedMessageTestController;
import app.demo.product.web.ProductWebServiceImpl;
import core.framework.http.HTTPClient;
import core.framework.module.Module;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import static core.framework.http.HTTPMethod.GET;
package app;
/**
* @author neo
*/
public class ProductModule extends Module {
@Override
protected void initialize() {
bind(HTTPClient.class, HTTPClient.builder().build());
cache().add(ProductView.class, Duration.ofHours(2)).local();
bind(ProductService.class);
// configureKafka();
| api().service(ProductWebService.class, bind(ProductWebServiceImpl.class)); |
neowu/core-ng-demo-project | demo-service/src/main/java/app/ProductModule.java | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/kafka/ProductUpdatedMessage.java
// public class ProductUpdatedMessage {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotBlank
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String desc;
// }
//
// Path: demo-service/src/main/java/app/demo/product/kafka/ProductUpdatedMessageHandler.java
// public class ProductUpdatedMessageHandler implements MessageHandler<ProductUpdatedMessage> {
// private final Logger logger = LoggerFactory.getLogger(ProductUpdatedMessageHandler.class);
//
// @Override
// public void handle(String key, ProductUpdatedMessage messages) {
// logger.debug("{}-{}", key, messages.name);
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductUpdatedMessageTestController.java
// public class ProductUpdatedMessageTestController implements Controller {
// @Inject
// MessagePublisher<ProductUpdatedMessage> publisher;
//
// @Override
// public Response execute(Request request) {
// ActionLogContext.triggerTrace(true);
// for (int i = 0; i < 10; i++) {
// ProductUpdatedMessage value = new ProductUpdatedMessage();
// value.id = String.valueOf(i);
// value.name = "name-" + i;
// publisher.publish(value.id, value);
// }
// return Response.empty();
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
// public class ProductWebServiceImpl implements ProductWebService {
// @Inject
// ProductService productService;
//
// @Override
// public SearchProductResponse search(SearchProductRequest request) {
// SearchProductResponse response = new SearchProductResponse();
// response.products = Lists.newArrayList();
// return response;
// }
//
// @LimitRate("product")
// @Override
// public Optional<ProductView> get(String id) {
// ActionLogContext.put("pid", id);
// return productService.get(id);
// }
//
// @Override
// public void create(CreateProductRequest request) {
// productService.create(request);
// }
//
// @Override
// public void update(String id, UpdateProductRequest request) {
// productService.update(id, request);
// }
// }
| import app.demo.api.ProductWebService;
import app.demo.api.product.ProductView;
import app.demo.api.product.kafka.ProductUpdatedMessage;
import app.demo.product.kafka.ProductUpdatedMessageHandler;
import app.demo.product.service.ProductService;
import app.demo.product.web.ProductUpdatedMessageTestController;
import app.demo.product.web.ProductWebServiceImpl;
import core.framework.http.HTTPClient;
import core.framework.module.Module;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import static core.framework.http.HTTPMethod.GET; | package app;
/**
* @author neo
*/
public class ProductModule extends Module {
@Override
protected void initialize() {
bind(HTTPClient.class, HTTPClient.builder().build());
cache().add(ProductView.class, Duration.ofHours(2)).local();
bind(ProductService.class);
// configureKafka();
api().service(ProductWebService.class, bind(ProductWebServiceImpl.class));
http().limitRate()
.add("product", 3, 20, TimeUnit.MINUTES);
}
private void configureKafka() {
kafka().uri("localhost");
| // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/kafka/ProductUpdatedMessage.java
// public class ProductUpdatedMessage {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotBlank
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String desc;
// }
//
// Path: demo-service/src/main/java/app/demo/product/kafka/ProductUpdatedMessageHandler.java
// public class ProductUpdatedMessageHandler implements MessageHandler<ProductUpdatedMessage> {
// private final Logger logger = LoggerFactory.getLogger(ProductUpdatedMessageHandler.class);
//
// @Override
// public void handle(String key, ProductUpdatedMessage messages) {
// logger.debug("{}-{}", key, messages.name);
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductUpdatedMessageTestController.java
// public class ProductUpdatedMessageTestController implements Controller {
// @Inject
// MessagePublisher<ProductUpdatedMessage> publisher;
//
// @Override
// public Response execute(Request request) {
// ActionLogContext.triggerTrace(true);
// for (int i = 0; i < 10; i++) {
// ProductUpdatedMessage value = new ProductUpdatedMessage();
// value.id = String.valueOf(i);
// value.name = "name-" + i;
// publisher.publish(value.id, value);
// }
// return Response.empty();
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
// public class ProductWebServiceImpl implements ProductWebService {
// @Inject
// ProductService productService;
//
// @Override
// public SearchProductResponse search(SearchProductRequest request) {
// SearchProductResponse response = new SearchProductResponse();
// response.products = Lists.newArrayList();
// return response;
// }
//
// @LimitRate("product")
// @Override
// public Optional<ProductView> get(String id) {
// ActionLogContext.put("pid", id);
// return productService.get(id);
// }
//
// @Override
// public void create(CreateProductRequest request) {
// productService.create(request);
// }
//
// @Override
// public void update(String id, UpdateProductRequest request) {
// productService.update(id, request);
// }
// }
// Path: demo-service/src/main/java/app/ProductModule.java
import app.demo.api.ProductWebService;
import app.demo.api.product.ProductView;
import app.demo.api.product.kafka.ProductUpdatedMessage;
import app.demo.product.kafka.ProductUpdatedMessageHandler;
import app.demo.product.service.ProductService;
import app.demo.product.web.ProductUpdatedMessageTestController;
import app.demo.product.web.ProductWebServiceImpl;
import core.framework.http.HTTPClient;
import core.framework.module.Module;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import static core.framework.http.HTTPMethod.GET;
package app;
/**
* @author neo
*/
public class ProductModule extends Module {
@Override
protected void initialize() {
bind(HTTPClient.class, HTTPClient.builder().build());
cache().add(ProductView.class, Duration.ofHours(2)).local();
bind(ProductService.class);
// configureKafka();
api().service(ProductWebService.class, bind(ProductWebServiceImpl.class));
http().limitRate()
.add("product", 3, 20, TimeUnit.MINUTES);
}
private void configureKafka() {
kafka().uri("localhost");
| kafka().subscribe("product-updated", ProductUpdatedMessage.class, bind(ProductUpdatedMessageHandler.class)); |
neowu/core-ng-demo-project | demo-service/src/main/java/app/ProductModule.java | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/kafka/ProductUpdatedMessage.java
// public class ProductUpdatedMessage {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotBlank
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String desc;
// }
//
// Path: demo-service/src/main/java/app/demo/product/kafka/ProductUpdatedMessageHandler.java
// public class ProductUpdatedMessageHandler implements MessageHandler<ProductUpdatedMessage> {
// private final Logger logger = LoggerFactory.getLogger(ProductUpdatedMessageHandler.class);
//
// @Override
// public void handle(String key, ProductUpdatedMessage messages) {
// logger.debug("{}-{}", key, messages.name);
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductUpdatedMessageTestController.java
// public class ProductUpdatedMessageTestController implements Controller {
// @Inject
// MessagePublisher<ProductUpdatedMessage> publisher;
//
// @Override
// public Response execute(Request request) {
// ActionLogContext.triggerTrace(true);
// for (int i = 0; i < 10; i++) {
// ProductUpdatedMessage value = new ProductUpdatedMessage();
// value.id = String.valueOf(i);
// value.name = "name-" + i;
// publisher.publish(value.id, value);
// }
// return Response.empty();
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
// public class ProductWebServiceImpl implements ProductWebService {
// @Inject
// ProductService productService;
//
// @Override
// public SearchProductResponse search(SearchProductRequest request) {
// SearchProductResponse response = new SearchProductResponse();
// response.products = Lists.newArrayList();
// return response;
// }
//
// @LimitRate("product")
// @Override
// public Optional<ProductView> get(String id) {
// ActionLogContext.put("pid", id);
// return productService.get(id);
// }
//
// @Override
// public void create(CreateProductRequest request) {
// productService.create(request);
// }
//
// @Override
// public void update(String id, UpdateProductRequest request) {
// productService.update(id, request);
// }
// }
| import app.demo.api.ProductWebService;
import app.demo.api.product.ProductView;
import app.demo.api.product.kafka.ProductUpdatedMessage;
import app.demo.product.kafka.ProductUpdatedMessageHandler;
import app.demo.product.service.ProductService;
import app.demo.product.web.ProductUpdatedMessageTestController;
import app.demo.product.web.ProductWebServiceImpl;
import core.framework.http.HTTPClient;
import core.framework.module.Module;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import static core.framework.http.HTTPMethod.GET; | package app;
/**
* @author neo
*/
public class ProductModule extends Module {
@Override
protected void initialize() {
bind(HTTPClient.class, HTTPClient.builder().build());
cache().add(ProductView.class, Duration.ofHours(2)).local();
bind(ProductService.class);
// configureKafka();
api().service(ProductWebService.class, bind(ProductWebServiceImpl.class));
http().limitRate()
.add("product", 3, 20, TimeUnit.MINUTES);
}
private void configureKafka() {
kafka().uri("localhost");
| // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/kafka/ProductUpdatedMessage.java
// public class ProductUpdatedMessage {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotBlank
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String desc;
// }
//
// Path: demo-service/src/main/java/app/demo/product/kafka/ProductUpdatedMessageHandler.java
// public class ProductUpdatedMessageHandler implements MessageHandler<ProductUpdatedMessage> {
// private final Logger logger = LoggerFactory.getLogger(ProductUpdatedMessageHandler.class);
//
// @Override
// public void handle(String key, ProductUpdatedMessage messages) {
// logger.debug("{}-{}", key, messages.name);
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductUpdatedMessageTestController.java
// public class ProductUpdatedMessageTestController implements Controller {
// @Inject
// MessagePublisher<ProductUpdatedMessage> publisher;
//
// @Override
// public Response execute(Request request) {
// ActionLogContext.triggerTrace(true);
// for (int i = 0; i < 10; i++) {
// ProductUpdatedMessage value = new ProductUpdatedMessage();
// value.id = String.valueOf(i);
// value.name = "name-" + i;
// publisher.publish(value.id, value);
// }
// return Response.empty();
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
// public class ProductWebServiceImpl implements ProductWebService {
// @Inject
// ProductService productService;
//
// @Override
// public SearchProductResponse search(SearchProductRequest request) {
// SearchProductResponse response = new SearchProductResponse();
// response.products = Lists.newArrayList();
// return response;
// }
//
// @LimitRate("product")
// @Override
// public Optional<ProductView> get(String id) {
// ActionLogContext.put("pid", id);
// return productService.get(id);
// }
//
// @Override
// public void create(CreateProductRequest request) {
// productService.create(request);
// }
//
// @Override
// public void update(String id, UpdateProductRequest request) {
// productService.update(id, request);
// }
// }
// Path: demo-service/src/main/java/app/ProductModule.java
import app.demo.api.ProductWebService;
import app.demo.api.product.ProductView;
import app.demo.api.product.kafka.ProductUpdatedMessage;
import app.demo.product.kafka.ProductUpdatedMessageHandler;
import app.demo.product.service.ProductService;
import app.demo.product.web.ProductUpdatedMessageTestController;
import app.demo.product.web.ProductWebServiceImpl;
import core.framework.http.HTTPClient;
import core.framework.module.Module;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import static core.framework.http.HTTPMethod.GET;
package app;
/**
* @author neo
*/
public class ProductModule extends Module {
@Override
protected void initialize() {
bind(HTTPClient.class, HTTPClient.builder().build());
cache().add(ProductView.class, Duration.ofHours(2)).local();
bind(ProductService.class);
// configureKafka();
api().service(ProductWebService.class, bind(ProductWebServiceImpl.class));
http().limitRate()
.add("product", 3, 20, TimeUnit.MINUTES);
}
private void configureKafka() {
kafka().uri("localhost");
| kafka().subscribe("product-updated", ProductUpdatedMessage.class, bind(ProductUpdatedMessageHandler.class)); |
neowu/core-ng-demo-project | demo-service/src/main/java/app/ProductModule.java | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/kafka/ProductUpdatedMessage.java
// public class ProductUpdatedMessage {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotBlank
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String desc;
// }
//
// Path: demo-service/src/main/java/app/demo/product/kafka/ProductUpdatedMessageHandler.java
// public class ProductUpdatedMessageHandler implements MessageHandler<ProductUpdatedMessage> {
// private final Logger logger = LoggerFactory.getLogger(ProductUpdatedMessageHandler.class);
//
// @Override
// public void handle(String key, ProductUpdatedMessage messages) {
// logger.debug("{}-{}", key, messages.name);
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductUpdatedMessageTestController.java
// public class ProductUpdatedMessageTestController implements Controller {
// @Inject
// MessagePublisher<ProductUpdatedMessage> publisher;
//
// @Override
// public Response execute(Request request) {
// ActionLogContext.triggerTrace(true);
// for (int i = 0; i < 10; i++) {
// ProductUpdatedMessage value = new ProductUpdatedMessage();
// value.id = String.valueOf(i);
// value.name = "name-" + i;
// publisher.publish(value.id, value);
// }
// return Response.empty();
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
// public class ProductWebServiceImpl implements ProductWebService {
// @Inject
// ProductService productService;
//
// @Override
// public SearchProductResponse search(SearchProductRequest request) {
// SearchProductResponse response = new SearchProductResponse();
// response.products = Lists.newArrayList();
// return response;
// }
//
// @LimitRate("product")
// @Override
// public Optional<ProductView> get(String id) {
// ActionLogContext.put("pid", id);
// return productService.get(id);
// }
//
// @Override
// public void create(CreateProductRequest request) {
// productService.create(request);
// }
//
// @Override
// public void update(String id, UpdateProductRequest request) {
// productService.update(id, request);
// }
// }
| import app.demo.api.ProductWebService;
import app.demo.api.product.ProductView;
import app.demo.api.product.kafka.ProductUpdatedMessage;
import app.demo.product.kafka.ProductUpdatedMessageHandler;
import app.demo.product.service.ProductService;
import app.demo.product.web.ProductUpdatedMessageTestController;
import app.demo.product.web.ProductWebServiceImpl;
import core.framework.http.HTTPClient;
import core.framework.module.Module;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import static core.framework.http.HTTPMethod.GET; | package app;
/**
* @author neo
*/
public class ProductModule extends Module {
@Override
protected void initialize() {
bind(HTTPClient.class, HTTPClient.builder().build());
cache().add(ProductView.class, Duration.ofHours(2)).local();
bind(ProductService.class);
// configureKafka();
api().service(ProductWebService.class, bind(ProductWebServiceImpl.class));
http().limitRate()
.add("product", 3, 20, TimeUnit.MINUTES);
}
private void configureKafka() {
kafka().uri("localhost");
kafka().subscribe("product-updated", ProductUpdatedMessage.class, bind(ProductUpdatedMessageHandler.class));
kafka().poolSize(2);
kafka().publish("product-updated", ProductUpdatedMessage.class); | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/kafka/ProductUpdatedMessage.java
// public class ProductUpdatedMessage {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotBlank
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String desc;
// }
//
// Path: demo-service/src/main/java/app/demo/product/kafka/ProductUpdatedMessageHandler.java
// public class ProductUpdatedMessageHandler implements MessageHandler<ProductUpdatedMessage> {
// private final Logger logger = LoggerFactory.getLogger(ProductUpdatedMessageHandler.class);
//
// @Override
// public void handle(String key, ProductUpdatedMessage messages) {
// logger.debug("{}-{}", key, messages.name);
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductUpdatedMessageTestController.java
// public class ProductUpdatedMessageTestController implements Controller {
// @Inject
// MessagePublisher<ProductUpdatedMessage> publisher;
//
// @Override
// public Response execute(Request request) {
// ActionLogContext.triggerTrace(true);
// for (int i = 0; i < 10; i++) {
// ProductUpdatedMessage value = new ProductUpdatedMessage();
// value.id = String.valueOf(i);
// value.name = "name-" + i;
// publisher.publish(value.id, value);
// }
// return Response.empty();
// }
// }
//
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
// public class ProductWebServiceImpl implements ProductWebService {
// @Inject
// ProductService productService;
//
// @Override
// public SearchProductResponse search(SearchProductRequest request) {
// SearchProductResponse response = new SearchProductResponse();
// response.products = Lists.newArrayList();
// return response;
// }
//
// @LimitRate("product")
// @Override
// public Optional<ProductView> get(String id) {
// ActionLogContext.put("pid", id);
// return productService.get(id);
// }
//
// @Override
// public void create(CreateProductRequest request) {
// productService.create(request);
// }
//
// @Override
// public void update(String id, UpdateProductRequest request) {
// productService.update(id, request);
// }
// }
// Path: demo-service/src/main/java/app/ProductModule.java
import app.demo.api.ProductWebService;
import app.demo.api.product.ProductView;
import app.demo.api.product.kafka.ProductUpdatedMessage;
import app.demo.product.kafka.ProductUpdatedMessageHandler;
import app.demo.product.service.ProductService;
import app.demo.product.web.ProductUpdatedMessageTestController;
import app.demo.product.web.ProductWebServiceImpl;
import core.framework.http.HTTPClient;
import core.framework.module.Module;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import static core.framework.http.HTTPMethod.GET;
package app;
/**
* @author neo
*/
public class ProductModule extends Module {
@Override
protected void initialize() {
bind(HTTPClient.class, HTTPClient.builder().build());
cache().add(ProductView.class, Duration.ofHours(2)).local();
bind(ProductService.class);
// configureKafka();
api().service(ProductWebService.class, bind(ProductWebServiceImpl.class));
http().limitRate()
.add("product", 3, 20, TimeUnit.MINUTES);
}
private void configureKafka() {
kafka().uri("localhost");
kafka().subscribe("product-updated", ProductUpdatedMessage.class, bind(ProductUpdatedMessageHandler.class));
kafka().poolSize(2);
kafka().publish("product-updated", ProductUpdatedMessage.class); | http().route(GET, "/kafka-test", bind(ProductUpdatedMessageTestController.class)); |
neowu/core-ng-demo-project | demo-service/src/main/java/app/JobModule.java | // Path: demo-service/src/main/java/app/demo/job/DemoJob.java
// public class DemoJob implements Job {
// private final Logger logger = LoggerFactory.getLogger(DemoJob.class);
//
// @Override
// public void execute(JobContext context) {
// logger.debug("run job, name={}, time={}", context.name, context.scheduledTime);
// }
// }
| import app.demo.job.DemoJob;
import core.framework.module.Module;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.temporal.ChronoUnit; | package app;
/**
* @author neo
*/
public class JobModule extends Module {
@Override
protected void initialize() {
// schedule().timeZone(ZoneId.of("America/Los_Angeles"));
| // Path: demo-service/src/main/java/app/demo/job/DemoJob.java
// public class DemoJob implements Job {
// private final Logger logger = LoggerFactory.getLogger(DemoJob.class);
//
// @Override
// public void execute(JobContext context) {
// logger.debug("run job, name={}, time={}", context.name, context.scheduledTime);
// }
// }
// Path: demo-service/src/main/java/app/JobModule.java
import app.demo.job.DemoJob;
import core.framework.module.Module;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
package app;
/**
* @author neo
*/
public class JobModule extends Module {
@Override
protected void initialize() {
// schedule().timeZone(ZoneId.of("America/Los_Angeles"));
| DemoJob job = bind(DemoJob.class); |
neowu/core-ng-demo-project | kibana-generator/src/main/java/core/kibana/KibanaObject.java | // Path: kibana-generator/src/main/java/core/util/JSON.java
// public class JSON {
// private static final ObjectMapper OBJECT_MAPPER = createObjectMapper();
//
// private static ObjectMapper createObjectMapper() {
// return JsonMapper.builder()
// .defaultDateFormat(new StdDateFormat())
// .serializationInclusion(JsonInclude.Include.NON_NULL)
// // .enable(SerializationFeature.INDENT_OUTPUT)
// .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
// .deactivateDefaultTyping()
// .build();
// }
//
// public static String toJSON(Object instance) {
// try {
// return OBJECT_MAPPER.writeValueAsString(instance);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
// }
| import core.util.JSON; | package core.kibana;
/**
* @author neo
*/
public class KibanaObject {
static KibanaObject visualization(TSVB tsvb) {
var visualization = new KibanaObject();
visualization.id = tsvb.title;
visualization.type = "visualization";
visualization.attributes.title = tsvb.title; | // Path: kibana-generator/src/main/java/core/util/JSON.java
// public class JSON {
// private static final ObjectMapper OBJECT_MAPPER = createObjectMapper();
//
// private static ObjectMapper createObjectMapper() {
// return JsonMapper.builder()
// .defaultDateFormat(new StdDateFormat())
// .serializationInclusion(JsonInclude.Include.NON_NULL)
// // .enable(SerializationFeature.INDENT_OUTPUT)
// .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
// .deactivateDefaultTyping()
// .build();
// }
//
// public static String toJSON(Object instance) {
// try {
// return OBJECT_MAPPER.writeValueAsString(instance);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
// }
// Path: kibana-generator/src/main/java/core/kibana/KibanaObject.java
import core.util.JSON;
package core.kibana;
/**
* @author neo
*/
public class KibanaObject {
static KibanaObject visualization(TSVB tsvb) {
var visualization = new KibanaObject();
visualization.id = tsvb.title;
visualization.type = "visualization";
visualization.attributes.title = tsvb.title; | visualization.attributes.visState = JSON.toJSON(tsvb); |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/customer/web/CustomerWebServiceImpl.java | // Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
// public interface CustomerWebService {
// @GET
// @Path("/customer/:id")
// CustomerView get(@PathParam("id") Long id);
//
// @POST
// @Path("/customer")
// @ResponseStatus(HTTPStatus.CREATED)
// CustomerView create(CreateCustomerRequest request);
//
// @PUT
// @Path("/customer/:id")
// CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
//
// @GET
// @Path("/customer")
// SearchCustomerResponse search(SearchCustomerRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
// public class CustomerService {
// @Inject
// Repository<Customer> customerRepository;
//
// public CustomerView get(Long id) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// return view(customer);
// }
//
// public CustomerView create(CreateCustomerRequest request) {
// Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
// if (existingCustomer.isPresent()) {
// throw new ConflictException("customer already exists, email=" + request.email);
// }
//
// Customer customer = new Customer();
// customer.status = CustomerStatus.ACTIVE;
// customer.email = request.email;
// customer.firstName = request.firstName;
// customer.lastName = request.lastName;
// customer.updatedTime = LocalDateTime.now();
// customer.id = customerRepository.insert(customer).orElseThrow();
//
// return view(customer);
// }
//
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// customer.updatedTime = LocalDateTime.now();
// customer.firstName = request.firstName;
// if (request.lastName != null) {
// customer.lastName = request.lastName;
// }
// customerRepository.partialUpdate(customer);
// return view(customer);
// }
//
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// SearchCustomerResponse result = new SearchCustomerResponse();
// Query<Customer> query = customerRepository.select();
// query.skip(request.skip);
// query.limit(request.limit);
// if (!Strings.isBlank(request.email)) {
// query.where("email = ?", request.email);
// }
// if (!Strings.isBlank(request.firstName)) {
// query.where("first_name like ?", Strings.format("{}%", request.firstName));
// }
// if (!Strings.isBlank(request.lastName)) {
// query.where("last_name like ?", Strings.format("{}%", request.lastName));
// }
// result.customers = query.fetch().stream().map(this::view).collect(Collectors.toList());
// result.total = query.count();
//
// return result;
// }
//
// private CustomerView view(Customer customer) {
// CustomerView result = new CustomerView();
// result.id = customer.id;
// result.email = customer.email;
// result.firstName = customer.firstName;
// result.lastName = customer.lastName;
// result.updatedTime = customer.updatedTime;
// return result;
// }
// }
| import app.demo.api.CustomerWebService;
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.service.CustomerService;
import core.framework.inject.Inject; | package app.demo.customer.web;
public class CustomerWebServiceImpl implements CustomerWebService {
@Inject | // Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
// public interface CustomerWebService {
// @GET
// @Path("/customer/:id")
// CustomerView get(@PathParam("id") Long id);
//
// @POST
// @Path("/customer")
// @ResponseStatus(HTTPStatus.CREATED)
// CustomerView create(CreateCustomerRequest request);
//
// @PUT
// @Path("/customer/:id")
// CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
//
// @GET
// @Path("/customer")
// SearchCustomerResponse search(SearchCustomerRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
// public class CustomerService {
// @Inject
// Repository<Customer> customerRepository;
//
// public CustomerView get(Long id) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// return view(customer);
// }
//
// public CustomerView create(CreateCustomerRequest request) {
// Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
// if (existingCustomer.isPresent()) {
// throw new ConflictException("customer already exists, email=" + request.email);
// }
//
// Customer customer = new Customer();
// customer.status = CustomerStatus.ACTIVE;
// customer.email = request.email;
// customer.firstName = request.firstName;
// customer.lastName = request.lastName;
// customer.updatedTime = LocalDateTime.now();
// customer.id = customerRepository.insert(customer).orElseThrow();
//
// return view(customer);
// }
//
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// customer.updatedTime = LocalDateTime.now();
// customer.firstName = request.firstName;
// if (request.lastName != null) {
// customer.lastName = request.lastName;
// }
// customerRepository.partialUpdate(customer);
// return view(customer);
// }
//
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// SearchCustomerResponse result = new SearchCustomerResponse();
// Query<Customer> query = customerRepository.select();
// query.skip(request.skip);
// query.limit(request.limit);
// if (!Strings.isBlank(request.email)) {
// query.where("email = ?", request.email);
// }
// if (!Strings.isBlank(request.firstName)) {
// query.where("first_name like ?", Strings.format("{}%", request.firstName));
// }
// if (!Strings.isBlank(request.lastName)) {
// query.where("last_name like ?", Strings.format("{}%", request.lastName));
// }
// result.customers = query.fetch().stream().map(this::view).collect(Collectors.toList());
// result.total = query.count();
//
// return result;
// }
//
// private CustomerView view(Customer customer) {
// CustomerView result = new CustomerView();
// result.id = customer.id;
// result.email = customer.email;
// result.firstName = customer.firstName;
// result.lastName = customer.lastName;
// result.updatedTime = customer.updatedTime;
// return result;
// }
// }
// Path: demo-service/src/main/java/app/demo/customer/web/CustomerWebServiceImpl.java
import app.demo.api.CustomerWebService;
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.service.CustomerService;
import core.framework.inject.Inject;
package app.demo.customer.web;
public class CustomerWebServiceImpl implements CustomerWebService {
@Inject | CustomerService customerService; |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/customer/web/CustomerWebServiceImpl.java | // Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
// public interface CustomerWebService {
// @GET
// @Path("/customer/:id")
// CustomerView get(@PathParam("id") Long id);
//
// @POST
// @Path("/customer")
// @ResponseStatus(HTTPStatus.CREATED)
// CustomerView create(CreateCustomerRequest request);
//
// @PUT
// @Path("/customer/:id")
// CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
//
// @GET
// @Path("/customer")
// SearchCustomerResponse search(SearchCustomerRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
// public class CustomerService {
// @Inject
// Repository<Customer> customerRepository;
//
// public CustomerView get(Long id) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// return view(customer);
// }
//
// public CustomerView create(CreateCustomerRequest request) {
// Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
// if (existingCustomer.isPresent()) {
// throw new ConflictException("customer already exists, email=" + request.email);
// }
//
// Customer customer = new Customer();
// customer.status = CustomerStatus.ACTIVE;
// customer.email = request.email;
// customer.firstName = request.firstName;
// customer.lastName = request.lastName;
// customer.updatedTime = LocalDateTime.now();
// customer.id = customerRepository.insert(customer).orElseThrow();
//
// return view(customer);
// }
//
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// customer.updatedTime = LocalDateTime.now();
// customer.firstName = request.firstName;
// if (request.lastName != null) {
// customer.lastName = request.lastName;
// }
// customerRepository.partialUpdate(customer);
// return view(customer);
// }
//
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// SearchCustomerResponse result = new SearchCustomerResponse();
// Query<Customer> query = customerRepository.select();
// query.skip(request.skip);
// query.limit(request.limit);
// if (!Strings.isBlank(request.email)) {
// query.where("email = ?", request.email);
// }
// if (!Strings.isBlank(request.firstName)) {
// query.where("first_name like ?", Strings.format("{}%", request.firstName));
// }
// if (!Strings.isBlank(request.lastName)) {
// query.where("last_name like ?", Strings.format("{}%", request.lastName));
// }
// result.customers = query.fetch().stream().map(this::view).collect(Collectors.toList());
// result.total = query.count();
//
// return result;
// }
//
// private CustomerView view(Customer customer) {
// CustomerView result = new CustomerView();
// result.id = customer.id;
// result.email = customer.email;
// result.firstName = customer.firstName;
// result.lastName = customer.lastName;
// result.updatedTime = customer.updatedTime;
// return result;
// }
// }
| import app.demo.api.CustomerWebService;
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.service.CustomerService;
import core.framework.inject.Inject; | package app.demo.customer.web;
public class CustomerWebServiceImpl implements CustomerWebService {
@Inject
CustomerService customerService;
@Override | // Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
// public interface CustomerWebService {
// @GET
// @Path("/customer/:id")
// CustomerView get(@PathParam("id") Long id);
//
// @POST
// @Path("/customer")
// @ResponseStatus(HTTPStatus.CREATED)
// CustomerView create(CreateCustomerRequest request);
//
// @PUT
// @Path("/customer/:id")
// CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
//
// @GET
// @Path("/customer")
// SearchCustomerResponse search(SearchCustomerRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
// public class CustomerService {
// @Inject
// Repository<Customer> customerRepository;
//
// public CustomerView get(Long id) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// return view(customer);
// }
//
// public CustomerView create(CreateCustomerRequest request) {
// Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
// if (existingCustomer.isPresent()) {
// throw new ConflictException("customer already exists, email=" + request.email);
// }
//
// Customer customer = new Customer();
// customer.status = CustomerStatus.ACTIVE;
// customer.email = request.email;
// customer.firstName = request.firstName;
// customer.lastName = request.lastName;
// customer.updatedTime = LocalDateTime.now();
// customer.id = customerRepository.insert(customer).orElseThrow();
//
// return view(customer);
// }
//
// public CustomerView update(Long id, UpdateCustomerRequest request) {
// Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
// customer.updatedTime = LocalDateTime.now();
// customer.firstName = request.firstName;
// if (request.lastName != null) {
// customer.lastName = request.lastName;
// }
// customerRepository.partialUpdate(customer);
// return view(customer);
// }
//
// public SearchCustomerResponse search(SearchCustomerRequest request) {
// SearchCustomerResponse result = new SearchCustomerResponse();
// Query<Customer> query = customerRepository.select();
// query.skip(request.skip);
// query.limit(request.limit);
// if (!Strings.isBlank(request.email)) {
// query.where("email = ?", request.email);
// }
// if (!Strings.isBlank(request.firstName)) {
// query.where("first_name like ?", Strings.format("{}%", request.firstName));
// }
// if (!Strings.isBlank(request.lastName)) {
// query.where("last_name like ?", Strings.format("{}%", request.lastName));
// }
// result.customers = query.fetch().stream().map(this::view).collect(Collectors.toList());
// result.total = query.count();
//
// return result;
// }
//
// private CustomerView view(Customer customer) {
// CustomerView result = new CustomerView();
// result.id = customer.id;
// result.email = customer.email;
// result.firstName = customer.firstName;
// result.lastName = customer.lastName;
// result.updatedTime = customer.updatedTime;
// return result;
// }
// }
// Path: demo-service/src/main/java/app/demo/customer/web/CustomerWebServiceImpl.java
import app.demo.api.CustomerWebService;
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.service.CustomerService;
import core.framework.inject.Inject;
package app.demo.customer.web;
public class CustomerWebServiceImpl implements CustomerWebService {
@Inject
CustomerService customerService;
@Override | public CustomerView get(Long id) { |
neowu/core-ng-demo-project | demo-service-interface/src/main/java/app/demo/api/ProductWebService.java | // Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
| import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.PATCH;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus;
import java.util.Optional; | package app.demo.api;
/**
* @author neo
*/
public interface ProductWebService {
@GET
@Path("/product") | // Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
// Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.PATCH;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus;
import java.util.Optional;
package app.demo.api;
/**
* @author neo
*/
public interface ProductWebService {
@GET
@Path("/product") | SearchProductResponse search(SearchProductRequest request); |
neowu/core-ng-demo-project | demo-service-interface/src/main/java/app/demo/api/ProductWebService.java | // Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
| import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.PATCH;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus;
import java.util.Optional; | package app.demo.api;
/**
* @author neo
*/
public interface ProductWebService {
@GET
@Path("/product") | // Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
// Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.PATCH;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus;
import java.util.Optional;
package app.demo.api;
/**
* @author neo
*/
public interface ProductWebService {
@GET
@Path("/product") | SearchProductResponse search(SearchProductRequest request); |
neowu/core-ng-demo-project | demo-service-interface/src/main/java/app/demo/api/ProductWebService.java | // Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
| import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.PATCH;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus;
import java.util.Optional; | package app.demo.api;
/**
* @author neo
*/
public interface ProductWebService {
@GET
@Path("/product")
SearchProductResponse search(SearchProductRequest request);
@GET
@Path("/product/:id") | // Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
// Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.PATCH;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus;
import java.util.Optional;
package app.demo.api;
/**
* @author neo
*/
public interface ProductWebService {
@GET
@Path("/product")
SearchProductResponse search(SearchProductRequest request);
@GET
@Path("/product/:id") | Optional<ProductView> get(@PathParam("id") String id); |
neowu/core-ng-demo-project | demo-service-interface/src/main/java/app/demo/api/ProductWebService.java | // Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
| import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.PATCH;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus;
import java.util.Optional; | package app.demo.api;
/**
* @author neo
*/
public interface ProductWebService {
@GET
@Path("/product")
SearchProductResponse search(SearchProductRequest request);
@GET
@Path("/product/:id")
Optional<ProductView> get(@PathParam("id") String id);
@POST
@Path("/product")
@ResponseStatus(HTTPStatus.CREATED) | // Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
// Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.PATCH;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus;
import java.util.Optional;
package app.demo.api;
/**
* @author neo
*/
public interface ProductWebService {
@GET
@Path("/product")
SearchProductResponse search(SearchProductRequest request);
@GET
@Path("/product/:id")
Optional<ProductView> get(@PathParam("id") String id);
@POST
@Path("/product")
@ResponseStatus(HTTPStatus.CREATED) | void create(CreateProductRequest request); |
neowu/core-ng-demo-project | demo-service-interface/src/main/java/app/demo/api/ProductWebService.java | // Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
| import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.PATCH;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus;
import java.util.Optional; | package app.demo.api;
/**
* @author neo
*/
public interface ProductWebService {
@GET
@Path("/product")
SearchProductResponse search(SearchProductRequest request);
@GET
@Path("/product/:id")
Optional<ProductView> get(@PathParam("id") String id);
@POST
@Path("/product")
@ResponseStatus(HTTPStatus.CREATED)
void create(CreateProductRequest request);
@PATCH
@Path("/product/:id") | // Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
// Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import core.framework.api.http.HTTPStatus;
import core.framework.api.web.service.GET;
import core.framework.api.web.service.PATCH;
import core.framework.api.web.service.POST;
import core.framework.api.web.service.Path;
import core.framework.api.web.service.PathParam;
import core.framework.api.web.service.ResponseStatus;
import java.util.Optional;
package app.demo.api;
/**
* @author neo
*/
public interface ProductWebService {
@GET
@Path("/product")
SearchProductResponse search(SearchProductRequest request);
@GET
@Path("/product/:id")
Optional<ProductView> get(@PathParam("id") String id);
@POST
@Path("/product")
@ResponseStatus(HTTPStatus.CREATED)
void create(CreateProductRequest request);
@PATCH
@Path("/product/:id") | void update(@PathParam("id") String id, UpdateProductRequest request); |
neowu/core-ng-demo-project | kibana-generator/src/main/java/core/kibana/KibanaObjectBuilder.java | // Path: kibana-generator/src/main/java/core/util/JSON.java
// public class JSON {
// private static final ObjectMapper OBJECT_MAPPER = createObjectMapper();
//
// private static ObjectMapper createObjectMapper() {
// return JsonMapper.builder()
// .defaultDateFormat(new StdDateFormat())
// .serializationInclusion(JsonInclude.Include.NON_NULL)
// // .enable(SerializationFeature.INDENT_OUTPUT)
// .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
// .deactivateDefaultTyping()
// .build();
// }
//
// public static String toJSON(Object instance) {
// try {
// return OBJECT_MAPPER.writeValueAsString(instance);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
// }
//
// Path: kibana-generator/src/main/java/core/kibana/KibanaObject.java
// static KibanaObject visualization(TSVB tsvb) {
// var visualization = new KibanaObject();
// visualization.id = tsvb.title;
// visualization.type = "visualization";
// visualization.attributes.title = tsvb.title;
// visualization.attributes.visState = JSON.toJSON(tsvb);
// return visualization;
// }
| import core.util.JSON;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static core.kibana.KibanaObject.visualization; | package core.kibana;
/**
* @author neo
*/
public class KibanaObjectBuilder {
private static final String[] COLOR_PALETTE = new String[]{
"#F94144", "#F3722C", "#F8961E", "#F9844A", "#F9C74F",
"#90BE6D", "#43AA8B", "#4D908E", "#577590", "#277DA1"
};
final List<KibanaObject> objects = new ArrayList<>();
private int colorIndex;
public String build() {
buildVisualization(); | // Path: kibana-generator/src/main/java/core/util/JSON.java
// public class JSON {
// private static final ObjectMapper OBJECT_MAPPER = createObjectMapper();
//
// private static ObjectMapper createObjectMapper() {
// return JsonMapper.builder()
// .defaultDateFormat(new StdDateFormat())
// .serializationInclusion(JsonInclude.Include.NON_NULL)
// // .enable(SerializationFeature.INDENT_OUTPUT)
// .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
// .deactivateDefaultTyping()
// .build();
// }
//
// public static String toJSON(Object instance) {
// try {
// return OBJECT_MAPPER.writeValueAsString(instance);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
// }
//
// Path: kibana-generator/src/main/java/core/kibana/KibanaObject.java
// static KibanaObject visualization(TSVB tsvb) {
// var visualization = new KibanaObject();
// visualization.id = tsvb.title;
// visualization.type = "visualization";
// visualization.attributes.title = tsvb.title;
// visualization.attributes.visState = JSON.toJSON(tsvb);
// return visualization;
// }
// Path: kibana-generator/src/main/java/core/kibana/KibanaObjectBuilder.java
import core.util.JSON;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static core.kibana.KibanaObject.visualization;
package core.kibana;
/**
* @author neo
*/
public class KibanaObjectBuilder {
private static final String[] COLOR_PALETTE = new String[]{
"#F94144", "#F3722C", "#F8961E", "#F9844A", "#F9C74F",
"#90BE6D", "#43AA8B", "#4D908E", "#577590", "#277DA1"
};
final List<KibanaObject> objects = new ArrayList<>();
private int colorIndex;
public String build() {
buildVisualization(); | return JSON.toJSON(objects); |
neowu/core-ng-demo-project | kibana-generator/src/main/java/core/kibana/KibanaObjectBuilder.java | // Path: kibana-generator/src/main/java/core/util/JSON.java
// public class JSON {
// private static final ObjectMapper OBJECT_MAPPER = createObjectMapper();
//
// private static ObjectMapper createObjectMapper() {
// return JsonMapper.builder()
// .defaultDateFormat(new StdDateFormat())
// .serializationInclusion(JsonInclude.Include.NON_NULL)
// // .enable(SerializationFeature.INDENT_OUTPUT)
// .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
// .deactivateDefaultTyping()
// .build();
// }
//
// public static String toJSON(Object instance) {
// try {
// return OBJECT_MAPPER.writeValueAsString(instance);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
// }
//
// Path: kibana-generator/src/main/java/core/kibana/KibanaObject.java
// static KibanaObject visualization(TSVB tsvb) {
// var visualization = new KibanaObject();
// visualization.id = tsvb.title;
// visualization.type = "visualization";
// visualization.attributes.title = tsvb.title;
// visualization.attributes.visState = JSON.toJSON(tsvb);
// return visualization;
// }
| import core.util.JSON;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static core.kibana.KibanaObject.visualization; | package core.kibana;
/**
* @author neo
*/
public class KibanaObjectBuilder {
private static final String[] COLOR_PALETTE = new String[]{
"#F94144", "#F3722C", "#F8961E", "#F9844A", "#F9C74F",
"#90BE6D", "#43AA8B", "#4D908E", "#577590", "#277DA1"
};
final List<KibanaObject> objects = new ArrayList<>();
private int colorIndex;
public String build() {
buildVisualization();
return JSON.toJSON(objects);
}
private void buildVisualization() { | // Path: kibana-generator/src/main/java/core/util/JSON.java
// public class JSON {
// private static final ObjectMapper OBJECT_MAPPER = createObjectMapper();
//
// private static ObjectMapper createObjectMapper() {
// return JsonMapper.builder()
// .defaultDateFormat(new StdDateFormat())
// .serializationInclusion(JsonInclude.Include.NON_NULL)
// // .enable(SerializationFeature.INDENT_OUTPUT)
// .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
// .deactivateDefaultTyping()
// .build();
// }
//
// public static String toJSON(Object instance) {
// try {
// return OBJECT_MAPPER.writeValueAsString(instance);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
// }
//
// Path: kibana-generator/src/main/java/core/kibana/KibanaObject.java
// static KibanaObject visualization(TSVB tsvb) {
// var visualization = new KibanaObject();
// visualization.id = tsvb.title;
// visualization.type = "visualization";
// visualization.attributes.title = tsvb.title;
// visualization.attributes.visState = JSON.toJSON(tsvb);
// return visualization;
// }
// Path: kibana-generator/src/main/java/core/kibana/KibanaObjectBuilder.java
import core.util.JSON;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static core.kibana.KibanaObject.visualization;
package core.kibana;
/**
* @author neo
*/
public class KibanaObjectBuilder {
private static final String[] COLOR_PALETTE = new String[]{
"#F94144", "#F3722C", "#F8961E", "#F9844A", "#F9C74F",
"#90BE6D", "#43AA8B", "#4D908E", "#577590", "#277DA1"
};
final List<KibanaObject> objects = new ArrayList<>();
private int colorIndex;
public String build() {
buildVisualization();
return JSON.toJSON(objects);
}
private void buildVisualization() { | objects.add(visualization(splitByTerm("action-count-by-response_code", "context.response_code"))); |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/product/service/ProductService.java | // Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
| import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.UpdateProductRequest;
import core.framework.cache.Cache;
import core.framework.inject.Inject;
import core.framework.util.Maps;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.Optional; | package app.demo.product.service;
/**
* @author neo
*/
public class ProductService {
private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
@Inject
Cache<ProductView> cache;
public Optional<ProductView> get(String id) {
ProductView view = cache.get(id, products::get);
return Optional.ofNullable(view);
}
| // Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.UpdateProductRequest;
import core.framework.cache.Cache;
import core.framework.inject.Inject;
import core.framework.util.Maps;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.Optional;
package app.demo.product.service;
/**
* @author neo
*/
public class ProductService {
private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
@Inject
Cache<ProductView> cache;
public Optional<ProductView> get(String id) {
ProductView view = cache.get(id, products::get);
return Optional.ofNullable(view);
}
| public void create(CreateProductRequest request) { |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/product/service/ProductService.java | // Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
| import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.UpdateProductRequest;
import core.framework.cache.Cache;
import core.framework.inject.Inject;
import core.framework.util.Maps;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.Optional; | package app.demo.product.service;
/**
* @author neo
*/
public class ProductService {
private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
@Inject
Cache<ProductView> cache;
public Optional<ProductView> get(String id) {
ProductView view = cache.get(id, products::get);
return Optional.ofNullable(view);
}
public void create(CreateProductRequest request) {
ProductView product = new ProductView();
product.id = request.id;
product.name = request.name;
product.description = request.description;
product.createdTime = LocalDateTime.now();
products.put(product.id, product);
}
| // Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.UpdateProductRequest;
import core.framework.cache.Cache;
import core.framework.inject.Inject;
import core.framework.util.Maps;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.Optional;
package app.demo.product.service;
/**
* @author neo
*/
public class ProductService {
private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
@Inject
Cache<ProductView> cache;
public Optional<ProductView> get(String id) {
ProductView view = cache.get(id, products::get);
return Optional.ofNullable(view);
}
public void create(CreateProductRequest request) {
ProductView product = new ProductView();
product.id = request.id;
product.name = request.name;
product.description = request.description;
product.createdTime = LocalDateTime.now();
products.put(product.id, product);
}
| public void update(String id, UpdateProductRequest request) { |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
| import app.demo.api.ProductWebService;
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import app.demo.product.service.ProductService;
import core.framework.inject.Inject;
import core.framework.log.ActionLogContext;
import core.framework.util.Lists;
import core.framework.web.rate.LimitRate;
import java.util.Optional; | package app.demo.product.web;
/**
* @author neo
*/
public class ProductWebServiceImpl implements ProductWebService {
@Inject | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
import app.demo.api.ProductWebService;
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import app.demo.product.service.ProductService;
import core.framework.inject.Inject;
import core.framework.log.ActionLogContext;
import core.framework.util.Lists;
import core.framework.web.rate.LimitRate;
import java.util.Optional;
package app.demo.product.web;
/**
* @author neo
*/
public class ProductWebServiceImpl implements ProductWebService {
@Inject | ProductService productService; |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
| import app.demo.api.ProductWebService;
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import app.demo.product.service.ProductService;
import core.framework.inject.Inject;
import core.framework.log.ActionLogContext;
import core.framework.util.Lists;
import core.framework.web.rate.LimitRate;
import java.util.Optional; | package app.demo.product.web;
/**
* @author neo
*/
public class ProductWebServiceImpl implements ProductWebService {
@Inject
ProductService productService;
@Override | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
import app.demo.api.ProductWebService;
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import app.demo.product.service.ProductService;
import core.framework.inject.Inject;
import core.framework.log.ActionLogContext;
import core.framework.util.Lists;
import core.framework.web.rate.LimitRate;
import java.util.Optional;
package app.demo.product.web;
/**
* @author neo
*/
public class ProductWebServiceImpl implements ProductWebService {
@Inject
ProductService productService;
@Override | public SearchProductResponse search(SearchProductRequest request) { |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
| import app.demo.api.ProductWebService;
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import app.demo.product.service.ProductService;
import core.framework.inject.Inject;
import core.framework.log.ActionLogContext;
import core.framework.util.Lists;
import core.framework.web.rate.LimitRate;
import java.util.Optional; | package app.demo.product.web;
/**
* @author neo
*/
public class ProductWebServiceImpl implements ProductWebService {
@Inject
ProductService productService;
@Override | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
import app.demo.api.ProductWebService;
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import app.demo.product.service.ProductService;
import core.framework.inject.Inject;
import core.framework.log.ActionLogContext;
import core.framework.util.Lists;
import core.framework.web.rate.LimitRate;
import java.util.Optional;
package app.demo.product.web;
/**
* @author neo
*/
public class ProductWebServiceImpl implements ProductWebService {
@Inject
ProductService productService;
@Override | public SearchProductResponse search(SearchProductRequest request) { |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
| import app.demo.api.ProductWebService;
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import app.demo.product.service.ProductService;
import core.framework.inject.Inject;
import core.framework.log.ActionLogContext;
import core.framework.util.Lists;
import core.framework.web.rate.LimitRate;
import java.util.Optional; | package app.demo.product.web;
/**
* @author neo
*/
public class ProductWebServiceImpl implements ProductWebService {
@Inject
ProductService productService;
@Override
public SearchProductResponse search(SearchProductRequest request) {
SearchProductResponse response = new SearchProductResponse();
response.products = Lists.newArrayList();
return response;
}
@LimitRate("product")
@Override | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
import app.demo.api.ProductWebService;
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import app.demo.product.service.ProductService;
import core.framework.inject.Inject;
import core.framework.log.ActionLogContext;
import core.framework.util.Lists;
import core.framework.web.rate.LimitRate;
import java.util.Optional;
package app.demo.product.web;
/**
* @author neo
*/
public class ProductWebServiceImpl implements ProductWebService {
@Inject
ProductService productService;
@Override
public SearchProductResponse search(SearchProductRequest request) {
SearchProductResponse response = new SearchProductResponse();
response.products = Lists.newArrayList();
return response;
}
@LimitRate("product")
@Override | public Optional<ProductView> get(String id) { |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
| import app.demo.api.ProductWebService;
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import app.demo.product.service.ProductService;
import core.framework.inject.Inject;
import core.framework.log.ActionLogContext;
import core.framework.util.Lists;
import core.framework.web.rate.LimitRate;
import java.util.Optional; | package app.demo.product.web;
/**
* @author neo
*/
public class ProductWebServiceImpl implements ProductWebService {
@Inject
ProductService productService;
@Override
public SearchProductResponse search(SearchProductRequest request) {
SearchProductResponse response = new SearchProductResponse();
response.products = Lists.newArrayList();
return response;
}
@LimitRate("product")
@Override
public Optional<ProductView> get(String id) {
ActionLogContext.put("pid", id);
return productService.get(id);
}
@Override | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
import app.demo.api.ProductWebService;
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import app.demo.product.service.ProductService;
import core.framework.inject.Inject;
import core.framework.log.ActionLogContext;
import core.framework.util.Lists;
import core.framework.web.rate.LimitRate;
import java.util.Optional;
package app.demo.product.web;
/**
* @author neo
*/
public class ProductWebServiceImpl implements ProductWebService {
@Inject
ProductService productService;
@Override
public SearchProductResponse search(SearchProductRequest request) {
SearchProductResponse response = new SearchProductResponse();
response.products = Lists.newArrayList();
return response;
}
@LimitRate("product")
@Override
public Optional<ProductView> get(String id) {
ActionLogContext.put("pid", id);
return productService.get(id);
}
@Override | public void create(CreateProductRequest request) { |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
| import app.demo.api.ProductWebService;
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import app.demo.product.service.ProductService;
import core.framework.inject.Inject;
import core.framework.log.ActionLogContext;
import core.framework.util.Lists;
import core.framework.web.rate.LimitRate;
import java.util.Optional; | package app.demo.product.web;
/**
* @author neo
*/
public class ProductWebServiceImpl implements ProductWebService {
@Inject
ProductService productService;
@Override
public SearchProductResponse search(SearchProductRequest request) {
SearchProductResponse response = new SearchProductResponse();
response.products = Lists.newArrayList();
return response;
}
@LimitRate("product")
@Override
public Optional<ProductView> get(String id) {
ActionLogContext.put("pid", id);
return productService.get(id);
}
@Override
public void create(CreateProductRequest request) {
productService.create(request);
}
@Override | // Path: demo-service-interface/src/main/java/app/demo/api/ProductWebService.java
// public interface ProductWebService {
// @GET
// @Path("/product")
// SearchProductResponse search(SearchProductRequest request);
//
// @GET
// @Path("/product/:id")
// Optional<ProductView> get(@PathParam("id") String id);
//
// @POST
// @Path("/product")
// @ResponseStatus(HTTPStatus.CREATED)
// void create(CreateProductRequest request);
//
// @PATCH
// @Path("/product/:id")
// void update(@PathParam("id") String id, UpdateProductRequest request);
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/CreateProductRequest.java
// public class CreateProductRequest {
// @NotNull(message = "id is required")
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/ProductView.java
// public class ProductView {
// @Property(name = "id")
// public String id;
//
// @NotNull(message = "name is required")
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
//
// @Property(name = "created_time")
// public LocalDateTime createdTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductRequest.java
// public class SearchProductRequest {
// @NotNull(message = "name is required")
// @QueryParam(name = "name")
// public String name;
//
// @QueryParam(name = "desc")
// public String description;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/SearchProductResponse.java
// public class SearchProductResponse {
// @Property(name = "products")
// public List<ProductView> products;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/product/UpdateProductRequest.java
// public class UpdateProductRequest {
// @Property(name = "name")
// public String name;
//
// @Property(name = "desc")
// public String description;
// }
//
// Path: demo-service/src/main/java/app/demo/product/service/ProductService.java
// public class ProductService {
// private final Map<String, ProductView> products = Maps.newConcurrentHashMap();
// @Inject
// Cache<ProductView> cache;
//
// public Optional<ProductView> get(String id) {
// ProductView view = cache.get(id, products::get);
// return Optional.ofNullable(view);
// }
//
// public void create(CreateProductRequest request) {
// ProductView product = new ProductView();
// product.id = request.id;
// product.name = request.name;
// product.description = request.description;
// product.createdTime = LocalDateTime.now();
// products.put(product.id, product);
// }
//
// public void update(String id, UpdateProductRequest request) {
// ProductView product = products.get(id);
// if (product == null) throw new NotFoundException("product not found");
// if (request.name != null) product.name = request.name;
// }
// }
// Path: demo-service/src/main/java/app/demo/product/web/ProductWebServiceImpl.java
import app.demo.api.ProductWebService;
import app.demo.api.product.CreateProductRequest;
import app.demo.api.product.ProductView;
import app.demo.api.product.SearchProductRequest;
import app.demo.api.product.SearchProductResponse;
import app.demo.api.product.UpdateProductRequest;
import app.demo.product.service.ProductService;
import core.framework.inject.Inject;
import core.framework.log.ActionLogContext;
import core.framework.util.Lists;
import core.framework.web.rate.LimitRate;
import java.util.Optional;
package app.demo.product.web;
/**
* @author neo
*/
public class ProductWebServiceImpl implements ProductWebService {
@Inject
ProductService productService;
@Override
public SearchProductResponse search(SearchProductRequest request) {
SearchProductResponse response = new SearchProductResponse();
response.products = Lists.newArrayList();
return response;
}
@LimitRate("product")
@Override
public Optional<ProductView> get(String id) {
ActionLogContext.put("pid", id);
return productService.get(id);
}
@Override
public void create(CreateProductRequest request) {
productService.create(request);
}
@Override | public void update(String id, UpdateProductRequest request) { |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/customer/service/CustomerService.java | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/CustomerStatus.java
// public enum CustomerStatus {
// @DBEnumValue("ACTIVE")
// ACTIVE,
// @DBEnumValue("INACTIVE")
// INACTIVE
// }
| import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.domain.Customer;
import app.demo.customer.domain.CustomerStatus;
import core.framework.db.Query;
import core.framework.db.Repository;
import core.framework.inject.Inject;
import core.framework.util.Strings;
import core.framework.web.exception.ConflictException;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.stream.Collectors; | package app.demo.customer.service;
public class CustomerService {
@Inject | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/CustomerStatus.java
// public enum CustomerStatus {
// @DBEnumValue("ACTIVE")
// ACTIVE,
// @DBEnumValue("INACTIVE")
// INACTIVE
// }
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.domain.Customer;
import app.demo.customer.domain.CustomerStatus;
import core.framework.db.Query;
import core.framework.db.Repository;
import core.framework.inject.Inject;
import core.framework.util.Strings;
import core.framework.web.exception.ConflictException;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.stream.Collectors;
package app.demo.customer.service;
public class CustomerService {
@Inject | Repository<Customer> customerRepository; |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/customer/service/CustomerService.java | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/CustomerStatus.java
// public enum CustomerStatus {
// @DBEnumValue("ACTIVE")
// ACTIVE,
// @DBEnumValue("INACTIVE")
// INACTIVE
// }
| import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.domain.Customer;
import app.demo.customer.domain.CustomerStatus;
import core.framework.db.Query;
import core.framework.db.Repository;
import core.framework.inject.Inject;
import core.framework.util.Strings;
import core.framework.web.exception.ConflictException;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.stream.Collectors; | package app.demo.customer.service;
public class CustomerService {
@Inject
Repository<Customer> customerRepository;
| // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/CustomerStatus.java
// public enum CustomerStatus {
// @DBEnumValue("ACTIVE")
// ACTIVE,
// @DBEnumValue("INACTIVE")
// INACTIVE
// }
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.domain.Customer;
import app.demo.customer.domain.CustomerStatus;
import core.framework.db.Query;
import core.framework.db.Repository;
import core.framework.inject.Inject;
import core.framework.util.Strings;
import core.framework.web.exception.ConflictException;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.stream.Collectors;
package app.demo.customer.service;
public class CustomerService {
@Inject
Repository<Customer> customerRepository;
| public CustomerView get(Long id) { |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/customer/service/CustomerService.java | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/CustomerStatus.java
// public enum CustomerStatus {
// @DBEnumValue("ACTIVE")
// ACTIVE,
// @DBEnumValue("INACTIVE")
// INACTIVE
// }
| import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.domain.Customer;
import app.demo.customer.domain.CustomerStatus;
import core.framework.db.Query;
import core.framework.db.Repository;
import core.framework.inject.Inject;
import core.framework.util.Strings;
import core.framework.web.exception.ConflictException;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.stream.Collectors; | package app.demo.customer.service;
public class CustomerService {
@Inject
Repository<Customer> customerRepository;
public CustomerView get(Long id) {
Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
return view(customer);
}
| // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/CustomerStatus.java
// public enum CustomerStatus {
// @DBEnumValue("ACTIVE")
// ACTIVE,
// @DBEnumValue("INACTIVE")
// INACTIVE
// }
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.domain.Customer;
import app.demo.customer.domain.CustomerStatus;
import core.framework.db.Query;
import core.framework.db.Repository;
import core.framework.inject.Inject;
import core.framework.util.Strings;
import core.framework.web.exception.ConflictException;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.stream.Collectors;
package app.demo.customer.service;
public class CustomerService {
@Inject
Repository<Customer> customerRepository;
public CustomerView get(Long id) {
Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
return view(customer);
}
| public CustomerView create(CreateCustomerRequest request) { |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/customer/service/CustomerService.java | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/CustomerStatus.java
// public enum CustomerStatus {
// @DBEnumValue("ACTIVE")
// ACTIVE,
// @DBEnumValue("INACTIVE")
// INACTIVE
// }
| import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.domain.Customer;
import app.demo.customer.domain.CustomerStatus;
import core.framework.db.Query;
import core.framework.db.Repository;
import core.framework.inject.Inject;
import core.framework.util.Strings;
import core.framework.web.exception.ConflictException;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.stream.Collectors; | package app.demo.customer.service;
public class CustomerService {
@Inject
Repository<Customer> customerRepository;
public CustomerView get(Long id) {
Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
return view(customer);
}
public CustomerView create(CreateCustomerRequest request) {
Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
if (existingCustomer.isPresent()) {
throw new ConflictException("customer already exists, email=" + request.email);
}
Customer customer = new Customer(); | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/CustomerStatus.java
// public enum CustomerStatus {
// @DBEnumValue("ACTIVE")
// ACTIVE,
// @DBEnumValue("INACTIVE")
// INACTIVE
// }
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.domain.Customer;
import app.demo.customer.domain.CustomerStatus;
import core.framework.db.Query;
import core.framework.db.Repository;
import core.framework.inject.Inject;
import core.framework.util.Strings;
import core.framework.web.exception.ConflictException;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.stream.Collectors;
package app.demo.customer.service;
public class CustomerService {
@Inject
Repository<Customer> customerRepository;
public CustomerView get(Long id) {
Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
return view(customer);
}
public CustomerView create(CreateCustomerRequest request) {
Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
if (existingCustomer.isPresent()) {
throw new ConflictException("customer already exists, email=" + request.email);
}
Customer customer = new Customer(); | customer.status = CustomerStatus.ACTIVE; |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/customer/service/CustomerService.java | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/CustomerStatus.java
// public enum CustomerStatus {
// @DBEnumValue("ACTIVE")
// ACTIVE,
// @DBEnumValue("INACTIVE")
// INACTIVE
// }
| import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.domain.Customer;
import app.demo.customer.domain.CustomerStatus;
import core.framework.db.Query;
import core.framework.db.Repository;
import core.framework.inject.Inject;
import core.framework.util.Strings;
import core.framework.web.exception.ConflictException;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.stream.Collectors; | package app.demo.customer.service;
public class CustomerService {
@Inject
Repository<Customer> customerRepository;
public CustomerView get(Long id) {
Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
return view(customer);
}
public CustomerView create(CreateCustomerRequest request) {
Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
if (existingCustomer.isPresent()) {
throw new ConflictException("customer already exists, email=" + request.email);
}
Customer customer = new Customer();
customer.status = CustomerStatus.ACTIVE;
customer.email = request.email;
customer.firstName = request.firstName;
customer.lastName = request.lastName;
customer.updatedTime = LocalDateTime.now();
customer.id = customerRepository.insert(customer).orElseThrow();
return view(customer);
}
| // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/CustomerStatus.java
// public enum CustomerStatus {
// @DBEnumValue("ACTIVE")
// ACTIVE,
// @DBEnumValue("INACTIVE")
// INACTIVE
// }
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.domain.Customer;
import app.demo.customer.domain.CustomerStatus;
import core.framework.db.Query;
import core.framework.db.Repository;
import core.framework.inject.Inject;
import core.framework.util.Strings;
import core.framework.web.exception.ConflictException;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.stream.Collectors;
package app.demo.customer.service;
public class CustomerService {
@Inject
Repository<Customer> customerRepository;
public CustomerView get(Long id) {
Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
return view(customer);
}
public CustomerView create(CreateCustomerRequest request) {
Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
if (existingCustomer.isPresent()) {
throw new ConflictException("customer already exists, email=" + request.email);
}
Customer customer = new Customer();
customer.status = CustomerStatus.ACTIVE;
customer.email = request.email;
customer.firstName = request.firstName;
customer.lastName = request.lastName;
customer.updatedTime = LocalDateTime.now();
customer.id = customerRepository.insert(customer).orElseThrow();
return view(customer);
}
| public CustomerView update(Long id, UpdateCustomerRequest request) { |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/customer/service/CustomerService.java | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/CustomerStatus.java
// public enum CustomerStatus {
// @DBEnumValue("ACTIVE")
// ACTIVE,
// @DBEnumValue("INACTIVE")
// INACTIVE
// }
| import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.domain.Customer;
import app.demo.customer.domain.CustomerStatus;
import core.framework.db.Query;
import core.framework.db.Repository;
import core.framework.inject.Inject;
import core.framework.util.Strings;
import core.framework.web.exception.ConflictException;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.stream.Collectors; | }
public CustomerView create(CreateCustomerRequest request) {
Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
if (existingCustomer.isPresent()) {
throw new ConflictException("customer already exists, email=" + request.email);
}
Customer customer = new Customer();
customer.status = CustomerStatus.ACTIVE;
customer.email = request.email;
customer.firstName = request.firstName;
customer.lastName = request.lastName;
customer.updatedTime = LocalDateTime.now();
customer.id = customerRepository.insert(customer).orElseThrow();
return view(customer);
}
public CustomerView update(Long id, UpdateCustomerRequest request) {
Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
customer.updatedTime = LocalDateTime.now();
customer.firstName = request.firstName;
if (request.lastName != null) {
customer.lastName = request.lastName;
}
customerRepository.partialUpdate(customer);
return view(customer);
}
| // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/CustomerStatus.java
// public enum CustomerStatus {
// @DBEnumValue("ACTIVE")
// ACTIVE,
// @DBEnumValue("INACTIVE")
// INACTIVE
// }
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.domain.Customer;
import app.demo.customer.domain.CustomerStatus;
import core.framework.db.Query;
import core.framework.db.Repository;
import core.framework.inject.Inject;
import core.framework.util.Strings;
import core.framework.web.exception.ConflictException;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.stream.Collectors;
}
public CustomerView create(CreateCustomerRequest request) {
Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
if (existingCustomer.isPresent()) {
throw new ConflictException("customer already exists, email=" + request.email);
}
Customer customer = new Customer();
customer.status = CustomerStatus.ACTIVE;
customer.email = request.email;
customer.firstName = request.firstName;
customer.lastName = request.lastName;
customer.updatedTime = LocalDateTime.now();
customer.id = customerRepository.insert(customer).orElseThrow();
return view(customer);
}
public CustomerView update(Long id, UpdateCustomerRequest request) {
Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
customer.updatedTime = LocalDateTime.now();
customer.firstName = request.firstName;
if (request.lastName != null) {
customer.lastName = request.lastName;
}
customerRepository.partialUpdate(customer);
return view(customer);
}
| public SearchCustomerResponse search(SearchCustomerRequest request) { |
neowu/core-ng-demo-project | demo-service/src/main/java/app/demo/customer/service/CustomerService.java | // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/CustomerStatus.java
// public enum CustomerStatus {
// @DBEnumValue("ACTIVE")
// ACTIVE,
// @DBEnumValue("INACTIVE")
// INACTIVE
// }
| import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.domain.Customer;
import app.demo.customer.domain.CustomerStatus;
import core.framework.db.Query;
import core.framework.db.Repository;
import core.framework.inject.Inject;
import core.framework.util.Strings;
import core.framework.web.exception.ConflictException;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.stream.Collectors; | }
public CustomerView create(CreateCustomerRequest request) {
Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
if (existingCustomer.isPresent()) {
throw new ConflictException("customer already exists, email=" + request.email);
}
Customer customer = new Customer();
customer.status = CustomerStatus.ACTIVE;
customer.email = request.email;
customer.firstName = request.firstName;
customer.lastName = request.lastName;
customer.updatedTime = LocalDateTime.now();
customer.id = customerRepository.insert(customer).orElseThrow();
return view(customer);
}
public CustomerView update(Long id, UpdateCustomerRequest request) {
Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
customer.updatedTime = LocalDateTime.now();
customer.firstName = request.firstName;
if (request.lastName != null) {
customer.lastName = request.lastName;
}
customerRepository.partialUpdate(customer);
return view(customer);
}
| // Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
// @NotNull
// @Property(name = "id")
// public Long id;
//
// @NotNull
// @NotBlank
// @Property(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
//
// @NotNull
// @Property(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
// @NotNull
// @QueryParam(name = "skip")
// public Integer skip = 0;
//
// @NotNull
// @QueryParam(name = "limit")
// public Integer limit = 1000;
//
// @QueryParam(name = "email")
// public String email;
//
// @QueryParam(name = "first_name")
// public String firstName;
//
// @QueryParam(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
// @Property(name = "total")
// public Long total;
//
// @Property(name = "customers")
// public List<CustomerView> customers;
// }
//
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
// @NotNull
// @NotBlank
// @Property(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Property(name = "last_name")
// public String lastName;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
// @PrimaryKey(autoIncrement = true)
// @Column(name = "id")
// public Long id;
//
// @NotNull
// @Column(name = "status")
// public CustomerStatus status;
//
// @NotNull
// @NotBlank
// @Column(name = "email")
// public String email;
//
// @NotNull
// @NotBlank
// @Column(name = "first_name")
// public String firstName;
//
// @NotBlank
// @Column(name = "last_name")
// public String lastName;
//
// @NotNull
// @Column(name = "updated_time")
// public LocalDateTime updatedTime;
// }
//
// Path: demo-service/src/main/java/app/demo/customer/domain/CustomerStatus.java
// public enum CustomerStatus {
// @DBEnumValue("ACTIVE")
// ACTIVE,
// @DBEnumValue("INACTIVE")
// INACTIVE
// }
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.domain.Customer;
import app.demo.customer.domain.CustomerStatus;
import core.framework.db.Query;
import core.framework.db.Repository;
import core.framework.inject.Inject;
import core.framework.util.Strings;
import core.framework.web.exception.ConflictException;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.stream.Collectors;
}
public CustomerView create(CreateCustomerRequest request) {
Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
if (existingCustomer.isPresent()) {
throw new ConflictException("customer already exists, email=" + request.email);
}
Customer customer = new Customer();
customer.status = CustomerStatus.ACTIVE;
customer.email = request.email;
customer.firstName = request.firstName;
customer.lastName = request.lastName;
customer.updatedTime = LocalDateTime.now();
customer.id = customerRepository.insert(customer).orElseThrow();
return view(customer);
}
public CustomerView update(Long id, UpdateCustomerRequest request) {
Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
customer.updatedTime = LocalDateTime.now();
customer.firstName = request.firstName;
if (request.lastName != null) {
customer.lastName = request.lastName;
}
customerRepository.partialUpdate(customer);
return view(customer);
}
| public SearchCustomerResponse search(SearchCustomerRequest request) { |
neowu/core-ng-demo-project | demo-site/src/main/java/app/web/ChatController.java | // Path: demo-site/src/main/java/app/web/ws/ChatMessage.java
// public class ChatMessage {
// @Property(name = "text")
// public String text;
// }
| import app.web.ws.ChatMessage;
import core.framework.inject.Inject;
import core.framework.web.Request;
import core.framework.web.Response;
import core.framework.web.websocket.Channel;
import core.framework.web.websocket.WebSocketContext;
import java.util.List; | package app.web;
/**
* @author neo
*/
public class ChatController {
@Inject
WebSocketContext context;
@Inject
LanguageManager languageManager;
public Response chat(Request request) {
return Response.html("/template/chat.html", new ChatPage(), languageManager.language());
}
public Response publish(Request request) { | // Path: demo-site/src/main/java/app/web/ws/ChatMessage.java
// public class ChatMessage {
// @Property(name = "text")
// public String text;
// }
// Path: demo-site/src/main/java/app/web/ChatController.java
import app.web.ws.ChatMessage;
import core.framework.inject.Inject;
import core.framework.web.Request;
import core.framework.web.Response;
import core.framework.web.websocket.Channel;
import core.framework.web.websocket.WebSocketContext;
import java.util.List;
package app.web;
/**
* @author neo
*/
public class ChatController {
@Inject
WebSocketContext context;
@Inject
LanguageManager languageManager;
public Response chat(Request request) {
return Response.html("/template/chat.html", new ChatPage(), languageManager.language());
}
public Response publish(Request request) { | final List<Channel<ChatMessage>> channels = context.all(); |
smartmarmot/DBforBIX | src/com/smartmarmot/dbforbix/config/element/DiscoveryConfigurationElement.java | // Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixItem.java
// public final class ZabbixItem implements Serializable {
//
// public static int ZBX_STATE_NORMAL=0;
// public static int ZBX_STATE_NOTSUPPORTED=1;
//
// private static final long serialVersionUID = 1374520722821228793L;
//
// private String key;
// private String value;
// private String host;
// private int state;
// private Long clock;
// private String lastlogsize;
// private IConfigurationElement configurationElement;
//
//
// //main case
// public ZabbixItem(String key, String value, int state, Long clock, IConfigurationElement configurationElement) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=configurationElement.getConfigurationItem().getHost();
// this.setConfigurationElement(configurationElement);
// this.setState(state);
// }
//
//
// //For persistence usage
// public ZabbixItem(String host, String key, String value, Long clock) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=host;
// this.configurationElement=null;
// }
//
//
//
//
// /**
// * @return The current hostname for this item.
// */
// public String getHost() {
// return host;
// }
//
// /**
// * @return The monitoring server's key for this item.
// */
// public String getKey() {
// return key;
// }
//
// /**
// * @return The current value for this item.
// */
// public String getValue() {
// return value;
// }
//
// public Long getClock() {
// return clock;
// }
//
//
// public String getLastlogsize() {
// return lastlogsize;
// }
//
// @Override
// public String toString() {
// return getHost() + " " + getKey() + ": " + getValue();
// }
//
// public IConfigurationElement getConfigurationElement() {
// return configurationElement;
// }
//
// public void setConfigurationElement(IConfigurationElement configurationElement) {
// this.configurationElement = configurationElement;
// }
//
//
// public int getState() {
// return state;
// }
//
//
// public void setState(int state) {
// this.state = state;
// }
//
//
// public void setValue(String value) {
// this.value = value;
// }
// }
| import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import org.apache.log4j.Logger;
import com.smartmarmot.dbforbix.zabbix.ZabbixItem;
| /*
* This file is part of DBforBix.
*
* DBforBix is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DBforBix is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* DBforBix. If not, see <http://www.gnu.org/licenses/>.
*/
package com.smartmarmot.dbforbix.config.element;
public class DiscoveryConfigurationElement extends AbstractConfigurationElement {
private static final Logger LOG = Logger.getLogger(DiscoveryConfigurationElement.class);
private String discoveryItemKey;
private String[] altNames;
public DiscoveryConfigurationElement(String _prefix, int time, String _item, String _names, String _query) {
super(_prefix, time, _item, "", _query);
discoveryItemKey = _prefix+_item;
altNames = _names.split("\\|");
}
@Override
| // Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixItem.java
// public final class ZabbixItem implements Serializable {
//
// public static int ZBX_STATE_NORMAL=0;
// public static int ZBX_STATE_NOTSUPPORTED=1;
//
// private static final long serialVersionUID = 1374520722821228793L;
//
// private String key;
// private String value;
// private String host;
// private int state;
// private Long clock;
// private String lastlogsize;
// private IConfigurationElement configurationElement;
//
//
// //main case
// public ZabbixItem(String key, String value, int state, Long clock, IConfigurationElement configurationElement) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=configurationElement.getConfigurationItem().getHost();
// this.setConfigurationElement(configurationElement);
// this.setState(state);
// }
//
//
// //For persistence usage
// public ZabbixItem(String host, String key, String value, Long clock) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=host;
// this.configurationElement=null;
// }
//
//
//
//
// /**
// * @return The current hostname for this item.
// */
// public String getHost() {
// return host;
// }
//
// /**
// * @return The monitoring server's key for this item.
// */
// public String getKey() {
// return key;
// }
//
// /**
// * @return The current value for this item.
// */
// public String getValue() {
// return value;
// }
//
// public Long getClock() {
// return clock;
// }
//
//
// public String getLastlogsize() {
// return lastlogsize;
// }
//
// @Override
// public String toString() {
// return getHost() + " " + getKey() + ": " + getValue();
// }
//
// public IConfigurationElement getConfigurationElement() {
// return configurationElement;
// }
//
// public void setConfigurationElement(IConfigurationElement configurationElement) {
// this.configurationElement = configurationElement;
// }
//
//
// public int getState() {
// return state;
// }
//
//
// public void setState(int state) {
// this.state = state;
// }
//
//
// public void setValue(String value) {
// this.value = value;
// }
// }
// Path: src/com/smartmarmot/dbforbix/config/element/DiscoveryConfigurationElement.java
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import org.apache.log4j.Logger;
import com.smartmarmot.dbforbix.zabbix.ZabbixItem;
/*
* This file is part of DBforBix.
*
* DBforBix is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DBforBix is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* DBforBix. If not, see <http://www.gnu.org/licenses/>.
*/
package com.smartmarmot.dbforbix.config.element;
public class DiscoveryConfigurationElement extends AbstractConfigurationElement {
private static final Logger LOG = Logger.getLogger(DiscoveryConfigurationElement.class);
private String discoveryItemKey;
private String[] altNames;
public DiscoveryConfigurationElement(String _prefix, int time, String _item, String _names, String _query) {
super(_prefix, time, _item, "", _query);
discoveryItemKey = _prefix+_item;
altNames = _names.split("\\|");
}
@Override
| public ZabbixItem[] getZabbixItemsData(Connection con, int timeout) throws SQLException {
|
smartmarmot/DBforBIX | src/com/smartmarmot/dbforbix/zabbix/protocol/Sender14.java | // Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixItem.java
// public final class ZabbixItem implements Serializable {
//
// public static int ZBX_STATE_NORMAL=0;
// public static int ZBX_STATE_NOTSUPPORTED=1;
//
// private static final long serialVersionUID = 1374520722821228793L;
//
// private String key;
// private String value;
// private String host;
// private int state;
// private Long clock;
// private String lastlogsize;
// private IConfigurationElement configurationElement;
//
//
// //main case
// public ZabbixItem(String key, String value, int state, Long clock, IConfigurationElement configurationElement) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=configurationElement.getConfigurationItem().getHost();
// this.setConfigurationElement(configurationElement);
// this.setState(state);
// }
//
//
// //For persistence usage
// public ZabbixItem(String host, String key, String value, Long clock) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=host;
// this.configurationElement=null;
// }
//
//
//
//
// /**
// * @return The current hostname for this item.
// */
// public String getHost() {
// return host;
// }
//
// /**
// * @return The monitoring server's key for this item.
// */
// public String getKey() {
// return key;
// }
//
// /**
// * @return The current value for this item.
// */
// public String getValue() {
// return value;
// }
//
// public Long getClock() {
// return clock;
// }
//
//
// public String getLastlogsize() {
// return lastlogsize;
// }
//
// @Override
// public String toString() {
// return getHost() + " " + getKey() + ": " + getValue();
// }
//
// public IConfigurationElement getConfigurationElement() {
// return configurationElement;
// }
//
// public void setConfigurationElement(IConfigurationElement configurationElement) {
// this.configurationElement = configurationElement;
// }
//
//
// public int getState() {
// return state;
// }
//
//
// public void setState(int state) {
// this.state = state;
// }
//
//
// public void setValue(String value) {
// this.value = value;
// }
// }
| import com.smartmarmot.dbforbix.zabbix.ZabbixItem;
| /*
* This file is part of DBforBix.
*
* DBforBix is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DBforBix is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* DBforBix. If not, see <http://www.gnu.org/licenses/>.
*/
package com.smartmarmot.dbforbix.zabbix.protocol;
/**
* Old zabbix 1.1 sender protocol, XML based
*
* @author Andrea Dalle Vacche
*/
public class Sender14 implements ISenderProtocol {
@Override
public boolean isMultiValueSupported() {
return false;
}
@Override
| // Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixItem.java
// public final class ZabbixItem implements Serializable {
//
// public static int ZBX_STATE_NORMAL=0;
// public static int ZBX_STATE_NOTSUPPORTED=1;
//
// private static final long serialVersionUID = 1374520722821228793L;
//
// private String key;
// private String value;
// private String host;
// private int state;
// private Long clock;
// private String lastlogsize;
// private IConfigurationElement configurationElement;
//
//
// //main case
// public ZabbixItem(String key, String value, int state, Long clock, IConfigurationElement configurationElement) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=configurationElement.getConfigurationItem().getHost();
// this.setConfigurationElement(configurationElement);
// this.setState(state);
// }
//
//
// //For persistence usage
// public ZabbixItem(String host, String key, String value, Long clock) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=host;
// this.configurationElement=null;
// }
//
//
//
//
// /**
// * @return The current hostname for this item.
// */
// public String getHost() {
// return host;
// }
//
// /**
// * @return The monitoring server's key for this item.
// */
// public String getKey() {
// return key;
// }
//
// /**
// * @return The current value for this item.
// */
// public String getValue() {
// return value;
// }
//
// public Long getClock() {
// return clock;
// }
//
//
// public String getLastlogsize() {
// return lastlogsize;
// }
//
// @Override
// public String toString() {
// return getHost() + " " + getKey() + ": " + getValue();
// }
//
// public IConfigurationElement getConfigurationElement() {
// return configurationElement;
// }
//
// public void setConfigurationElement(IConfigurationElement configurationElement) {
// this.configurationElement = configurationElement;
// }
//
//
// public int getState() {
// return state;
// }
//
//
// public void setState(int state) {
// this.state = state;
// }
//
//
// public void setValue(String value) {
// this.value = value;
// }
// }
// Path: src/com/smartmarmot/dbforbix/zabbix/protocol/Sender14.java
import com.smartmarmot.dbforbix.zabbix.ZabbixItem;
/*
* This file is part of DBforBix.
*
* DBforBix is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DBforBix is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* DBforBix. If not, see <http://www.gnu.org/licenses/>.
*/
package com.smartmarmot.dbforbix.zabbix.protocol;
/**
* Old zabbix 1.1 sender protocol, XML based
*
* @author Andrea Dalle Vacche
*/
public class Sender14 implements ISenderProtocol {
@Override
public boolean isMultiValueSupported() {
return false;
}
@Override
| public String encodeItem(ZabbixItem item) {
|
smartmarmot/DBforBIX | src/com/smartmarmot/dbforbix/config/ZabbixServer.java | // Path: src/com/smartmarmot/dbforbix/config/Config.java
// interface Validable {
//
// public boolean isValid();
// }
//
// Path: src/com/smartmarmot/dbforbix/config/item/IConfigurationItem.java
// public interface IConfigurationItem {
//
// String getConfigurationUID();
// void setConfigurationUID(String _configurationUID);
// String getHost();
// void setHost(String _host);
// String getHostid();
// void setHostid(String _hostid);
// String getDb();
// void setDb(String _db);
// String getKey();
// void setKey(String _key);
// String getParam();
// void setParam(String _param);
// String getHashParam();
// void setHashParam(String _hashParam);
// ZabbixServer getZabbixServer();
// void setZabbixServer(ZabbixServer _zabbixServer);
// Set<IConfigurationElement> getConfigurationElements();
// void addConfigurationElements(Set<IConfigurationElement> configurationElements);
//
// }
//
// Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixSender.java
// public enum PROTOCOL {
// V14, V18, V32
// }
| import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.smartmarmot.dbforbix.config.Config.Validable;
import com.smartmarmot.dbforbix.config.item.IConfigurationItem;
import com.smartmarmot.dbforbix.zabbix.ZabbixSender.PROTOCOL;
| package com.smartmarmot.dbforbix.config;
/**
* Zabbix server config entry
*/
public class ZabbixServer implements Validable {
String zbxServerHost = null;
int zbxServerPort = 10051;
private String zbxServerNameFC = null;
String proxy = null;
| // Path: src/com/smartmarmot/dbforbix/config/Config.java
// interface Validable {
//
// public boolean isValid();
// }
//
// Path: src/com/smartmarmot/dbforbix/config/item/IConfigurationItem.java
// public interface IConfigurationItem {
//
// String getConfigurationUID();
// void setConfigurationUID(String _configurationUID);
// String getHost();
// void setHost(String _host);
// String getHostid();
// void setHostid(String _hostid);
// String getDb();
// void setDb(String _db);
// String getKey();
// void setKey(String _key);
// String getParam();
// void setParam(String _param);
// String getHashParam();
// void setHashParam(String _hashParam);
// ZabbixServer getZabbixServer();
// void setZabbixServer(ZabbixServer _zabbixServer);
// Set<IConfigurationElement> getConfigurationElements();
// void addConfigurationElements(Set<IConfigurationElement> configurationElements);
//
// }
//
// Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixSender.java
// public enum PROTOCOL {
// V14, V18, V32
// }
// Path: src/com/smartmarmot/dbforbix/config/ZabbixServer.java
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.smartmarmot.dbforbix.config.Config.Validable;
import com.smartmarmot.dbforbix.config.item.IConfigurationItem;
import com.smartmarmot.dbforbix.zabbix.ZabbixSender.PROTOCOL;
package com.smartmarmot.dbforbix.config;
/**
* Zabbix server config entry
*/
public class ZabbixServer implements Validable {
String zbxServerHost = null;
int zbxServerPort = 10051;
private String zbxServerNameFC = null;
String proxy = null;
| private PROTOCOL protocol = PROTOCOL.V32;
|
smartmarmot/DBforBIX | src/com/smartmarmot/dbforbix/config/ZabbixServer.java | // Path: src/com/smartmarmot/dbforbix/config/Config.java
// interface Validable {
//
// public boolean isValid();
// }
//
// Path: src/com/smartmarmot/dbforbix/config/item/IConfigurationItem.java
// public interface IConfigurationItem {
//
// String getConfigurationUID();
// void setConfigurationUID(String _configurationUID);
// String getHost();
// void setHost(String _host);
// String getHostid();
// void setHostid(String _hostid);
// String getDb();
// void setDb(String _db);
// String getKey();
// void setKey(String _key);
// String getParam();
// void setParam(String _param);
// String getHashParam();
// void setHashParam(String _hashParam);
// ZabbixServer getZabbixServer();
// void setZabbixServer(ZabbixServer _zabbixServer);
// Set<IConfigurationElement> getConfigurationElements();
// void addConfigurationElements(Set<IConfigurationElement> configurationElements);
//
// }
//
// Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixSender.java
// public enum PROTOCOL {
// V14, V18, V32
// }
| import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.smartmarmot.dbforbix.config.Config.Validable;
import com.smartmarmot.dbforbix.config.item.IConfigurationItem;
import com.smartmarmot.dbforbix.zabbix.ZabbixSender.PROTOCOL;
| package com.smartmarmot.dbforbix.config;
/**
* Zabbix server config entry
*/
public class ZabbixServer implements Validable {
String zbxServerHost = null;
int zbxServerPort = 10051;
private String zbxServerNameFC = null;
String proxy = null;
private PROTOCOL protocol = PROTOCOL.V32;
private Collection<String> definedDBNames = null;
/**
* reinit
*/
private Map<String,List<String> > hosts=null;
private Map<String,List<String> > items=null;
private Map<String,List<String> > hostmacro=null;
private Map<String,List<String>> hostsTemplates=null;
| // Path: src/com/smartmarmot/dbforbix/config/Config.java
// interface Validable {
//
// public boolean isValid();
// }
//
// Path: src/com/smartmarmot/dbforbix/config/item/IConfigurationItem.java
// public interface IConfigurationItem {
//
// String getConfigurationUID();
// void setConfigurationUID(String _configurationUID);
// String getHost();
// void setHost(String _host);
// String getHostid();
// void setHostid(String _hostid);
// String getDb();
// void setDb(String _db);
// String getKey();
// void setKey(String _key);
// String getParam();
// void setParam(String _param);
// String getHashParam();
// void setHashParam(String _hashParam);
// ZabbixServer getZabbixServer();
// void setZabbixServer(ZabbixServer _zabbixServer);
// Set<IConfigurationElement> getConfigurationElements();
// void addConfigurationElements(Set<IConfigurationElement> configurationElements);
//
// }
//
// Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixSender.java
// public enum PROTOCOL {
// V14, V18, V32
// }
// Path: src/com/smartmarmot/dbforbix/config/ZabbixServer.java
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.smartmarmot.dbforbix.config.Config.Validable;
import com.smartmarmot.dbforbix.config.item.IConfigurationItem;
import com.smartmarmot.dbforbix.zabbix.ZabbixSender.PROTOCOL;
package com.smartmarmot.dbforbix.config;
/**
* Zabbix server config entry
*/
public class ZabbixServer implements Validable {
String zbxServerHost = null;
int zbxServerPort = 10051;
private String zbxServerNameFC = null;
String proxy = null;
private PROTOCOL protocol = PROTOCOL.V32;
private Collection<String> definedDBNames = null;
/**
* reinit
*/
private Map<String,List<String> > hosts=null;
private Map<String,List<String> > items=null;
private Map<String,List<String> > hostmacro=null;
private Map<String,List<String>> hostsTemplates=null;
| private Map<String,IConfigurationItem> configurationItems = new HashMap<>();
|
smartmarmot/DBforBIX | src/com/smartmarmot/dbforbix/config/element/MultiRowConfigurationElement.java | // Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixItem.java
// public final class ZabbixItem implements Serializable {
//
// public static int ZBX_STATE_NORMAL=0;
// public static int ZBX_STATE_NOTSUPPORTED=1;
//
// private static final long serialVersionUID = 1374520722821228793L;
//
// private String key;
// private String value;
// private String host;
// private int state;
// private Long clock;
// private String lastlogsize;
// private IConfigurationElement configurationElement;
//
//
// //main case
// public ZabbixItem(String key, String value, int state, Long clock, IConfigurationElement configurationElement) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=configurationElement.getConfigurationItem().getHost();
// this.setConfigurationElement(configurationElement);
// this.setState(state);
// }
//
//
// //For persistence usage
// public ZabbixItem(String host, String key, String value, Long clock) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=host;
// this.configurationElement=null;
// }
//
//
//
//
// /**
// * @return The current hostname for this item.
// */
// public String getHost() {
// return host;
// }
//
// /**
// * @return The monitoring server's key for this item.
// */
// public String getKey() {
// return key;
// }
//
// /**
// * @return The current value for this item.
// */
// public String getValue() {
// return value;
// }
//
// public Long getClock() {
// return clock;
// }
//
//
// public String getLastlogsize() {
// return lastlogsize;
// }
//
// @Override
// public String toString() {
// return getHost() + " " + getKey() + ": " + getValue();
// }
//
// public IConfigurationElement getConfigurationElement() {
// return configurationElement;
// }
//
// public void setConfigurationElement(IConfigurationElement configurationElement) {
// this.configurationElement = configurationElement;
// }
//
//
// public int getState() {
// return state;
// }
//
//
// public void setState(int state) {
// this.state = state;
// }
//
//
// public void setValue(String value) {
// this.value = value;
// }
// }
| import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import com.smartmarmot.dbforbix.zabbix.ZabbixItem;
| /*
* This file is part of DBforBix.
*
* DBforBix is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DBforBix is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* DBforBix. If not, see <http://www.gnu.org/licenses/>.
*/
package com.smartmarmot.dbforbix.config.element;
public class MultiRowConfigurationElement extends AbstractMultiConfigurationElement {
private static final Logger LOG = Logger.getLogger(MultiRowConfigurationElement.class);
public MultiRowConfigurationElement(String _prefix, int _time, String _items, String _noData, String _query) {
//noData shouldn't be null!!! Initialize by empty string at least!
super(_prefix, _time, _items, _noData==null?"":_noData, _query);
}
@Override
| // Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixItem.java
// public final class ZabbixItem implements Serializable {
//
// public static int ZBX_STATE_NORMAL=0;
// public static int ZBX_STATE_NOTSUPPORTED=1;
//
// private static final long serialVersionUID = 1374520722821228793L;
//
// private String key;
// private String value;
// private String host;
// private int state;
// private Long clock;
// private String lastlogsize;
// private IConfigurationElement configurationElement;
//
//
// //main case
// public ZabbixItem(String key, String value, int state, Long clock, IConfigurationElement configurationElement) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=configurationElement.getConfigurationItem().getHost();
// this.setConfigurationElement(configurationElement);
// this.setState(state);
// }
//
//
// //For persistence usage
// public ZabbixItem(String host, String key, String value, Long clock) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=host;
// this.configurationElement=null;
// }
//
//
//
//
// /**
// * @return The current hostname for this item.
// */
// public String getHost() {
// return host;
// }
//
// /**
// * @return The monitoring server's key for this item.
// */
// public String getKey() {
// return key;
// }
//
// /**
// * @return The current value for this item.
// */
// public String getValue() {
// return value;
// }
//
// public Long getClock() {
// return clock;
// }
//
//
// public String getLastlogsize() {
// return lastlogsize;
// }
//
// @Override
// public String toString() {
// return getHost() + " " + getKey() + ": " + getValue();
// }
//
// public IConfigurationElement getConfigurationElement() {
// return configurationElement;
// }
//
// public void setConfigurationElement(IConfigurationElement configurationElement) {
// this.configurationElement = configurationElement;
// }
//
//
// public int getState() {
// return state;
// }
//
//
// public void setState(int state) {
// this.state = state;
// }
//
//
// public void setValue(String value) {
// this.value = value;
// }
// }
// Path: src/com/smartmarmot/dbforbix/config/element/MultiRowConfigurationElement.java
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import com.smartmarmot.dbforbix.zabbix.ZabbixItem;
/*
* This file is part of DBforBix.
*
* DBforBix is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DBforBix is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* DBforBix. If not, see <http://www.gnu.org/licenses/>.
*/
package com.smartmarmot.dbforbix.config.element;
public class MultiRowConfigurationElement extends AbstractMultiConfigurationElement {
private static final Logger LOG = Logger.getLogger(MultiRowConfigurationElement.class);
public MultiRowConfigurationElement(String _prefix, int _time, String _items, String _noData, String _query) {
//noData shouldn't be null!!! Initialize by empty string at least!
super(_prefix, _time, _items, _noData==null?"":_noData, _query);
}
@Override
| public ZabbixItem[] getZabbixItemsData(Connection con, int timeout) throws SQLException {
|
smartmarmot/DBforBIX | src/com/smartmarmot/dbforbix/zabbix/protocol/Sender18.java | // Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixItem.java
// public final class ZabbixItem implements Serializable {
//
// public static int ZBX_STATE_NORMAL=0;
// public static int ZBX_STATE_NOTSUPPORTED=1;
//
// private static final long serialVersionUID = 1374520722821228793L;
//
// private String key;
// private String value;
// private String host;
// private int state;
// private Long clock;
// private String lastlogsize;
// private IConfigurationElement configurationElement;
//
//
// //main case
// public ZabbixItem(String key, String value, int state, Long clock, IConfigurationElement configurationElement) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=configurationElement.getConfigurationItem().getHost();
// this.setConfigurationElement(configurationElement);
// this.setState(state);
// }
//
//
// //For persistence usage
// public ZabbixItem(String host, String key, String value, Long clock) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=host;
// this.configurationElement=null;
// }
//
//
//
//
// /**
// * @return The current hostname for this item.
// */
// public String getHost() {
// return host;
// }
//
// /**
// * @return The monitoring server's key for this item.
// */
// public String getKey() {
// return key;
// }
//
// /**
// * @return The current value for this item.
// */
// public String getValue() {
// return value;
// }
//
// public Long getClock() {
// return clock;
// }
//
//
// public String getLastlogsize() {
// return lastlogsize;
// }
//
// @Override
// public String toString() {
// return getHost() + " " + getKey() + ": " + getValue();
// }
//
// public IConfigurationElement getConfigurationElement() {
// return configurationElement;
// }
//
// public void setConfigurationElement(IConfigurationElement configurationElement) {
// this.configurationElement = configurationElement;
// }
//
//
// public int getState() {
// return state;
// }
//
//
// public void setState(int state) {
// this.state = state;
// }
//
//
// public void setValue(String value) {
// this.value = value;
// }
// }
| import java.io.UnsupportedEncodingException;
import org.apache.commons.codec.binary.Base64;
import com.smartmarmot.dbforbix.zabbix.ZabbixItem;
| * @return byte[] containing the encoded data
*/
private byte[] encodeString(String data) {
try {
return data.getBytes("ASCII");
} catch (UnsupportedEncodingException e) {
return data.getBytes();
}
}
private String base64Encode(String data) {
return new String(Base64.encodeBase64(encodeString(data)));
}
private String buildJSonString(String host, String item, String value, String clock) {
String head = "<req><host>" + base64Encode(host) + "</host><key>";
final StringBuilder message = new StringBuilder(head);
message.append(base64Encode(item));
message.append(data);
message.append(base64Encode(value == null ? "" : value));
message.append(time);
message.append(base64Encode(clock));
message.append(tail);
return message.toString();
}
@Override
| // Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixItem.java
// public final class ZabbixItem implements Serializable {
//
// public static int ZBX_STATE_NORMAL=0;
// public static int ZBX_STATE_NOTSUPPORTED=1;
//
// private static final long serialVersionUID = 1374520722821228793L;
//
// private String key;
// private String value;
// private String host;
// private int state;
// private Long clock;
// private String lastlogsize;
// private IConfigurationElement configurationElement;
//
//
// //main case
// public ZabbixItem(String key, String value, int state, Long clock, IConfigurationElement configurationElement) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=configurationElement.getConfigurationItem().getHost();
// this.setConfigurationElement(configurationElement);
// this.setState(state);
// }
//
//
// //For persistence usage
// public ZabbixItem(String host, String key, String value, Long clock) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=host;
// this.configurationElement=null;
// }
//
//
//
//
// /**
// * @return The current hostname for this item.
// */
// public String getHost() {
// return host;
// }
//
// /**
// * @return The monitoring server's key for this item.
// */
// public String getKey() {
// return key;
// }
//
// /**
// * @return The current value for this item.
// */
// public String getValue() {
// return value;
// }
//
// public Long getClock() {
// return clock;
// }
//
//
// public String getLastlogsize() {
// return lastlogsize;
// }
//
// @Override
// public String toString() {
// return getHost() + " " + getKey() + ": " + getValue();
// }
//
// public IConfigurationElement getConfigurationElement() {
// return configurationElement;
// }
//
// public void setConfigurationElement(IConfigurationElement configurationElement) {
// this.configurationElement = configurationElement;
// }
//
//
// public int getState() {
// return state;
// }
//
//
// public void setState(int state) {
// this.state = state;
// }
//
//
// public void setValue(String value) {
// this.value = value;
// }
// }
// Path: src/com/smartmarmot/dbforbix/zabbix/protocol/Sender18.java
import java.io.UnsupportedEncodingException;
import org.apache.commons.codec.binary.Base64;
import com.smartmarmot.dbforbix.zabbix.ZabbixItem;
* @return byte[] containing the encoded data
*/
private byte[] encodeString(String data) {
try {
return data.getBytes("ASCII");
} catch (UnsupportedEncodingException e) {
return data.getBytes();
}
}
private String base64Encode(String data) {
return new String(Base64.encodeBase64(encodeString(data)));
}
private String buildJSonString(String host, String item, String value, String clock) {
String head = "<req><host>" + base64Encode(host) + "</host><key>";
final StringBuilder message = new StringBuilder(head);
message.append(base64Encode(item));
message.append(data);
message.append(base64Encode(value == null ? "" : value));
message.append(time);
message.append(base64Encode(clock));
message.append(tail);
return message.toString();
}
@Override
| public String encodeItem(ZabbixItem item) {
|
smartmarmot/DBforBIX | src/com/smartmarmot/dbforbix/zabbix/ZabbixItem.java | // Path: src/com/smartmarmot/dbforbix/config/element/IConfigurationElement.java
// public interface IConfigurationElement {
// String getElementID();
// String getPrefix();
// ZabbixItem[] getZabbixItemsData(Connection con, int timeout) throws SQLException;
// ZabbixServer getZabbixServer();
// IConfigurationItem getConfigurationItem();
// void setConfigurationItem(IConfigurationItem configurationItem);
// String getQuery();
// String getNoData();
// int getTime();
// String getConfigurationUID() throws NullPointerException;
// }
| import java.io.Serializable;
import com.smartmarmot.dbforbix.config.element.IConfigurationElement;
| /*
* This file is part of DBforBix.
*
* DBforBix is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DBforBix is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* DBforBix. If not, see <http://www.gnu.org/licenses/>.
*/
package com.smartmarmot.dbforbix.zabbix;
public final class ZabbixItem implements Serializable {
public static int ZBX_STATE_NORMAL=0;
public static int ZBX_STATE_NOTSUPPORTED=1;
private static final long serialVersionUID = 1374520722821228793L;
private String key;
private String value;
private String host;
private int state;
private Long clock;
private String lastlogsize;
| // Path: src/com/smartmarmot/dbforbix/config/element/IConfigurationElement.java
// public interface IConfigurationElement {
// String getElementID();
// String getPrefix();
// ZabbixItem[] getZabbixItemsData(Connection con, int timeout) throws SQLException;
// ZabbixServer getZabbixServer();
// IConfigurationItem getConfigurationItem();
// void setConfigurationItem(IConfigurationItem configurationItem);
// String getQuery();
// String getNoData();
// int getTime();
// String getConfigurationUID() throws NullPointerException;
// }
// Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixItem.java
import java.io.Serializable;
import com.smartmarmot.dbforbix.config.element.IConfigurationElement;
/*
* This file is part of DBforBix.
*
* DBforBix is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DBforBix is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* DBforBix. If not, see <http://www.gnu.org/licenses/>.
*/
package com.smartmarmot.dbforbix.zabbix;
public final class ZabbixItem implements Serializable {
public static int ZBX_STATE_NORMAL=0;
public static int ZBX_STATE_NOTSUPPORTED=1;
private static final long serialVersionUID = 1374520722821228793L;
private String key;
private String value;
private String host;
private int state;
private Long clock;
private String lastlogsize;
| private IConfigurationElement configurationElement;
|
smartmarmot/DBforBIX | src/com/smartmarmot/dbforbix/config/element/SimpleConfigurationElement.java | // Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixItem.java
// public final class ZabbixItem implements Serializable {
//
// public static int ZBX_STATE_NORMAL=0;
// public static int ZBX_STATE_NOTSUPPORTED=1;
//
// private static final long serialVersionUID = 1374520722821228793L;
//
// private String key;
// private String value;
// private String host;
// private int state;
// private Long clock;
// private String lastlogsize;
// private IConfigurationElement configurationElement;
//
//
// //main case
// public ZabbixItem(String key, String value, int state, Long clock, IConfigurationElement configurationElement) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=configurationElement.getConfigurationItem().getHost();
// this.setConfigurationElement(configurationElement);
// this.setState(state);
// }
//
//
// //For persistence usage
// public ZabbixItem(String host, String key, String value, Long clock) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=host;
// this.configurationElement=null;
// }
//
//
//
//
// /**
// * @return The current hostname for this item.
// */
// public String getHost() {
// return host;
// }
//
// /**
// * @return The monitoring server's key for this item.
// */
// public String getKey() {
// return key;
// }
//
// /**
// * @return The current value for this item.
// */
// public String getValue() {
// return value;
// }
//
// public Long getClock() {
// return clock;
// }
//
//
// public String getLastlogsize() {
// return lastlogsize;
// }
//
// @Override
// public String toString() {
// return getHost() + " " + getKey() + ": " + getValue();
// }
//
// public IConfigurationElement getConfigurationElement() {
// return configurationElement;
// }
//
// public void setConfigurationElement(IConfigurationElement configurationElement) {
// this.configurationElement = configurationElement;
// }
//
//
// public int getState() {
// return state;
// }
//
//
// public void setState(int state) {
// this.state = state;
// }
//
//
// public void setValue(String value) {
// this.value = value;
// }
// }
| import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import com.smartmarmot.dbforbix.zabbix.ZabbixItem;
| /*
* This file is part of DBforBix.
*
* DBforBix is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DBforBix is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* DBforBix. If not, see <http://www.gnu.org/licenses/>.
*/
package com.smartmarmot.dbforbix.config.element;
public class SimpleConfigurationElement extends AbstractConfigurationElement {
private static final Logger LOG = Logger.getLogger(SimpleConfigurationElement.class);
private String simpleItemKey;
public SimpleConfigurationElement(String _prefix, int _time, String _item, String _noData, String _query) {
super(_prefix,_time,_item,_noData,_query);
simpleItemKey=_prefix+_item;
}
@Override
| // Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixItem.java
// public final class ZabbixItem implements Serializable {
//
// public static int ZBX_STATE_NORMAL=0;
// public static int ZBX_STATE_NOTSUPPORTED=1;
//
// private static final long serialVersionUID = 1374520722821228793L;
//
// private String key;
// private String value;
// private String host;
// private int state;
// private Long clock;
// private String lastlogsize;
// private IConfigurationElement configurationElement;
//
//
// //main case
// public ZabbixItem(String key, String value, int state, Long clock, IConfigurationElement configurationElement) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=configurationElement.getConfigurationItem().getHost();
// this.setConfigurationElement(configurationElement);
// this.setState(state);
// }
//
//
// //For persistence usage
// public ZabbixItem(String host, String key, String value, Long clock) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=host;
// this.configurationElement=null;
// }
//
//
//
//
// /**
// * @return The current hostname for this item.
// */
// public String getHost() {
// return host;
// }
//
// /**
// * @return The monitoring server's key for this item.
// */
// public String getKey() {
// return key;
// }
//
// /**
// * @return The current value for this item.
// */
// public String getValue() {
// return value;
// }
//
// public Long getClock() {
// return clock;
// }
//
//
// public String getLastlogsize() {
// return lastlogsize;
// }
//
// @Override
// public String toString() {
// return getHost() + " " + getKey() + ": " + getValue();
// }
//
// public IConfigurationElement getConfigurationElement() {
// return configurationElement;
// }
//
// public void setConfigurationElement(IConfigurationElement configurationElement) {
// this.configurationElement = configurationElement;
// }
//
//
// public int getState() {
// return state;
// }
//
//
// public void setState(int state) {
// this.state = state;
// }
//
//
// public void setValue(String value) {
// this.value = value;
// }
// }
// Path: src/com/smartmarmot/dbforbix/config/element/SimpleConfigurationElement.java
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import com.smartmarmot.dbforbix.zabbix.ZabbixItem;
/*
* This file is part of DBforBix.
*
* DBforBix is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DBforBix is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* DBforBix. If not, see <http://www.gnu.org/licenses/>.
*/
package com.smartmarmot.dbforbix.config.element;
public class SimpleConfigurationElement extends AbstractConfigurationElement {
private static final Logger LOG = Logger.getLogger(SimpleConfigurationElement.class);
private String simpleItemKey;
public SimpleConfigurationElement(String _prefix, int _time, String _item, String _noData, String _query) {
super(_prefix,_time,_item,_noData,_query);
simpleItemKey=_prefix+_item;
}
@Override
| public ZabbixItem[] getZabbixItemsData(Connection con, int timeout) throws SQLException {
|
smartmarmot/DBforBIX | src/com/smartmarmot/dbforbix/zabbix/protocol/ISenderProtocol.java | // Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixItem.java
// public final class ZabbixItem implements Serializable {
//
// public static int ZBX_STATE_NORMAL=0;
// public static int ZBX_STATE_NOTSUPPORTED=1;
//
// private static final long serialVersionUID = 1374520722821228793L;
//
// private String key;
// private String value;
// private String host;
// private int state;
// private Long clock;
// private String lastlogsize;
// private IConfigurationElement configurationElement;
//
//
// //main case
// public ZabbixItem(String key, String value, int state, Long clock, IConfigurationElement configurationElement) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=configurationElement.getConfigurationItem().getHost();
// this.setConfigurationElement(configurationElement);
// this.setState(state);
// }
//
//
// //For persistence usage
// public ZabbixItem(String host, String key, String value, Long clock) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=host;
// this.configurationElement=null;
// }
//
//
//
//
// /**
// * @return The current hostname for this item.
// */
// public String getHost() {
// return host;
// }
//
// /**
// * @return The monitoring server's key for this item.
// */
// public String getKey() {
// return key;
// }
//
// /**
// * @return The current value for this item.
// */
// public String getValue() {
// return value;
// }
//
// public Long getClock() {
// return clock;
// }
//
//
// public String getLastlogsize() {
// return lastlogsize;
// }
//
// @Override
// public String toString() {
// return getHost() + " " + getKey() + ": " + getValue();
// }
//
// public IConfigurationElement getConfigurationElement() {
// return configurationElement;
// }
//
// public void setConfigurationElement(IConfigurationElement configurationElement) {
// this.configurationElement = configurationElement;
// }
//
//
// public int getState() {
// return state;
// }
//
//
// public void setState(int state) {
// this.state = state;
// }
//
//
// public void setValue(String value) {
// this.value = value;
// }
// }
| import com.smartmarmot.dbforbix.zabbix.ZabbixItem;
| /*
* This file is part of DBforBix.
*
* DBforBix is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DBforBix is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* DBforBix. If not, see <http://www.gnu.org/licenses/>.
*/
package com.smartmarmot.dbforbix.zabbix.protocol;
public interface ISenderProtocol {
public boolean isMultiValueSupported();
| // Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixItem.java
// public final class ZabbixItem implements Serializable {
//
// public static int ZBX_STATE_NORMAL=0;
// public static int ZBX_STATE_NOTSUPPORTED=1;
//
// private static final long serialVersionUID = 1374520722821228793L;
//
// private String key;
// private String value;
// private String host;
// private int state;
// private Long clock;
// private String lastlogsize;
// private IConfigurationElement configurationElement;
//
//
// //main case
// public ZabbixItem(String key, String value, int state, Long clock, IConfigurationElement configurationElement) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=configurationElement.getConfigurationItem().getHost();
// this.setConfigurationElement(configurationElement);
// this.setState(state);
// }
//
//
// //For persistence usage
// public ZabbixItem(String host, String key, String value, Long clock) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=host;
// this.configurationElement=null;
// }
//
//
//
//
// /**
// * @return The current hostname for this item.
// */
// public String getHost() {
// return host;
// }
//
// /**
// * @return The monitoring server's key for this item.
// */
// public String getKey() {
// return key;
// }
//
// /**
// * @return The current value for this item.
// */
// public String getValue() {
// return value;
// }
//
// public Long getClock() {
// return clock;
// }
//
//
// public String getLastlogsize() {
// return lastlogsize;
// }
//
// @Override
// public String toString() {
// return getHost() + " " + getKey() + ": " + getValue();
// }
//
// public IConfigurationElement getConfigurationElement() {
// return configurationElement;
// }
//
// public void setConfigurationElement(IConfigurationElement configurationElement) {
// this.configurationElement = configurationElement;
// }
//
//
// public int getState() {
// return state;
// }
//
//
// public void setState(int state) {
// this.state = state;
// }
//
//
// public void setValue(String value) {
// this.value = value;
// }
// }
// Path: src/com/smartmarmot/dbforbix/zabbix/protocol/ISenderProtocol.java
import com.smartmarmot.dbforbix.zabbix.ZabbixItem;
/*
* This file is part of DBforBix.
*
* DBforBix is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DBforBix is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* DBforBix. If not, see <http://www.gnu.org/licenses/>.
*/
package com.smartmarmot.dbforbix.zabbix.protocol;
public interface ISenderProtocol {
public boolean isMultiValueSupported();
| public String encodeItem(ZabbixItem item);
|
smartmarmot/DBforBIX | src/com/smartmarmot/dbforbix/config/item/ConfigurationItemParserNative.java | // Path: src/com/smartmarmot/dbforbix/config/element/IConfigurationElement.java
// public interface IConfigurationElement {
// String getElementID();
// String getPrefix();
// ZabbixItem[] getZabbixItemsData(Connection con, int timeout) throws SQLException;
// ZabbixServer getZabbixServer();
// IConfigurationItem getConfigurationItem();
// void setConfigurationItem(IConfigurationItem configurationItem);
// String getQuery();
// String getNoData();
// int getTime();
// String getConfigurationUID() throws NullPointerException;
// }
| import java.util.Set;
import org.apache.commons.lang3.NotImplementedException;
import com.smartmarmot.dbforbix.config.element.IConfigurationElement;
| package com.smartmarmot.dbforbix.config.item;
public class ConfigurationItemParserNative implements IConfigurationItemParser {
public ConfigurationItemParserNative(String config) {
// TODO Auto-generated constructor stub
throw new NotImplementedException("ConfigurationItemParserNative class is not implemented yet!");
}
@Override
| // Path: src/com/smartmarmot/dbforbix/config/element/IConfigurationElement.java
// public interface IConfigurationElement {
// String getElementID();
// String getPrefix();
// ZabbixItem[] getZabbixItemsData(Connection con, int timeout) throws SQLException;
// ZabbixServer getZabbixServer();
// IConfigurationItem getConfigurationItem();
// void setConfigurationItem(IConfigurationItem configurationItem);
// String getQuery();
// String getNoData();
// int getTime();
// String getConfigurationUID() throws NullPointerException;
// }
// Path: src/com/smartmarmot/dbforbix/config/item/ConfigurationItemParserNative.java
import java.util.Set;
import org.apache.commons.lang3.NotImplementedException;
import com.smartmarmot.dbforbix.config.element.IConfigurationElement;
package com.smartmarmot.dbforbix.config.item;
public class ConfigurationItemParserNative implements IConfigurationItemParser {
public ConfigurationItemParserNative(String config) {
// TODO Auto-generated constructor stub
throw new NotImplementedException("ConfigurationItemParserNative class is not implemented yet!");
}
@Override
| public Set<IConfigurationElement> buildConfigurationElements() {
|
smartmarmot/DBforBIX | src/com/smartmarmot/dbforbix/config/element/MultiColumnConfigurationElement.java | // Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixItem.java
// public final class ZabbixItem implements Serializable {
//
// public static int ZBX_STATE_NORMAL=0;
// public static int ZBX_STATE_NOTSUPPORTED=1;
//
// private static final long serialVersionUID = 1374520722821228793L;
//
// private String key;
// private String value;
// private String host;
// private int state;
// private Long clock;
// private String lastlogsize;
// private IConfigurationElement configurationElement;
//
//
// //main case
// public ZabbixItem(String key, String value, int state, Long clock, IConfigurationElement configurationElement) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=configurationElement.getConfigurationItem().getHost();
// this.setConfigurationElement(configurationElement);
// this.setState(state);
// }
//
//
// //For persistence usage
// public ZabbixItem(String host, String key, String value, Long clock) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=host;
// this.configurationElement=null;
// }
//
//
//
//
// /**
// * @return The current hostname for this item.
// */
// public String getHost() {
// return host;
// }
//
// /**
// * @return The monitoring server's key for this item.
// */
// public String getKey() {
// return key;
// }
//
// /**
// * @return The current value for this item.
// */
// public String getValue() {
// return value;
// }
//
// public Long getClock() {
// return clock;
// }
//
//
// public String getLastlogsize() {
// return lastlogsize;
// }
//
// @Override
// public String toString() {
// return getHost() + " " + getKey() + ": " + getValue();
// }
//
// public IConfigurationElement getConfigurationElement() {
// return configurationElement;
// }
//
// public void setConfigurationElement(IConfigurationElement configurationElement) {
// this.configurationElement = configurationElement;
// }
//
//
// public int getState() {
// return state;
// }
//
//
// public void setState(int state) {
// this.state = state;
// }
//
//
// public void setValue(String value) {
// this.value = value;
// }
// }
| import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import com.smartmarmot.dbforbix.zabbix.ZabbixItem;
| /*
* This file is part of DBforBix.
*
* DBforBix is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DBforBix is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* DBforBix. If not, see <http://www.gnu.org/licenses/>.
*/
package com.smartmarmot.dbforbix.config.element;
public class MultiColumnConfigurationElement extends AbstractMultiConfigurationElement {
private static final Logger LOG = Logger.getLogger(MultiColumnConfigurationElement.class);
public MultiColumnConfigurationElement(String _prefix, int _time, String _items, String _noData, String _query) {
super(_prefix, _time, _items, _noData, _query);
}
@Override
| // Path: src/com/smartmarmot/dbforbix/zabbix/ZabbixItem.java
// public final class ZabbixItem implements Serializable {
//
// public static int ZBX_STATE_NORMAL=0;
// public static int ZBX_STATE_NOTSUPPORTED=1;
//
// private static final long serialVersionUID = 1374520722821228793L;
//
// private String key;
// private String value;
// private String host;
// private int state;
// private Long clock;
// private String lastlogsize;
// private IConfigurationElement configurationElement;
//
//
// //main case
// public ZabbixItem(String key, String value, int state, Long clock, IConfigurationElement configurationElement) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=configurationElement.getConfigurationItem().getHost();
// this.setConfigurationElement(configurationElement);
// this.setState(state);
// }
//
//
// //For persistence usage
// public ZabbixItem(String host, String key, String value, Long clock) {
// if (key == null || "".equals(key.trim()))
// throw new IllegalArgumentException("empty key");
// if (value == null)
// throw new IllegalArgumentException("null value for key '" + key + "'");
// if (configurationElement == null)
// throw new IllegalArgumentException("null configuration element for '" + host + "." + key + "'");
//
// this.key = key;
// this.value = value;
// this.clock = clock;
// this.host=host;
// this.configurationElement=null;
// }
//
//
//
//
// /**
// * @return The current hostname for this item.
// */
// public String getHost() {
// return host;
// }
//
// /**
// * @return The monitoring server's key for this item.
// */
// public String getKey() {
// return key;
// }
//
// /**
// * @return The current value for this item.
// */
// public String getValue() {
// return value;
// }
//
// public Long getClock() {
// return clock;
// }
//
//
// public String getLastlogsize() {
// return lastlogsize;
// }
//
// @Override
// public String toString() {
// return getHost() + " " + getKey() + ": " + getValue();
// }
//
// public IConfigurationElement getConfigurationElement() {
// return configurationElement;
// }
//
// public void setConfigurationElement(IConfigurationElement configurationElement) {
// this.configurationElement = configurationElement;
// }
//
//
// public int getState() {
// return state;
// }
//
//
// public void setState(int state) {
// this.state = state;
// }
//
//
// public void setValue(String value) {
// this.value = value;
// }
// }
// Path: src/com/smartmarmot/dbforbix/config/element/MultiColumnConfigurationElement.java
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import com.smartmarmot.dbforbix.zabbix.ZabbixItem;
/*
* This file is part of DBforBix.
*
* DBforBix is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DBforBix is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* DBforBix. If not, see <http://www.gnu.org/licenses/>.
*/
package com.smartmarmot.dbforbix.config.element;
public class MultiColumnConfigurationElement extends AbstractMultiConfigurationElement {
private static final Logger LOG = Logger.getLogger(MultiColumnConfigurationElement.class);
public MultiColumnConfigurationElement(String _prefix, int _time, String _items, String _noData, String _query) {
super(_prefix, _time, _items, _noData, _query);
}
@Override
| public ZabbixItem[] getZabbixItemsData(Connection con, int timeout) throws SQLException {
|
RockinChaos/ItemJoin | src/me/RockinChaos/itemjoin/utils/interfaces/Button.java | // Path: src/me/RockinChaos/itemjoin/ItemJoin.java
// public class ItemJoin extends JavaPlugin {
//
// private static ItemJoin instance;
// private boolean isStarted = false;
//
// /**
// * Called when the plugin is loaded.
// *
// */
// @Override
// public void onLoad() {
// instance = this;
// }
//
// /**
// * Called when the plugin is enabled.
// *
// */
// @Override
// public void onEnable() {
// ConfigHandler.getConfig().registerEvents();
// SchedulerUtils.runAsync(() -> {
// UpdateHandler.getUpdater(true); {
// ServerUtils.logDebug("has been Enabled.");
// }
// });
// }
//
// /**
// * Called when the plugin is disabled.
// *
// */
// @Override
// public void onDisable() {
// Bukkit.getScheduler().cancelTasks(this);
// Menu.closeMenu();
// ItemHandler.saveCooldowns();
// ItemHandler.purgeCraftItems(true);
// Database.getDatabase().closeConnection(true);
// ProtocolManager.closeProtocol();
// ItemUtilities.getUtilities().clearItems();
// ServerUtils.logDebug("has been Disabled.");
// }
//
// /**
// * Checks if the plugin has fully loaded.
// *
// */
// public boolean isStarted() {
// return this.isStarted;
// }
//
// /**
// * Sets the plugin as fully loaded.
// *
// */
// public void setStarted(final boolean bool) {
// this.isStarted = bool;
// }
//
// /**
// * Gets the Plugin File.
// *
// * @return The Plugin File.
// */
// public File getPlugin() {
// return this.getFile();
// }
//
// /**
// * Gets the static instance of the main class for ItemJoin.
// * Notice: This class is not the actual API class, this is the main class that extends JavaPlugin.
// * For API methods, use the static methods available from the class: {@link ItemJoinAPI}.
// *
// * @return ItemJoin instance.
// */
// public static ItemJoin getInstance() {
// return instance;
// }
// }
| import java.util.Objects;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.inventory.ItemStack;
import me.RockinChaos.itemjoin.ItemJoin; | /*
* ItemJoin
* Copyright (C) CraftationGaming <https://www.craftationgaming.com/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.RockinChaos.itemjoin.utils.interfaces;
public class Button {
private int counter;
private final int ID = counter++;
private ItemStack itemStack;
private Consumer<InventoryClickEvent> clickAction;
private Consumer<AsyncPlayerChatEvent> chatAction;
/**
* Creates a new button instance.
* There is no click event or chat event.
*
* @param itemStack - The ItemStack the button is to be placed as.
*/
public Button(ItemStack itemStack) {
this(itemStack, event -> {});
}
/**
* Creates a new button instance.
* There is no chat event.
*
* @param itemStack - The ItemStack the button is to be placed as.
* @param clickAction - The method to be executed upon clicking the button.
*/
public Button(ItemStack itemStack, Consumer < InventoryClickEvent > clickAction) {
this.itemStack = itemStack;
this.clickAction = clickAction;
}
/**
* Creates a new button instance.
*
* @param itemStack - The ItemStack the button is to be placed as.
* @param clickAction - The method to be executed upon clicking the button.
* @param chatAction - The method to be executed upon chatting after clicking the button.
*/
public Button(ItemStack itemStack, Consumer < InventoryClickEvent > clickAction, Consumer < AsyncPlayerChatEvent > chatAction) {
this.itemStack = itemStack;
this.clickAction = clickAction;
this.chatAction = chatAction;
}
/**
* Gets the ItemStack for the button.
*
* @return The buttons ItemStack.
*/
public ItemStack getItemStack() {
return this.itemStack;
}
/**
* Sets the click action method to be executed.
*
* @param clickAction - The click action method to be executed.
*/
public void setClickAction(Consumer < InventoryClickEvent > clickAction) {
this.clickAction = clickAction;
}
/**
* Sets the chat action method to be executed.
*
* @param chatAction - The chat action method to be executed.
*/
public void setChatAction(Consumer < AsyncPlayerChatEvent > chatAction) {
this.chatAction = chatAction;
}
/**
* Called on player inventory click.
* Executes the pending click actions.
*
* @param event - InventoryClickEvent
*/
public void onClick(InventoryClickEvent event) { | // Path: src/me/RockinChaos/itemjoin/ItemJoin.java
// public class ItemJoin extends JavaPlugin {
//
// private static ItemJoin instance;
// private boolean isStarted = false;
//
// /**
// * Called when the plugin is loaded.
// *
// */
// @Override
// public void onLoad() {
// instance = this;
// }
//
// /**
// * Called when the plugin is enabled.
// *
// */
// @Override
// public void onEnable() {
// ConfigHandler.getConfig().registerEvents();
// SchedulerUtils.runAsync(() -> {
// UpdateHandler.getUpdater(true); {
// ServerUtils.logDebug("has been Enabled.");
// }
// });
// }
//
// /**
// * Called when the plugin is disabled.
// *
// */
// @Override
// public void onDisable() {
// Bukkit.getScheduler().cancelTasks(this);
// Menu.closeMenu();
// ItemHandler.saveCooldowns();
// ItemHandler.purgeCraftItems(true);
// Database.getDatabase().closeConnection(true);
// ProtocolManager.closeProtocol();
// ItemUtilities.getUtilities().clearItems();
// ServerUtils.logDebug("has been Disabled.");
// }
//
// /**
// * Checks if the plugin has fully loaded.
// *
// */
// public boolean isStarted() {
// return this.isStarted;
// }
//
// /**
// * Sets the plugin as fully loaded.
// *
// */
// public void setStarted(final boolean bool) {
// this.isStarted = bool;
// }
//
// /**
// * Gets the Plugin File.
// *
// * @return The Plugin File.
// */
// public File getPlugin() {
// return this.getFile();
// }
//
// /**
// * Gets the static instance of the main class for ItemJoin.
// * Notice: This class is not the actual API class, this is the main class that extends JavaPlugin.
// * For API methods, use the static methods available from the class: {@link ItemJoinAPI}.
// *
// * @return ItemJoin instance.
// */
// public static ItemJoin getInstance() {
// return instance;
// }
// }
// Path: src/me/RockinChaos/itemjoin/utils/interfaces/Button.java
import java.util.Objects;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.inventory.ItemStack;
import me.RockinChaos.itemjoin.ItemJoin;
/*
* ItemJoin
* Copyright (C) CraftationGaming <https://www.craftationgaming.com/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.RockinChaos.itemjoin.utils.interfaces;
public class Button {
private int counter;
private final int ID = counter++;
private ItemStack itemStack;
private Consumer<InventoryClickEvent> clickAction;
private Consumer<AsyncPlayerChatEvent> chatAction;
/**
* Creates a new button instance.
* There is no click event or chat event.
*
* @param itemStack - The ItemStack the button is to be placed as.
*/
public Button(ItemStack itemStack) {
this(itemStack, event -> {});
}
/**
* Creates a new button instance.
* There is no chat event.
*
* @param itemStack - The ItemStack the button is to be placed as.
* @param clickAction - The method to be executed upon clicking the button.
*/
public Button(ItemStack itemStack, Consumer < InventoryClickEvent > clickAction) {
this.itemStack = itemStack;
this.clickAction = clickAction;
}
/**
* Creates a new button instance.
*
* @param itemStack - The ItemStack the button is to be placed as.
* @param clickAction - The method to be executed upon clicking the button.
* @param chatAction - The method to be executed upon chatting after clicking the button.
*/
public Button(ItemStack itemStack, Consumer < InventoryClickEvent > clickAction, Consumer < AsyncPlayerChatEvent > chatAction) {
this.itemStack = itemStack;
this.clickAction = clickAction;
this.chatAction = chatAction;
}
/**
* Gets the ItemStack for the button.
*
* @return The buttons ItemStack.
*/
public ItemStack getItemStack() {
return this.itemStack;
}
/**
* Sets the click action method to be executed.
*
* @param clickAction - The click action method to be executed.
*/
public void setClickAction(Consumer < InventoryClickEvent > clickAction) {
this.clickAction = clickAction;
}
/**
* Sets the chat action method to be executed.
*
* @param chatAction - The chat action method to be executed.
*/
public void setChatAction(Consumer < AsyncPlayerChatEvent > chatAction) {
this.chatAction = chatAction;
}
/**
* Called on player inventory click.
* Executes the pending click actions.
*
* @param event - InventoryClickEvent
*/
public void onClick(InventoryClickEvent event) { | if (ItemJoin.getInstance().isEnabled()) { |
RockinChaos/ItemJoin | src/me/RockinChaos/itemjoin/utils/enchants/EnchantWrapper.java | // Path: src/me/RockinChaos/itemjoin/ItemJoin.java
// public class ItemJoin extends JavaPlugin {
//
// private static ItemJoin instance;
// private boolean isStarted = false;
//
// /**
// * Called when the plugin is loaded.
// *
// */
// @Override
// public void onLoad() {
// instance = this;
// }
//
// /**
// * Called when the plugin is enabled.
// *
// */
// @Override
// public void onEnable() {
// ConfigHandler.getConfig().registerEvents();
// SchedulerUtils.runAsync(() -> {
// UpdateHandler.getUpdater(true); {
// ServerUtils.logDebug("has been Enabled.");
// }
// });
// }
//
// /**
// * Called when the plugin is disabled.
// *
// */
// @Override
// public void onDisable() {
// Bukkit.getScheduler().cancelTasks(this);
// Menu.closeMenu();
// ItemHandler.saveCooldowns();
// ItemHandler.purgeCraftItems(true);
// Database.getDatabase().closeConnection(true);
// ProtocolManager.closeProtocol();
// ItemUtilities.getUtilities().clearItems();
// ServerUtils.logDebug("has been Disabled.");
// }
//
// /**
// * Checks if the plugin has fully loaded.
// *
// */
// public boolean isStarted() {
// return this.isStarted;
// }
//
// /**
// * Sets the plugin as fully loaded.
// *
// */
// public void setStarted(final boolean bool) {
// this.isStarted = bool;
// }
//
// /**
// * Gets the Plugin File.
// *
// * @return The Plugin File.
// */
// public File getPlugin() {
// return this.getFile();
// }
//
// /**
// * Gets the static instance of the main class for ItemJoin.
// * Notice: This class is not the actual API class, this is the main class that extends JavaPlugin.
// * For API methods, use the static methods available from the class: {@link ItemJoinAPI}.
// *
// * @return ItemJoin instance.
// */
// public static ItemJoin getInstance() {
// return instance;
// }
// }
| import org.bukkit.enchantments.Enchantment;
import me.RockinChaos.itemjoin.ItemJoin; | /*
* ItemJoin
* Copyright (C) CraftationGaming <https://www.craftationgaming.com/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.RockinChaos.itemjoin.utils.enchants;
public abstract class EnchantWrapper extends Enchantment {
/**
* Creates a new Enchantment.
*
* @param namespace - The name that should be set as the Enchantment.
*/
public EnchantWrapper(final String namespace) { | // Path: src/me/RockinChaos/itemjoin/ItemJoin.java
// public class ItemJoin extends JavaPlugin {
//
// private static ItemJoin instance;
// private boolean isStarted = false;
//
// /**
// * Called when the plugin is loaded.
// *
// */
// @Override
// public void onLoad() {
// instance = this;
// }
//
// /**
// * Called when the plugin is enabled.
// *
// */
// @Override
// public void onEnable() {
// ConfigHandler.getConfig().registerEvents();
// SchedulerUtils.runAsync(() -> {
// UpdateHandler.getUpdater(true); {
// ServerUtils.logDebug("has been Enabled.");
// }
// });
// }
//
// /**
// * Called when the plugin is disabled.
// *
// */
// @Override
// public void onDisable() {
// Bukkit.getScheduler().cancelTasks(this);
// Menu.closeMenu();
// ItemHandler.saveCooldowns();
// ItemHandler.purgeCraftItems(true);
// Database.getDatabase().closeConnection(true);
// ProtocolManager.closeProtocol();
// ItemUtilities.getUtilities().clearItems();
// ServerUtils.logDebug("has been Disabled.");
// }
//
// /**
// * Checks if the plugin has fully loaded.
// *
// */
// public boolean isStarted() {
// return this.isStarted;
// }
//
// /**
// * Sets the plugin as fully loaded.
// *
// */
// public void setStarted(final boolean bool) {
// this.isStarted = bool;
// }
//
// /**
// * Gets the Plugin File.
// *
// * @return The Plugin File.
// */
// public File getPlugin() {
// return this.getFile();
// }
//
// /**
// * Gets the static instance of the main class for ItemJoin.
// * Notice: This class is not the actual API class, this is the main class that extends JavaPlugin.
// * For API methods, use the static methods available from the class: {@link ItemJoinAPI}.
// *
// * @return ItemJoin instance.
// */
// public static ItemJoin getInstance() {
// return instance;
// }
// }
// Path: src/me/RockinChaos/itemjoin/utils/enchants/EnchantWrapper.java
import org.bukkit.enchantments.Enchantment;
import me.RockinChaos.itemjoin.ItemJoin;
/*
* ItemJoin
* Copyright (C) CraftationGaming <https://www.craftationgaming.com/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.RockinChaos.itemjoin.utils.enchants;
public abstract class EnchantWrapper extends Enchantment {
/**
* Creates a new Enchantment.
*
* @param namespace - The name that should be set as the Enchantment.
*/
public EnchantWrapper(final String namespace) { | super(new org.bukkit.NamespacedKey(ItemJoin.getInstance(), namespace)); |
RockinChaos/ItemJoin | src/me/RockinChaos/itemjoin/utils/SchedulerUtils.java | // Path: src/me/RockinChaos/itemjoin/ItemJoin.java
// public class ItemJoin extends JavaPlugin {
//
// private static ItemJoin instance;
// private boolean isStarted = false;
//
// /**
// * Called when the plugin is loaded.
// *
// */
// @Override
// public void onLoad() {
// instance = this;
// }
//
// /**
// * Called when the plugin is enabled.
// *
// */
// @Override
// public void onEnable() {
// ConfigHandler.getConfig().registerEvents();
// SchedulerUtils.runAsync(() -> {
// UpdateHandler.getUpdater(true); {
// ServerUtils.logDebug("has been Enabled.");
// }
// });
// }
//
// /**
// * Called when the plugin is disabled.
// *
// */
// @Override
// public void onDisable() {
// Bukkit.getScheduler().cancelTasks(this);
// Menu.closeMenu();
// ItemHandler.saveCooldowns();
// ItemHandler.purgeCraftItems(true);
// Database.getDatabase().closeConnection(true);
// ProtocolManager.closeProtocol();
// ItemUtilities.getUtilities().clearItems();
// ServerUtils.logDebug("has been Disabled.");
// }
//
// /**
// * Checks if the plugin has fully loaded.
// *
// */
// public boolean isStarted() {
// return this.isStarted;
// }
//
// /**
// * Sets the plugin as fully loaded.
// *
// */
// public void setStarted(final boolean bool) {
// this.isStarted = bool;
// }
//
// /**
// * Gets the Plugin File.
// *
// * @return The Plugin File.
// */
// public File getPlugin() {
// return this.getFile();
// }
//
// /**
// * Gets the static instance of the main class for ItemJoin.
// * Notice: This class is not the actual API class, this is the main class that extends JavaPlugin.
// * For API methods, use the static methods available from the class: {@link ItemJoinAPI}.
// *
// * @return ItemJoin instance.
// */
// public static ItemJoin getInstance() {
// return instance;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitRunnable;
import me.RockinChaos.itemjoin.ItemJoin; | /*
* ItemJoin
* Copyright (C) CraftationGaming <https://www.craftationgaming.com/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.RockinChaos.itemjoin.utils;
public class SchedulerUtils {
private static List < Runnable > SINGLE_QUEUE = new ArrayList < Runnable > ();
private static Boolean SINGLE_ACTIVE = false;
/**
* Runs the task on the main thread
* @param runnable - The task to be performed.
*/
public static void run(final Runnable runnable){ | // Path: src/me/RockinChaos/itemjoin/ItemJoin.java
// public class ItemJoin extends JavaPlugin {
//
// private static ItemJoin instance;
// private boolean isStarted = false;
//
// /**
// * Called when the plugin is loaded.
// *
// */
// @Override
// public void onLoad() {
// instance = this;
// }
//
// /**
// * Called when the plugin is enabled.
// *
// */
// @Override
// public void onEnable() {
// ConfigHandler.getConfig().registerEvents();
// SchedulerUtils.runAsync(() -> {
// UpdateHandler.getUpdater(true); {
// ServerUtils.logDebug("has been Enabled.");
// }
// });
// }
//
// /**
// * Called when the plugin is disabled.
// *
// */
// @Override
// public void onDisable() {
// Bukkit.getScheduler().cancelTasks(this);
// Menu.closeMenu();
// ItemHandler.saveCooldowns();
// ItemHandler.purgeCraftItems(true);
// Database.getDatabase().closeConnection(true);
// ProtocolManager.closeProtocol();
// ItemUtilities.getUtilities().clearItems();
// ServerUtils.logDebug("has been Disabled.");
// }
//
// /**
// * Checks if the plugin has fully loaded.
// *
// */
// public boolean isStarted() {
// return this.isStarted;
// }
//
// /**
// * Sets the plugin as fully loaded.
// *
// */
// public void setStarted(final boolean bool) {
// this.isStarted = bool;
// }
//
// /**
// * Gets the Plugin File.
// *
// * @return The Plugin File.
// */
// public File getPlugin() {
// return this.getFile();
// }
//
// /**
// * Gets the static instance of the main class for ItemJoin.
// * Notice: This class is not the actual API class, this is the main class that extends JavaPlugin.
// * For API methods, use the static methods available from the class: {@link ItemJoinAPI}.
// *
// * @return ItemJoin instance.
// */
// public static ItemJoin getInstance() {
// return instance;
// }
// }
// Path: src/me/RockinChaos/itemjoin/utils/SchedulerUtils.java
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitRunnable;
import me.RockinChaos.itemjoin.ItemJoin;
/*
* ItemJoin
* Copyright (C) CraftationGaming <https://www.craftationgaming.com/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.RockinChaos.itemjoin.utils;
public class SchedulerUtils {
private static List < Runnable > SINGLE_QUEUE = new ArrayList < Runnable > ();
private static Boolean SINGLE_ACTIVE = false;
/**
* Runs the task on the main thread
* @param runnable - The task to be performed.
*/
public static void run(final Runnable runnable){ | if (ItemJoin.getInstance().isEnabled()) { |
kmizu/jcombinator | src/main/java/com/github/kmizu/jcombinator/Functions.java | // Path: src/main/java/com/github/kmizu/jcombinator/datatype/Function1.java
// public interface Function1<T1, R> {
// R invoke(T1 arg);
// }
//
// Path: src/main/java/com/github/kmizu/jcombinator/datatype/Procedure1.java
// public interface Procedure1<T1> {
// void invoke(T1 arg);
// }
//
// Path: src/main/java/com/github/kmizu/jcombinator/datatype/Tuple2.java
// public class Tuple2<X, Y> {
// private X item1;
// private Y item2;
//
// public Tuple2(X item1, Y item2) {
// this.item1 = item1;
// this.item2 = item2;
// }
//
// public X item1() {
// return item1;
// }
//
// public Y item2() {
// return item2;
// }
//
// public <U> U extract(Function2<X, Y, U> f) {
// return f.invoke(item1, item2);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Tuple2<?, ?> tp2 = (Tuple2<?, ?>) o;
//
// if (!item1.equals(tp2.item1)) return false;
// return item2.equals(tp2.item2);
// }
//
// @Override
// public int hashCode() {
// int result = item1.hashCode();
// result = 31 * result + item2.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// return "Tuple2{" + "item1=" + item1 + ", item2=" + item2 + '}';
// }
// }
| import com.github.kmizu.jcombinator.datatype.Function1;
import com.github.kmizu.jcombinator.datatype.Procedure1;
import com.github.kmizu.jcombinator.datatype.Tuple2;
import java.util.List; | package com.github.kmizu.jcombinator;
public class Functions {
public static <T, U> U let(T value, Function1<T, U> fn) {
return fn.invoke(value);
}
| // Path: src/main/java/com/github/kmizu/jcombinator/datatype/Function1.java
// public interface Function1<T1, R> {
// R invoke(T1 arg);
// }
//
// Path: src/main/java/com/github/kmizu/jcombinator/datatype/Procedure1.java
// public interface Procedure1<T1> {
// void invoke(T1 arg);
// }
//
// Path: src/main/java/com/github/kmizu/jcombinator/datatype/Tuple2.java
// public class Tuple2<X, Y> {
// private X item1;
// private Y item2;
//
// public Tuple2(X item1, Y item2) {
// this.item1 = item1;
// this.item2 = item2;
// }
//
// public X item1() {
// return item1;
// }
//
// public Y item2() {
// return item2;
// }
//
// public <U> U extract(Function2<X, Y, U> f) {
// return f.invoke(item1, item2);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Tuple2<?, ?> tp2 = (Tuple2<?, ?>) o;
//
// if (!item1.equals(tp2.item1)) return false;
// return item2.equals(tp2.item2);
// }
//
// @Override
// public int hashCode() {
// int result = item1.hashCode();
// result = 31 * result + item2.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// return "Tuple2{" + "item1=" + item1 + ", item2=" + item2 + '}';
// }
// }
// Path: src/main/java/com/github/kmizu/jcombinator/Functions.java
import com.github.kmizu.jcombinator.datatype.Function1;
import com.github.kmizu.jcombinator.datatype.Procedure1;
import com.github.kmizu.jcombinator.datatype.Tuple2;
import java.util.List;
package com.github.kmizu.jcombinator;
public class Functions {
public static <T, U> U let(T value, Function1<T, U> fn) {
return fn.invoke(value);
}
| public static <T> void let(T value, Procedure1<T> pr) { |
kmizu/jcombinator | src/main/java/com/github/kmizu/jcombinator/Functions.java | // Path: src/main/java/com/github/kmizu/jcombinator/datatype/Function1.java
// public interface Function1<T1, R> {
// R invoke(T1 arg);
// }
//
// Path: src/main/java/com/github/kmizu/jcombinator/datatype/Procedure1.java
// public interface Procedure1<T1> {
// void invoke(T1 arg);
// }
//
// Path: src/main/java/com/github/kmizu/jcombinator/datatype/Tuple2.java
// public class Tuple2<X, Y> {
// private X item1;
// private Y item2;
//
// public Tuple2(X item1, Y item2) {
// this.item1 = item1;
// this.item2 = item2;
// }
//
// public X item1() {
// return item1;
// }
//
// public Y item2() {
// return item2;
// }
//
// public <U> U extract(Function2<X, Y, U> f) {
// return f.invoke(item1, item2);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Tuple2<?, ?> tp2 = (Tuple2<?, ?>) o;
//
// if (!item1.equals(tp2.item1)) return false;
// return item2.equals(tp2.item2);
// }
//
// @Override
// public int hashCode() {
// int result = item1.hashCode();
// result = 31 * result + item2.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// return "Tuple2{" + "item1=" + item1 + ", item2=" + item2 + '}';
// }
// }
| import com.github.kmizu.jcombinator.datatype.Function1;
import com.github.kmizu.jcombinator.datatype.Procedure1;
import com.github.kmizu.jcombinator.datatype.Tuple2;
import java.util.List; | package com.github.kmizu.jcombinator;
public class Functions {
public static <T, U> U let(T value, Function1<T, U> fn) {
return fn.invoke(value);
}
public static <T> void let(T value, Procedure1<T> pr) {
pr.invoke(value);
}
| // Path: src/main/java/com/github/kmizu/jcombinator/datatype/Function1.java
// public interface Function1<T1, R> {
// R invoke(T1 arg);
// }
//
// Path: src/main/java/com/github/kmizu/jcombinator/datatype/Procedure1.java
// public interface Procedure1<T1> {
// void invoke(T1 arg);
// }
//
// Path: src/main/java/com/github/kmizu/jcombinator/datatype/Tuple2.java
// public class Tuple2<X, Y> {
// private X item1;
// private Y item2;
//
// public Tuple2(X item1, Y item2) {
// this.item1 = item1;
// this.item2 = item2;
// }
//
// public X item1() {
// return item1;
// }
//
// public Y item2() {
// return item2;
// }
//
// public <U> U extract(Function2<X, Y, U> f) {
// return f.invoke(item1, item2);
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Tuple2<?, ?> tp2 = (Tuple2<?, ?>) o;
//
// if (!item1.equals(tp2.item1)) return false;
// return item2.equals(tp2.item2);
// }
//
// @Override
// public int hashCode() {
// int result = item1.hashCode();
// result = 31 * result + item2.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// return "Tuple2{" + "item1=" + item1 + ", item2=" + item2 + '}';
// }
// }
// Path: src/main/java/com/github/kmizu/jcombinator/Functions.java
import com.github.kmizu.jcombinator.datatype.Function1;
import com.github.kmizu.jcombinator.datatype.Procedure1;
import com.github.kmizu.jcombinator.datatype.Tuple2;
import java.util.List;
package com.github.kmizu.jcombinator;
public class Functions {
public static <T, U> U let(T value, Function1<T, U> fn) {
return fn.invoke(value);
}
public static <T> void let(T value, Procedure1<T> pr) {
pr.invoke(value);
}
| public static <T, U> U foldLeft(List<T> list, U init, Function1<Tuple2<U, T>, U> f) { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.